]> git.ipfire.org Git - thirdparty/systemd.git/blame - Makefile
substitute format chars in RUN after rule matching
[thirdparty/systemd.git] / Makefile
CommitLineData
8dfc8dbe 1# Makefile for udev
f0083e3d 2#
e7c4f85f 3# Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
6c18b1fb 4# Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
f0083e3d
GKH
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; version 2 of the License.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
7155bfb7 20VERSION = 081
0e47c219
KS
21
22# set this to make use of syslog
05230184 23USE_LOG = true
54988802 24
0e47c219
KS
25# compile-in development debug messages
26# (export UDEV_LOG="debug" or set udev_log="debug" in udev.conf
27# to print the debug messages to syslog)
29b82deb 28DEBUG = false
f0083e3d 29
a8b38f1c 30# compile with gcc's code coverage option
a8b38f1c
KS
31USE_GCOV = false
32
0e47c219 33# include Security-Enhanced Linux support
9825617b 34USE_SELINUX = false
f0083e3d 35
0e47c219 36# comile with klibc instead of glibc
6c18b1fb
KS
37USE_KLIBC = false
38
0e47c219 39# set this to create statically linked binaries
6c18b1fb
KS
40USE_STATIC = false
41
0e47c219
KS
42# to build any of the extras programs pass:
43# make EXTRAS="extras/<extra1> extras/<extra2>"
638b983b 44EXTRAS =
6c18b1fb 45
d8a57e7c 46# make the build silent.
638b983b 47V = false
6c18b1fb 48
0e47c219
KS
49PROGRAMS = \
50 udev \
51 udevd \
52 udevsend \
0e47c219
KS
53 udevcontrol \
54 udevmonitor \
55 udevinfo \
56 udevtest \
57 udevstart
58
59HEADERS = \
60 udev.h \
0e47c219 61 udev_rules.h \
0e47c219
KS
62 logging.h \
63 udev_libc_wrapper.h \
64 udev_selinux.h \
65 list.h
66
67UDEV_OBJS = \
0e47c219
KS
68 udev_device.o \
69 udev_config.o \
70 udev_add.o \
71 udev_remove.o \
0e47c219 72 udev_db.o \
1aa1e248 73 udev_sysfs.o \
0e47c219
KS
74 udev_rules.o \
75 udev_rules_parse.o \
76 udev_utils.o \
77 udev_utils_string.o \
78 udev_utils_file.o \
79 udev_utils_run.o \
80 udev_libc_wrapper.o
81LIBUDEV = libudev.a
82
83MAN_PAGES = \
7b86ada7 84 udev.8 \
0e47c219
KS
85 udevmonitor.8 \
86 udevd.8 \
7b86ada7 87 udevsend.8 \
0e47c219
KS
88 udevtest.8 \
89 udevinfo.8 \
90 udevstart.8
91
0e47c219
KS
92GEN_HEADERS = \
93 udev_version.h
977083c2 94
9f53b06a 95prefix =
9f53b06a 96etcdir = ${prefix}/etc
d7363ee1
KS
97sbindir = ${prefix}/sbin
98usrbindir = ${prefix}/usr/bin
99usrsbindir = ${prefix}/usr/sbin
100libudevdir = ${prefix}/lib/udev
9f53b06a 101mandir = ${prefix}/usr/share/man
aef6bb13 102configdir = ${etcdir}/udev
0e47c219 103udevdir = /dev
0e47c219 104DESTDIR =
9f53b06a
GKH
105
106INSTALL = /usr/bin/install -c
107INSTALL_PROGRAM = ${INSTALL}
d8a57e7c 108INSTALL_DATA = ${INSTALL} -m 644
9f53b06a 109INSTALL_SCRIPT = ${INSTALL_PROGRAM}
89067448
GKH
110PWD = $(shell pwd)
111
638b983b 112CROSS =
f0083e3d 113CC = $(CROSS)gcc
74894b53 114LD = $(CROSS)gcc
f0083e3d 115AR = $(CROSS)ar
b137e367 116RANLIB = $(CROSS)ranlib
c04a1647 117HOSTCC = gcc
f032e0ed
KS
118STRIP = $(CROSS)strip
119STRIPCMD = $(STRIP) -s
f0083e3d 120
f032e0ed
KS
121CFLAGS = -g -Wall -pipe -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
122WARNINGS = -Wstrict-prototypes -Wsign-compare -Wshadow \
123 -Wchar-subscripts -Wmissing-declarations -Wnested-externs \
124 -Wpointer-arith -Wcast-align -Wsign-compare -Wmissing-prototypes
f032e0ed 125CFLAGS += $(WARNINGS)
12901d99 126
638b983b
KS
127LDFLAGS = -Wl,-warn-common
128
c756114f 129OPTFLAGS = -Os
f032e0ed 130CFLAGS += $(OPTFLAGS)
1196e46c 131
05230184 132ifeq ($(strip $(USE_LOG)),true)
6c18b1fb 133 CFLAGS += -DUSE_LOG
54988802
KS
134endif
135
f032e0ed 136# if DEBUG is enabled, then we do not strip
f0083e3d 137ifeq ($(strip $(DEBUG)),true)
638b983b 138 CFLAGS += -DDEBUG
6cb1bbe4 139 STRIPCMD =
f0083e3d
GKH
140endif
141
a8b38f1c
KS
142ifeq ($(strip $(USE_GCOV)),true)
143 CFLAGS += -fprofile-arcs -ftest-coverage
638b983b 144 LDFLAGS += -fprofile-arcs
a8b38f1c
KS
145endif
146
66626948 147ifeq ($(strip $(USE_KLIBC)),true)
a8349b33 148 KLCC = /usr/bin/$(CROSS)klcc
92ebb398
KS
149 CC = $(KLCC)
150 LD = $(KLCC)
49fb51c6 151 V = true
f0083e3d
GKH
152endif
153
9825617b 154ifeq ($(strip $(USE_SELINUX)),true)
045b1f0f 155 UDEV_OBJS += udev_selinux.o
586e1a37 156 LIB_OBJS += -lselinux -lsepol
045b1f0f 157 CFLAGS += -DUSE_SELINUX
9825617b
HH
158endif
159
6c18b1fb
KS
160ifeq ($(strip $(USE_STATIC)),true)
161 CFLAGS += -DUSE_STATIC
162 LDFLAGS += -static
163endif
164
045b1f0f
KS
165ifeq ($(strip $(V)),false)
166 QUIET=@$(PWD)/ccdv
167 HOST_PROGS=ccdv
168else
169 QUIET=
170 HOST_PROGS=
171endif
eadb1bbc 172
a8349b33 173all: $(PROGRAMS) $(MAN_PAGES)
0e47c219
KS
174 @extras="$(EXTRAS)"; for target in $$extras; do \
175 echo $$target; \
49fb51c6 176 $(MAKE) CC="$(CC)" \
db28d2ea 177 CFLAGS="$(CFLAGS)" \
977083c2 178 LD="$(LD)" \
db28d2ea
KS
179 LDFLAGS="$(LDFLAGS)" \
180 STRIPCMD="$(STRIPCMD)" \
181 LIB_OBJS="$(LIB_OBJS)" \
0e47c219 182 LIBUDEV="$(PWD)/$(LIBUDEV)" \
09f27560 183 QUIET="$(QUIET)" \
c699bc48 184 -C $$target $@ || exit 1; \
0e47c219
KS
185 done;
186.PHONY: all
17d3cb12 187.DEFAULT: all
f0083e3d 188
7a526da6
KS
189# clear implicit rules
190.SUFFIXES:
191
192# build the objects
1aa1e248 193%.o: %.c $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS)
7a526da6
KS
194 $(QUIET) $(CC) -c $(CFLAGS) $< -o $@
195
196# "Static Pattern Rule" to build all programs
1aa1e248
KS
197$(PROGRAMS): %: $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS) $(LIBUDEV) %.o
198 $(QUIET) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIB_OBJS)
c1bf1ede 199ifneq ($(STRIPCMD),)
0e47c219 200 $(QUIET) $(STRIPCMD) $@
6cb1bbe4 201endif
0e47c219 202
0e47c219
KS
203$(LIBUDEV): $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS)
204 @rm -f $@
7c2aae11
KS
205 $(QUIET) $(AR) cq $@ $(UDEV_OBJS)
206 $(QUIET) $(RANLIB) $@
207
f0083e3d 208udev_version.h:
d8a57e7c
KS
209 @echo "/* Generated by make. */" > $@
210 @echo \#define UDEV_VERSION \"$(VERSION)\" >> $@
2b41e68a 211 @echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
aef6bb13
KS
212 @echo \#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
213 @echo \#define UDEV_RULES_FILE \"$(configdir)/rules.d\" >> $@
f0083e3d 214
420a506e
KS
215# man pages
216%.8: docs/%.xml
217 xmlto man $?
0e47c219 218.PRECIOUS: %.8
56a8a624 219
0e47c219
KS
220ccdv: ccdv.c
221 @$(HOSTCC) -O1 ccdv.c -o ccdv
222.SILENT: ccdv
223
f0083e3d 224clean:
a5e551b9 225 - rm -f $(HOST_PROGS)
17d3cb12 226 - find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print0 | xargs -0rt rm -f
a8b38f1c
KS
227 - find -name "*.gcno" -print0 | xargs -0rt rm -f
228 - find -name "*.gcda" -print0 | xargs -0rt rm -f
229 - find -name "*.gcov" -print0 | xargs -0rt rm -f
230 - rm -f udev_gcov.txt
d8a57e7c 231 - rm -f core $(PROGRAMS) $(GEN_HEADERS)
cf686d37 232 - rm -f udev-$(VERSION).tar.gz
d8a57e7c 233 - rm -f udev-$(VERSION).tar.bz2
0e47c219
KS
234 @extras="$(EXTRAS)"; for target in $$extras; do \
235 echo $$target; \
c699bc48 236 $(MAKE) -C $$target $@ || exit 1; \
0e47c219 237 done;
49fb51c6 238.PHONY: clean
2761f9b9 239
49fb51c6 240release:
cf686d37 241 git-tar-tree HEAD udev-$(VERSION) | gzip -9v > udev-$(VERSION).tar.gz
d8a57e7c 242 git-tar-tree HEAD udev-$(VERSION) | bzip2 -9v > udev-$(VERSION).tar.bz2
0e47c219 243.PHONY: release
54e3a5d3 244
d8a57e7c 245install-config:
aef6bb13 246 $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d
aef6bb13 247 @if [ ! -r $(DESTDIR)$(configdir)/udev.conf ]; then \
d8a57e7c 248 $(INSTALL_DATA) etc/udev/udev.conf $(DESTDIR)$(configdir); \
7591c18a 249 fi
aef6bb13 250 @if [ ! -r $(DESTDIR)$(configdir)/rules.d/50-udev.rules ]; then \
0e47c219 251 echo; \
d2e8d41b 252 echo "pick a udev rules file from the etc/udev directory that matches your distribution"; \
0e47c219 253 echo; \
7591c18a 254 fi
1ac216b1
JB
255 @extras="$(EXTRAS)"; for target in $$extras; do \
256 echo $$target; \
c699bc48 257 $(MAKE) -C $$target $@ || exit 1; \
1ac216b1 258 done;
0e47c219 259.PHONY: install-config
7591c18a 260
487c1b35 261install-man:
438ac360
GKH
262 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
263 $(INSTALL_DATA) -D udevinfo.8 $(DESTDIR)$(mandir)/man8/udevinfo.8
264 $(INSTALL_DATA) -D udevtest.8 $(DESTDIR)$(mandir)/man8/udevtest.8
265 $(INSTALL_DATA) -D udevstart.8 $(DESTDIR)$(mandir)/man8/udevstart.8
266 $(INSTALL_DATA) -D udevd.8 $(DESTDIR)$(mandir)/man8/udevd.8
7b86ada7 267 $(INSTALL_DATA) -D udevsend.8 $(DESTDIR)$(mandir)/man8/udevsend.8
420a506e 268 $(INSTALL_DATA) -D udevmonitor.8 $(DESTDIR)$(mandir)/man8/udevmonitor.8
420a506e 269 - ln -f -s udevd.8 $(DESTDIR)$(mandir)/man8/udevcontrol.8
1ac216b1
JB
270 @extras="$(EXTRAS)"; for target in $$extras; do \
271 echo $$target; \
c699bc48 272 $(MAKE) -C $$target $@ || exit 1; \
1ac216b1 273 done;
0e47c219 274.PHONY: install-man
438ac360
GKH
275
276uninstall-man:
49fb51c6
KS
277 - rm -f $(DESTDIR)$(mandir)/man8/udev.8
278 - rm -f $(DESTDIR)$(mandir)/man8/udevinfo.8
279 - rm -f $(DESTDIR)$(mandir)/man8/udevtest.8
280 - rm -f $(DESTDIR)$(mandir)/man8/udevstart.8
281 - rm -f $(DESTDIR)$(mandir)/man8/udevd.8
282 - rm -f $(DESTDIR)$(mandir)/man8/udevmonitor.8
283 - rm -f $(DESTDIR)$(mandir)/man8/udevsend.8
284 - rm -f $(DESTDIR)$(mandir)/man8/udevcontrol.8
1ac216b1
JB
285 @extras="$(EXTRAS)"; for target in $$extras; do \
286 echo $$target; \
c699bc48 287 $(MAKE) -C $$target $@ || exit 1; \
1ac216b1 288 done;
0e47c219 289.PHONY: uninstall-man
438ac360 290
17d3cb12 291install-bin:
7591c18a 292 $(INSTALL) -d $(DESTDIR)$(udevdir)
0e47c219
KS
293 $(INSTALL_PROGRAM) -D udev $(DESTDIR)$(sbindir)/udev
294 $(INSTALL_PROGRAM) -D udevd $(DESTDIR)$(sbindir)/udevd
295 $(INSTALL_PROGRAM) -D udevsend $(DESTDIR)$(sbindir)/udevsend
296 $(INSTALL_PROGRAM) -D udevcontrol $(DESTDIR)$(sbindir)/udevcontrol
297 $(INSTALL_PROGRAM) -D udevmonitor $(DESTDIR)$(usrsbindir)/udevmonitor
298 $(INSTALL_PROGRAM) -D udevinfo $(DESTDIR)$(usrbindir)/udevinfo
299 $(INSTALL_PROGRAM) -D udevtest $(DESTDIR)$(usrbindir)/udevtest
300 $(INSTALL_PROGRAM) -D udevstart $(DESTDIR)$(sbindir)/udevstart
db28d2ea
KS
301 @extras="$(EXTRAS)"; for target in $$extras; do \
302 echo $$target; \
c699bc48 303 $(MAKE) -C $$target $@ || exit 1; \
db28d2ea 304 done;
f070df16 305ifndef DESTDIR
0e47c219 306 - killall udevd
fc55cf68 307 - rm -rf /dev/.udev
0e47c219 308 - $(sbindir)/udevd --daemon
f070df16 309endif
17d3cb12 310.PHONY: install-bin
6785820d 311
17d3cb12 312uninstall-bin:
49fb51c6
KS
313 - rm -f $(DESTDIR)$(sbindir)/udev
314 - rm -f $(DESTDIR)$(sbindir)/udevd
315 - rm -f $(DESTDIR)$(sbindir)/udevsend
49fb51c6
KS
316 - rm -f $(DESTDIR)$(sbindir)/udevcontrol
317 - rm -f $(DESTDIR)$(sbindir)/udevstart
318 - rm -f $(DESTDIR)$(usrsbindir)/udevmonitor
d8a57e7c
KS
319 - rm -f $(DESTDIR)$(usrbindir)/udevinfo
320 - rm -f $(DESTDIR)$(usrbindir)/udevtest
49fb51c6 321ifndef DESTDIR
0e47c219 322 - killall udevd
fc55cf68 323 - rm -rf /dev/.udev
49fb51c6 324endif
0e47c219
KS
325 @extras="$(EXTRAS)"; for target in $$extras; do \
326 echo $$target; \
c699bc48 327 $(MAKE) -C $$target $@ || exit 1; \
0e47c219 328 done;
17d3cb12
KS
329.PHONY: uninstall-bin
330
331install: all install-bin install-config install-man
332.PHONY: install
333
334uninstall: uninstall-bin uninstall-man
335.PHONY: uninstall
0e47c219
KS
336
337test tests: all
e9f65389 338 @ cd test && ./udev-test.pl
05bd6efb 339 @ cd test && ./udevstart-test.pl
0e47c219 340.PHONY: test tests
0de3c3ed 341
17d3cb12 342buildtest:
ed0e3cbd 343 test/simple-build-check.sh
a8b38f1c
KS
344.PHONY: buildtest
345
ed0e3cbd
KS
346ChangeLog: Makefile
347 @ mv $@ $@.tmp
731a7d6d 348 @ echo "Summary of changes from v$(shell printf '%03i' $$(expr $(VERSION) - 1)) to v$(VERSION)" >> $@
ed0e3cbd 349 @ echo "============================================" >> $@
731a7d6d
KS
350 @ echo >> $@
351 @ git log --pretty=short $(shell printf '%03i' $$(expr $(VERSION) - 1))..HEAD | git shortlog >> $@
ed0e3cbd
KS
352 @ echo >> $@
353 @ cat $@
354 @ cat $@.tmp >> $@
355 @ rm $@.tmp
356
a8b38f1c 357gcov-all:
f032e0ed 358 $(MAKE) clean all STRIPCMD= USE_GCOV=true
a8b38f1c
KS
359 @echo
360 @echo "binaries built with gcov support."
361 @echo "run the tests and analyze with 'make udev_gcov.txt'"
362.PHONY: gcov-all
363
364# see docs/README-gcov_for_udev
365udev_gcov.txt: $(wildcard *.gcda) $(wildcard *.gcno)
366 for file in `find -maxdepth 1 -name "*.gcno"`; do \
367 name=`basename $$file .gcno`; \
368 echo "################" >> $@; \
369 echo "$$name.c" >> $@; \
370 echo "################" >> $@; \
371 if [ -e "$$name.gcda" ]; then \
372 gcov -l "$$name.c" >> $@ 2>&1; \
373 else \
374 echo "code for $$name.c was never executed" >> $@ 2>&1; \
375 fi; \
376 echo >> $@; \
377 done; \
378 echo "view $@ for the result"