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

Revision 4770, 8.5 KB (checked in by khali, 6 years ago)

sensors-conf-convert: New, script to convert old configuration files
to use the new symbol names.

  • 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
32#WARN := 0
33WARN := 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
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)
169include $(INCLUDEFILES)
170endif
171endif
172endif
173endif
174
175# Man pages
176MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \
177            $(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8
178
179user ::
180user_install::
181        @echo "*** Important notes:"
182        @echo "***  * The libsensors configuration file ($(ETCDIR)/sensors.conf) is never"
183        @echo "***    overwritten by our installation process, so that you won't lose"
184        @echo "***    your personal settings in that file. You still can get our latest"
185        @echo "***    default config file in etc/sensors.conf.eg and manually copy it to"
186        @echo "***    $(ETCDIR)/sensors.conf if you want. You will then want to edit it"
187        @echo "***    to fit your needs again."
188        @echo "***  * The format of $(ETCDIR)/sensors.conf changed with lm-sensors 3.0.0."
189        @echo "***    If you have a custom configuration file using the old format, you"
190        @echo "***    can convert it using the sensors-conf-convert script. Otherwise just"
191        @echo "***    overwrite your old configuration file with the new default one."
192all :: user
193install :: all user_install
194
195clean::
196        $(RM) lm_sensors-* lex.backup
197
198user_uninstall::
199
200uninstall :: user_uninstall
201
202help:
203        @echo 'Make targets are:'
204        @echo '  all (default): build library and userspace programs'
205        @echo '  install: install library and userspace programs'
206        @echo '  uninstall: uninstall library and userspace programs'
207        @echo '  clean: cleanup'
208
209# Generate html man pages to be copied to the lm_sensors website.
210# This uses the man2html from here
211# http://ftp.math.utah.edu/pub/sgml/
212# which works directly from the nroff source
213manhtml:
214        $(MKDIR) html
215        cp $(MANPAGES) html
216        cd html ; \
217        export LOGNAME=sensors ; \
218        export HOSTNAME=www.lm-sensors.org ; \
219        man2html *.[1-8] ; \
220        $(RM) *.[1-8]
221
222# Here, we define all implicit rules we want to use.
223
224.SUFFIXES:
225
226# We need to create dependency files. Tricky. The sed rule puts dir/file.d and
227# dir/file.c in front of the dependency file rule.
228
229
230# .ro files are used for programs (as opposed to modules)
231%.ro: %.c
232        $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
233
234%.rd: %.c
235        $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
236        $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
237
238
239%: %.ro
240        $(CC) $(EXLDFLAGS) -o $@ $^
241
242
243# .ao files are used for static archives
244%.ao: %.c
245        $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
246
247%.ad: %.c
248        $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
249        $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
250
251
252# .lo files are used for shared libraries
253%.lo: %.c
254        $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
255
256%.ld: %.c
257        $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
258        $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
259
260
261# Flex and Bison
262%c: %y
263        $(BISON) -p sensors_yy -d $< -o $@
264
265ifeq ($(DEBUG),1)
266FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8
267else
268FLEX_FLAGS := -Psensors_yy -t -Cfe -8
269endif
270
271%.c: %.l
272        $(FLEX) $(FLEX_FLAGS) $< > $@
Note: See TracBrowser for help on using the browser.