root/lm-sensors/tags/V3-0-0-RC3/Makefile

Revision 4985, 8.3 KB (checked in by khali, 5 years ago)

Let libsensors know the default path to its configuration file.
That way, applications no longer have to care.

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