]> git.ipfire.org Git - thirdparty/systemd.git/blob - Makefile
udevd: export current seqnum and add udevsettle
[thirdparty/systemd.git] / Makefile
1 # Makefile for udev
2 #
3 # Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
4 # Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
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
20 VERSION = 089
21
22 # set this to make use of syslog
23 USE_LOG = true
24
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)
28 DEBUG = false
29
30 # compile with gcc's code coverage option
31 USE_GCOV = false
32
33 # include Security-Enhanced Linux support
34 USE_SELINUX = false
35
36 # comile with klibc instead of glibc
37 USE_KLIBC = false
38
39 # set this to create statically linked binaries
40 USE_STATIC = false
41
42 # to build any of the extras programs pass:
43 # make EXTRAS="extras/<extra1> extras/<extra2>"
44 EXTRAS =
45
46 # make the build silent
47 V =
48
49 PROGRAMS = \
50 udev \
51 udevd \
52 udevtrigger \
53 udevsettle \
54 udevsend \
55 udevcontrol \
56 udevmonitor \
57 udevinfo \
58 udevtest \
59 udevstart
60
61 HEADERS = \
62 udev.h \
63 udev_rules.h \
64 logging.h \
65 udev_libc_wrapper.h \
66 udev_selinux.h \
67 list.h
68
69 UDEV_OBJS = \
70 udev_device.o \
71 udev_config.o \
72 udev_add.o \
73 udev_remove.o \
74 udev_db.o \
75 udev_sysfs.o \
76 udev_rules.o \
77 udev_rules_parse.o \
78 udev_utils.o \
79 udev_utils_string.o \
80 udev_utils_file.o \
81 udev_utils_run.o \
82 udev_libc_wrapper.o
83 LIBUDEV = libudev.a
84
85 MAN_PAGES = \
86 udev.7 \
87 udevmonitor.8 \
88 udevd.8 \
89 udevtrigger.8 \
90 udevsettle.8 \
91 udevsend.8 \
92 udevtest.8 \
93 udevinfo.8 \
94 udevstart.8
95
96 GEN_HEADERS = \
97 udev_version.h
98
99 prefix =
100 etcdir = ${prefix}/etc
101 sbindir = ${prefix}/sbin
102 usrbindir = ${prefix}/usr/bin
103 usrsbindir = ${prefix}/usr/sbin
104 libudevdir = ${prefix}/lib/udev
105 mandir = ${prefix}/usr/share/man
106 configdir = ${etcdir}/udev
107 udevdir = /dev
108 DESTDIR =
109
110 INSTALL = /usr/bin/install -c
111 INSTALL_PROGRAM = ${INSTALL}
112 INSTALL_DATA = ${INSTALL} -m 644
113 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
114 PWD = $(shell pwd)
115
116 CROSS_COMPILE =
117 CC = $(CROSS_COMPILE)gcc
118 LD = $(CROSS_COMPILE)gcc
119 AR = $(CROSS_COMPILE)ar
120 RANLIB = $(CROSS_COMPILE)ranlib
121
122 CFLAGS = -g -Wall -pipe -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
123 WARNINGS = -Wstrict-prototypes -Wsign-compare -Wshadow \
124 -Wchar-subscripts -Wmissing-declarations -Wnested-externs \
125 -Wpointer-arith -Wcast-align -Wsign-compare -Wmissing-prototypes
126 CFLAGS += $(WARNINGS)
127
128 LDFLAGS = -Wl,-warn-common
129
130 OPTFLAGS = -Os
131 CFLAGS += $(OPTFLAGS)
132
133 ifeq ($(strip $(USE_LOG)),true)
134 CFLAGS += -DUSE_LOG
135 endif
136
137 # if DEBUG is enabled, then we do not strip
138 ifeq ($(strip $(DEBUG)),true)
139 CFLAGS += -DDEBUG
140 endif
141
142 ifeq ($(strip $(USE_GCOV)),true)
143 CFLAGS += -fprofile-arcs -ftest-coverage
144 LDFLAGS += -fprofile-arcs
145 endif
146
147 ifeq ($(strip $(USE_KLIBC)),true)
148 KLCC = /usr/bin/$(CROSS_COMPILE)klcc
149 CC = $(KLCC)
150 LD = $(KLCC)
151 endif
152
153 ifeq ($(strip $(USE_SELINUX)),true)
154 UDEV_OBJS += udev_selinux.o
155 LIB_OBJS += -lselinux -lsepol
156 CFLAGS += -DUSE_SELINUX
157 endif
158
159 ifeq ($(strip $(USE_STATIC)),true)
160 CFLAGS += -DUSE_STATIC
161 LDFLAGS += -static
162 endif
163
164 ifeq ($(strip $(V)),)
165 E = @echo
166 Q = @
167 else
168 E = @\#
169 Q =
170 endif
171 export E Q
172
173 all: $(PROGRAMS) $(MAN_PAGES)
174 $(Q) extras="$(EXTRAS)"; for target in $$extras; do \
175 $(MAKE) CC="$(CC)" \
176 CFLAGS="$(CFLAGS)" \
177 LD="$(LD)" \
178 LDFLAGS="$(LDFLAGS)" \
179 AR="$(AR)" \
180 RANLIB="$(RANLIB)" \
181 LIB_OBJS="$(LIB_OBJS)" \
182 LIBUDEV="$(PWD)/$(LIBUDEV)" \
183 -C $$target $@ || exit 1; \
184 done;
185 .PHONY: all
186 .DEFAULT: all
187
188 # clear implicit rules
189 .SUFFIXES:
190
191 # build the objects
192 %.o: %.c $(HEADERS) $(GEN_HEADERS)
193 $(E) " CC " $@
194 $(Q) $(CC) -c $(CFLAGS) $< -o $@
195
196 # "Static Pattern Rule" to build all programs
197 $(PROGRAMS): %: $(HEADERS) $(GEN_HEADERS) $(LIBUDEV) %.o
198 $(E) " LD " $@
199 $(Q) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIB_OBJS)
200
201 $(LIBUDEV): $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS)
202 $(Q) rm -f $@
203 $(E) " AR " $@
204 $(Q) $(AR) cq $@ $(UDEV_OBJS)
205 $(E) " RANLIB " $@
206 $(Q) $(RANLIB) $@
207
208 udev_version.h:
209 $(E) " GENHDR " $@
210 $(Q) echo "/* Generated by make. */" > $@
211 $(Q) echo \#define UDEV_VERSION \"$(VERSION)\" >> $@
212 $(Q) echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
213 $(Q) echo \#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
214 $(Q) echo \#define UDEV_RULES_FILE \"$(configdir)/rules.d\" >> $@
215
216 # man pages
217 %.8 %.7: %.xml
218 $(E) " XMLTO " $@
219 $(Q) xmlto man $?
220 .PRECIOUS: %.8
221
222 clean:
223 $(E) " CLEAN "
224 $(Q) - find . -type f -name '*.orig' -print0 | xargs -0r rm -f
225 $(Q) - find . -type f -name '*.rej' -print0 | xargs -0r rm -f
226 $(Q) - find . -type f -name '*~' -print0 | xargs -0r rm -f
227 $(Q) - find . -type f -name '*.[oas]' -print0 | xargs -0r rm -f
228 $(Q) - find . -type f -name "*.gcno" -print0 | xargs -0r rm -f
229 $(Q) - find . -type f -name "*.gcda" -print0 | xargs -0r rm -f
230 $(Q) - find . -type f -name "*.gcov" -print0 | xargs -0r rm -f
231 $(Q) - rm -f udev_gcov.txt
232 $(Q) - rm -f core $(PROGRAMS) $(GEN_HEADERS)
233 $(Q) - rm -f udev-$(VERSION).tar.gz
234 $(Q) - rm -f udev-$(VERSION).tar.bz2
235 @ extras="$(EXTRAS)"; for target in $$extras; do \
236 $(MAKE) -C $$target $@ || exit 1; \
237 done;
238 .PHONY: clean
239
240 release:
241 git-tar-tree HEAD udev-$(VERSION) | gzip -9v > udev-$(VERSION).tar.gz
242 git-tar-tree HEAD udev-$(VERSION) | bzip2 -9v > udev-$(VERSION).tar.bz2
243 .PHONY: release
244
245 install-config:
246 $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d
247 @ if [ ! -r $(DESTDIR)$(configdir)/udev.conf ]; then \
248 $(INSTALL_DATA) etc/udev/udev.conf $(DESTDIR)$(configdir); \
249 fi
250 @ if [ ! -r $(DESTDIR)$(configdir)/rules.d/50-udev.rules ]; then \
251 echo; \
252 echo "pick a udev rules file from the etc/udev directory that matches your distribution"; \
253 echo; \
254 fi
255 @ extras="$(EXTRAS)"; for target in $$extras; do \
256 $(MAKE) -C $$target $@ || exit 1; \
257 done;
258 .PHONY: install-config
259
260 install-man:
261 $(INSTALL_DATA) -D udev.7 $(DESTDIR)$(mandir)/man7/udev.7
262 $(INSTALL_DATA) -D udevinfo.8 $(DESTDIR)$(mandir)/man8/udevinfo.8
263 $(INSTALL_DATA) -D udevtest.8 $(DESTDIR)$(mandir)/man8/udevtest.8
264 $(INSTALL_DATA) -D udevd.8 $(DESTDIR)$(mandir)/man8/udevd.8
265 $(INSTALL_DATA) -D udevtrigger.8 $(DESTDIR)$(mandir)/man8/udevtrigger.8
266 $(INSTALL_DATA) -D udevsettle.8 $(DESTDIR)$(mandir)/man8/udevsettle.8
267 $(INSTALL_DATA) -D udevmonitor.8 $(DESTDIR)$(mandir)/man8/udevmonitor.8
268 - ln -f -s udevd.8 $(DESTDIR)$(mandir)/man8/udevcontrol.8
269 @extras="$(EXTRAS)"; for target in $$extras; do \
270 $(MAKE) -C $$target $@ || exit 1; \
271 done;
272 .PHONY: install-man
273
274 uninstall-man:
275 - rm -f $(DESTDIR)$(mandir)/man7/udev.7
276 - rm -f $(DESTDIR)$(mandir)/man8/udevinfo.8
277 - rm -f $(DESTDIR)$(mandir)/man8/udevtest.8
278 - rm -f $(DESTDIR)$(mandir)/man8/udevd.8
279 - rm -f $(DESTDIR)$(mandir)/man8/udevtrigger.8
280 - rm -f $(DESTDIR)$(mandir)/man8/udevsettle.8
281 - rm -f $(DESTDIR)$(mandir)/man8/udevmonitor.8
282 - rm -f $(DESTDIR)$(mandir)/man8/udevcontrol.8
283 @ extras="$(EXTRAS)"; for target in $$extras; do \
284 $(MAKE) -C $$target $@ || exit 1; \
285 done;
286 .PHONY: uninstall-man
287
288 install-bin:
289 $(INSTALL) -d $(DESTDIR)$(udevdir)
290 $(INSTALL_PROGRAM) -D udevd $(DESTDIR)$(sbindir)/udevd
291 $(INSTALL_PROGRAM) -D udevtrigger $(DESTDIR)$(sbindir)/udevtrigger
292 $(INSTALL_PROGRAM) -D udevsettle $(DESTDIR)$(sbindir)/udevsettle
293 $(INSTALL_PROGRAM) -D udevcontrol $(DESTDIR)$(sbindir)/udevcontrol
294 $(INSTALL_PROGRAM) -D udevmonitor $(DESTDIR)$(usrsbindir)/udevmonitor
295 $(INSTALL_PROGRAM) -D udevinfo $(DESTDIR)$(usrbindir)/udevinfo
296 $(INSTALL_PROGRAM) -D udevtest $(DESTDIR)$(usrbindir)/udevtest
297 @extras="$(EXTRAS)"; for target in $$extras; do \
298 $(MAKE) -C $$target $@ || exit 1; \
299 done;
300 ifndef DESTDIR
301 - killall udevd
302 - rm -rf /dev/.udev
303 - $(sbindir)/udevd --daemon
304 endif
305 .PHONY: install-bin
306
307 uninstall-bin:
308 - rm -f $(DESTDIR)$(sbindir)/udevd
309 - rm -f $(DESTDIR)$(sbindir)/udevtrigger
310 - rm -f $(DESTDIR)$(sbindir)/udevsettle
311 - rm -f $(DESTDIR)$(sbindir)/udevcontrol
312 - rm -f $(DESTDIR)$(usrsbindir)/udevmonitor
313 - rm -f $(DESTDIR)$(usrbindir)/udevinfo
314 - rm -f $(DESTDIR)$(usrbindir)/udevtest
315 ifndef DESTDIR
316 - killall udevd
317 - rm -rf /dev/.udev
318 endif
319 @extras="$(EXTRAS)"; for target in $$extras; do \
320 $(MAKE) -C $$target $@ || exit 1; \
321 done;
322 .PHONY: uninstall-bin
323
324 install: all install-bin install-config install-man
325 .PHONY: install
326
327 uninstall: uninstall-bin uninstall-man
328 .PHONY: uninstall
329
330 test tests: all
331 @ cd test && ./udev-test.pl
332 @ cd test && ./udevstart-test.pl
333 .PHONY: test tests
334
335 buildtest:
336 test/simple-build-check.sh
337 .PHONY: buildtest
338
339 ChangeLog: Makefile
340 @ mv $@ $@.tmp
341 @ echo "Summary of changes from v$(shell printf '%03i' $$(expr $(VERSION) - 1)) to v$(VERSION)" >> $@
342 @ echo "============================================" >> $@
343 @ echo >> $@
344 @ git log --pretty=short $(shell printf '%03i' $$(expr $(VERSION) - 1))..HEAD | git shortlog >> $@
345 @ echo >> $@
346 @ cat $@
347 @ cat $@.tmp >> $@
348 @ rm $@.tmp
349
350 gcov-all:
351 $(MAKE) clean all USE_GCOV=true
352 @ echo
353 @ echo "binaries built with gcov support."
354 @ echo "run the tests and analyze with 'make udev_gcov.txt'"
355 .PHONY: gcov-all
356
357 # see docs/README-gcov_for_udev
358 udev_gcov.txt: $(wildcard *.gcda) $(wildcard *.gcno)
359 for file in `find -maxdepth 1 -name "*.gcno"`; do \
360 name=`basename $$file .gcno`; \
361 echo "################" >> $@; \
362 echo "$$name.c" >> $@; \
363 echo "################" >> $@; \
364 if [ -e "$$name.gcda" ]; then \
365 gcov -l "$$name.c" >> $@ 2>&1; \
366 else \
367 echo "code for $$name.c was never executed" >> $@ 2>&1; \
368 fi; \
369 echo >> $@; \
370 done; \
371 echo "view $@ for the result"