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

Revision 1664, 10.8 kB (checked in by khali, 6 years ago)

Back to the old MODPREF

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