root/lm-sensors/tags/V3-0-0-RC2/Makefile

Revision 4877, 8.3 kB (checked in by khali, 1 year ago)

bash should no longer be needed at build time.

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