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

Revision 4601, 9.0 KB (checked in by khali, 7 years ago)

Delete LM_DATE and libsensors_date.

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