3 # Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
4 # Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
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.
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.
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
22 # set this to make use of syslog
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)
30 # compile with gcc's code coverage option
33 # include Security-Enhanced Linux support
36 # comile with klibc instead of glibc
39 # set this to create statically linked binaries
42 # to build any of the extras programs pass:
43 # make EXTRAS="extras/<extra1> extras/<extra2>"
46 # make the build silent. Set this to something else to make it noisy again.
94 libsysfs/sysfs_class.o \
95 libsysfs/sysfs_device.o \
96 libsysfs/sysfs_dir.o \
97 libsysfs/sysfs_driver.o \
98 libsysfs/sysfs_utils.o \
100 LIBSYSFS = libsysfs/libsysfs.a
102 # config files automatically generated
104 $(LOCAL_CFG_DIR)/udev.conf
110 etcdir = ${prefix}/etc
111 sbindir = ${prefix}/sbin
112 usrbindir = ${prefix}/usr/bin
113 usrsbindir = ${prefix}/usr/sbin
114 libudevdir = ${prefix}/lib/udev
115 mandir = ${prefix}/usr/share/man
116 configdir = ${etcdir}/udev
118 LOCAL_CFG_DIR = etc/udev
121 INSTALL = /usr/bin/install -c
122 INSTALL_PROGRAM = ${INSTALL}
123 INSTALL_DATA = ${INSTALL} -m 644
124 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
131 RANLIB = $(CROSS)ranlib
133 STRIP = $(CROSS)strip
134 STRIPCMD = $(STRIP) -s
136 CFLAGS = -g -Wall -pipe -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
137 WARNINGS = -Wstrict-prototypes -Wsign-compare -Wshadow \
138 -Wchar-subscripts -Wmissing-declarations -Wnested-externs \
139 -Wpointer-arith -Wcast-align -Wsign-compare -Wmissing-prototypes
140 CFLAGS += $(WARNINGS)
142 LDFLAGS = -Wl,-warn-common
145 CFLAGS += $(OPTFLAGS)
147 # include our local copy of libsysfs
148 CFLAGS += -I$(PWD)/libsysfs/sysfs \
151 ifeq ($(strip $(USE_LOG)),true)
155 # if DEBUG is enabled, then we do not strip
156 ifeq ($(strip $(DEBUG)),true)
161 ifeq ($(strip $(USE_GCOV)),true)
162 CFLAGS += -fprofile-arcs -ftest-coverage
163 LDFLAGS += -fprofile-arcs
166 # if our own version of klibc is used, we need to build it
167 ifeq ($(strip $(USE_KLIBC)),true)
168 KLCC = /usr/bin/$(CROSS)klcc
174 ifeq ($(strip $(USE_SELINUX)),true)
175 UDEV_OBJS += udev_selinux.o
176 LIB_OBJS += -lselinux -lsepol
177 CFLAGS += -DUSE_SELINUX
180 ifeq ($(strip $(USE_STATIC)),true)
181 CFLAGS += -DUSE_STATIC
185 ifeq ($(strip $(V)),false)
193 all: $(PROGRAMS) $(MAN_PAGES)
194 @extras="$(EXTRAS)"; for target in $$extras; do \
199 LDFLAGS="$(LDFLAGS)" \
200 STRIPCMD="$(STRIPCMD)" \
201 LIB_OBJS="$(LIB_OBJS)" \
202 LIBUDEV="$(PWD)/$(LIBUDEV)" \
203 LIBSYSFS="$(PWD)/$(LIBSYSFS)" \
205 -C $$target $@ || exit 1; \
210 # clear implicit rules
214 %.o: %.c $(HOST_PROGS) $(GEN_HEADERS)
215 $(QUIET) $(CC) -c $(CFLAGS) $< -o $@
217 # "Static Pattern Rule" to build all programs
218 $(PROGRAMS): %: $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS) $(LIBSYSFS) $(LIBUDEV) %.o
219 $(QUIET) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIBSYSFS) $(LIB_OBJS)
221 $(QUIET) $(STRIPCMD) $@
225 $(LIBUDEV): $(HOST_PROGS) $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS)
227 $(QUIET) $(AR) cq $@ $(UDEV_OBJS)
228 $(QUIET) $(RANLIB) $@
231 $(LIBSYSFS): $(HOST_PROGS) $(SYSFS_OBJS)
233 $(QUIET) $(AR) cq $@ $(SYSFS_OBJS)
234 $(QUIET) $(RANLIB) $@
236 # generate config files
238 sed -e "s:@udevdir@:$(udevdir):" -e "s:@configdir@:$(configdir):" < $@.in > $@
240 # generate config header file
242 @echo "Creating udev_version.h"
243 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
244 @echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
245 @echo \#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
246 @echo \#define UDEV_RULES_FILE \"$(configdir)/rules.d\" >> $@
254 @$(HOSTCC) -O1 ccdv.c -o ccdv
258 - rm -f $(HOST_PROGS)
259 - find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print0 | xargs -0rt rm -f
260 - find -name "*.gcno" -print0 | xargs -0rt rm -f
261 - find -name "*.gcda" -print0 | xargs -0rt rm -f
262 - find -name "*.gcov" -print0 | xargs -0rt rm -f
263 - rm -f udev_gcov.txt
264 - rm -f core $(PROGRAMS) $(GEN_HEADERS) $(GEN_CONFIGS)
265 - rm -f udev-$(VERSION).tar.gz
266 @extras="$(EXTRAS)"; for target in $$extras; do \
268 $(MAKE) -C $$target $@ || exit 1; \
273 git-tar-tree HEAD udev-$(VERSION) | gzip -9v > udev-$(VERSION).tar.gz
274 @echo "udev-$(VERSION).tar.gz created"
277 install-config: $(GEN_CONFIGS)
278 $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d
279 @if [ ! -r $(DESTDIR)$(configdir)/udev.conf ]; then \
280 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
281 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
283 @if [ ! -r $(DESTDIR)$(configdir)/rules.d/50-udev.rules ]; then \
285 echo "pick a udev rules file from the etc/udev directory that matches your distribution"; \
288 @extras="$(EXTRAS)"; for target in $$extras; do \
290 $(MAKE) -C $$target $@ || exit 1; \
292 .PHONY: install-config
295 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
296 $(INSTALL_DATA) -D udevinfo.8 $(DESTDIR)$(mandir)/man8/udevinfo.8
297 $(INSTALL_DATA) -D udevtest.8 $(DESTDIR)$(mandir)/man8/udevtest.8
298 $(INSTALL_DATA) -D udevstart.8 $(DESTDIR)$(mandir)/man8/udevstart.8
299 $(INSTALL_DATA) -D udevd.8 $(DESTDIR)$(mandir)/man8/udevd.8
300 $(INSTALL_DATA) -D udevsend.8 $(DESTDIR)$(mandir)/man8/udevsend.8
301 $(INSTALL_DATA) -D udevmonitor.8 $(DESTDIR)$(mandir)/man8/udevmonitor.8
302 - ln -f -s udevd.8 $(DESTDIR)$(mandir)/man8/udevcontrol.8
303 @extras="$(EXTRAS)"; for target in $$extras; do \
305 $(MAKE) -C $$target $@ || exit 1; \
310 - rm -f $(DESTDIR)$(mandir)/man8/udev.8
311 - rm -f $(DESTDIR)$(mandir)/man8/udevinfo.8
312 - rm -f $(DESTDIR)$(mandir)/man8/udevtest.8
313 - rm -f $(DESTDIR)$(mandir)/man8/udevstart.8
314 - rm -f $(DESTDIR)$(mandir)/man8/udevd.8
315 - rm -f $(DESTDIR)$(mandir)/man8/udevmonitor.8
316 - rm -f $(DESTDIR)$(mandir)/man8/udevsend.8
317 - rm -f $(DESTDIR)$(mandir)/man8/udevcontrol.8
318 @extras="$(EXTRAS)"; for target in $$extras; do \
320 $(MAKE) -C $$target $@ || exit 1; \
322 .PHONY: uninstall-man
325 $(INSTALL) -d $(DESTDIR)$(udevdir)
326 $(INSTALL_PROGRAM) -D udev $(DESTDIR)$(sbindir)/udev
327 $(INSTALL_PROGRAM) -D udevd $(DESTDIR)$(sbindir)/udevd
328 $(INSTALL_PROGRAM) -D udevsend $(DESTDIR)$(sbindir)/udevsend
329 $(INSTALL_PROGRAM) -D udevcontrol $(DESTDIR)$(sbindir)/udevcontrol
330 $(INSTALL_PROGRAM) -D udevmonitor $(DESTDIR)$(usrsbindir)/udevmonitor
331 $(INSTALL_PROGRAM) -D udevinfo $(DESTDIR)$(usrbindir)/udevinfo
332 $(INSTALL_PROGRAM) -D udevtest $(DESTDIR)$(usrbindir)/udevtest
333 $(INSTALL_PROGRAM) -D udevstart $(DESTDIR)$(sbindir)/udevstart
334 @extras="$(EXTRAS)"; for target in $$extras; do \
336 $(MAKE) -C $$target $@ || exit 1; \
341 - $(sbindir)/udevd --daemon
346 - rm -f $(DESTDIR)$(sbindir)/udev
347 - rm -f $(DESTDIR)$(sbindir)/udevd
348 - rm -f $(DESTDIR)$(sbindir)/udevsend
349 - rm -f $(DESTDIR)$(sbindir)/udevcontrol
350 - rm -f $(DESTDIR)$(sbindir)/udevstart
351 - rm -f $(DESTDIR)$(usrsbindir)/udevmonitor
352 - rm -f $(usrbindir)/udevinfo
353 - rm -f $(DESTDIR)$(DESTDIR)$(usrbindir)/udevtest
358 @extras="$(EXTRAS)"; for target in $$extras; do \
360 $(MAKE) -C $$target $@ || exit 1; \
362 .PHONY: uninstall-bin
364 install: all install-bin install-config install-man
367 uninstall: uninstall-bin uninstall-man
371 @ cd test && ./udev-test.pl
372 @ cd test && ./udevstart-test.pl
376 test/simple-build-check.sh
381 @ echo "Summary of changes from v$(shell printf '%03i' $$(expr $(VERSION) - 1)) to v$(VERSION)" >> $@
382 @ echo "============================================" >> $@
384 @ git log --pretty=short $(shell printf '%03i' $$(expr $(VERSION) - 1))..HEAD | git shortlog >> $@
391 $(MAKE) clean all STRIPCMD= USE_GCOV=true
393 @echo "binaries built with gcov support."
394 @echo "run the tests and analyze with 'make udev_gcov.txt'"
397 # see docs/README-gcov_for_udev
398 udev_gcov.txt: $(wildcard *.gcda) $(wildcard *.gcno)
399 for file in `find -maxdepth 1 -name "*.gcno"`; do \
400 name=`basename $$file .gcno`; \
401 echo "################" >> $@; \
402 echo "$$name.c" >> $@; \
403 echo "################" >> $@; \
404 if [ -e "$$name.gcda" ]; then \
405 gcov -l "$$name.c" >> $@ 2>&1; \
407 echo "code for $$name.c was never executed" >> $@ 2>&1; \
411 echo "view $@ for the result"