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

Revision 2273, 12.8 kB (checked in by khali, 5 years ago)

Move note about sensors.conf from install to install_user.

  • 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 # Your C compiler
83 CC := gcc
84
85 # This is the main modules directory into which the modules will be installed.
86 # The magic invocation will return something like this:
87 #   /lib/modules/2.2.15-ac9
88 #MODDIR := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`/misc
89 #MODPREF := /lib/modules/$(KERNELVERSION)
90 #MODPREF := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`
91 MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"')
92
93 # This is the directory where sensors.conf will be installed, if no other
94 # configuration file is found
95 ETCDIR := /etc
96
97 # You should not need to change this. It is the directory into which the
98 # library files (both static and shared) will be installed.
99 LIBDIR := $(PREFIX)/lib
100
101 EXLDFLAGS := -Wl,-rpath,$(LIBDIR)
102
103 # You should not need to change this. It is the directory into which the
104 # executable program files will be installed. BINDIR for programs that are
105 # also useful for normal users, SBINDIR for programs that can only be run
106 # by the superuser.
107 # Note that not all programs in this package are really installed;
108 # some are just examples. You can always install them by hand, of
109 # course.
110 BINDIR := $(PREFIX)/bin
111 SBINDIR := $(PREFIX)/sbin
112
113 # You should not need to change this. It is the basic directory into which
114 # include files will be installed. The actual directory will be
115 # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors
116 # for library include files. If PREFIX equals the default /usr/local/bin,
117 # you will be able to use '#include <linux/sensors.h>' regardless of the
118 # current kernel selected.
119 INCLUDEDIR := $(PREFIX)/include
120 SYSINCLUDEDIR := $(INCLUDEDIR)/linux
121 LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
122
123 # You should not need to change this. It is the base directory under which the
124 # manual pages will be installed.
125 MANDIR := $(PREFIX)/man
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 BISON := bison
169 FLEX := flex
170 AR := ar
171 INSTALL := install
172 LN := ln -sf
173 GREP := grep
174 AWK := awk
175 SED := sed
176
177 # Determine the default compiler flags
178 # Set CFLAGS or CPPFLAGS above to add your own flags to all.
179 # ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
180 # MODCPPFLAGS/MODCFLAGS is to create in-kernel object files (modules).
181 # PROGCPPFLAGS/PROGCFLAGS is to create non-kernel object files (which are linked into executables).
182 # ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
183 # LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
184 ALL_CPPFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS)
185 ALL_CFLAGS := -Wall
186
187 ifeq ($(DEBUG),1)
188 ALL_CPPFLAGS += -DDEBUG
189 ALL_CFLAGS += -O -g
190 else
191 ALL_CFLAGS += -O2
192 endif
193
194 ifeq ($(WARN),1)
195 ALL_CFLAGS += -W -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
196             -Wcast-align -Wwrite-strings -Wnested-externs -Winline
197 endif
198
199 ALL_CPPFLAGS += $(CPPFLAGS)
200 ALL_CFLAGS += $(CFLAGS)
201
202 MODCPPFLAGS :=
203 MODCFLAGS :=
204
205 ifeq ($(MACHINE),alpha)
206 MODCFLAGS += -ffixed-8 -mno-fp-regs -mcpu=ev56
207 endif
208
209 ifeq ($(MACHINE),x86_64)
210 MODCFLAGS += -fno-strict-aliasing -fno-common -fomit-frame-pointer -mno-red-zone \
211              -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce
212 endif
213
214 ifeq ($(SMP),1)
215 MODCPPFLAGS += -D__SMP__
216 endif
217
218 ifeq ($(MODVER),1)
219 MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h
220 endif
221
222 # This magic is from the kernel Makefile.
223 # Extra cflags for kbuild 2.4.  The default is to forbid includes by kernel code
224 # from user space headers.
225 kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
226
227 MODCPPFLAGS += -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -fomit-frame-pointer $(ALL_CPPFLAGS) -I$(LINUX_HEADERS) $(kbuild_2_4_nostdinc)
228 MODCFLAGS += $(ALL_CFLAGS)
229 PROGCPPFLAGS := $(ALL_CPPFLAGS)
230 PROGCFLAGS := $(ALL_CFLAGS)
231 ARCPPFLAGS := $(ALL_CPPFLAGS)
232 ARCFLAGS := $(ALL_CFLAGS)
233 LIBCPPFLAGS := $(ALL_CPPFLAGS)
234 LIBCFLAGS := -fpic $(ALL_CFLAGS)
235
236 .PHONY: all clean install version package dep
237
238 # Make all the default rule
239 all::
240
241 # Include all makefiles for sub-modules
242 INCLUDEFILES :=
243 include $(patsubst %,%/Module.mk,$(SRCDIRS))
244 ifneq ($(MAKECMDGOALS),clean)
245 include $(INCLUDEFILES)
246 endif
247
248 # Making the dependency files - done automatically!
249 dep :
250
251 user ::
252 user_install::
253         @echo "*** Important note:"
254         @echo "***  * The libsensors configuration file ($(ETCDIR)/sensors.conf) is never"
255         @echo "***    overwritten by our installation process, so that you won't lose"
256         @echo "***    your personal settings in that file. You still can get our latest"
257         @echo "***    default config file in etc/sensors.conf.eg and manually copy it to"
258         @echo "***    $(ETCDIR)/sensors.conf if you want. You will then want to edit it"
259         @echo "***    to fit your needs again."
260 all :: user
261 install :: all user_install
262         @echo "*** The depmod command below may generate errors. We are aware of the"
263         @echo "*** problem and are working on a solution."
264 ifeq ($(DESTDIR),)
265         -/sbin/depmod -a
266 else
267         -/sbin/depmod -a -b $(DESTDIR)
268 endif
269
270 clean::
271         $(RM) lm_sensors-*
272
273 # This is tricky, but it works like a charm. It needs lots of utilities
274 # though: cut, find, gzip, ln, tail and tar.
275 package: version clean
276         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
277         lmpackage=lm_sensors-$$lmversion; \
278         ln -s . $$lmpackage;  \
279         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
280                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
281                                     grep -v ^$$lmpackage/$$ | \
282                                     grep -v /CVS | \
283                                     grep -v /\\.# | \
284                                     tar rvf $$lmpackage.tar -T -; \
285         gzip -9 $$lmpackage.tar ;\
286         $(RM) $$lmpackage.tar $$lmpackage
287         cat doc/developers/checklist
288
289 version:
290         $(RM) version.h
291         echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
292         echo -n 'Version: '; \
293         echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
294
295 help:
296         @echo 'Make targets are:'
297         @echo '  all (default): build modules and userspace programs'
298         @echo '  install: install modules and userspace programs'
299         @echo '  user: build userspace programs'
300         @echo '  user_install: install userspace programs'
301         @echo '  clean: cleanup'
302         @echo '  package: create a distribution package'
303         @echo 'Note: make dep is automatic'
304
305 $(LINUX)/.config:
306         @echo
307         @echo "Error - missing file $(LINUX)/.config !! "
308         @echo "  Verify kernel source is in $(LINUX) and then"
309         @echo "  cd to $(LINUX) and run 'make config' !!"
310         @echo
311         @echo "Exception: if you're using a stock RedHat kernel..."
312         @echo "  (1) Install the appropriate kernel-source RPM."
313         @echo "  (2) Copy the appropriate config..."
314         @echo "      from $(LINUX)/configs/<...>"
315         @echo "      to $(LINUX)/.config"
316         @echo "  (3) Do *NOT* 'make dep' or 'make config'."
317         @echo
318         @exit 1
319
320 # Here, we define all implicit rules we want to use.
321
322 .SUFFIXES:
323
324 # We need to create dependency files. Tricky. We sed rule puts dir/file.d and
325 # dir/file.c in front of the dependency file rule.
326
327 # .o files are used for modules
328 # depend on the kernel config file!
329 %.o: %.c $(LINUX)/.config
330         $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@
331
332 %.d: %.c $(LINUX)/.config
333         $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \
334         $(SED) -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
335
336
337
338 # .ro files are used for programs (as opposed to modules)
339 %.ro: %.c
340         $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
341
342 %.rd: %.c
343         $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
344         $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
345
346
347 %: %.ro
348         $(CC) $(EXLDFLAGS) -o $@ $^
349
350
351 # .ao files are used for static archives
352 %.ao: %.c
353         $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
354
355 %.ad: %.c
356         $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
357         $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
358
359
360 # .lo files are used for shared libraries
361 %.lo: %.c
362         $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
363
364 %.ld: %.c
365         $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
366         $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
367
368
369 # Flex and Bison
370 %c: %y
371         $(BISON) -p sensors_yy -d $< -o $@
372
373 %.c: %.l
374         $(FLEX) -Psensors_yy -t $< > $@
Note: See TracBrowser for help on using the browser.