2 # Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
3 # Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # set this to make use of syslog
24 # compile-in development debug messages
25 # (export UDEV_LOG="debug" or set udev_log="debug" in udev.conf
26 # to print the debug messages to syslog)
29 # compile with gcc's code coverage option
32 # include Security-Enhanced Linux support
35 # set this to create statically linked binaries
38 # to build any of the extras programs pass:
39 # make EXTRAS="extras/<extra1> extras/<extra2>"
42 # make the build silent
88 etcdir = ${prefix}/etc
89 sbindir = ${prefix}/sbin
90 usrbindir = ${prefix}/usr/bin
91 libudevdir = ${prefix}/lib/udev
92 mandir = ${prefix}/usr/share/man
93 configdir = ${etcdir}/udev
98 INSTALL_PROGRAM = ${INSTALL}
99 INSTALL_DATA = ${INSTALL} -m 644
100 INSTALL_SCRIPT = ${INSTALL}
104 CC = $(CROSS_COMPILE)gcc
105 LD = $(CROSS_COMPILE)gcc
106 AR = $(CROSS_COMPILE)ar
107 RANLIB = $(CROSS_COMPILE)ranlib
109 CFLAGS += -g -Wall -pipe -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
110 WARNINGS = -Wstrict-prototypes -Wsign-compare -Wshadow \
111 -Wchar-subscripts -Wmissing-declarations -Wnested-externs \
112 -Wpointer-arith -Wcast-align -Wsign-compare -Wmissing-prototypes
113 CFLAGS += $(WARNINGS)
115 LDFLAGS += -Wl,-warn-common,--as-needed
118 CFLAGS += $(OPTFLAGS)
120 ifeq ($(strip $(USE_LOG)),true)
124 # if DEBUG is enabled, then we do not strip
125 ifeq ($(strip $(DEBUG)),true)
129 ifeq ($(strip $(USE_GCOV)),true)
130 CFLAGS += -fprofile-arcs -ftest-coverage
131 LDFLAGS += -fprofile-arcs
134 ifeq ($(strip $(USE_SELINUX)),true)
135 UDEV_OBJS += udev_selinux.o
136 LIB_OBJS += -lselinux -lsepol
137 CFLAGS += -DUSE_SELINUX
140 ifeq ($(strip $(USE_STATIC)),true)
141 CFLAGS += -DUSE_STATIC
145 ifeq ($(strip $(V)),)
154 all: $(PROGRAMS) $(MAN_PAGES)
155 $(Q) extras="$(EXTRAS)"; for target in $$extras; do \
159 LDFLAGS="$(LDFLAGS)" \
162 LIB_OBJS="$(LIB_OBJS)" \
163 LIBUDEV="$(PWD)/$(LIBUDEV)" \
164 -C $$target $@ || exit 1; \
169 # clear implicit rules
173 %.o: %.c $(HEADERS) $(GEN_HEADERS)
175 $(Q) $(CC) -c $(CFLAGS) $< -o $@
177 # "Static Pattern Rule" to build all programs
178 $(PROGRAMS): %: $(HEADERS) $(GEN_HEADERS) $(LIBUDEV) %.o
180 $(Q) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIB_OBJS)
182 $(LIBUDEV): $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS)
185 $(Q) $(AR) cq $@ $(UDEV_OBJS)
191 $(Q) echo "/* Generated by make. */" > $@
192 $(Q) echo \#define UDEV_VERSION \"$(VERSION)\" >> $@
193 $(Q) echo \#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
203 $(Q) - find . -type f -name '*.orig' -print0 | xargs -0r rm -f
204 $(Q) - find . -type f -name '*.rej' -print0 | xargs -0r rm -f
205 $(Q) - find . -type f -name '*~' -print0 | xargs -0r rm -f
206 $(Q) - find . -type f -name '*.[oas]' -print0 | xargs -0r rm -f
207 $(Q) - find . -type f -name "*.gcno" -print0 | xargs -0r rm -f
208 $(Q) - find . -type f -name "*.gcda" -print0 | xargs -0r rm -f
209 $(Q) - find . -type f -name "*.gcov" -print0 | xargs -0r rm -f
210 $(Q) - rm -f udev_gcov.txt
211 $(Q) - rm -f core $(PROGRAMS) $(GEN_HEADERS)
212 $(Q) - rm -f udev-$(VERSION).tar.gz
213 $(Q) - rm -f udev-$(VERSION).tar.bz2
214 $(Q) - rm -f udev-git-HEAD.patch
215 @ extras="$(EXTRAS)"; for target in $$extras; do \
216 $(MAKE) -C $$target $@ || exit 1; \
221 $(INSTALL) -d $(DESTDIR)$(libudevdir)/rules.d
222 $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d
223 @ if [ ! -r $(DESTDIR)$(configdir)/udev.conf ]; then \
224 $(INSTALL_DATA) udev.conf $(DESTDIR)$(configdir); \
226 cp rules/rules.d/* $(DESTDIR)$(libudevdir)/rules.d
227 @ extras="$(EXTRAS)"; for target in $$extras; do \
228 $(MAKE) -C $$target $@ || exit 1; \
230 .PHONY: install-config
233 $(INSTALL) -d $(DESTDIR)$(mandir)/man7
234 $(INSTALL_DATA) udev.7 $(DESTDIR)$(mandir)/man7/udev.7
235 $(INSTALL) -d $(DESTDIR)$(mandir)/man8
236 $(INSTALL_DATA) udevd.8 $(DESTDIR)$(mandir)/man8/udevd.8
237 $(INSTALL_DATA) udevadm.8 $(DESTDIR)$(mandir)/man8/udevadm.8
238 @extras="$(EXTRAS)"; for target in $$extras; do \
239 $(MAKE) -C $$target $@ || exit 1; \
244 - rm -f $(DESTDIR)$(mandir)/man7/udev.7
245 - rm -f $(DESTDIR)$(mandir)/man8/udevadm.8
246 - rm -f $(DESTDIR)$(mandir)/man8/udevd.8
247 @ extras="$(EXTRAS)"; for target in $$extras; do \
248 $(MAKE) -C $$target $@ || exit 1; \
250 .PHONY: uninstall-man
253 $(INSTALL) -d $(DESTDIR)$(sbindir)
254 $(INSTALL_PROGRAM) udevd $(DESTDIR)$(sbindir)/udevd
255 $(INSTALL_PROGRAM) udevadm $(DESTDIR)$(sbindir)/udevadm
256 ln -f -s udevadm $(DESTDIR)$(sbindir)/udevsettle
257 $(INSTALL) -d $(DESTDIR)$(usrbindir)
258 ln -f -s $(sbindir)/udevadm $(DESTDIR)$(usrbindir)/udevinfo
259 @extras="$(EXTRAS)"; for target in $$extras; do \
260 $(MAKE) -C $$target $@ || exit 1; \
264 - rm -rf $(udevdir)/.udev
265 - $(sbindir)/udevd --daemon
270 - rm -f $(DESTDIR)$(sbindir)/udevd
271 - rm -f $(DESTDIR)$(sbindir)/udevadm
272 - rm -f $(DESTDIR)$(sbindir)/udevsettle
273 - rm -f $(DESTDIR)$(usrbindir)/udevinfo
276 - rm -rf $(udevdir)/.udev
278 @extras="$(EXTRAS)"; for target in $$extras; do \
279 $(MAKE) -C $$target $@ || exit 1; \
281 .PHONY: uninstall-bin
283 install: all install-bin install-config install-man
286 uninstall: uninstall-bin uninstall-man
290 @ cd test && ./udev-test.pl
294 test/simple-build-check.sh
298 head -1 $@ | grep -q "to v$(shell echo $$(($(VERSION) - 1)))"
300 @ echo "Summary of changes from v$(shell echo $$(($(VERSION) - 1))) to v$(VERSION)" >> $@
301 @ echo "============================================" >> $@
303 @ git log --pretty=short $(shell echo $$(($(VERSION) - 1)))..HEAD | git shortlog >> $@
308 head -1 $@ | grep -q "to v$(VERSION)"
313 $(Q) - rm -f udev-$(VERSION).tar.gz
314 $(Q) - rm -f udev-$(VERSION).tar.bz2
315 head -1 ChangeLog | grep -q "to v$(VERSION)"
316 head -1 RELEASE-NOTES | grep -q "udev $(VERSION)"
317 git commit -a -m "release $(VERSION)"
318 cat .git/refs/heads/master > .git/refs/tags/$(VERSION)
320 git-archive --format=tar --prefix=udev-$(VERSION)/ HEAD | gzip -9v > udev-$(VERSION).tar.gz
321 git-archive --format=tar --prefix=udev-$(VERSION)/ HEAD | bzip2 -9v > udev-$(VERSION).tar.bz2
325 git-archive --format=tar --prefix=udev-$(VERSION)/ HEAD | gzip -9v > udev-$(VERSION).tar.gz
326 git-archive --format=tar --prefix=udev-$(VERSION)/ HEAD | bzip2 -9v > udev-$(VERSION).tar.bz2
330 git diff $(shell echo $$(($(VERSION) - 1))) HEAD > udev-git-HEAD.patch
334 $(MAKE) clean all USE_GCOV=true
336 @ echo "binaries built with gcov support."
337 @ echo "run the tests and analyze with 'make udev_gcov.txt'"
340 # see docs/README-gcov_for_udev
341 udev_gcov.txt: $(wildcard *.gcda) $(wildcard *.gcno)
342 for file in `find -maxdepth 1 -name "*.gcno"`; do \
343 name=`basename $$file .gcno`; \
344 echo "################" >> $@; \
345 echo "$$name.c" >> $@; \
346 echo "################" >> $@; \
347 if [ -e "$$name.gcda" ]; then \
348 gcov -l "$$name.c" >> $@ 2>&1; \
350 echo "code for $$name.c was never executed" >> $@ 2>&1; \
354 echo "view $@ for the result"