| 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 bash, GNU make, flex (>= 2.5.1) |
|---|
| 23 | # and bison. |
|---|
| 24 | |
|---|
| 25 | # If your /bin/sh is not bash, change the below definition so that make can |
|---|
| 26 | # find bash. Or you can hope your sh-like shell understands all scripts. |
|---|
| 27 | # I think so, but I have not tested it. |
|---|
| 28 | #SHELL := /usr/bin/bash |
|---|
| 29 | |
|---|
| 30 | # The currently running kernel version. This is used right below to |
|---|
| 31 | # determine where the kernel sources can be found. |
|---|
| 32 | KERNELVERSION := $(shell uname -r) |
|---|
| 33 | |
|---|
| 34 | # The location of linux itself. This is used to find the kernel headers |
|---|
| 35 | # and other things. |
|---|
| 36 | #LINUX := /usr/src/linux |
|---|
| 37 | LINUX := $(shell if [ -L "/lib/modules/$(KERNELVERSION)/build" ] ; \ |
|---|
| 38 | then echo "/lib/modules/$(KERNELVERSION)/build" ; \ |
|---|
| 39 | else echo "/usr/src/linux" ; fi) |
|---|
| 40 | LINUX_HEADERS := $(LINUX)/include |
|---|
| 41 | |
|---|
| 42 | # If you have installed the i2c header at some other place (like |
|---|
| 43 | # /usr/local/include/linux), set that directory here. Please check this out |
|---|
| 44 | # if you get strange compilation errors; the default Linux i2c headers |
|---|
| 45 | # may be used mistakenly. Note: This should point to the directory |
|---|
| 46 | # *above* the linux/ subdirectory, so to /usr/local/include in the |
|---|
| 47 | # above example. |
|---|
| 48 | I2C_HEADERS := /usr/local/include |
|---|
| 49 | #I2C_HEADERS := $(LINUX_HEADERS) |
|---|
| 50 | |
|---|
| 51 | ifneq ($(MAKECMDGOALS),user) |
|---|
| 52 | ifneq ($(MAKECMDGOALS),user_install) |
|---|
| 53 | ifneq ($(MAKECMDGOALS),user_uninstall) |
|---|
| 54 | SMP := $(shell if grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \ |
|---|
| 55 | then echo 1; else echo 0; fi) |
|---|
| 56 | MODVER := $(shell if grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_MODVERSIONS[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \ |
|---|
| 57 | then echo 1; else echo 0; fi) |
|---|
| 58 | endif |
|---|
| 59 | endif |
|---|
| 60 | endif |
|---|
| 61 | |
|---|
| 62 | # Uncomment the second line if you are a developer. This will enable many |
|---|
| 63 | # additional warnings at compile-time |
|---|
| 64 | WARN := 0 |
|---|
| 65 | #WARN := 1 |
|---|
| 66 | |
|---|
| 67 | # Uncomment the second line if you want to get (loads of) debug information |
|---|
| 68 | # at run-time. |
|---|
| 69 | # Not recommended, unless you are actually debugging the code |
|---|
| 70 | DEBUG := 0 |
|---|
| 71 | #DEBUG := 1 |
|---|
| 72 | |
|---|
| 73 | # If you want to install at some other place then at from which you will run |
|---|
| 74 | # everything, set DESTDIR to the extra prefix. |
|---|
| 75 | DESTDIR := |
|---|
| 76 | |
|---|
| 77 | # This is the prefix that will be used for almost all directories below. |
|---|
| 78 | PREFIX := /usr/local |
|---|
| 79 | |
|---|
| 80 | # Your C compiler |
|---|
| 81 | CC := gcc |
|---|
| 82 | |
|---|
| 83 | # This is the main modules directory into which the modules will be installed. |
|---|
| 84 | # The magic invocation will return something like this: |
|---|
| 85 | # /lib/modules/2.4.29 |
|---|
| 86 | KERNELVERSION := $(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release | cut -f 2 -d'"') |
|---|
| 87 | MODPREF := /lib/modules/$(KERNELVERSION) |
|---|
| 88 | |
|---|
| 89 | # When building userspace for use with 2.4.x series kernels, we turn off |
|---|
| 90 | # sysfs support by default. You can override this (e.g. if you want |
|---|
| 91 | # to build binaries that work for both 2.4.x, and 2.6.x and above) |
|---|
| 92 | # by uncommenting the line after the next endif. Keep in mind, if and only |
|---|
| 93 | # if you do this: you will need to install the libsysfs libraries on your |
|---|
| 94 | # kernel 2.4.x systems also. |
|---|
| 95 | ifeq (,$(findstring /2.4., $(MODPREF))) |
|---|
| 96 | SYSFS_SUPPORT := 1 |
|---|
| 97 | else |
|---|
| 98 | SYSFS_SUPPORT := |
|---|
| 99 | endif |
|---|
| 100 | #SYSFS_SUPPORT := 1 |
|---|
| 101 | |
|---|
| 102 | # Prevent 2.6+ users from using improper targets, as this won't work. |
|---|
| 103 | ifeq (,$(findstring /2.4., $(MODPREF))) |
|---|
| 104 | ifeq (, $(MAKECMDGOALS)) |
|---|
| 105 | $(error For 2.6 kernels and later, use "make user") |
|---|
| 106 | endif |
|---|
| 107 | ifeq (install, $(MAKECMDGOALS)) |
|---|
| 108 | $(error For 2.6 kernels and later, use "make user_install") |
|---|
| 109 | endif |
|---|
| 110 | endif |
|---|
| 111 | |
|---|
| 112 | # This is the directory where sensors.conf will be installed, if no other |
|---|
| 113 | # configuration file is found |
|---|
| 114 | ETCDIR := /etc |
|---|
| 115 | |
|---|
| 116 | # You should not need to change this. It is the directory into which the |
|---|
| 117 | # library files (both static and shared) will be installed. |
|---|
| 118 | LIBDIR := $(PREFIX)/lib |
|---|
| 119 | |
|---|
| 120 | EXLDFLAGS := -Wl,-rpath,$(LIBDIR) |
|---|
| 121 | |
|---|
| 122 | # You should not need to change this. It is the directory into which the |
|---|
| 123 | # executable program files will be installed. BINDIR for programs that are |
|---|
| 124 | # also useful for normal users, SBINDIR for programs that can only be run |
|---|
| 125 | # by the superuser. |
|---|
| 126 | # Note that not all programs in this package are really installed; |
|---|
| 127 | # some are just examples. You can always install them by hand, of |
|---|
| 128 | # course. |
|---|
| 129 | BINDIR := $(PREFIX)/bin |
|---|
| 130 | SBINDIR := $(PREFIX)/sbin |
|---|
| 131 | |
|---|
| 132 | # You should not need to change this. It is the basic directory into which |
|---|
| 133 | # include files will be installed. The actual directory will be |
|---|
| 134 | # $(INCLUDEDIR)/linux for system include files, and $(INCLUDEDIR)/sensors |
|---|
| 135 | # for library include files. If PREFIX equals the default /usr/local/bin, |
|---|
| 136 | # you will be able to use '#include <linux/sensors.h>' regardless of the |
|---|
| 137 | # current kernel selected. |
|---|
| 138 | INCLUDEDIR := $(PREFIX)/include |
|---|
| 139 | SYSINCLUDEDIR := $(INCLUDEDIR)/linux |
|---|
| 140 | LIBINCLUDEDIR := $(INCLUDEDIR)/sensors |
|---|
| 141 | |
|---|
| 142 | # You should not need to change this. It is the base directory under which the |
|---|
| 143 | # manual pages will be installed. |
|---|
| 144 | MANDIR := $(PREFIX)/man |
|---|
| 145 | |
|---|
| 146 | MACHINE := $(shell uname -m) |
|---|
| 147 | |
|---|
| 148 | # Extra non-default programs to build; e.g., sensord |
|---|
| 149 | # PROG_EXTRA := sensord |
|---|
| 150 | |
|---|
| 151 | # Set these to add preprocessor or compiler flags, or use |
|---|
| 152 | # environment variables |
|---|
| 153 | # CFLAGS := |
|---|
| 154 | # CPPFLAGS := |
|---|
| 155 | |
|---|
| 156 | ################################################## |
|---|
| 157 | # Below this, nothing should need to be changed. # |
|---|
| 158 | ################################################## |
|---|
| 159 | |
|---|
| 160 | # Note that this is a monolithic Makefile; it calls no sub-Makefiles, |
|---|
| 161 | # but instead, it compiles everything right from here. Yes, there are |
|---|
| 162 | # some distinct advantages to this; see the following paper for more info: |
|---|
| 163 | # http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html |
|---|
| 164 | # Note that is still uses Makefile fragments in sub-directories; these |
|---|
| 165 | # are called 'Module.mk'. |
|---|
| 166 | |
|---|
| 167 | # Within each Module.mk, rules and dependencies can be added to targets |
|---|
| 168 | # all, install and clean. Use double colons instead of single ones |
|---|
| 169 | # to do this. |
|---|
| 170 | |
|---|
| 171 | # The subdirectories we need to build things in |
|---|
| 172 | SRCDIRS := |
|---|
| 173 | ifneq ($(MAKECMDGOALS),user) |
|---|
| 174 | ifneq ($(MAKECMDGOALS),user_install) |
|---|
| 175 | ifneq ($(MAKECMDGOALS),user_uninstall) |
|---|
| 176 | ifneq ($(MAKECMDGOALS),package) |
|---|
| 177 | ifneq ($(MAKECMDGOALS),userpackage) |
|---|
| 178 | ifneq ($(MAKECMDGOALS),manhtml) |
|---|
| 179 | SRCDIRS += mkpatch |
|---|
| 180 | SRCDIRS += kernel kernel/busses kernel/chips |
|---|
| 181 | endif |
|---|
| 182 | endif |
|---|
| 183 | endif |
|---|
| 184 | endif |
|---|
| 185 | endif |
|---|
| 186 | endif |
|---|
| 187 | SRCDIRS += kernel/include |
|---|
| 188 | SRCDIRS += lib prog/detect prog/dump prog/eeprom prog/pwm \ |
|---|
| 189 | prog/sensors prog/xeon ${PROG_EXTRA:%=prog/%} etc |
|---|
| 190 | SRCDIRS += lib/test |
|---|
| 191 | |
|---|
| 192 | # Some often-used commands with default options |
|---|
| 193 | MKDIR := mkdir -p |
|---|
| 194 | RMDIR := rmdir |
|---|
| 195 | RM := rm -f |
|---|
| 196 | BISON := bison |
|---|
| 197 | FLEX := flex |
|---|
| 198 | AR := ar |
|---|
| 199 | INSTALL := install |
|---|
| 200 | LN := ln -sf |
|---|
| 201 | GREP := grep |
|---|
| 202 | AWK := awk |
|---|
| 203 | SED := sed |
|---|
| 204 | |
|---|
| 205 | # Determine the default compiler flags |
|---|
| 206 | # Set CFLAGS or CPPFLAGS above to add your own flags to all. |
|---|
| 207 | # ALLCPPFLAGS/ALLCFLAGS are common flags, plus any user-specified overrides from the environment or make command line. |
|---|
| 208 | # MODCPPFLAGS/MODCFLAGS is to create in-kernel object files (modules). |
|---|
| 209 | # PROGCPPFLAGS/PROGCFLAGS is to create non-kernel object files (which are linked into executables). |
|---|
| 210 | # ARCPPFLAGS/ARCFLAGS are used to create archive object files (static libraries). |
|---|
| 211 | # LIBCPPFLAGS/LIBCFLAGS are for shared library objects. |
|---|
| 212 | ALL_CPPFLAGS := -I. -Ikernel/include -I$(I2C_HEADERS) |
|---|
| 213 | ALL_CFLAGS := -Wall |
|---|
| 214 | |
|---|
| 215 | ifeq ($(DEBUG),1) |
|---|
| 216 | ALL_CPPFLAGS += -DDEBUG |
|---|
| 217 | ALL_CFLAGS += -O -g |
|---|
| 218 | else |
|---|
| 219 | ALL_CFLAGS += -O2 |
|---|
| 220 | endif |
|---|
| 221 | |
|---|
| 222 | ifeq ($(WARN),1) |
|---|
| 223 | ALL_CFLAGS += -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ |
|---|
| 224 | -Wcast-align -Wwrite-strings -Wnested-externs -Winline |
|---|
| 225 | endif |
|---|
| 226 | |
|---|
| 227 | ALL_CPPFLAGS += $(CPPFLAGS) |
|---|
| 228 | ALL_CFLAGS += $(CFLAGS) |
|---|
| 229 | |
|---|
| 230 | MODCPPFLAGS := |
|---|
| 231 | MODCFLAGS := -fno-strict-aliasing |
|---|
| 232 | |
|---|
| 233 | ifeq ($(MACHINE),alpha) |
|---|
| 234 | MODCFLAGS += -ffixed-8 -mno-fp-regs -mcpu=ev56 |
|---|
| 235 | endif |
|---|
| 236 | |
|---|
| 237 | ifeq ($(MACHINE),x86_64) |
|---|
| 238 | MODCFLAGS += -fno-common -fomit-frame-pointer -mno-red-zone \ |
|---|
| 239 | -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce |
|---|
| 240 | endif |
|---|
| 241 | |
|---|
| 242 | ifeq ($(MACHINE),mips) |
|---|
| 243 | MODCFLAGS += -mabi=32 -mips3 -Wa,-32 -Wa,-mips3 -Wa,--trap |
|---|
| 244 | endif |
|---|
| 245 | |
|---|
| 246 | ifeq ($(MACHINE),sparc32) |
|---|
| 247 | MODCFLAGS += -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 |
|---|
| 248 | endif |
|---|
| 249 | |
|---|
| 250 | ifeq ($(MACHINE),sparc64) |
|---|
| 251 | MODCFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow \ |
|---|
| 252 | -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare \ |
|---|
| 253 | -Wa,--undeclared-regs |
|---|
| 254 | endif |
|---|
| 255 | |
|---|
| 256 | ifeq ($(SMP),1) |
|---|
| 257 | MODCPPFLAGS += -D__SMP__ |
|---|
| 258 | endif |
|---|
| 259 | |
|---|
| 260 | ifeq ($(MODVER),1) |
|---|
| 261 | MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h |
|---|
| 262 | endif |
|---|
| 263 | |
|---|
| 264 | # This magic is from the kernel Makefile. |
|---|
| 265 | # Extra cflags for kbuild 2.4. The default is to forbid includes by kernel code |
|---|
| 266 | # from user space headers. |
|---|
| 267 | kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp') |
|---|
| 268 | |
|---|
| 269 | MODCPPFLAGS += -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -fomit-frame-pointer $(ALL_CPPFLAGS) -I$(LINUX_HEADERS) $(kbuild_2_4_nostdinc) |
|---|
| 270 | MODCFLAGS += $(ALL_CFLAGS) |
|---|
| 271 | PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS) -Wundef |
|---|
| 272 | PROGCFLAGS := $(ALL_CFLAGS) |
|---|
| 273 | ARCPPFLAGS := $(ALL_CPPFLAGS) |
|---|
| 274 | ifdef SYSFS_SUPPORT |
|---|
| 275 | ARCPPFLAGS := $(ARCPPFLAGS) -DSYSFS_SUPPORT |
|---|
| 276 | endif |
|---|
| 277 | ARCFLAGS := $(ALL_CFLAGS) |
|---|
| 278 | LIBCPPFLAGS := $(ALL_CPPFLAGS) |
|---|
| 279 | ifdef SYSFS_SUPPORT |
|---|
| 280 | LIBCPPFLAGS := $(LIBCPPFLAGS) -DSYSFS_SUPPORT |
|---|
| 281 | endif |
|---|
| 282 | LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS) |
|---|
| 283 | |
|---|
| 284 | .PHONY: all user clean install user_install uninstall user_uninstall version package |
|---|
| 285 | |
|---|
| 286 | # Make all the default rule |
|---|
| 287 | all:: |
|---|
| 288 | |
|---|
| 289 | # Include all makefiles for sub-modules |
|---|
| 290 | INCLUDEFILES := |
|---|
| 291 | include $(patsubst %,%/Module.mk,$(SRCDIRS)) |
|---|
| 292 | ifneq ($(MAKECMDGOALS),clean) |
|---|
| 293 | ifneq ($(MAKECMDGOALS),uninstall) |
|---|
| 294 | ifneq ($(MAKECMDGOALS),user_uninstall) |
|---|
| 295 | ifneq ($(MAKECMDGOALS),help) |
|---|
| 296 | ifneq ($(MAKECMDGOALS),package) |
|---|
| 297 | ifneq ($(MAKECMDGOALS),userpackage) |
|---|
| 298 | include $(INCLUDEFILES) |
|---|
| 299 | endif |
|---|
| 300 | endif |
|---|
| 301 | endif |
|---|
| 302 | endif |
|---|
| 303 | endif |
|---|
| 304 | endif |
|---|
| 305 | |
|---|
| 306 | # Man pages |
|---|
| 307 | MANPAGES := $(LIBMAN3FILES) $(LIBMAN5FILES) $(PROGDETECTMAN8FILES) $(PROGDUMPMAN8FILES) \ |
|---|
| 308 | $(PROGSENSORSMAN1FILES) $(PROGPWMMAN8FILES) prog/sensord/sensord.8 |
|---|
| 309 | |
|---|
| 310 | user :: |
|---|
| 311 | user_install:: |
|---|
| 312 | @echo "*** Important note:" |
|---|
| 313 | @echo "*** * The libsensors configuration file ($(ETCDIR)/sensors.conf) is never" |
|---|
| 314 | @echo "*** overwritten by our installation process, so that you won't lose" |
|---|
| 315 | @echo "*** your personal settings in that file. You still can get our latest" |
|---|
| 316 | @echo "*** default config file in etc/sensors.conf.eg and manually copy it to" |
|---|
| 317 | @echo "*** $(ETCDIR)/sensors.conf if you want. You will then want to edit it" |
|---|
| 318 | @echo "*** to fit your needs again." |
|---|
| 319 | all :: user |
|---|
| 320 | install :: all user_install |
|---|
| 321 | ifeq ($(DESTDIR),) |
|---|
| 322 | -if [ -r $(MODPREF)/build/System.map -a -x /sbin/depmod ] ; then \ |
|---|
| 323 | /sbin/depmod -a -F $(MODPREF)/build/System.map $(KERNELVERSION) ; \ |
|---|
| 324 | fi |
|---|
| 325 | else |
|---|
| 326 | @echo "*** This is a \`staged' install using \"$(DESTDIR)\" as prefix." |
|---|
| 327 | @echo "***" |
|---|
| 328 | @echo "*** Once the modules have been moved to their final destination" |
|---|
| 329 | @echo "*** you must run the command \"/sbin/depmod -a\"." |
|---|
| 330 | @echo "***" |
|---|
| 331 | @echo "*** Alternatively, if you build a package (e.g. rpm), include the" |
|---|
| 332 | @echo "*** command \"/sbin/depmod -a\" in the post-(un)install procedure." |
|---|
| 333 | @echo "***" |
|---|
| 334 | @echo "*** The depmod command mentioned above may generate errors. We are" |
|---|
| 335 | @echo "*** aware of the problem and are working on a solution." |
|---|
| 336 | endif |
|---|
| 337 | |
|---|
| 338 | clean:: |
|---|
| 339 | $(RM) lm_sensors-* lex.backup |
|---|
| 340 | |
|---|
| 341 | user_uninstall:: |
|---|
| 342 | |
|---|
| 343 | uninstall :: user_uninstall |
|---|
| 344 | @echo "*** Note:" |
|---|
| 345 | @echo "*** * Kernel modules were not uninstalled." |
|---|
| 346 | |
|---|
| 347 | # This is tricky, but it works like a charm. It needs lots of utilities |
|---|
| 348 | # though: cut, find, gzip, ln, tail and tar. |
|---|
| 349 | package: version clean |
|---|
| 350 | lmversion=`tail -1 version.h|cut -f 2 -d \"`; \ |
|---|
| 351 | lmpackage=lm_sensors-$$lmversion; \ |
|---|
| 352 | ln -s . $$lmpackage; \ |
|---|
| 353 | find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \ |
|---|
| 354 | grep -v ^$$lmpackage/$$lmpackage.tar$$ | \ |
|---|
| 355 | grep -v ^$$lmpackage/$$ | \ |
|---|
| 356 | grep -v /CVS | \ |
|---|
| 357 | grep -v /\\.# | \ |
|---|
| 358 | tar rvf $$lmpackage.tar -T -; \ |
|---|
| 359 | gzip -9 $$lmpackage.tar ;\ |
|---|
| 360 | $(RM) $$lmpackage.tar $$lmpackage |
|---|
| 361 | cat doc/developers/checklist |
|---|
| 362 | |
|---|
| 363 | # doesn't work well yet... needs Makefile changes too |
|---|
| 364 | userpackage: version clean $(KERNELINCLUDEDIR)/sensors.h |
|---|
| 365 | lmversion=`tail -1 version.h|cut -f 2 -d \"`; \ |
|---|
| 366 | lmpackage=lm_sensors-user-$$lmversion; \ |
|---|
| 367 | ln -s . $$lmpackage; \ |
|---|
| 368 | find $$lmpackage/ -type f | grep -v ^$$lmpackage/$$lmpackage$$ | \ |
|---|
| 369 | grep -v ^$$lmpackage/$$lmpackage.tar$$ | \ |
|---|
| 370 | grep -v ^$$lmpackage/doc/chips | \ |
|---|
| 371 | grep -v ^$$lmpackage/doc/busses | \ |
|---|
| 372 | grep -v ^$$lmpackage/kernel/chips | \ |
|---|
| 373 | grep -v ^$$lmpackage/kernel/busses | \ |
|---|
| 374 | grep -v ^$$lmpackage/$$ | \ |
|---|
| 375 | grep -v /CVS | \ |
|---|
| 376 | grep -v /\\.# | \ |
|---|
| 377 | tar rvf $$lmpackage.tar -T -; \ |
|---|
| 378 | gzip -9 $$lmpackage.tar ;\ |
|---|
| 379 | $(RM) $$lmpackage.tar $$lmpackage |
|---|
| 380 | cat doc/developers/checklist |
|---|
| 381 | |
|---|
| 382 | version: |
|---|
| 383 | $(RM) version.h |
|---|
| 384 | echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h |
|---|
| 385 | echo -n 'Version: '; \ |
|---|
| 386 | echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h |
|---|
| 387 | |
|---|
| 388 | help: |
|---|
| 389 | @echo 'Make targets are:' |
|---|
| 390 | @echo ' all (default): build modules and userspace programs' |
|---|
| 391 | @echo ' install: install modules and userspace programs' |
|---|
| 392 | @echo ' user: build userspace programs' |
|---|
| 393 | @echo ' user_install: install userspace programs' |
|---|
| 394 | @echo ' user_uninstall: remove userspace programs' |
|---|
| 395 | @echo ' clean: cleanup' |
|---|
| 396 | @echo ' package: create a distribution package' |
|---|
| 397 | |
|---|
| 398 | $(LINUX)/.config: |
|---|
| 399 | @echo |
|---|
| 400 | @echo "Error - missing file $(LINUX)/.config !! " |
|---|
| 401 | @echo " Verify kernel source is in $(LINUX) and then" |
|---|
| 402 | @echo " cd to $(LINUX) and run 'make config' !!" |
|---|
| 403 | @echo |
|---|
| 404 | @echo "Exception: if you're using a stock RedHat kernel..." |
|---|
| 405 | @echo " (1) Install the appropriate kernel-source RPM." |
|---|
| 406 | @echo " (2) Copy the appropriate config..." |
|---|
| 407 | @echo " from $(LINUX)/configs/<...>" |
|---|
| 408 | @echo " to $(LINUX)/.config" |
|---|
| 409 | @echo " (3) Do *NOT* 'make dep' or 'make config'." |
|---|
| 410 | @echo |
|---|
| 411 | @exit 1 |
|---|
| 412 | |
|---|
| 413 | # Generate html man pages to be copied to the lm_sensors website. |
|---|
| 414 | # This uses the man2html from here |
|---|
| 415 | # http://ftp.math.utah.edu/pub/sgml/ |
|---|
| 416 | # which works directly from the nroff source |
|---|
| 417 | manhtml: |
|---|
| 418 | $(MKDIR) html |
|---|
| 419 | cp $(MANPAGES) html |
|---|
| 420 | cd html ; \ |
|---|
| 421 | export LOGNAME=sensors ; \ |
|---|
| 422 | export HOSTNAME=www.lm-sensors.org ; \ |
|---|
| 423 | man2html *.[1-8] ; \ |
|---|
| 424 | $(RM) *.[1-8] |
|---|
| 425 | |
|---|
| 426 | # Here, we define all implicit rules we want to use. |
|---|
| 427 | |
|---|
| 428 | .SUFFIXES: |
|---|
| 429 | |
|---|
| 430 | # We need to create dependency files. Tricky. The sed rule puts dir/file.d and |
|---|
| 431 | # dir/file.c in front of the dependency file rule. |
|---|
| 432 | |
|---|
| 433 | # .o files are used for modules |
|---|
| 434 | # depend on the kernel config file! |
|---|
| 435 | %.o: %.c $(LINUX)/.config |
|---|
| 436 | $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@ |
|---|
| 437 | |
|---|
| 438 | %.d: %.c $(LINUX)/.config |
|---|
| 439 | $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \ |
|---|
| 440 | $(SED) -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@ |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | |
|---|
| 444 | # .ro files are used for programs (as opposed to modules) |
|---|
| 445 | %.ro: %.c |
|---|
| 446 | $(CC) $(PROGCPPFLAGS) $(PROGCFLAGS) -c $< -o $@ |
|---|
| 447 | |
|---|
| 448 | %.rd: %.c |
|---|
| 449 | $(CC) -M -MG $(PROGCPPFLAGS) $(PROGCFLAGS) $< | \ |
|---|
| 450 | $(SED) -e 's@^\(.*\)\.o:@$*.rd $*.ro: Makefile '`dirname $*.rd`/Module.mk' @' > $@ |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | %: %.ro |
|---|
| 454 | $(CC) $(EXLDFLAGS) -o $@ $^ |
|---|
| 455 | |
|---|
| 456 | |
|---|
| 457 | # .ao files are used for static archives |
|---|
| 458 | %.ao: %.c |
|---|
| 459 | $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -c $< -o $@ |
|---|
| 460 | |
|---|
| 461 | %.ad: %.c |
|---|
| 462 | $(CC) -M -MG $(ARCPPFLAGS) $(ARCFLAGS) $< | \ |
|---|
| 463 | $(SED) -e 's@^\(.*\)\.o:@$*.ad $*.ao: Makefile '`dirname $*.ad`/Module.mk' @' > $@ |
|---|
| 464 | |
|---|
| 465 | |
|---|
| 466 | # .lo files are used for shared libraries |
|---|
| 467 | %.lo: %.c |
|---|
| 468 | $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -c $< -o $@ |
|---|
| 469 | |
|---|
| 470 | %.ld: %.c |
|---|
| 471 | $(CC) -M -MG $(LIBCPPFLAGS) $(LIBCFLAGS) $< | \ |
|---|
| 472 | $(SED) -e 's@^\(.*\)\.o:@$*.ld $*.lo: Makefile '`dirname $*.ld`/Module.mk' @' > $@ |
|---|
| 473 | |
|---|
| 474 | |
|---|
| 475 | # Flex and Bison |
|---|
| 476 | %c: %y |
|---|
| 477 | $(BISON) -p sensors_yy -d $< -o $@ |
|---|
| 478 | |
|---|
| 479 | ifeq ($(DEBUG),1) |
|---|
| 480 | FLEX_FLAGS := -Psensors_yy -t -b -Cfe -8 |
|---|
| 481 | else |
|---|
| 482 | FLEX_FLAGS := -Psensors_yy -t -Cfe -8 |
|---|
| 483 | endif |
|---|
| 484 | |
|---|
| 485 | %.c: %.l |
|---|
| 486 | $(FLEX) $(FLEX_FLAGS) $< > $@ |
|---|