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

Revision 1108, 9.4 kB (checked in by mds, 8 years ago)

Updates for DEC Tsunami from Oleg Vdovikin

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