forked from lm-sensors/lm-sensors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
287 lines (233 loc) · 9.25 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# Makefile - Makefile for a Linux module for reading sensor data.
# Copyright (c) 1998, 1999 Frodo Looijaard <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
# Everything you may want to change is in the top of this file. Usually, you
# can just use the defaults, fortunately.
# You need a full complement of GNU utilities to run this Makefile
# successfully; most notably, you need GNU make, flex (>= 2.5.1)
# and bison.
# Uncomment the second line if you are a developer. This will enable many
# additional warnings at compile-time
#WARN := 0
WARN := 1
# Uncomment the second line if you want to get (loads of) debug information
# at run-time.
# Not recommended, unless you are actually debugging the code
DEBUG := 0
#DEBUG := 1
# Note that all the installation paths below can also be set on the make
# command line (e.g. "make PREFIX=/usr").
# If you want to install at some other place then at from which you will run
# everything, set DESTDIR to the extra prefix.
DESTDIR :=
# This is the prefix that will be used for almost all directories below.
PREFIX := /usr/local
# Your C compiler
CC := gcc
# This is the directory where sensors3.conf will be installed, if no other
# configuration file is found
ETCDIR := /etc
# You should not need to change this. It is the directory into which the
# library files (both static and shared) will be installed.
LIBDIR := $(PREFIX)/lib
EXLDFLAGS := -Wl,-rpath,$(LIBDIR)
# You should not need to change this. It is the directory into which the
# executable program files will be installed. BINDIR for programs that are
# also useful for normal users, SBINDIR for programs that can only be run
# by the superuser.
# Note that not all programs in this package are really installed;
# some are just examples. You can always install them by hand, of
# course.
BINDIR := $(PREFIX)/bin
SBINDIR := $(PREFIX)/sbin
# You should not need to change this. It is the basic directory into which
# include files will be installed. The actual directory will be
# $(INCLUDEDIR)/sensors for library include files.
INCLUDEDIR := $(PREFIX)/include
LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
# You should not need to change this. It is the base directory under which the
# manual pages will be installed.
MANDIR := $(PREFIX)/man
MACHINE := $(shell uname -m)
# Extra non-default programs to build; e.g., sensord
#PROG_EXTRA := sensord
# Build and install static library
BUILD_STATIC_LIB := 1
# Set these to add preprocessor or compiler flags, or use
# environment variables
# CFLAGS :=
# CPPFLAGS :=
##################################################
# Below this, nothing should need to be changed. #
##################################################
# Note that this is a monolithic Makefile; it calls no sub-Makefiles,
# but instead, it compiles everything right from here. Yes, there are
# some distinct advantages to this; see the following paper for more info:
# http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
# Note that is still uses Makefile fragments in sub-directories; these
# are called 'Module.mk'.
# Within each Module.mk, rules and dependencies can be added to targets
# all, install and clean. Use double colons instead of single ones
# to do this.
# The subdirectories we need to build things in
SRCDIRS := lib prog/detect prog/pwm \
prog/sensors ${PROG_EXTRA:%=prog/%} etc
# Only build isadump and isaset on x86 machines.
ifneq (,$(findstring $(MACHINE), i386 i486 i586 i686 x86_64))
SRCDIRS += prog/dump
endif
SRCDIRS += lib/test
# Some often-used commands with default options
MKDIR := mkdir -p
RMDIR := rmdir
RM := rm -f
MV := mv -f
BISON := bison
FLEX := flex
AR := ar
INSTALL := install
LN := ln -sf
GREP := grep
AWK := awk
SED := sed
# Determine the default compiler flags
# Set CFLAGS or CPPFLAGS above to add your own flags to all.
# ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
# PROGCPPFLAGS/PROGCFLAGS is to create regular object files (which are linked into executables).
# ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
# LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
ALL_CPPFLAGS := -I.
ALL_CFLAGS := -Wall
ifeq ($(DEBUG),1)
ALL_CPPFLAGS += -DDEBUG
ALL_CFLAGS += -O -g
else
ALL_CFLAGS += -O2
endif
ifeq ($(WARN),1)
ALL_CFLAGS += -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wnested-externs -Winline -W \
-Wmissing-prototypes -Wundef
endif
ALL_CPPFLAGS += $(CPPFLAGS)
ALL_CFLAGS += $(CFLAGS)
PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
PROGCFLAGS := $(ALL_CFLAGS)
ARCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
ARCFLAGS := $(ALL_CFLAGS)
LIBCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS)
.PHONY: all user clean install user_install uninstall user_uninstall
# Make all the default rule
all::
# Include all makefiles for sub-modules
INCLUDEFILES :=
include $(patsubst %,%/Module.mk,$(SRCDIRS))
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),uninstall)
ifneq ($(MAKECMDGOALS),user_uninstall)
ifneq ($(MAKECMDGOALS),help)
include $(INCLUDEFILES)
endif
endif
endif
endif
# Man pages
MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \
$(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8
user ::
user_install::
@echo "*** Important notes:"
@echo "*** * The libsensors configuration file ($(ETCDIR)/sensors3.conf) is never"
@echo "*** overwritten by our installation process, so that you won't lose"
@echo "*** your personal settings in that file. You still can get our latest"
@echo "*** default config file in etc/sensors.conf.default and manually copy"
@echo "*** it to $(ETCDIR)/sensors3.conf if you want. You will then want to"
@echo "*** edit it to fit your needs again."
@echo "*** * The format of $(ETCDIR)/sensors3.conf changed with lm-sensors 3.0.0."
@echo "*** If you have a custom configuration file using the old format, you"
@echo "*** can convert it using the sensors-conf-convert script. Otherwise just"
@echo "*** overwrite your old configuration file with the new default one."
@echo "*** * As of lm-sensors 3.1.0, the default configuration file only"
@echo "*** contains statements which do not depend on how chips are wired."
@echo "*** If you miss parts of the bigger configuration file that used to be"
@echo "*** the default, copy the relevant parts from etc/sensors.conf.eg to"
@echo "*** $(ETCDIR)/sensors3.conf."
all :: user
install :: all user_install
clean::
$(RM) lm_sensors-* lex.backup
user_uninstall::
uninstall :: user_uninstall
help:
@echo 'Make targets are:'
@echo ' all (default): build library and userspace programs'
@echo ' install: install library and userspace programs'
@echo ' uninstall: uninstall library and userspace programs'
@echo ' clean: cleanup'
# Generate html man pages to be copied to the lm_sensors website.
# This uses the man2html from here
# http://ftp.math.utah.edu/pub/sgml/
# which works directly from the nroff source
manhtml:
$(MKDIR) html
cp $(MANPAGES) html
cd html ; \
export LOGNAME=sensors ; \
export HOSTNAME=hwmon.wiki.kernel.org ; \
man2html *.[1-8] ; \
$(RM) *.[1-8]
# Here, we define all implicit rules we want to use.
.SUFFIXES:
# We need to create dependency files. Tricky. The sed rule puts dir/file.d and
# dir/file.c in front of the dependency file rule.
# .ro files are used for programs (as opposed to modules)
%.ro: %.c
$(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
%.rd: %.c
$(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
$(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
# .ao files are used for static archives
%.ao: %.c
$(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
%.ad: %.c
$(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
$(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
# .lo files are used for shared libraries
%.lo: %.c
$(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
%.ld: %.c
$(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
$(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
# Flex and Bison
%.c: %.y
@if ! which $(BISON) 2> /dev/null ; then \
echo "Please install $(BISON), then run \"make clean\" and try again" ; \
false ; \
fi
$(BISON) -p sensors_yy -d $< -o $@
ifeq ($(DEBUG),1)
FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8
else
FLEX_FLAGS := -Psensors_yy -t -Cfe -8
endif
%.c: %.l
@if ! which $(FLEX) 2> /dev/null ; then \
echo "Please install $(FLEX), then run \"make clean\" and try again" ; \
false ; \
fi
$(FLEX) $(FLEX_FLAGS) $< > $@