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

Revision 5035, 8.5 KB (checked in by jwrdegoede, 6 years ago)

Fix building on PPC machines

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