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