root/lm-sensors/tags/V2-8-2/Makefile

Revision 2118, 13.0 kB (checked in by khali, 5 years ago)

Don't include dmidecode anymore.

  • 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. It
51 # is a bit complicated because SMP configuration changed around kernel 2.1.130
52 SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \
53                   grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
54                then echo 1; else echo 0; fi)
55 #SMP := 0
56 #SMP := 1
57
58 # Uncomment the second or third line if the magic invocation fails.
59 # We need to know whether CONFIG_MODVERSIONS is defined.
60 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)
61 #MODVER := 0
62 #MODVER := 1
63
64 # Uncomment the second line if you are a developer. This will enable many
65 # additional warnings at compile-time
66 WARN := 0
67 #WARN := 1
68
69 # Uncomment the second line if you want to get (loads of) debug information
70 # at run-time.
71 # Not recommended, unless you are actually debugging the code
72 DEBUG := 0
73 #DEBUG := 1
74
75 # If you want to install at some other place then at from which you will run
76 # everything, set DESTDIR to the extra prefix.
77 DESTDIR :=
78
79 # This is the prefix that will be used for almost all directories below.
80 PREFIX := /usr/local
81
82 # This is the main modules directory into which the modules will be installed.
83 # The magic invocation will return something like this:
84 #   /lib/modules/2.2.15-ac9
85 #MODDIR := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`/misc
86 #MODPREF := /lib/modules/$(KERNELVERSION)
87 #MODPREF := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`
88 MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"')
89
90 # This is the directory where sensors.conf will be installed, if no other
91 # configuration file is found
92 ETCDIR := /etc
93
94 # You should not need to change this. It is the directory into which the
95 # library files (both static and shared) will be installed.
96 LIBDIR := $(PREFIX)/lib
97
98 # You should not need to change this. It is the directory into which the
99 # executable program files will be installed. BINDIR for programs that are
100 # also useful for normal users, SBINDIR for programs that can only be run
101 # by the superuser.
102 # Note that not all programs in this package are really installed;
103 # some are just examples. You can always install them by hand, of
104 # course.
105 BINDIR := $(PREFIX)/bin
106 SBINDIR := $(PREFIX)/sbin
107
108 # You should not need to change this. It is the basic directory into which
109 # include files will be installed. The actual directory will be
110 # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors
111 # for library include files. If PREFIX equals the default /usr/local/bin,
112 # you will be able to use '#include <linux/sensors.h>' regardless of the
113 # current kernel selected.
114 INCLUDEDIR := $(PREFIX)/include
115 SYSINCLUDEDIR := $(INCLUDEDIR)/linux
116 LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
117
118 # You should not need to change this. It is the base directory under which the
119 # manual pages will be installed.
120 MANDIR := $(PREFIX)/man
121
122 # You should not need to change this. It defines the manual owner and group
123 # as which manual pages are installed.
124 MANOWN := root
125 MANGRP := root
126
127 MACHINE := $(shell uname -m)
128
129 # Extra non-default programs to build; e.g., sensord
130 # PROG_EXTRA := sensord
131
132 # Set these to add preprocessor or compiler flags, or use
133 # environment variables
134 # CFLAGS :=
135 # CPPFLAGS :=
136
137 ##################################################
138 # Below this, nothing should need to be changed. #
139 ##################################################
140
141 # Note that this is a monolithic Makefile; it calls no sub-Makefiles,
142 # but instead, it compiles everything right from here. Yes, there are
143 # some distinct advantages to this; see the following paper for more info:
144 #   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
145 # Note that is still uses Makefile fragments in sub-directories; these
146 # are called 'Module.mk'.
147
148 # Within each Module.mk, rules and dependencies can be added to targets
149 # all, install and clean. Use double colons instead of single ones
150 # to do this.
151
152 # The subdirectories we need to build things in
153 SRCDIRS :=
154 ifneq ($(MAKECMDGOALS),user)
155 ifneq ($(MAKECMDGOALS),user_install)
156 SRCDIRS += mkpatch
157 SRCDIRS += kernel kernel/busses kernel/chips
158 endif
159 endif
160 SRCDIRS += kernel/include
161 SRCDIRS += lib prog/detect prog/dump prog/eeprom prog/pwm \
162            prog/sensors prog/xeon ${PROG_EXTRA:%=prog/%} etc
163
164 # Some often-used commands with default options
165 MKDIR := mkdir -p
166 RMDIR := rmdir
167 RM := rm -f
168 CC := gcc
169 BISON := bison
170 FLEX := flex
171 AR := ar
172 INSTALL := install
173 LN := ln -sf
174 GREP := grep
175 AWK := awk
176 SED := sed
177
178 # Determine the default compiler flags
179 # Set CFLAGS or CPPFLAGS above to add your own flags to all.
180 # ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
181 # MODCPPFLAGS/MODCFLAGS is to create in-kernel object files (modules).
182 # PROGCPPFLAGS/PROGCFLAGS is to create non-kernel object files (which are linked into executables).
183 # ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
184 # LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
185 ALL_CPPFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS)
186 ALL_CFLAGS := -Wall
187
188 ifeq ($(DEBUG),1)
189 ALL_CPPFLAGS += -DDEBUG
190 ALL_CFLAGS += -O -g
191 else
192 ALL_CFLAGS += -O2
193 endif
194
195 ifeq ($(WARN),1)
196 ALL_CFLAGS += -W -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
197             -Wcast-align -Wwrite-strings -Wnested-externs -Winline
198 endif
199
200 ALL_CPPFLAGS += $(CPPFLAGS)
201 ALL_CFLAGS += $(CFLAGS)
202
203 MODCPPFLAGS :=
204 MODCFLAGS :=
205
206 ifeq ($(MACHINE),alpha)
207 MODCFLAGS += -ffixed-8
208 endif
209
210 ifeq ($(MACHINE),x86_64)
211 MODCFLAGS += -fno-strict-aliasing -fno-common -fomit-frame-pointer -mno-red-zone\
212              -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce
213 endif
214
215 ifeq ($(SMP),1)
216 MODCPPFLAGS += -D__SMP__
217 endif
218
219 ifeq ($(MODVER),1)
220 MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h
221 endif
222
223 # This magic is from the kernel Makefile.
224 # Extra cflags for kbuild 2.4.  The default is to forbid includes by kernel code
225 # from user space headers.
226 kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
227
228 MODCPPFLAGS += -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -fomit-frame-pointer $(ALL_CPPFLAGS) -I$(LINUX_HEADERS) $(kbuild_2_4_nostdinc)
229 MODCFLAGS += $(ALL_CFLAGS)
230 PROGCPPFLAGS := $(ALL_CPPFLAGS)
231 PROGCFLAGS := $(ALL_CFLAGS)
232 ARCPPFLAGS := $(ALL_CPPFLAGS)
233 ARCFLAGS := $(ALL_CFLAGS)
234 LIBCPPFLAGS := $(ALL_CPPFLAGS)
235 LIBCFLAGS := -fpic $(ALL_CFLAGS)
236
237 .PHONY: all clean install version package dep
238
239 # Make all the default rule
240 all::
241
242 # Include all makefiles for sub-modules
243 INCLUDEFILES :=
244 include $(patsubst %,%/Module.mk,$(SRCDIRS))
245 ifneq ($(MAKECMDGOALS),clean)
246 include $(INCLUDEFILES)
247 endif
248
249 # Making the dependency files - done automatically!
250 dep :
251
252 user ::
253 user_install::
254 all :: user
255 install :: all user_install
256         @echo "*** The depmod command below may generate errors. We are aware of the"
257         @echo "*** problem and are working on a solution. You should ignore them for now."
258 ifeq ($(DESTDIR),)
259         -/sbin/depmod -a
260 else
261         -/sbin/depmod -a -b $(DESTDIR)
262 endif
263         @echo "*** Installation successful!"
264         @echo "*** Important note:"
265         @echo "***  * The libsensors configuration file ($(ETCDIR)/sensors.conf) is never"
266         @echo "***    overwritten by our installation process, so that you won't lose"
267         @echo "***    your personal settings in that file. You still can get our latest"
268         @echo "***    default config file in etc/sensors.conf.eg and manually copy it to"
269         @echo "***    $(ETCDIR)/sensors.conf if you want. You will then want to edit it"
270         @echo "***    to fit your needs again."
271
272 clean::
273         $(RM) lm_sensors-*
274
275 # This is tricky, but it works like a charm. It needs lots of utilities
276 # though: cut, find, gzip, ln, tail and tar.
277 package: version clean
278         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
279         lmpackage=lm_sensors-$$lmversion; \
280         ln -s . $$lmpackage;  \
281         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
282                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
283                                     grep -v ^$$lmpackage/$$ | \
284                                     grep -v /CVS | \
285                                     grep -v /\\.# | \
286                                     tar rvf $$lmpackage.tar -T -; \
287         gzip -9 $$lmpackage.tar ;\
288         $(RM) $$lmpackage.tar $$lmpackage
289         cat doc/developers/checklist
290
291 version:
292         $(RM) version.h
293         echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
294         echo -n 'Version: '; \
295         echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
296
297 help:
298         @echo 'Make targets are:'
299         @echo '  all (default): build modules and userspace programs'
300         @echo '  install: install modules and userspace programs'
301         @echo '  user: build userspace programs'
302         @echo '  user_install: install userspace programs'
303         @echo '  clean: cleanup'
304         @echo '  package: create a distribution package'
305         @echo 'Note: make dep is automatic'
306
307 $(LINUX)/.config:
308         @echo
309         @echo "Error - missing file $(LINUX)/.config !! "
310         @echo "  Verify kernel source is in $(LINUX) and then"
311         @echo "  cd to $(LINUX) and run 'make config' !!"
312         @echo
313         @echo "Exception: if you're using a stock RedHat kernel..."
314         @echo "  (1) Install the appropriate kernel-source RPM."
315         @echo "  (2) Copy the appropriate config..."
316         @echo "      from $(LINUX)/configs/<...>"
317         @echo "      to $(LINUX)/.config"
318         @echo "  (3) Do *NOT* 'make dep' or 'make config'."
319         @echo
320         @exit 1
321
322 # Here, we define all implicit rules we want to use.
323
324 .SUFFIXES:
325
326 # We need to create dependency files. Tricky. We sed rule puts dir/file.d and
327 # dir/file.c in front of the dependency file rule.
328
329 # .o files are used for modules
330 # depend on the kernel config file!
331 %.o: %.c $(LINUX)/.config
332         $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@
333
334 %.d: %.c $(LINUX)/.config
335         $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \
336         $(SED) -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
337
338
339
340 # .ro files are used for programs (as opposed to modules)
341 %.ro: %.c
342         $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
343
344 %.rd: %.c
345         $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
346         $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
347
348
349 %: %.ro
350         $(CC) $(EXLDFLAGS) -o $@ $^
351
352
353 # .ao files are used for static archives
354 %.ao: %.c
355         $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
356
357 %.ad: %.c
358         $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
359         $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
360
361
362 # .lo files are used for shared libraries
363 %.lo: %.c
364         $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
365
366 %.ld: %.c
367         $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
368         $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
369
370
371 # Flex and Bison
372 %c: %y
373         $(BISON) -p sensors_yy -d $< -o $@
374
375 %.c: %.l
376         $(FLEX) -Psensors_yy -t $< > $@
Note: See TracBrowser for help on using the browser.