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
94 etcdir
= ${prefix}/etc
95 sbindir
= ${prefix}/sbin
96 usrbindir
= ${prefix}/usr
/bin
97 usrsbindir
= ${prefix}/usr
/sbin
98 libudevdir
= ${prefix}/lib
/udev
99 mandir = ${prefix}/usr
/share
/man
100 configdir
= ${etcdir}/udev
105 INSTALL_PROGRAM
= ${INSTALL}
106 INSTALL_DATA
= ${INSTALL} -m
644
107 INSTALL_SCRIPT
= ${INSTALL}
111 CC
= $(CROSS_COMPILE
)gcc
112 LD
= $(CROSS_COMPILE
)gcc
113 AR
= $(CROSS_COMPILE
)ar
114 RANLIB
= $(CROSS_COMPILE
)ranlib
116 CFLAGS
+= -g
-Wall
-pipe
-D_GNU_SOURCE
-D_FILE_OFFSET_BITS
=64
117 WARNINGS
= -Wstrict-prototypes
-Wsign-compare
-Wshadow \
118 -Wchar-subscripts
-Wmissing-declarations
-Wnested-externs \
119 -Wpointer-arith
-Wcast-align
-Wsign-compare
-Wmissing-prototypes
120 CFLAGS
+= $(WARNINGS
)
122 LDFLAGS
+= -Wl
,-warn-common
125 CFLAGS
+= $(OPTFLAGS
)
127 ifeq ($(strip $(USE_LOG
)),true
)
131 # if DEBUG is enabled, then we do not strip
132 ifeq ($(strip $(DEBUG
)),true
)
136 ifeq ($(strip $(USE_GCOV
)),true
)
137 CFLAGS
+= -fprofile-arcs
-ftest-coverage
138 LDFLAGS
+= -fprofile-arcs
141 ifeq ($(strip $(USE_SELINUX
)),true
)
142 UDEV_OBJS
+= udev_selinux.o
143 LIB_OBJS
+= -lselinux
-lsepol
144 CFLAGS
+= -DUSE_SELINUX
147 ifeq ($(strip $(USE_STATIC
)),true
)
148 CFLAGS
+= -DUSE_STATIC
152 ifeq ($(strip $(V
)),)
161 all: $(PROGRAMS
) $(MAN_PAGES
)
162 $(Q
) extras
="$(EXTRAS)"; for target in
$$extras; do \
166 LDFLAGS
="$(LDFLAGS)" \
169 LIB_OBJS
="$(LIB_OBJS)" \
170 LIBUDEV
="$(PWD)/$(LIBUDEV)" \
171 -C
$$target $@ || exit
1; \
176 # clear implicit rules
180 %.o
: %.c
$(HEADERS
) $(GEN_HEADERS
)
182 $(Q
) $(CC
) -c
$(CFLAGS
) $< -o
$@
184 # "Static Pattern Rule" to build all programs
185 $(PROGRAMS
): %: $(HEADERS
) $(GEN_HEADERS
) $(LIBUDEV
) %.o
187 $(Q
) $(LD
) $(LDFLAGS
) $@.o
-o
$@
$(LIBUDEV
) $(LIB_OBJS
)
189 $(LIBUDEV
): $(HEADERS
) $(GEN_HEADERS
) $(UDEV_OBJS
)
192 $(Q
) $(AR
) cq
$@
$(UDEV_OBJS
)
198 $(Q
) echo
"/* Generated by make. */" > $@
199 $(Q
) echo \
#define UDEV_VERSION \"$(VERSION)\" >> $@
200 $(Q
) echo \
#define UDEV_ROOT \"$(udevdir)\" >> $@
201 $(Q
) echo \
#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
202 $(Q
) echo \
#define UDEV_RULES_DIR \"$(configdir)/rules.d\" >> $@
212 $(Q
) - find .
-type f
-name
'*.orig' -print0 | xargs
-0r
rm -f
213 $(Q
) - find .
-type f
-name
'*.rej' -print0 | xargs
-0r
rm -f
214 $(Q
) - find .
-type f
-name
'*~' -print0 | xargs
-0r
rm -f
215 $(Q
) - find .
-type f
-name
'*.[oas]' -print0 | xargs
-0r
rm -f
216 $(Q
) - find .
-type f
-name
"*.gcno" -print0 | xargs
-0r
rm -f
217 $(Q
) - find .
-type f
-name
"*.gcda" -print0 | xargs
-0r
rm -f
218 $(Q
) - find .
-type f
-name
"*.gcov" -print0 | xargs
-0r
rm -f
219 $(Q
) - rm -f udev_gcov.txt
220 $(Q
) - rm -f core
$(PROGRAMS
) $(GEN_HEADERS
)
221 $(Q
) - rm -f udev-
$(VERSION
).
tar.gz
222 $(Q
) - rm -f udev-
$(VERSION
).
tar.bz2
223 @ extras
="$(EXTRAS)"; for target in
$$extras; do \
224 $(MAKE
) -C
$$target $@ || exit
1; \
229 git-archive
--format
=tar --prefix=udev-
$(VERSION
)/ HEAD | gzip
-9v
> udev-
$(VERSION
).
tar.gz
230 git-archive
--format
=tar --prefix=udev-
$(VERSION
)/ HEAD | bzip2
-9v
> udev-
$(VERSION
).
tar.bz2
234 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)/rules.d
235 @ if
[ ! -r
$(DESTDIR
)$(configdir
)/udev.conf
]; then \
236 $(INSTALL_DATA
) etc
/udev
/udev.conf
$(DESTDIR
)$(configdir
); \
238 @ if
[ ! -r
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
]; then \
240 echo
"pick a udev rules file from the etc/udev directory that matches your distribution"; \
243 @ extras
="$(EXTRAS)"; for target in
$$extras; do \
244 $(MAKE
) -C
$$target $@ || exit
1; \
246 .PHONY
: install-config
249 $(INSTALL_DATA
) -D udev
.7 $(DESTDIR
)$(mandir)/man7
/udev
.7
250 $(INSTALL_DATA
) -D udevinfo
.8 $(DESTDIR
)$(mandir)/man8
/udevinfo
.8
251 $(INSTALL_DATA
) -D udevtest
.8 $(DESTDIR
)$(mandir)/man8
/udevtest
.8
252 $(INSTALL_DATA
) -D udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevd
.8
253 $(INSTALL_DATA
) -D udevtrigger
.8 $(DESTDIR
)$(mandir)/man8
/udevtrigger
.8
254 $(INSTALL_DATA
) -D udevsettle
.8 $(DESTDIR
)$(mandir)/man8
/udevsettle
.8
255 $(INSTALL_DATA
) -D udevmonitor
.8 $(DESTDIR
)$(mandir)/man8
/udevmonitor
.8
256 - ln
-f
-s udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevcontrol
.8
257 @extras
="$(EXTRAS)"; for target in
$$extras; do \
258 $(MAKE
) -C
$$target $@ || exit
1; \
263 - rm -f
$(DESTDIR
)$(mandir)/man7
/udev
.7
264 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevinfo
.8
265 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevtest
.8
266 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevd
.8
267 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevtrigger
.8
268 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevsettle
.8
269 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevmonitor
.8
270 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevcontrol
.8
271 @ extras
="$(EXTRAS)"; for target in
$$extras; do \
272 $(MAKE
) -C
$$target $@ || exit
1; \
274 .PHONY
: uninstall-man
277 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
278 $(INSTALL_PROGRAM
) -D udevd
$(DESTDIR
)$(sbindir
)/udevd
279 $(INSTALL_PROGRAM
) -D udevtrigger
$(DESTDIR
)$(sbindir
)/udevtrigger
280 $(INSTALL_PROGRAM
) -D udevsettle
$(DESTDIR
)$(sbindir
)/udevsettle
281 $(INSTALL_PROGRAM
) -D udevcontrol
$(DESTDIR
)$(sbindir
)/udevcontrol
282 $(INSTALL_PROGRAM
) -D udevmonitor
$(DESTDIR
)$(usrsbindir
)/udevmonitor
283 $(INSTALL_PROGRAM
) -D udevinfo
$(DESTDIR
)$(usrbindir
)/udevinfo
284 $(INSTALL_PROGRAM
) -D udevtest
$(DESTDIR
)$(usrbindir
)/udevtest
285 @extras
="$(EXTRAS)"; for target in
$$extras; do \
286 $(MAKE
) -C
$$target $@ || exit
1; \
291 - $(sbindir
)/udevd
--daemon
296 - rm -f
$(DESTDIR
)$(sbindir
)/udevd
297 - rm -f
$(DESTDIR
)$(sbindir
)/udevtrigger
298 - rm -f
$(DESTDIR
)$(sbindir
)/udevsettle
299 - rm -f
$(DESTDIR
)$(sbindir
)/udevcontrol
300 - rm -f
$(DESTDIR
)$(usrsbindir
)/udevmonitor
301 - rm -f
$(DESTDIR
)$(usrbindir
)/udevinfo
302 - rm -f
$(DESTDIR
)$(usrbindir
)/udevtest
307 @extras
="$(EXTRAS)"; for target in
$$extras; do \
308 $(MAKE
) -C
$$target $@ || exit
1; \
310 .PHONY
: uninstall-bin
312 install: all install-bin install-config install-man
315 uninstall: uninstall-bin uninstall-man
319 @ cd
test && .
/udev-test.pl
320 @ cd
test && .
/udevstart-test.pl
324 test/simple-build-check.sh
329 @ echo
"Summary of changes from v$(shell echo $$(($(VERSION) - 1))) to v$(VERSION)" >> $@
330 @ echo
"============================================" >> $@
332 @ git log
--pretty
=short
$(shell echo
$$(($(VERSION
) - 1)))..HEAD | git shortlog
>> $@
339 $(MAKE
) clean all USE_GCOV
=true
341 @ echo
"binaries built with gcov support."
342 @ echo
"run the tests and analyze with 'make udev_gcov.txt'"
345 # see docs/README-gcov_for_udev
346 udev_gcov.txt
: $(wildcard *.gcda
) $(wildcard *.gcno
)
347 for file in
`find -maxdepth 1 -name "*.gcno"`; do \
348 name
=`basename $$file .gcno`; \
349 echo
"################" >> $@
; \
350 echo
"$$name.c" >> $@
; \
351 echo
"################" >> $@
; \
352 if
[ -e
"$$name.gcda" ]; then \
353 gcov
-l
"$$name.c" >> $@
2>&1; \
355 echo
"code for $$name.c was never executed" >> $@
2>&1; \
359 echo
"view $@ for the result"