root/lm-sensors/trunk/Makefile @ 323

Revision 323, 8.5 KB (checked in by frodo, 14 years ago)

Finished renaming of detect.pl

* Either Phil had not done a 'cvs update', or I forgot a 'cvs commit'; anyway,

the last changes to detect.pl have been ported to sensors-detect.

* Added a rule to the Makefile fragment to install it in $(SBINDIR).
* Added SBINDIR to the main Makefile.
* Deleted detect.pl

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