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

Revision 450, 9.1 kB (checked in by frodo, 10 years ago)

Enhanced `make package'

It now handles CVS directories better, as well as '.#' files left-over by
CVS merges.

  • 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 and bison.
23
24 # The location of your kernel headers (which should be the linux and asm
25 # subdirectories). For most people, the below works perfectly. If you use
26 # Debian, you may want to change this to something like /usr/src/linux/include.
27 LINUX_HEADERS=/usr/include
28
29 # The location of linux itself. This is only used to determine whether you
30 # use a SMP kernel in the magic invocation just below.
31 LINUX=/usr/src/linux
32
33 # Uncomment the third line on SMP systems if the magic invocation fails. It
34 # is a bit complicated because SMP configuration changed around kernel 2.1.130
35 SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \
36                   grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
37                then echo 1; else echo 0; fi)
38 #SMP := 0
39 #SMP := 1
40
41 # Uncomment the second or third line if the magic invocation fails.
42 # We need to know whether CONFIG_MODVERSIONS is defined.
43 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)
44 #MODVER := 0
45 #MODVER := 1
46
47 # Uncomment the second line if you do not want to compile the included
48 # i2c modules. WARNING! If the i2c module version does not match the
49 # smbus/sensor module versions, you will get into severe problems.
50 # If you want to use a self-compiled version of the i2c modules, make
51 # sure <linux/i2c.h> contains the *correct* i2c header file! The stock
52 # Linux 2.1.xxx and 2.2.x modules are *not* good enough; you really need
53 # Simon Vogl's version!
54 I2C := 1
55 #I2C := 0
56
57 # Uncomment the second line if you are a developer. This will enable many
58 # additional warnings at compile-time
59 WARN := 0
60 #WARN := 1
61
62 # Uncomment the second line if you want to get (loads of) debug information.
63 # Not recommended, unless you are actually debugging the code
64 DEBUG := 0
65 #DEBUG := 1
66
67 # This is the prefix that will be used for almost all directories below.
68 PREFIX := /usr/local
69
70 # This is the directory into which the modules will be installed.
71 MODDIR := /lib/modules/current/extra/misc
72
73 # This is the directory where sensors.conf will be installed, if no other
74 # configuration file is found
75 ETCDIR := /etc
76
77 # You should not need to change this. It is the directory into which the
78 # library files (both static and shared) will be installed.
79 LIBDIR := $(PREFIX)/lib
80
81 # You should not need to change this. It is the directory into which the
82 # executable program files will be installed. BINDIR for programs that are
83 # also useful for normal users, SBINDIR for programs that can only be run
84 # by the superuser.
85 # Note that not all programs in this package are really installed;
86 # some are just examples. You can always install them by hand, of
87 # course.
88 BINDIR := $(PREFIX)/bin
89 SBINDIR := $(PREFIX)/sbin
90
91 # You should not need to change this. It is the basic directory into which
92 # include files will be installed. The actual directory will be
93 # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors
94 # for library include files. If PREFIX equals the default /usr/local/bin,
95 # you will be able to use '#include <linux/sensors.h>' regardless of the
96 # current kernel selected.
97 INCLUDEDIR := $(PREFIX)/include
98 SYSINCLUDEDIR := $(INCLUDEDIR)/linux
99 LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
100
101 # You should not need to change this. It is the base directory under which the
102 # manual pages will be installed.
103 MANDIR := $(PREFIX)/man
104
105 # You should not need to change this. It defines the manual owner and group
106 # as which manual pages are installed.
107 MANOWN := root
108 MANGRP := root
109
110 # If your /bin/sh is not bash, change the below definition so that make can
111 # find bash.
112 # SHELL=/usr/bin/bash
113
114 ##################################################
115 # Below this, nothing should need to be changed. #
116 ##################################################
117
118 # Note that this is a monolithic Makefile; it calls no sub-Makefiles,
119 # but instead, it compiles everything right from here. Yes, there are
120 # some distinct advantages to this; see the following paper for more info:
121 #   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
122 # Note that is still uses Makefile fragments in sub-directories; these
123 # are called 'Module.mk'.
124
125 # Within each Module.mk, rules and dependencies can be added to targets
126 # all, install and clean. Use double colons instead of single ones
127 # to do this.
128
129 # The subdirectories we need to build things in
130 SRCDIRS := kernel kernel/busses kernel/chips kernel/include lib prog/sensors \
131            prog/dump prog/detect etc
132 ifeq ($(I2C),1)
133 SRCDIRS += i2c i2c/detect i2c/drivers i2c/eeprom
134 endif
135
136 # Some often-used commands with default options
137 MKDIR := mkdir -p
138 RM := rm -f
139 CC := gcc
140 BISON := bison
141 FLEX := flex
142 AR := ar
143 INSTALL := install
144 LN := ln -sfn
145 GREP := grep
146
147 # Determine the default compiler flags
148 # MODCFLAGS is to create in-kernel object files (modules); PROGFLAGS is to
149 # create non-kernel object files (which are linked into executables).
150 # ARCFLAGS are used to create archive object files (static libraries), and
151 # LIBCFLAGS are for shared library objects.
152 CFLAGS := -I. -Ii2c -Ikernel/include -I$(LINUX_HEADERS) -O2 -DLM_SENSORS
153
154 ifeq ($(DEBUG),1)
155 CFLAGS += -DDEBUG
156 endif
157
158 ifeq ($(WARN),1)
159 CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
160           -Wcast-align -Wwrite-strings -Wnested-externs -Winline
161 endif
162
163 ifeq ($(I2C),1)
164 CFLAGS += -DI2C
165 endif
166
167 MODCFLAGS := $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer
168 PROGCFLAGS := $(CFLAGS)
169 ARCFLAGS := $(CFLAGS)
170 LIBCFLAGS := $(CFLAGS) -fpic
171
172 ifeq ($(SMP),1)
173 MODCFLAGS += -D__SMP__
174 endif
175
176 ifeq ($(MODVER),1)
177 MODCFLAGS += -DMODVERSIONS -include /usr/include/linux/modversions.h
178 endif
179
180 .PHONY: all clean install version package dep
181
182 # Make all the default rule
183 all::
184
185 # Include all makefiles for sub-modules
186 INCLUDEFILES :=
187 include $(patsubst %,%/Module.mk,$(SRCDIRS))
188 ifneq ($(MAKECMDGOALS),clean)
189 include $(INCLUDEFILES)
190 endif
191
192 # Making the dependency files - done automatically!
193 dep :
194
195 all ::
196
197 install :: all
198
199 clean::
200         $(RM) lm_sensors-*
201
202 # This is tricky, but it works like a charm. It needs lots of utilities
203 # though: cut, find, gzip, ln, tail and tar.
204 package: version clean
205         lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
206         lmpackage=lm_sensors-$$lmversion; \
207         ln -s . $$lmpackage;  \
208         find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
209                                     grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
210                                     grep -v ^$$lmpackage/$$ | \
211                                     grep -v /CVS | \
212                                     grep -v /\\.# | \
213                                     tar rvf $$lmpackage.tar -T -; \
214         gzip -9 $$lmpackage.tar ;\
215         $(RM) $$lmpackage.tar $$lmpackage
216         cat doc/developers/checklist
217
218 version:
219         $(RM) version.h
220         echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
221         echo -n 'Version: '; \
222         echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
223
224
225 # Here, we define all implicit rules we want to use.
226
227 .SUFFIXES:
228
229 # We need to create dependency files. Tricky. We sed rule puts dir/file.d and
230 # dir/file.c # in front of the dependency file rule.
231
232 # .o files are used for modules
233 %.o: %.c
234         $(CC) $(MODCFLAGS) -c $< -o $@
235
236 %.d: %.c
237         $(CC) -M -MG $(MODCFLAGS) $< | \
238         sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
239
240
241
242 # .ro files are used for programs (as opposed to modules)
243 %.ro: %.c
244         $(CC) $(PROGCFLAGS) -c $< -o $@
245
246 %.rd: %.c
247         $(CC) -M -MG $(PROGCFLAGS) $< | \
248         sed -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
249
250
251 %: %.ro
252         $(CC) $(EXLDFLAGS) -o $@ $^
253
254
255 # .ao files are used for static archives
256 %.ao: %.c
257         $(CC) $(ARCFLAGS) -c $< -o $@
258
259 %.ad: %.c
260         $(CC) -M -MG $(ARCFLAGS) $< | \
261         sed -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
262
263
264 # .lo files are used for shared libraries
265 %.lo: %.c
266         $(CC) $(LIBCFLAGS) -c $< -o $@
267
268 %.ld: %.c
269         $(CC) -M -MG $(LIBCFLAGS) $< | \
270         sed -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
271
272
273 # Flex and Bison
274 %c: %y
275         $(BISON) -p sensors_yy -d $< -o $@
276
277 %.c: %.l
278         $(FLEX) -Psensors_yy -t $< > $@
Note: See TracBrowser for help on using the browser.