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

Revision 4628, 8.2 KB (checked in by khali, 6 years ago)

Drop the package target.

  • 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 note:"
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."
188all :: user
189install :: all user_install
190
191clean::
192        $(RM) lm_sensors-* lex.backup
193
194user_uninstall::
195
196uninstall :: user_uninstall
197
198help:
199        @echo 'Make targets are:'
200        @echo '  all (default): build library and userspace programs'
201        @echo '  install: install library and userspace programs'
202        @echo '  uninstall: uninstall library and userspace programs'
203        @echo '  clean: cleanup'
204
205# Generate html man pages to be copied to the lm_sensors website.
206# This uses the man2html from here
207# http://ftp.math.utah.edu/pub/sgml/
208# which works directly from the nroff source
209manhtml:
210        $(MKDIR) html
211        cp $(MANPAGES) html
212        cd html ; \
213        export LOGNAME=sensors ; \
214        export HOSTNAME=www.lm-sensors.org ; \
215        man2html *.[1-8] ; \
216        $(RM) *.[1-8]
217
218# Here, we define all implicit rules we want to use.
219
220.SUFFIXES:
221
222# We need to create dependency files. Tricky. The sed rule puts dir/file.d and
223# dir/file.c in front of the dependency file rule.
224
225
226# .ro files are used for programs (as opposed to modules)
227%.ro: %.c
228        $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
229
230%.rd: %.c
231        $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
232        $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
233
234
235%: %.ro
236        $(CC) $(EXLDFLAGS) -o $@ $^
237
238
239# .ao files are used for static archives
240%.ao: %.c
241        $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
242
243%.ad: %.c
244        $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
245        $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
246
247
248# .lo files are used for shared libraries
249%.lo: %.c
250        $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
251
252%.ld: %.c
253        $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
254        $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
255
256
257# Flex and Bison
258%c: %y
259        $(BISON) -p sensors_yy -d $< -o $@
260
261ifeq ($(DEBUG),1)
262FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8
263else
264FLEX_FLAGS := -Psensors_yy -t -Cfe -8
265endif
266
267%.c: %.l
268        $(FLEX) $(FLEX_FLAGS) $< > $@
Note: See TracBrowser for help on using the browser.