root/lm-sensors/tags/V2-10-0/Makefile

Revision 3096, 16.1 kB (checked in by mmh, 3 years ago)

(mmh)
This patch makes optional the sysfs support in libsensors. The default is to
*disable* sysfs support if a 2.4.x kernel is detected, for all other versions,
support will be enabled. This can be overridden in the top-level Makefile.

  • 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 (>= 2.5.1) 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 currently running kernel version. This is used right below to
30 # determine where the kernel sources can be found.
31 KERNELVERSION := $(shell uname -r)
32
33 # The location of linux itself. This is used to find the kernel headers
34 # and other things.
35 #LINUX := /usr/src/linux
36 LINUX := $(shell if [ -L "/lib/modules/$(KERNELVERSION)/build" ] ; \
37         then echo "/lib/modules/$(KERNELVERSION)/build" ; \
38         else echo "/usr/src/linux" ; fi)
39 LINUX_HEADERS := $(LINUX)/include
40
41 # If you have installed the i2c header at some other place (like
42 # /usr/local/include/linux), set that directory here. Please check this out
43 # if you get strange compilation errors; the default Linux i2c headers
44 # may be used mistakenly. Note: This should point to the directory
45 # *above* the linux/ subdirectory, so to /usr/local/include in the
46 # above example.
47 I2C_HEADERS := /usr/local/include
48 #I2C_HEADERS := $(LINUX_HEADERS)
49
50 # Uncomment the third line on SMP systems if the magic invocation fails.
51 SMP := $(shell if grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
52                then echo 1; else echo 0; fi)
53 #SMP := 0
54 #SMP := 1
55
56 # Uncomment the second or third line if the magic invocation fails.
57 # We need to know whether CONFIG_MODVERSIONS is defined.
58 MODVER := $(shell if grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_MODVERSIONS[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
59                   then echo 1; else echo 0; fi)
60 #MODVER := 0
61 #MODVER := 1
62
63 # Uncomment the second line if you are a developer. This will enable many
64 # additional warnings at compile-time
65 WARN := 0
66 #WARN := 1
67
68 # Uncomment the second line if you want to get (loads of) debug information
69 # at run-time.
70 # Not recommended, unless you are actually debugging the code
71 DEBUG := 0
72 #DEBUG := 1
73
74 # If you want to install at some other place then at from which you will run
75 # everything, set DESTDIR to the extra prefix.
76 DESTDIR :=
77
78 # This is the prefix that will be used for almost all directories below.
79 PREFIX := /usr/local
80
81 # Your C compiler
82 CC := gcc
83
84 # This is the main modules directory into which the modules will be installed.
85 # The magic invocation will return something like this:
86 #   /lib/modules/2.4.29
87 MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"')
88
89 # When building userspace for use with 2.4.x series kernels, we turn off
90 # sysfs support by default.  You can override this (e.g. if you want
91 # to build binaries that work for both 2.4.x, and 2.6.x and above)
92 # by uncommenting the line after the next endif.  Keep in mind, if and only
93 # if you do this: you will need to install the libsysfs libraries on your
94 # kernel 2.4.x systems also.
95 ifeq (,$(findstring /2.4., $(MODPREF)))
96         SYSFS_SUPPORT := 1
97 else
98         SYSFS_SUPPORT :=
99 endif
100 #SYSFS_SUPPORT := 1
101
102 # Prevent 2.6+ users from using improper targets, as this won't work.
103 ifeq (,$(findstring /2.4., $(MODPREF)))
104     ifeq (, $(MAKECMDGOALS))
105         $(error For 2.6 kernels and later, use "make user")
106     endif
107     ifeq (install, $(MAKECMDGOALS))
108         $(error For 2.6 kernels and later, use "make user_install")
109     endif
110 endif
111
112 # This is the directory where sensors.conf will be installed, if no other
113 # configuration file is found
114 ETCDIR := /etc
115
116 # You should not need to change this. It is the directory into which the
117 # library files (both static and shared) will be installed.
118 LIBDIR := $(PREFIX)/lib
119
120 EXLDFLAGS := -Wl,-rpath,$(LIBDIR)
121
122 # You should not need to change this. It is the directory into which the
123 # executable program files will be installed. BINDIR for programs that are
124 # also useful for normal users, SBINDIR for programs that can only be run
125 # by the superuser.
126 # Note that not all programs in this package are really installed;
127 # some are just examples. You can always install them by hand, of
128 # course.
129 BINDIR := $(PREFIX)/bin
130 SBINDIR := $(PREFIX)/sbin
131
132 # You should not need to change this. It is the basic directory into which
133 # include files will be installed. The actual directory will be
134 # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors
135 # for library include files. If PREFIX equals the default /usr/local/bin,
136 # you will be able to use '#include <linux/sensors.h>' regardless of the
137 # current kernel selected.
138 INCLUDEDIR := $(PREFIX)/include
139 SYSINCLUDEDIR := $(INCLUDEDIR)/linux
140 LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
141
142 # You should not need to change this. It is the base directory under which the
143 # manual pages will be installed.
144 MANDIR := $(PREFIX)/man
145
146 MACHINE := $(shell uname -m)
147
148 # Extra non-default programs to build; e.g., sensord
149 # PROG_EXTRA := sensord
150
151 # Set these to add preprocessor or compiler flags, or use
152 # environment variables
153 # CFLAGS :=
154 # CPPFLAGS :=
155
156 ##################################################
157 # Below this, nothing should need to be changed. #
158 ##################################################
159
160 # Note that this is a monolithic Makefile; it calls no sub-Makefiles,
161 # but instead, it compiles everything right from here. Yes, there are
162 # some distinct advantages to this; see the following paper for more info:
163 #   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
164 # Note that is still uses Makefile fragments in sub-directories; these
165 # are called 'Module.mk'.
166
167 # Within each Module.mk, rules and dependencies can be added to targets
168 # all, install and clean. Use double colons instead of single ones
169 # to do this.
170
171 # The subdirectories we need to build things in
172 SRCDIRS :=
173 ifneq ($(MAKECMDGOALS),user)
174 ifneq ($(MAKECMDGOALS),user_install)
175 ifneq ($(MAKECMDGOALS),user_uninstall)
176 ifneq ($(MAKECMDGOALS),package)
177 ifneq ($(MAKECMDGOALS),userpackage)
178 ifneq ($(MAKECMDGOALS),manhtml)
179 SRCDIRS += mkpatch
180 SRCDIRS += kernel kernel/busses kernel/chips
181 endif
182 endif
183 endif
184 endif
185 endif
186 endif
187 SRCDIRS += kernel/include
188 SRCDIRS += lib prog/detect prog/dump prog/eeprom prog/pwm \
189            prog/sensors prog/xeon ${PROG_EXTRA:%=prog/%} etc
190
191 # Some often-used commands with default options
192 MKDIR := mkdir -p
193 RMDIR := rmdir
194 RM := rm -f
195 BISON := bison
196 FLEX := flex
197 AR := ar
198 INSTALL := install
199 LN := ln -sf
200 GREP := grep
201 AWK := awk
202 SED := sed
203
204 # Determine the default compiler flags
205 # Set CFLAGS or CPPFLAGS above to add your own flags to all.
206 # ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
207 # MODCPPFLAGS/MODCFLAGS is to create in-kernel object files (modules).
208 # PROGCPPFLAGS/PROGCFLAGS is to create non-kernel object files (which are linked into executables).
209 # ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
210 # LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
211 ALL_CPPFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS)
212 ALL_CFLAGS := -Wall
213
214 ifeq ($(DEBUG),1)
215 ALL_CPPFLAGS += -DDEBUG
216 ALL_CFLAGS += -O -g
217 else
218 ALL_CFLAGS += -O2
219 endif
220
221 ifeq ($(WARN),1)
222 ALL_CFLAGS += -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
223             -Wcast-align -Wwrite-strings -Wnested-externs -Winline
224 endif
225
226 ALL_CPPFLAGS += $(CPPFLAGS)
227 ALL_CFLAGS += $(CFLAGS)
228
229 MODCPPFLAGS :=
230 MODCFLAGS := -fno-strict-aliasing
231
232 ifeq ($(MACHINE),alpha)
233 MODCFLAGS += -ffixed-8 -mno-fp-regs -mcpu=ev56
234 endif
235
236 ifeq ($(MACHINE),x86_64)
237 MODCFLAGS += -fno-common -fomit-frame-pointer -mno-red-zone \
238              -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce
239 endif
240
241 ifeq ($(MACHINE),mips)
242 MODCFLAGS += -mabi=32 -mips3 -Wa,-32 -Wa,-mips3 -Wa,--trap
243 endif
244
245 ifeq ($(MACHINE),sparc32)
246 MODCFLAGS += -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
247 endif
248
249 ifeq ($(MACHINE),sparc64)
250 MODCFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow \
251              -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare \
252              -Wa,--undeclared-regs
253 endif
254
255 ifeq ($(SMP),1)
256 MODCPPFLAGS += -D__SMP__
257 endif
258
259 ifeq ($(MODVER),1)
260 MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h
261 endif
262
263 # This magic is from the kernel Makefile.
264 # Extra cflags for kbuild 2.4.  The default is to forbid includes by kernel code
265 # from user space headers.
266 kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
267
268 MODCPPFLAGS += -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -fomit-frame-pointer $(ALL_CPPFLAGS) -I$(LINUX_HEADERS) $(kbuild_2_4_nostdinc)
269 MODCFLAGS += $(ALL_CFLAGS)
270 PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS) -Wundef
271 PROGCFLAGS := $(ALL_CFLAGS)
272 ARCPPFLAGS := $(ALL_CPPFLAGS)
273 ifdef SYSFS_SUPPORT
274 ARCPPFLAGS := $(ARCPPFLAGS) -DSYSFS_SUPPORT
275 endif
276 ARCFLAGS := $(ALL_CFLAGS)
277 LIBCPPFLAGS := $(ALL_CPPFLAGS)
278 ifdef SYSFS_SUPPORT
279 LIBCPPFLAGS := $(LIBCPPFLAGS) -DSYSFS_SUPPORT
280 endif
281 LIBCFLAGS := -fpic $(ALL_CFLAGS)
282
283 .PHONY: all clean install version package dep
284
285 # Make all the default rule
286 all::
287
288 # Include all makefiles for sub-modules
289 INCLUDEFILES :=
290 include $(patsubst %,%/Module.mk,$(SRCDIRS))
291 ifneq ($(MAKECMDGOALS),clean)
292 ifneq ($(MAKECMDGOALS),uninstall)
293 ifneq ($(MAKECMDGOALS),user_uninstall)
294 ifneq ($(MAKECMDGOALS),help)
295 ifneq ($(MAKECMDGOALS),package)
296 ifneq ($(MAKECMDGOALS),userpackage)
297 include $(INCLUDEFILES)
298 endif
299 endif
300 endif
301 endif
302 endif
303 endif
304
305 # Man pages
306 MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \
307             $(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8
308
309 # Making the dependency files - done automatically!
310 dep :
311
312 user ::
313 user_install::
314         @echo "*** Important note:"
315         @echo "***  * The libsensors configuration file ($(ETCDIR)/sensors.conf) is never"
316         @echo "***    overwritten by our installation process, so that you won't lose"
317         @echo "***    your personal settings in that file. You still can get our latest"
318         @echo "***    default config file in etc/sensors.conf.eg and manually copy it to"
319         @echo "***    $(ETCDIR)/sensors.conf if you want. You will then want to edit it"
320         @echo "***    to fit your needs again."
321 all :: user
322 install :: all user_install
323 ifeq ($(DESTDIR),)
324         -/sbin/depmod -a
325 else
326         @echo "*** This is a \`staged' install using \"$(DESTDIR)\" as prefix."
327         @echo "***"
328         @echo "*** Once the modules have been moved to their final destination"
329         @echo "*** you must run the command \"/sbin/depmod -a\"."
330         @echo "***"
331         @echo "*** Alternatively, if you build a package (e.g. rpm), include the"
332         @echo "*** command \"/sbin/depmod -a\" in the post-(un)install procedure."
333         @echo "***"
334         @echo "*** The depmod command mentioned above may generate errors. We are"
335         @echo "*** aware of the problem and are working on a solution."
336 endif
337
338 clean::
339         $(RM) lm_sensors-*
340
341 user_uninstall::
342
343 uninstall :: user_uninstall
344         @echo "*** Note:"
345         @echo "***  * Kernel modules were not uninstalled."
346
347 # This is tricky, but it works like a charm. It needs lots of utilities
348 # though: cut, find, gzip, ln, tail and tar.
349 package: version clean
350         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
351         lmpackage=lm_sensors-$$lmversion; \
352         ln -s . $$lmpackage;  \
353         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
354                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
355                                     grep -v ^$$lmpackage/$$ | \
356                                     grep -v /CVS | \
357                                     grep -v /\\.# | \
358                                     tar rvf $$lmpackage.tar -T -; \
359         gzip -9 $$lmpackage.tar ;\
360         $(RM) $$lmpackage.tar $$lmpackage
361         cat doc/developers/checklist
362
363 # doesn't work well yet... needs Makefile changes too
364 userpackage: version clean $(KERNELINCLUDEDIR)/sensors.h
365         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
366         lmpackage=lm_sensors-user-$$lmversion; \
367         ln -s . $$lmpackage;  \
368         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
369                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
370                                     grep -v ^$$lmpackage/doc/chips | \
371                                     grep -v ^$$lmpackage/doc/busses | \
372                                     grep -v ^$$lmpackage/kernel/chips | \
373                                     grep -v ^$$lmpackage/kernel/busses | \
374                                     grep -v ^$$lmpackage/$$ | \
375                                     grep -v /CVS | \
376                                     grep -v /\\.# | \
377                                     tar rvf $$lmpackage.tar -T -; \
378         gzip -9 $$lmpackage.tar ;\
379         $(RM) $$lmpackage.tar $$lmpackage
380         cat doc/developers/checklist
381
382 version:
383         $(RM) version.h
384         echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
385         echo -n 'Version: '; \
386         echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
387
388 help:
389         @echo 'Make targets are:'
390         @echo '  all (default): build modules and userspace programs'
391         @echo '  install: install modules and userspace programs'
392         @echo '  user: build userspace programs'
393         @echo '  user_install: install userspace programs'
394         @echo '  user_uninstall: remove userspace programs'
395         @echo '  clean: cleanup'
396         @echo '  package: create a distribution package'
397         @echo 'Note: make dep is automatic'
398
399 $(LINUX)/.config:
400         @echo
401         @echo "Error - missing file $(LINUX)/.config !! "
402         @echo "  Verify kernel source is in $(LINUX) and then"
403         @echo "  cd to $(LINUX) and run 'make config' !!"
404         @echo
405         @echo "Exception: if you're using a stock RedHat kernel..."
406         @echo "  (1) Install the appropriate kernel-source RPM."
407         @echo "  (2) Copy the appropriate config..."
408         @echo "      from $(LINUX)/configs/<...>"
409         @echo "      to $(LINUX)/.config"
410         @echo "  (3) Do *NOT* 'make dep' or 'make config'."
411         @echo
412         @exit 1
413
414 # Generate html man pages to be copied to the lm_sensors website.
415 # This uses the man2html from here
416 # http://ftp.math.utah.edu/pub/sgml/
417 # which works directly from the nroff source
418 manhtml:
419         $(MKDIR) html
420         cp $(MANPAGES) html
421         cd html ; \
422         export LOGNAME=sensors ; \
423         export HOSTNAME=stimpy.netroedge.com ; \
424         man2html *.[1-8] ; \
425         $(RM) *.[1-8]
426
427 # Here, we define all implicit rules we want to use.
428
429 .SUFFIXES:
430
431 # We need to create dependency files. Tricky. We sed rule puts dir/file.d and
432 # dir/file.c in front of the dependency file rule.
433
434 # .o files are used for modules
435 # depend on the kernel config file!
436 %.o: %.c $(LINUX)/.config
437         $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@
438
439 %.d: %.c $(LINUX)/.config
440         $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \
441         $(SED) -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
442
443
444
445 # .ro files are used for programs (as opposed to modules)
446 %.ro: %.c
447         $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
448
449 %.rd: %.c
450         $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
451         $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
452
453
454 %: %.ro
455         $(CC) $(EXLDFLAGS) -o $@ $^
456
457
458 # .ao files are used for static archives
459 %.ao: %.c
460         $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
461
462 %.ad: %.c
463         $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
464         $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
465
466
467 # .lo files are used for shared libraries
468 %.lo: %.c
469         $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
470
471 %.ld: %.c
472         $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
473         $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
474
475
476 # Flex and Bison
477 %c: %y
478         $(BISON) -p sensors_yy -d $< -o $@
479
480 %.c: %.l
481         $(FLEX) -Psensors_yy -t $< > $@
Note: See TracBrowser for help on using the browser.