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