root/lm-sensors/trunk/Makefile @ 5711

Revision 5711, 9.0 KB (checked in by khali, 4 years ago)

Make it possible to skip building of the static library. Just run:
make BUILD_STATIC_LIB=0

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