root/lm-sensors/trunk/Makefile @ 5869

Revision 5869, 9.2 KB (checked in by khali, 4 years ago)

Warn the user is either flex or bison is missing.

  • 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
121MV := mv -f
122BISON := bison
123FLEX := flex
124AR := ar
125INSTALL := install
126LN := ln -sf
127GREP := grep
128AWK := awk
129SED := sed
130
131# Determine the default compiler flags
132# Set CFLAGS or CPPFLAGS above to add your own flags to all.
133# ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
134# PROGCPPFLAGS/PROGCFLAGS is to create regular object files (which are linked into executables).
135# ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
136# LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
137ALL_CPPFLAGS := -I.
138ALL_CFLAGS := -Wall
139
140ifeq ($(DEBUG),1)
141ALL_CPPFLAGS += -DDEBUG
142ALL_CFLAGS += -O -g
143else
144ALL_CFLAGS += -O2
145endif
146
147ifeq ($(WARN),1)
148ALL_CFLAGS += -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
149            -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W \
150            -Wmissing-prototypes -Wundef
151endif
152
153ALL_CPPFLAGS += $(CPPFLAGS)
154ALL_CFLAGS += $(CFLAGS)
155
156PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
157PROGCFLAGS := $(ALL_CFLAGS)
158ARCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
159ARCFLAGS := $(ALL_CFLAGS)
160LIBCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
161LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS)
162
163.PHONY: all user clean install user_install uninstall user_uninstall
164
165# Make all the default rule
166all::
167
168# Include all makefiles for sub-modules
169INCLUDEFILES := 
170include $(patsubst %,%/Module.mk,$(SRCDIRS))
171ifneq ($(MAKECMDGOALS),clean)
172ifneq ($(MAKECMDGOALS),uninstall)
173ifneq ($(MAKECMDGOALS),user_uninstall)
174ifneq ($(MAKECMDGOALS),help)
175include $(INCLUDEFILES)
176endif
177endif
178endif
179endif
180
181# Man pages
182MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \
183            $(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8
184
185user ::
186user_install::
187        @echo "*** Important notes:"
188        @echo "***  * The libsensors configuration file ($(ETCDIR)/sensors3.conf) is never"
189        @echo "***    overwritten by our installation process, so that you won't lose"
190        @echo "***    your personal settings in that file. You still can get our latest"
191        @echo "***    default config file in etc/sensors.conf.default and manually copy"
192        @echo "***    it to $(ETCDIR)/sensors3.conf if you want. You will then want to"
193        @echo "***    edit it to fit your needs again."
194        @echo "***  * The format of $(ETCDIR)/sensors3.conf changed with lm-sensors 3.0.0."
195        @echo "***    If you have a custom configuration file using the old format, you"
196        @echo "***    can convert it using the sensors-conf-convert script. Otherwise just"
197        @echo "***    overwrite your old configuration file with the new default one."
198        @echo "***  * As off lm-sensors 3.1.0, the default configuration file only"
199        @echo "***    contains statements which do not depend on how chips are wired."
200        @echo "***    If you miss parts of the bigger configuration file that used to be"
201        @echo "***    the default, copy the relevant parts from etc/sensors.conf.eg to"
202        @echo "***    $(ETCDIR)/sensors3.conf."
203all :: user
204install :: all user_install
205
206clean::
207        $(RM) lm_sensors-* lex.backup
208
209user_uninstall::
210
211uninstall :: user_uninstall
212
213help:
214        @echo 'Make targets are:'
215        @echo '  all (default): build library and userspace programs'
216        @echo '  install: install library and userspace programs'
217        @echo '  uninstall: uninstall library and userspace programs'
218        @echo '  clean: cleanup'
219
220# Generate html man pages to be copied to the lm_sensors website.
221# This uses the man2html from here
222# http://ftp.math.utah.edu/pub/sgml/
223# which works directly from the nroff source
224manhtml:
225        $(MKDIR) html
226        cp $(MANPAGES) html
227        cd html ; \
228        export LOGNAME=sensors ; \
229        export HOSTNAME=www.lm-sensors.org ; \
230        man2html *.[1-8] ; \
231        $(RM) *.[1-8]
232
233# Here, we define all implicit rules we want to use.
234
235.SUFFIXES:
236
237# We need to create dependency files. Tricky. The sed rule puts dir/file.d and
238# dir/file.c in front of the dependency file rule.
239
240
241# .ro files are used for programs (as opposed to modules)
242%.ro: %.c
243        $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
244
245%.rd: %.c
246        $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
247        $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
248
249
250# .ao files are used for static archives
251%.ao: %.c
252        $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
253
254%.ad: %.c
255        $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
256        $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
257
258
259# .lo files are used for shared libraries
260%.lo: %.c
261        $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
262
263%.ld: %.c
264        $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
265        $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
266
267
268# Flex and Bison
269%.c: %.y
270        @if ! which $(BISON) 2> /dev/null ; then \
271                echo "Please install $(BISON), then run \"make clean\" and try again" ; \
272                false ; \
273        fi
274        $(BISON) -p sensors_yy -d $< -o $@
275
276ifeq ($(DEBUG),1)
277FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8
278else
279FLEX_FLAGS := -Psensors_yy -t -Cfe -8
280endif
281
282%.c: %.l
283        @if ! which $(FLEX) 2> /dev/null ; then \
284                echo "Please install $(FLEX), then run \"make clean\" and try again" ; \
285                false ; \
286        fi
287        $(FLEX) $(FLEX_FLAGS) $< > $@
Note: See TracBrowser for help on using the browser.