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

Revision 1874, 13.2 kB (checked in by khali, 5 years ago)

Add two important notes about the configuration file and dmidecode

after "make install".

  • 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 # Determine whether we need to compile the kernel modules, or only the
42 # user-space utilities. By default, the kernel modules are compiled.
43 # Leave this set to 1. If you want to compile and install only
44 # the library and the userspace programs,
45 #  use 'make user' and 'make user_install'
46 #COMPILE_KERNEL := 0
47 COMPILE_KERNEL := 1
48
49 # If you have installed the i2c header at some other place (like
50 # /usr/local/include/linux), set that directory here. Please check this out
51 # if you get strange compilation errors; the default Linux i2c headers
52 # may be used mistakenly. Note: This should point to the directory
53 # *above* the linux/ subdirectory, so to /usr/local/include in the
54 # above example.
55 I2C_HEADERS := /usr/local/include
56 #I2C_HEADERS := $(LINUX_HEADERS)
57
58 # Uncomment the third line on SMP systems if the magic invocation fails. It
59 # is a bit complicated because SMP configuration changed around kernel 2.1.130
60 SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \
61                   grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
62                then echo 1; else echo 0; fi)
63 #SMP := 0
64 #SMP := 1
65
66 # Uncomment the second or third line if the magic invocation fails.
67 # We need to know whether CONFIG_MODVERSIONS is defined.
68 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)
69 #MODVER := 0
70 #MODVER := 1
71
72 # Uncomment the second line if you are a developer. This will enable many
73 # additional warnings at compile-time
74 WARN := 0
75 #WARN := 1
76
77 # Uncomment the second line if you want to get (loads of) debug information
78 # at run-time.
79 # Not recommended, unless you are actually debugging the code
80 DEBUG := 0
81 #DEBUG := 1
82
83 # If you want to install at some other place then at from which you will run
84 # everything, set DESTDIR to the extra prefix.
85 DESTDIR :=
86
87 # This is the prefix that will be used for almost all directories below.
88 PREFIX := /usr/local
89
90 # This is the main modules directory into which the modules will be installed.
91 # The magic invocation will return something like this:
92 #   /lib/modules/2.2.15-ac9
93 #MODDIR := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`/misc
94 #MODPREF := /lib/modules/$(KERNELVERSION)
95 #MODPREF := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`
96 MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"')
97
98 # This is the directory where sensors.conf will be installed, if no other
99 # configuration file is found
100 ETCDIR := /etc
101
102 # You should not need to change this. It is the directory into which the
103 # library files (both static and shared) will be installed.
104 LIBDIR := $(PREFIX)/lib
105
106 # You should not need to change this. It is the directory into which the
107 # executable program files will be installed. BINDIR for programs that are
108 # also useful for normal users, SBINDIR for programs that can only be run
109 # by the superuser.
110 # Note that not all programs in this package are really installed;
111 # some are just examples. You can always install them by hand, of
112 # course.
113 BINDIR := $(PREFIX)/bin
114 SBINDIR := $(PREFIX)/sbin
115
116 # You should not need to change this. It is the basic directory into which
117 # include files will be installed. The actual directory will be
118 # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors
119 # for library include files. If PREFIX equals the default /usr/local/bin,
120 # you will be able to use '#include <linux/sensors.h>' regardless of the
121 # current kernel selected.
122 INCLUDEDIR := $(PREFIX)/include
123 SYSINCLUDEDIR := $(INCLUDEDIR)/linux
124 LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
125
126 # You should not need to change this. It is the base directory under which the
127 # manual pages will be installed.
128 MANDIR := $(PREFIX)/man
129
130 # You should not need to change this. It defines the manual owner and group
131 # as which manual pages are installed.
132 MANOWN := root
133 MANGRP := root
134
135 MACHINE := $(shell uname -m)
136
137 # Extra non-default programs to build; e.g., sensord
138 # PROG_EXTRA := sensord
139
140 # Set these to add preprocessor or compiler flags, or use
141 # environment variables
142 # CFLAGS :=
143 # CPPFLAGS :=
144
145 ##################################################
146 # Below this, nothing should need to be changed. #
147 ##################################################
148
149 # Note that this is a monolithic Makefile; it calls no sub-Makefiles,
150 # but instead, it compiles everything right from here. Yes, there are
151 # some distinct advantages to this; see the following paper for more info:
152 #   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
153 # Note that is still uses Makefile fragments in sub-directories; these
154 # are called 'Module.mk'.
155
156 # Within each Module.mk, rules and dependencies can be added to targets
157 # all, install and clean. Use double colons instead of single ones
158 # to do this.
159
160 # The subdirectories we need to build things in
161 SRCDIRS := mkpatch
162 ifeq ($(COMPILE_KERNEL),1)
163 SRCDIRS += kernel kernel/busses kernel/chips kernel/include
164 endif
165 SRCDIRS += lib prog/sensors prog/dump prog/detect ${PROG_EXTRA:%=prog/%} etc
166
167 # Some often-used commands with default options
168 MKDIR := mkdir -p
169 RMDIR := rmdir
170 RM := rm -f
171 CC := gcc
172 BISON := bison
173 FLEX := flex
174 AR := ar
175 INSTALL := install
176 LN := ln -sfn
177 GREP := grep
178 AWK := awk
179 SED := sed
180
181 # Determine the default compiler flags
182 # Set CFLAGS or CPPFLAGS above to add your own flags to all.
183 # ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
184 # MODCPPFLAGS/MODCFLAGS is to create in-kernel object files (modules).
185 # PROGCPPFLAGS/PROGCFLAGS is to create non-kernel object files (which are linked into executables).
186 # ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
187 # LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
188 ALL_CPPFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS) -I$(LINUX_HEADERS)
189 ALL_CFLAGS := -Wall -O2
190
191 ifeq ($(DEBUG),1)
192 ALL_CPPFLAGS += -DDEBUG
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) $(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 notes:"
265         @echo "*** 1* 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         @echo "*** 2* The dmidecode tool ($(SBINDIR)/dmidecode) is not necessarily"
272         @echo "***    overwritten either, because we don't distribute the latest version."
273         @echo "***    If you know you have an old one (1.7 or earlier), you should copy"
274         @echo "***    our version (prog/detect/dmidecode) to $(SBINDIR)/dmidecode. Our"
275         @echo "***    installation process relies on a simple date comparison to decide"
276         @echo "***    wether or not it should overwrite the file, but the trick may"
277         @echo "***    fail if for any reason you installed an old verion of dmidecode"
278         @echo "***    at a time a newer version was available."
279
280 clean::
281         $(RM) lm_sensors-*
282
283 # This is tricky, but it works like a charm. It needs lots of utilities
284 # though: cut, find, gzip, ln, tail and tar.
285 package: version clean
286         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
287         lmpackage=lm_sensors-$$lmversion; \
288         ln -s . $$lmpackage;  \
289         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
290                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
291                                     grep -v ^$$lmpackage/$$ | \
292                                     grep -v /CVS | \
293                                     grep -v /\\.# | \
294                                     tar rvf $$lmpackage.tar -T -; \
295         gzip -9 $$lmpackage.tar ;\
296         $(RM) $$lmpackage.tar $$lmpackage
297         cat doc/developers/checklist
298
299 version:
300         $(RM) version.h
301         echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
302         echo -n 'Version: '; \
303         echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
304
305 help:
306         @echo 'Make targets are:'
307         @echo '  all (default): build modules and userspace programs'
308         @echo '  install: install modules and userspace programs'
309         @echo '  user: build userspace programs'
310         @echo '  user_install: install userspace programs'
311         @echo '  clean: cleanup'
312         @echo '  package: create a distribution package'
313         @echo 'Note: make dep is automatic'
314
315 # Here, we define all implicit rules we want to use.
316
317 .SUFFIXES:
318
319 # We need to create dependency files. Tricky. We sed rule puts dir/file.d and
320 # dir/file.c in front of the dependency file rule.
321
322 # .o files are used for modules
323 %.o: %.c
324         $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@
325
326 %.d: %.c
327         $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \
328         $(SED) -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
329
330
331
332 # .ro files are used for programs (as opposed to modules)
333 %.ro: %.c
334         $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
335
336 %.rd: %.c
337         $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
338         $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
339
340
341 %: %.ro
342         $(CC) $(EXLDFLAGS) -o $@ $^
343
344
345 # .ao files are used for static archives
346 %.ao: %.c
347         $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
348
349 %.ad: %.c
350         $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
351         $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
352
353
354 # .lo files are used for shared libraries
355 %.lo: %.c
356         $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
357
358 %.ld: %.c
359         $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
360         $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
361
362
363 # Flex and Bison
364 %c: %y
365         $(BISON) -p sensors_yy -d $< -o $@
366
367 %.c: %.l
368         $(FLEX) -Psensors_yy -t $< > $@
Note: See TracBrowser for help on using the browser.