root/lm-sensors/trunk/Makefile @ 176

Revision 176, 7.9 KB (checked in by phil, 14 years ago)

(Phil) Made slight adjustments so the new file arrangement will build.
I added two new make file 'includes': busses/Module.mk and chips/Module.mk
Frodo- You may want to review the makefile structure to make sure that
the system works as you intended.

Note: The docs still need to be updated to reflect the new file arrangement,
but at least it builds!

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