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

Revision 4458, 9.4 KB (checked in by khali, 7 years ago)

Always build libsensors with sysfs support.

  • 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)/linux for system include files, and $(INCLUDEDIR)/sensors
74# for library include files. If PREFIX equals the default /usr/local/bin,
75# you will be able to use '#include <linux/sensors.h>' regardless of the
76# current kernel selected.
77INCLUDEDIR := $(PREFIX)/include
78SYSINCLUDEDIR := $(INCLUDEDIR)/linux
79LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
80
81# You should not need to change this. It is the base directory under which the
82# manual pages will be installed.
83MANDIR := $(PREFIX)/man
84
85MACHINE := $(shell uname -m)
86
87# Extra non-default programs to build; e.g., sensord
88# PROG_EXTRA := sensord
89
90# Set these to add preprocessor or compiler flags, or use
91# environment variables
92# CFLAGS :=
93# CPPFLAGS :=
94
95##################################################
96# Below this, nothing should need to be changed. #
97##################################################
98
99# Note that this is a monolithic Makefile; it calls no sub-Makefiles,
100# but instead, it compiles everything right from here. Yes, there are
101# some distinct advantages to this; see the following paper for more info:
102#   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
103# Note that is still uses Makefile fragments in sub-directories; these
104# are called 'Module.mk'.
105
106# Within each Module.mk, rules and dependencies can be added to targets
107# all, install and clean. Use double colons instead of single ones
108# to do this.
109
110# The subdirectories we need to build things in
111SRCDIRS :=
112SRCDIRS += kernel/include
113SRCDIRS += lib prog/detect prog/dump prog/eeprom prog/pwm \
114           prog/sensors prog/xeon ${PROG_EXTRA:%=prog/%} etc
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. -Ikernel/include
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
149endif
150
151ALL_CPPFLAGS += $(CPPFLAGS)
152ALL_CFLAGS += $(CFLAGS)
153
154PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS) -Wundef
155PROGCFLAGS := $(ALL_CFLAGS)
156ARCPPFLAGS := $(ALL_CPPFLAGS)
157ARCFLAGS := $(ALL_CFLAGS)
158LIBCPPFLAGS := $(ALL_CPPFLAGS)
159LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS)
160
161.PHONY: all user clean install user_install uninstall user_uninstall version package
162
163# Make all the default rule
164all::
165
166# Include all makefiles for sub-modules
167INCLUDEFILES := 
168include $(patsubst %,%/Module.mk,$(SRCDIRS))
169ifneq ($(MAKECMDGOALS),clean)
170ifneq ($(MAKECMDGOALS),uninstall)
171ifneq ($(MAKECMDGOALS),user_uninstall)
172ifneq ($(MAKECMDGOALS),help)
173ifneq ($(MAKECMDGOALS),package)
174ifneq ($(MAKECMDGOALS),userpackage)
175include $(INCLUDEFILES)
176endif
177endif
178endif
179endif
180endif
181endif
182
183# Man pages
184MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \
185            $(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8
186
187user ::
188user_install::
189        @echo "*** Important note:"
190        @echo "***  * The libsensors configuration file ($(ETCDIR)/sensors.conf) is never"
191        @echo "***    overwritten by our installation process, so that you won't lose"
192        @echo "***    your personal settings in that file. You still can get our latest"
193        @echo "***    default config file in etc/sensors.conf.eg and manually copy it to"
194        @echo "***    $(ETCDIR)/sensors.conf if you want. You will then want to edit it"
195        @echo "***    to fit your needs again."
196all :: user
197install :: all user_install
198
199clean::
200        $(RM) lm_sensors-* lex.backup
201
202user_uninstall::
203
204uninstall :: user_uninstall
205
206# This is tricky, but it works like a charm. It needs lots of utilities
207# though: cut, find, gzip, ln, tail and tar.
208package: version clean
209        lmversion=`tail -1 version.h|cut -f 2 -d \"`; \
210        lmpackage=lm_sensors-$$lmversion; \
211        ln -s . $$lmpackage;  \
212        find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \
213                                    grep -v ^$$lmpackage/$$lmpackage.tar$$ | \
214                                    grep -v ^$$lmpackage/$$ | \
215                                    grep -v /CVS | \
216                                    grep -v /\\.# | \
217                                    tar rvf $$lmpackage.tar -T -; \
218        gzip -9 $$lmpackage.tar ;\
219        $(RM) $$lmpackage.tar $$lmpackage
220        cat doc/developers/checklist
221
222version:
223        $(RM) version.h
224        echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
225        echo -n 'Version: '; \
226        echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
227
228help:
229        @echo 'Make targets are:'
230        @echo '  all (default): build library and userspace programs'
231        @echo '  install: install library and userspace programs'
232        @echo '  uninstall: uninstall library and userspace programs'
233        @echo '  clean: cleanup'
234        @echo '  package: create a distribution package'
235
236# Generate html man pages to be copied to the lm_sensors website.
237# This uses the man2html from here
238# http://ftp.math.utah.edu/pub/sgml/
239# which works directly from the nroff source
240manhtml:
241        $(MKDIR) html
242        cp $(MANPAGES) html
243        cd html ; \
244        export LOGNAME=sensors ; \
245        export HOSTNAME=www.lm-sensors.org ; \
246        man2html *.[1-8] ; \
247        $(RM) *.[1-8]
248
249# Here, we define all implicit rules we want to use.
250
251.SUFFIXES:
252
253# We need to create dependency files. Tricky. The sed rule puts dir/file.d and
254# dir/file.c in front of the dependency file rule.
255
256
257# .ro files are used for programs (as opposed to modules)
258%.ro: %.c
259        $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
260
261%.rd: %.c
262        $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
263        $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
264
265
266%: %.ro
267        $(CC) $(EXLDFLAGS) -o $@ $^
268
269
270# .ao files are used for static archives
271%.ao: %.c
272        $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
273
274%.ad: %.c
275        $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
276        $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
277
278
279# .lo files are used for shared libraries
280%.lo: %.c
281        $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
282
283%.ld: %.c
284        $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
285        $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
286
287
288# Flex and Bison
289%c: %y
290        $(BISON) -p sensors_yy -d $< -o $@
291
292ifeq ($(DEBUG),1)
293FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8
294else
295FLEX_FLAGS := -Psensors_yy -t -Cfe -8
296endif
297
298%.c: %.l
299        $(FLEX) $(FLEX_FLAGS) $< > $@
Note: See TracBrowser for help on using the browser.