root/lm-sensors/trunk/Makefile @ 567

Revision 567, 9.2 KB (checked in by frodo, 15 years ago)

Updated INSTALL and README files

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