root/lm-sensors/tags/V2-4-5/Makefile

Revision 675, 9.3 kB (checked in by frodo, 9 years ago)

Added DESTDIR Makefile variable

Set DESTDIR if you want to install at some other place then where you
will run everything from.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #  Makefile - Makefile for a Linux module for reading sensor data.
2 #  Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
3 #
4 #  This program is free software; you can redistribute it and/or modify
5 #  it under the terms of the GNU General Public License as published by
6 #  the Free Software Foundation; either version 2 of the License, or
7 #  (at your option) any later version.
8 #
9 #  This program is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #  GNU General Public License for more details.
13 #
14 #  You should have received a copy of the GNU General Public License
15 #  along with this program; if not, write to the Free Software
16 #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 # Everything you may want to change is in the top of this file. Usually, you
19 # can just use the defaults, fortunately.
20
21 # You need a full complement of GNU utilities to run this Makefile succesfully;
22 # most notably, you need bash, GNU make, flex and bison.
23
24 # If your /bin/sh is not bash, change the below definition so that make can
25 # find bash. Or you can hope your sh-like shell understands all scripts.
26 # I think so, but I have not tested it.
27 # SHELL=/usr/bin/bash
28
29 # The location of linux itself. This is used to find the kernel headers
30 # and other things.
31 LINUX=/usr/src/linux
32 LINUX_HEADERS=$(LINUX)/include
33
34 # Determine whether we need to compile the kernel modules, or only the
35 # user-space utilities. By default, the kernel modules are compiled.
36 #COMPILE_KERNEL := 0
37 COMPILE_KERNEL := 1
38
39 # If you have installed the i2c header at some other place (like
40 # /usr/local/include/linux), set that directory here. Please check this out
41 # if you get strange compilation errors; the default Linux i2c headers
42 # may be used mistakenly.
43 I2C_HEADERS=/usr/local/include
44 #I2C_HEADERS=$(LINUX_HEADERS)
45
46 # Uncomment the third line on SMP systems if the magic invocation fails. It
47 # is a bit complicated because SMP configuration changed around kernel 2.1.130
48 SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \
49                   grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
50                then echo 1; else echo 0; fi)
51 #SMP := 0
52 #SMP := 1
53
54 # Uncomment the second or third line if the magic invocation fails.
55 # We need to know whether CONFIG_MODVERSIONS is defined.
56 MODVER := $(shell if cat $(LINUX_HEADERS)/linux/config.h $(LINUX_HEADERS)/linux/autoconf.h 2>/dev/null | grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_MODVERSIONS[[:space:]]*1'; then echo 1; else echo 0; fi)
57 #MODVER := 0
58 #MODVER := 1
59
60 # Uncomment the second line if you are a developer. This will enable many
61 # additional warnings at compile-time
62 WARN := 0
63 #WARN := 1
64
65 # Uncomment the second line if you want to get (loads of) debug information
66 # at run-time.
67 # Not recommended, unless you are actually debugging the code
68 DEBUG := 0
69 #DEBUG := 1
70
71 # If you want to install at some other place then at from which you will run
72 # everything, set DESTDIR to the extra prefix.
73 DESTDIR :=
74
75 # This is the prefix that will be used for almost all directories below.
76 PREFIX := /usr/local
77
78 # This is the directory into which the modules will be installed.
79 # The magic invocation will return something like this:
80 #   /lib/modules/2.2.15-ac9/extra/misc
81 MODDIR := /lib/modules/`sed -ne '1,4 { s/.*= *\(.*\)/\1/; 1,2 s/.*/&./; p; };' <$(LINUX)/Makefile | tr -d '\n'`/misc
82
83 # This is the directory where sensors.conf will be installed, if no other
84 # configuration file is found
85 ETCDIR := /etc
86
87 # You should not need to change this. It is the directory into which the
88 # library files (both static and shared) will be installed.
89 LIBDIR := $(PREFIX)/lib
90
91 # You should not need to change this. It is the directory into which the
92 # executable program files will be installed. BINDIR for programs that are
93 # also useful for normal users, SBINDIR for programs that can only be run
94 # by the superuser.
95 # Note that not all programs in this package are really installed;
96 # some are just examples. You can always install them by hand, of
97 # course.
98 BINDIR := $(PREFIX)/bin
99 SBINDIR := $(PREFIX)/sbin
100
101 # You should not need to change this. It is the basic directory into which
102 # include files will be installed. The actual directory will be
103 # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors
104 # for library include files. If PREFIX equals the default /usr/local/bin,
105 # you will be able to use '#include <linux/sensors.h>' regardless of the
106 # current kernel selected.
107 INCLUDEDIR := $(PREFIX)/include
108 SYSINCLUDEDIR := $(INCLUDEDIR)/linux
109 LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
110
111 # You should not need to change this. It is the base directory under which the
112 # manual pages will be installed.
113 MANDIR := $(PREFIX)/man
114
115 # You should not need to change this. It defines the manual owner and group
116 # as which manual pages are installed.
117 MANOWN := root
118 MANGRP := root
119
120 ##################################################
121 # Below this, nothing should need to be changed. #
122 ##################################################
123
124 # Note that this is a monolithic Makefile; it calls no sub-Makefiles,
125 # but instead, it compiles everything right from here. Yes, there are
126 # some distinct advantages to this; see the following paper for more info:
127 #   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
128 # Note that is still uses Makefile fragments in sub-directories; these
129 # are called 'Module.mk'.
130
131 # Within each Module.mk, rules and dependencies can be added to targets
132 # all, install and clean. Use double colons instead of single ones
133 # to do this.
134
135 # The subdirectories we need to build things in
136 SRCDIRS := mkpatch
137 ifeq ($(COMPILE_KERNEL),1)
138 SRCDIRS += kernel kernel/busses kernel/chips kernel/include
139 endif
140 SRCDIRS += lib prog/sensors prog/sensord prog/dump prog/detect etc
141
142 # Some often-used commands with default options
143 MKDIR := mkdir -p
144 RM := rm -f
145 CC := gcc
146 BISON := bison
147 FLEX := flex
148 AR := ar
149 INSTALL := install
150 LN := ln -sfn
151 GREP := grep
152
153 # Determine the default compiler flags
154 # MODCFLAGS is to create in-kernel object files (modules); PROGFLAGS is to
155 # create non-kernel object files (which are linked into executables).
156 # ARCFLAGS are used to create archive object files (static libraries), and
157 # LIBCFLAGS are for shared library objects.
158 CFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS) -I$(LINUX_HEADERS) -O2
159
160 ifeq ($(DEBUG),1)
161 CFLAGS += -DDEBUG
162 endif
163
164 ifeq ($(WARN),1)
165 CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
166           -Wcast-align -Wwrite-strings -Wnested-externs -Winline
167 endif
168
169 MODCFLAGS := $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer
170 MODCFLAGS := $(MODCFLAGS) -DEXPORT_SYMTAB
171 PROGCFLAGS := $(CFLAGS)
172 ARCFLAGS := $(CFLAGS)
173 LIBCFLAGS := $(CFLAGS) -fpic
174
175 ifeq ($(SMP),1)
176 MODCFLAGS += -D__SMP__
177 endif
178
179 ifeq ($(MODVER),1)
180 MODCFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h
181 endif
182
183 .PHONY: all clean install version package dep
184
185 # Make all the default rule
186 all::
187
188 # Include all makefiles for sub-modules
189 INCLUDEFILES :=
190 include $(patsubst %,%/Module.mk,$(SRCDIRS))
191 ifneq ($(MAKECMDGOALS),clean)
192 include $(INCLUDEFILES)
193 endif
194
195 # Making the dependency files - done automatically!
196 dep :
197
198 all ::
199
200 install :: all
201
202 clean::
203         $(RM) lm_sensors-*
204
205 # This is tricky, but it works like a charm. It needs lots of utilities
206 # though: cut, find, gzip, ln, tail and tar.
207 package: version clean
208         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
209         lmpackage=lm_sensors-$$lmversion; \
210         ln -s . $$lmpackage;  \
211         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
212                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
213                                     grep -v ^$$lmpackage/$$ | \
214                                     grep -v /CVS | \
215                                     grep -v /\\.# | \
216                                     tar rvf $$lmpackage.tar -T -; \
217         gzip -9 $$lmpackage.tar ;\
218         $(RM) $$lmpackage.tar $$lmpackage
219         cat doc/developers/checklist
220
221 version:
222         $(RM) version.h
223         echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
224         echo -n 'Version: '; \
225         echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
226
227
228 # Here, we define all implicit rules we want to use.
229
230 .SUFFIXES:
231
232 # We need to create dependency files. Tricky. We sed rule puts dir/file.d and
233 # dir/file.c # in front of the dependency file rule.
234
235 # .o files are used for modules
236 %.o: %.c
237         $(CC) $(MODCFLAGS) -c $< -o $@
238
239 %.d: %.c
240         $(CC) -M -MG $(MODCFLAGS) $< | \
241         sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
242
243
244
245 # .ro files are used for programs (as opposed to modules)
246 %.ro: %.c
247         $(CC) $(PROGCFLAGS) -c $< -o $@
248
249 %.rd: %.c
250         $(CC) -M -MG $(PROGCFLAGS) $< | \
251         sed -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
252
253
254 %: %.ro
255         $(CC) $(EXLDFLAGS) -o $@ $^
256
257
258 # .ao files are used for static archives
259 %.ao: %.c
260         $(CC) $(ARCFLAGS) -c $< -o $@
261
262 %.ad: %.c
263         $(CC) -M -MG $(ARCFLAGS) $< | \
264         sed -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
265
266
267 # .lo files are used for shared libraries
268 %.lo: %.c
269         $(CC) $(LIBCFLAGS) -c $< -o $@
270
271 %.ld: %.c
272         $(CC) -M -MG $(LIBCFLAGS) $< | \
273         sed -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
274
275
276 # Flex and Bison
277 %c: %y
278         $(BISON) -p sensors_yy -d $< -o $@
279
280 %.c: %.l
281         $(FLEX) -Psensors_yy -t $< > $@
Note: See TracBrowser for help on using the browser.