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