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