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

Revision 1361, 10.3 kB (checked in by mds, 7 years ago)

use $CFLAGS and $CPPFLAGS from environment or if specified

in Makfile. Patch from

"Kevin P. Fleming" <kevin@labsysgrp.com>

  • 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 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. Note: This should point to the directory
43 # *above* the linux/ subdirectory, so to /usr/local/include in the
44 # above example.
45 I2C_HEADERS=/usr/local/include
46 #I2C_HEADERS=$(LINUX_HEADERS)
47
48 # Uncomment the third line on SMP systems if the magic invocation fails. It
49 # is a bit complicated because SMP configuration changed around kernel 2.1.130
50 SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \
51                   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 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)
59 #MODVER := 0
60 #MODVER := 1
61
62 # Uncomment the second line if you are a developer. This will enable many
63 # additional warnings at compile-time
64 WARN := 0
65 #WARN := 1
66
67 # Uncomment the second line if you want to get (loads of) debug information
68 # at run-time.
69 # Not recommended, unless you are actually debugging the code
70 DEBUG := 0
71 #DEBUG := 1
72
73 # If you want to install at some other place then at from which you will run
74 # everything, set DESTDIR to the extra prefix.
75 DESTDIR :=
76
77 # This is the prefix that will be used for almost all directories below.
78 PREFIX := /usr/local
79
80 # This is the directory into which the modules will be installed.
81 # The magic invocation will return something like this:
82 #   /lib/modules/2.2.15-ac9/misc
83 # MODDIR := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`/misc
84 MODPREF := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`
85
86 # This is the directory where sensors.conf will be installed, if no other
87 # configuration file is found
88 ETCDIR := /etc
89
90 # You should not need to change this. It is the directory into which the
91 # library files (both static and shared) will be installed.
92 LIBDIR := $(PREFIX)/lib
93
94 # You should not need to change this. It is the directory into which the
95 # executable program files will be installed. BINDIR for programs that are
96 # also useful for normal users, SBINDIR for programs that can only be run
97 # by the superuser.
98 # Note that not all programs in this package are really installed;
99 # some are just examples. You can always install them by hand, of
100 # course.
101 BINDIR := $(PREFIX)/bin
102 SBINDIR := $(PREFIX)/sbin
103
104 # You should not need to change this. It is the basic directory into which
105 # include files will be installed. The actual directory will be
106 # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors
107 # for library include files. If PREFIX equals the default /usr/local/bin,
108 # you will be able to use '#include <linux/sensors.h>' regardless of the
109 # current kernel selected.
110 INCLUDEDIR := $(PREFIX)/include
111 SYSINCLUDEDIR := $(INCLUDEDIR)/linux
112 LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
113
114 # You should not need to change this. It is the base directory under which the
115 # manual pages will be installed.
116 MANDIR := $(PREFIX)/man
117
118 # You should not need to change this. It defines the manual owner and group
119 # as which manual pages are installed.
120 MANOWN := root
121 MANGRP := root
122
123 MACHINE := $(shell uname -m)
124
125 # Extra non-default programs to build; e.g., sensord
126 # PROG_EXTRA := sensord
127
128 # Set these to add preprocessor or compiler flags, or use
129 # environment variables
130 # CFLAGS :=
131 # CPPFLAGS :=
132
133 ##################################################
134 # Below this, nothing should need to be changed. #
135 ##################################################
136
137 # Note that this is a monolithic Makefile; it calls no sub-Makefiles,
138 # but instead, it compiles everything right from here. Yes, there are
139 # some distinct advantages to this; see the following paper for more info:
140 #   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
141 # Note that is still uses Makefile fragments in sub-directories; these
142 # are called 'Module.mk'.
143
144 # Within each Module.mk, rules and dependencies can be added to targets
145 # all, install and clean. Use double colons instead of single ones
146 # to do this.
147
148 # The subdirectories we need to build things in
149 SRCDIRS := mkpatch
150 ifeq ($(COMPILE_KERNEL),1)
151 SRCDIRS += kernel kernel/busses kernel/chips kernel/include
152 endif
153 SRCDIRS += lib prog/sensors prog/dump prog/detect ${PROG_EXTRA:%=prog/%} etc
154
155 # Some often-used commands with default options
156 MKDIR := mkdir -p
157 RM := rm -f
158 CC := gcc
159 BISON := bison
160 FLEX := flex
161 AR := ar
162 INSTALL := install
163 LN := ln -sfn
164 GREP := grep
165
166 # Determine the default compiler flags
167 # Set CFLAGS or CPPFLAGS above to add your own flags to all.
168 # ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
169 # MODCPPFLAGS/MODCFLAGS is to create in-kernel object files (modules).
170 # PROGCPPFLAGS/PROGCFLAGS is to create non-kernel object files (which are linked into executables).
171 # ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
172 # LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
173 ALL_CPPFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS) -I$(LINUX_HEADERS)
174 ALL_CFLAGS := -O2
175
176 ifeq ($(DEBUG),1)
177 ALL_CPPFLAGS += -DDEBUG
178 endif
179
180 ifeq ($(WARN),1)
181 ALL_CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
182             -Wcast-align -Wwrite-strings -Wnested-externs -Winline
183 endif
184
185 ALL_CPPFLAGS += $(CPPFLAGS)
186 ALL_CFLAGS += $(CFLAGS)
187
188 MODCPPFLAGS :=
189 MODCFLAGS :=
190
191 ifeq ($(MACHINE),alpha)
192 MODCFLAGS += -ffixed-8
193 endif
194
195 ifeq ($(SMP),1)
196 MODCPPFLAGS += -D__SMP__
197 endif
198
199 ifeq ($(MODVER),1)
200 MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h
201 endif
202
203 MODCPPFLAGS += -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -fomit-frame-pointer $(ALL_CPPFLAGS)
204 MODCFLAGS += $(ALL_CFLAGS)
205 PROGCPPFLAGS := $(ALL_CPPFLAGS)
206 PROGCFLAGS := $(ALL_CFLAGS)
207 ARCPPFLAGS := $(ALL_CPPFLAGS)
208 ARCFLAGS := $(ALL_CFLAGS)
209 LIBCPPFLAGS := $(ALL_CPPFLAGS)
210 LIBCFLAGS := -fpic $(ALL_CFLAGS)
211
212 .PHONY: all clean install version package dep
213
214 # Make all the default rule
215 all::
216
217 # Include all makefiles for sub-modules
218 INCLUDEFILES :=
219 include $(patsubst %,%/Module.mk,$(SRCDIRS))
220 ifneq ($(MAKECMDGOALS),clean)
221 include $(INCLUDEFILES)
222 endif
223
224 # Making the dependency files - done automatically!
225 dep :
226
227 all ::
228
229 install :: all
230
231 clean::
232         $(RM) lm_sensors-*
233
234 # This is tricky, but it works like a charm. It needs lots of utilities
235 # though: cut, find, gzip, ln, tail and tar.
236 package: version clean
237         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
238         lmpackage=lm_sensors-$$lmversion; \
239         ln -s . $$lmpackage;  \
240         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
241                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
242                                     grep -v ^$$lmpackage/$$ | \
243                                     grep -v /CVS | \
244                                     grep -v /\\.# | \
245                                     tar rvf $$lmpackage.tar -T -; \
246         gzip -9 $$lmpackage.tar ;\
247         $(RM) $$lmpackage.tar $$lmpackage
248         cat doc/developers/checklist
249
250 version:
251         $(RM) version.h
252         echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
253         echo -n 'Version: '; \
254         echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
255
256
257 # Here, we define all implicit rules we want to use.
258
259 .SUFFIXES:
260
261 # We need to create dependency files. Tricky. We sed rule puts dir/file.d and
262 # dir/file.c in front of the dependency file rule.
263
264 # .o files are used for modules
265 %.o: %.c
266         $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@
267
268 %.d: %.c
269         $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \
270         sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
271
272
273
274 # .ro files are used for programs (as opposed to modules)
275 %.ro: %.c
276         $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
277
278 %.rd: %.c
279         $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
280         sed -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
281
282
283 %: %.ro
284         $(CC) $(EXLDFLAGS) -o $@ $^
285
286
287 # .ao files are used for static archives
288 %.ao: %.c
289         $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
290
291 %.ad: %.c
292         $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
293         sed -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
294
295
296 # .lo files are used for shared libraries
297 %.lo: %.c
298         $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
299
300 %.ld: %.c
301         $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
302         sed -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
303
304
305 # Flex and Bison
306 %c: %y
307         $(BISON) -p sensors_yy -d $< -o $@
308
309 %.c: %.l
310         $(FLEX) -Psensors_yy -t $< > $@
Note: See TracBrowser for help on using the browser.