|
Packit |
53d5b6 |
# Makefile - Makefile for a Linux module for reading sensor data.
|
|
Packit |
53d5b6 |
# Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
|
|
Packit |
53d5b6 |
#
|
|
Packit |
53d5b6 |
# This program is free software; you can redistribute it and/or modify
|
|
Packit |
53d5b6 |
# it under the terms of the GNU General Public License as published by
|
|
Packit |
53d5b6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
53d5b6 |
# (at your option) any later version.
|
|
Packit |
53d5b6 |
#
|
|
Packit |
53d5b6 |
# This program is distributed in the hope that it will be useful,
|
|
Packit |
53d5b6 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
53d5b6 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
53d5b6 |
# GNU General Public License for more details.
|
|
Packit |
53d5b6 |
#
|
|
Packit |
53d5b6 |
# You should have received a copy of the GNU General Public License
|
|
Packit |
53d5b6 |
# along with this program; if not, write to the Free Software
|
|
Packit |
53d5b6 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
Packit |
53d5b6 |
# MA 02110-1301 USA.
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Everything you may want to change is in the top of this file. Usually, you
|
|
Packit |
53d5b6 |
# can just use the defaults, fortunately.
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# You need a full complement of GNU utilities to run this Makefile
|
|
Packit |
53d5b6 |
# successfully; most notably, you need GNU make, flex (>= 2.5.1)
|
|
Packit |
53d5b6 |
# and bison.
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Uncomment the second line if you are a developer. This will enable many
|
|
Packit |
53d5b6 |
# additional warnings at compile-time
|
|
Packit |
53d5b6 |
#WARN := 0
|
|
Packit |
53d5b6 |
WARN := 1
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Uncomment the second line if you want to get (loads of) debug information
|
|
Packit |
53d5b6 |
# at run-time.
|
|
Packit |
53d5b6 |
# Not recommended, unless you are actually debugging the code
|
|
Packit |
53d5b6 |
DEBUG := 0
|
|
Packit |
53d5b6 |
#DEBUG := 1
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Note that all the installation paths below can also be set on the make
|
|
Packit |
53d5b6 |
# command line (e.g. "make PREFIX=/usr").
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# If you want to install at some other place then at from which you will run
|
|
Packit |
53d5b6 |
# everything, set DESTDIR to the extra prefix.
|
|
Packit |
53d5b6 |
DESTDIR :=
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# This is the prefix that will be used for almost all directories below.
|
|
Packit |
53d5b6 |
PREFIX := /usr/local
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Your C compiler
|
|
Packit |
53d5b6 |
CC := gcc
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# This is the directory where sensors3.conf will be installed, if no other
|
|
Packit |
53d5b6 |
# configuration file is found
|
|
Packit |
53d5b6 |
ETCDIR := /etc
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# You should not need to change this. It is the directory into which the
|
|
Packit |
53d5b6 |
# library files (both static and shared) will be installed.
|
|
Packit |
53d5b6 |
LIBDIR := $(PREFIX)/lib
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
EXLDFLAGS := -Wl,-rpath,$(LIBDIR)
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# You should not need to change this. It is the directory into which the
|
|
Packit |
53d5b6 |
# executable program files will be installed. BINDIR for programs that are
|
|
Packit |
53d5b6 |
# also useful for normal users, SBINDIR for programs that can only be run
|
|
Packit |
53d5b6 |
# by the superuser.
|
|
Packit |
53d5b6 |
# Note that not all programs in this package are really installed;
|
|
Packit |
53d5b6 |
# some are just examples. You can always install them by hand, of
|
|
Packit |
53d5b6 |
# course.
|
|
Packit |
53d5b6 |
BINDIR := $(PREFIX)/bin
|
|
Packit |
53d5b6 |
SBINDIR := $(PREFIX)/sbin
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# You should not need to change this. It is the basic directory into which
|
|
Packit |
53d5b6 |
# include files will be installed. The actual directory will be
|
|
Packit |
53d5b6 |
# $(INCLUDEDIR)/sensors for library include files.
|
|
Packit |
53d5b6 |
INCLUDEDIR := $(PREFIX)/include
|
|
Packit |
53d5b6 |
LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# You should not need to change this. It is the base directory under which the
|
|
Packit |
53d5b6 |
# manual pages will be installed.
|
|
Packit |
53d5b6 |
MANDIR := $(PREFIX)/man
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
MACHINE := $(shell uname -m)
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Extra non-default programs to build; e.g., sensord
|
|
Packit |
53d5b6 |
#PROG_EXTRA := sensord
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Build and install static library
|
|
Packit |
53d5b6 |
BUILD_STATIC_LIB := 1
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Set these to add preprocessor or compiler flags, or use
|
|
Packit |
53d5b6 |
# environment variables
|
|
Packit |
53d5b6 |
# CFLAGS :=
|
|
Packit |
53d5b6 |
# CPPFLAGS :=
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
##################################################
|
|
Packit |
53d5b6 |
# Below this, nothing should need to be changed. #
|
|
Packit |
53d5b6 |
##################################################
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Note that this is a monolithic Makefile; it calls no sub-Makefiles,
|
|
Packit |
53d5b6 |
# but instead, it compiles everything right from here. Yes, there are
|
|
Packit |
53d5b6 |
# some distinct advantages to this; see the following paper for more info:
|
|
Packit |
53d5b6 |
# http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
|
|
Packit |
53d5b6 |
# Note that is still uses Makefile fragments in sub-directories; these
|
|
Packit |
53d5b6 |
# are called 'Module.mk'.
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Within each Module.mk, rules and dependencies can be added to targets
|
|
Packit |
53d5b6 |
# all, install and clean. Use double colons instead of single ones
|
|
Packit |
53d5b6 |
# to do this.
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# The subdirectories we need to build things in
|
|
Packit |
53d5b6 |
SRCDIRS := lib prog/detect prog/pwm \
|
|
Packit |
53d5b6 |
prog/sensors ${PROG_EXTRA:%=prog/%} etc
|
|
Packit |
53d5b6 |
# Only build isadump and isaset on x86 machines.
|
|
Packit |
53d5b6 |
ifneq (,$(findstring $(MACHINE), i386 i486 i586 i686 x86_64))
|
|
Packit |
53d5b6 |
SRCDIRS += prog/dump
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
SRCDIRS += lib/test
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Some often-used commands with default options
|
|
Packit |
53d5b6 |
MKDIR := mkdir -p
|
|
Packit |
53d5b6 |
RMDIR := rmdir
|
|
Packit |
53d5b6 |
RM := rm -f
|
|
Packit |
53d5b6 |
MV := mv -f
|
|
Packit |
53d5b6 |
BISON := bison
|
|
Packit |
53d5b6 |
FLEX := flex
|
|
Packit |
53d5b6 |
AR := ar
|
|
Packit |
53d5b6 |
INSTALL := install
|
|
Packit |
53d5b6 |
LN := ln -sf
|
|
Packit |
53d5b6 |
GREP := grep
|
|
Packit |
53d5b6 |
AWK := awk
|
|
Packit |
53d5b6 |
SED := sed
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Determine the default compiler flags
|
|
Packit |
53d5b6 |
# Set CFLAGS or CPPFLAGS above to add your own flags to all.
|
|
Packit |
53d5b6 |
# ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line.
|
|
Packit |
53d5b6 |
# PROGCPPFLAGS/PROGCFLAGS is to create regular object files (which are linked into executables).
|
|
Packit |
53d5b6 |
# ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries).
|
|
Packit |
53d5b6 |
# LIBCPPFLAGS/LIBCFLAGS are for shared library objects.
|
|
Packit |
53d5b6 |
ALL_CPPFLAGS := -I.
|
|
Packit |
53d5b6 |
ALL_CFLAGS := -Wall
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
ifeq ($(DEBUG),1)
|
|
Packit |
53d5b6 |
ALL_CPPFLAGS += -DDEBUG
|
|
Packit |
53d5b6 |
ALL_CFLAGS += -O -g
|
|
Packit |
53d5b6 |
else
|
|
Packit |
53d5b6 |
ALL_CFLAGS += -O2
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
ifeq ($(WARN),1)
|
|
Packit |
53d5b6 |
ALL_CFLAGS += -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
|
|
Packit |
53d5b6 |
-Wcast-align -Wwrite-strings -Wnested-externs -Winline -W \
|
|
Packit |
53d5b6 |
-Wmissing-prototypes -Wundef
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
ALL_CPPFLAGS += $(CPPFLAGS)
|
|
Packit |
53d5b6 |
ALL_CFLAGS += $(CFLAGS)
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
|
|
Packit |
53d5b6 |
PROGCFLAGS := $(ALL_CFLAGS)
|
|
Packit |
53d5b6 |
ARCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
|
|
Packit |
53d5b6 |
ARCFLAGS := $(ALL_CFLAGS)
|
|
Packit |
53d5b6 |
LIBCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS)
|
|
Packit |
53d5b6 |
LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS)
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
.PHONY: all user clean install user_install uninstall user_uninstall
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Make all the default rule
|
|
Packit |
53d5b6 |
all::
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Include all makefiles for sub-modules
|
|
Packit |
53d5b6 |
INCLUDEFILES :=
|
|
Packit |
53d5b6 |
include $(patsubst %,%/Module.mk,$(SRCDIRS))
|
|
Packit |
53d5b6 |
ifneq ($(MAKECMDGOALS),clean)
|
|
Packit |
53d5b6 |
ifneq ($(MAKECMDGOALS),uninstall)
|
|
Packit |
53d5b6 |
ifneq ($(MAKECMDGOALS),user_uninstall)
|
|
Packit |
53d5b6 |
ifneq ($(MAKECMDGOALS),help)
|
|
Packit |
53d5b6 |
include $(INCLUDEFILES)
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Man pages
|
|
Packit |
53d5b6 |
MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \
|
|
Packit |
53d5b6 |
$(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
user ::
|
|
Packit |
53d5b6 |
user_install::
|
|
Packit |
53d5b6 |
@echo "*** Important notes:"
|
|
Packit |
53d5b6 |
@echo "*** * The libsensors configuration file ($(ETCDIR)/sensors3.conf) is never"
|
|
Packit |
53d5b6 |
@echo "*** overwritten by our installation process, so that you won't lose"
|
|
Packit |
53d5b6 |
@echo "*** your personal settings in that file. You still can get our latest"
|
|
Packit |
53d5b6 |
@echo "*** default config file in etc/sensors.conf.default and manually copy"
|
|
Packit |
53d5b6 |
@echo "*** it to $(ETCDIR)/sensors3.conf if you want. You will then want to"
|
|
Packit |
53d5b6 |
@echo "*** edit it to fit your needs again."
|
|
Packit |
53d5b6 |
@echo "*** * The format of $(ETCDIR)/sensors3.conf changed with lm-sensors 3.0.0."
|
|
Packit |
53d5b6 |
@echo "*** If you have a custom configuration file using the old format, you"
|
|
Packit |
53d5b6 |
@echo "*** can convert it using the sensors-conf-convert script. Otherwise just"
|
|
Packit |
53d5b6 |
@echo "*** overwrite your old configuration file with the new default one."
|
|
Packit |
53d5b6 |
@echo "*** * As of lm-sensors 3.1.0, the default configuration file only"
|
|
Packit |
53d5b6 |
@echo "*** contains statements which do not depend on how chips are wired."
|
|
Packit |
53d5b6 |
@echo "*** If you miss parts of the bigger configuration file that used to be"
|
|
Packit |
53d5b6 |
@echo "*** the default, copy the relevant parts from etc/sensors.conf.eg to"
|
|
Packit |
53d5b6 |
@echo "*** $(ETCDIR)/sensors3.conf."
|
|
Packit |
53d5b6 |
all :: user
|
|
Packit |
53d5b6 |
install :: all user_install
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
clean::
|
|
Packit |
53d5b6 |
$(RM) lm_sensors-* lex.backup
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
user_uninstall::
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
uninstall :: user_uninstall
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
help:
|
|
Packit |
53d5b6 |
@echo 'Make targets are:'
|
|
Packit |
53d5b6 |
@echo ' all (default): build library and userspace programs'
|
|
Packit |
53d5b6 |
@echo ' install: install library and userspace programs'
|
|
Packit |
53d5b6 |
@echo ' uninstall: uninstall library and userspace programs'
|
|
Packit |
53d5b6 |
@echo ' clean: cleanup'
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Generate html man pages to be copied to the lm_sensors website.
|
|
Packit |
53d5b6 |
# This uses the man2html from here
|
|
Packit |
53d5b6 |
# http://ftp.math.utah.edu/pub/sgml/
|
|
Packit |
53d5b6 |
# which works directly from the nroff source
|
|
Packit |
53d5b6 |
manhtml:
|
|
Packit |
53d5b6 |
$(MKDIR) html
|
|
Packit |
53d5b6 |
cp $(MANPAGES) html
|
|
Packit |
53d5b6 |
cd html ; \
|
|
Packit |
53d5b6 |
export LOGNAME=sensors ; \
|
|
Packit Service |
5377e5 |
export HOSTNAME=hwmon.wiki.kernel.org ; \
|
|
Packit |
53d5b6 |
man2html *.[1-8] ; \
|
|
Packit |
53d5b6 |
$(RM) *.[1-8]
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Here, we define all implicit rules we want to use.
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
.SUFFIXES:
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# We need to create dependency files. Tricky. The sed rule puts dir/file.d and
|
|
Packit |
53d5b6 |
# dir/file.c in front of the dependency file rule.
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# .ro files are used for programs (as opposed to modules)
|
|
Packit |
53d5b6 |
%.ro: %.c
|
|
Packit |
53d5b6 |
$(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
%.rd: %.c
|
|
Packit |
53d5b6 |
$(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \
|
|
Packit |
53d5b6 |
$(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# .ao files are used for static archives
|
|
Packit |
53d5b6 |
%.ao: %.c
|
|
Packit |
53d5b6 |
$(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
%.ad: %.c
|
|
Packit |
53d5b6 |
$(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \
|
|
Packit |
53d5b6 |
$(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# .lo files are used for shared libraries
|
|
Packit |
53d5b6 |
%.lo: %.c
|
|
Packit |
53d5b6 |
$(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
%.ld: %.c
|
|
Packit |
53d5b6 |
$(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \
|
|
Packit |
53d5b6 |
$(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
# Flex and Bison
|
|
Packit |
53d5b6 |
%.c: %.y
|
|
Packit |
53d5b6 |
@if ! which $(BISON) 2> /dev/null ; then \
|
|
Packit |
53d5b6 |
echo "Please install $(BISON), then run \"make clean\" and try again" ; \
|
|
Packit |
53d5b6 |
false ; \
|
|
Packit |
53d5b6 |
fi
|
|
Packit |
53d5b6 |
$(BISON) -p sensors_yy -d $< -o $@
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
ifeq ($(DEBUG),1)
|
|
Packit |
53d5b6 |
FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8
|
|
Packit |
53d5b6 |
else
|
|
Packit |
53d5b6 |
FLEX_FLAGS := -Psensors_yy -t -Cfe -8
|
|
Packit |
53d5b6 |
endif
|
|
Packit |
53d5b6 |
|
|
Packit |
53d5b6 |
%.c: %.l
|
|
Packit |
53d5b6 |
@if ! which $(FLEX) 2> /dev/null ; then \
|
|
Packit |
53d5b6 |
echo "Please install $(FLEX), then run \"make clean\" and try again" ; \
|
|
Packit |
53d5b6 |
false ; \
|
|
Packit |
53d5b6 |
fi
|
|
Packit |
53d5b6 |
$(FLEX) $(FLEX_FLAGS) $< > $@
|