Blame Makefile

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