root/lm-sensors/branches/lm-sensors-3.0.0/Makefile @ 5107

Revision 5107, 8.6 KB (checked in by khali, 7 years ago)

Document the variable overriding mechanism (#2296).

  • 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
22# successfully; most notably, you need GNU make, flex (>= 2.5.1)
23# and bison.
24
25# Uncomment the second line if you are a developer. This will enable many
26# additional warnings at compile-time
27#WARN := 0
28WARN := 1
29
30# Uncomment the second line if you want to get (loads of) debug information
31# at run-time.
32# Not recommended, unless you are actually debugging the code
33DEBUG := 0
34#DEBUG := 1
35
36# Note that all the installation paths below can also be set on the make
37# command line (e.g. "make PREFIX=/usr").
38
39# If you want to install at some other place then at from which you will run
40# everything, set DESTDIR to the extra prefix.
41DESTDIR :=
42
43# This is the prefix that will be used for almost all directories below.
44PREFIX := /usr/local
45
46# Your C compiler
47CC := gcc
48
49# This is the directory where sensors.conf will be installed, if no other
50# configuration file is found
51ETCDIR := /etc
52
53# You should not need to change this. It is the directory into which the
54# library files (both static and shared) will be installed.
55LIBDIR := $(PREFIX)/lib
56
57EXLDFLAGS := -Wl,-rpath,$(LIBDIR)
58
59# You should not need to change this. It is the directory into which the
60# executable program files will be installed. BINDIR for programs that are
61# also useful for normal users, SBINDIR for programs that can only be run
62# by the superuser.
63# Note that not all programs in this package are really installed;
64# some are just examples. You can always install them by hand, of
65# course.
66BINDIR := $(PREFIX)/bin
67SBINDIR := $(PREFIX)/sbin
68
69# You should not need to change this. It is the basic directory into which
70# include files will be installed. The actual directory will be
71# $(INCLUDEDIR)/sensors for library include files.
72INCLUDEDIR := $(PREFIX)/include
73LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
74
75# You should not need to change this. It is the base directory under which the
76# manual pages will be installed.
77MANDIR := $(PREFIX)/man
78
79MACHINE := $(shell uname -m)
80
81# Extra non-default programs to build; e.g., sensord
82# PROG_EXTRA := sensord
83
84# Set these to add preprocessor or compiler flags, or use
85# environment variables
86# CFLAGS :=
87# CPPFLAGS :=
88
89##################################################
90# Below this, nothing should need to be changed. #
91##################################################
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 := lib prog/detect prog/pwm \
106           prog/sensors ${PROG_EXTRA:%=prog/%} etc
107# Only build isadump and isaset on x86 machines.
108ifneq (,$(findstring $(MACHINE), i386 i486 i586 i686 x86_64))
109SRCDIRS += prog/dump
110endif
111SRCDIRS += lib/test
112
113# Some often-used commands with default options
114MKDIR := mkdir -p
115RMDIR := rmdir
116RM := rm -f
117BISON := bison
118FLEX := flex
119AR := ar
120INSTALL := install
121LN := ln -sf
122GREP := grep
123AWK := awk
124SED := sed
125
126# Determine the default compiler flags
127# Set CFLAGS or CPPFLAGS above to add your own flags to all.
128# ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
129# PROGCPPFLAGS/PROGCFLAGS is to create regular object files (which are linked into executables).
130# ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
131# LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
132ALL_CPPFLAGS := -I.
133ALL_CFLAGS := -Wall
134
135ifeq ($(DEBUG),1)
136ALL_CPPFLAGS += -DDEBUG
137ALL_CFLAGS += -O -g
138else
139ALL_CFLAGS += -O2
140endif
141
142ifeq ($(WARN),1)
143ALL_CFLAGS += -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
144            -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W \
145            -Wmissing-prototypes -Wundef
146endif
147
148ALL_CPPFLAGS += $(CPPFLAGS)
149ALL_CFLAGS += $(CFLAGS)
150
151PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
152PROGCFLAGS := $(ALL_CFLAGS)
153ARCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
154ARCFLAGS := $(ALL_CFLAGS)
155LIBCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
156LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS)
157
158.PHONY: all user clean install user_install uninstall user_uninstall
159
160# Make all the default rule
161all::
162
163# Include all makefiles for sub-modules
164INCLUDEFILES := 
165include $(patsubst %,%/Module.mk,$(SRCDIRS))
166ifneq ($(MAKECMDGOALS),clean)
167ifneq ($(MAKECMDGOALS),uninstall)
168ifneq ($(MAKECMDGOALS),user_uninstall)
169ifneq ($(MAKECMDGOALS),help)
170include $(INCLUDEFILES)
171endif
172endif
173endif
174endif
175
176# Man pages
177MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \
178            $(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8
179
180user ::
181user_install::
182        @echo "*** Important notes:"
183        @echo "***  * The libsensors configuration file ($(ETCDIR)/sensors.conf) is never"
184        @echo "***    overwritten by our installation process, so that you won't lose"
185        @echo "***    your personal settings in that file. You still can get our latest"
186        @echo "***    default config file in etc/sensors.conf.eg and manually copy it to"
187        @echo "***    $(ETCDIR)/sensors.conf if you want. You will then want to edit it"
188        @echo "***    to fit your needs again."
189        @echo "***  * The format of $(ETCDIR)/sensors.conf changed with lm-sensors 3.0.0."
190        @echo "***    If you have a custom configuration file using the old format, you"
191        @echo "***    can convert it using the sensors-conf-convert script. Otherwise just"
192        @echo "***    overwrite your old configuration file with the new default one."
193all :: user
194install :: all user_install
195
196clean::
197        $(RM) lm_sensors-* lex.backup
198
199user_uninstall::
200
201uninstall :: user_uninstall
202
203help:
204        @echo 'Make targets are:'
205        @echo '  all (default): build library and userspace programs'
206        @echo '  install: install library and userspace programs'
207        @echo '  uninstall: uninstall library and userspace programs'
208        @echo '  clean: cleanup'
209
210# Generate html man pages to be copied to the lm_sensors website.
211# This uses the man2html from here
212# http://ftp.math.utah.edu/pub/sgml/
213# which works directly from the nroff source
214manhtml:
215        $(MKDIR) html
216        cp $(MANPAGES) html
217        cd html ; \
218        export LOGNAME=sensors ; \
219        export HOSTNAME=www.lm-sensors.org ; \
220        man2html *.[1-8] ; \
221        $(RM) *.[1-8]
222
223# Here, we define all implicit rules we want to use.
224
225.SUFFIXES:
226
227# We need to create dependency files. Tricky. The sed rule puts dir/file.d and
228# dir/file.c in front of the dependency file rule.
229
230
231# .ro files are used for programs (as opposed to modules)
232%.ro: %.c
233        $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
234
235%.rd: %.c
236        $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
237        $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
238
239
240%: %.ro
241        $(CC) $(EXLDFLAGS) -o $@ $^
242
243
244# .ao files are used for static archives
245%.ao: %.c
246        $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
247
248%.ad: %.c
249        $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
250        $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
251
252
253# .lo files are used for shared libraries
254%.lo: %.c
255        $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
256
257%.ld: %.c
258        $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
259        $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
260
261
262# Flex and Bison
263%c: %y
264        $(BISON) -p sensors_yy -d $< -o $@
265
266ifeq ($(DEBUG),1)
267FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8
268else
269FLEX_FLAGS := -Psensors_yy -t -Cfe -8
270endif
271
272%.c: %.l
273        $(FLEX) $(FLEX_FLAGS) $< > $@
Note: See TracBrowser for help on using the browser.