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
-Wsign-compare
-Wmissing-prototypes
120 CFLAGS
+= $(WARNINGS
) $(EXTRACFLAGS
)
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
)),)
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 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)/rules.d
230 @ if
[ ! -r
$(DESTDIR
)$(configdir
)/udev.conf
]; then \
231 $(INSTALL_DATA
) etc
/udev
/udev.conf
$(DESTDIR
)$(configdir
); \
233 @ if
[ ! -r
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
]; then \
235 echo
"pick a udev rules file from the etc/udev directory that matches your distribution"; \
238 @ extras
="$(EXTRAS)"; for target in
$$extras; do \
239 $(MAKE
) -C
$$target $@ || exit
1; \
241 .PHONY
: install-config
244 $(INSTALL_DATA
) -D udev
.7 $(DESTDIR
)$(mandir)/man7
/udev
.7
245 $(INSTALL_DATA
) -D udevinfo
.8 $(DESTDIR
)$(mandir)/man8
/udevinfo
.8
246 $(INSTALL_DATA
) -D udevtest
.8 $(DESTDIR
)$(mandir)/man8
/udevtest
.8
247 $(INSTALL_DATA
) -D udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevd
.8
248 $(INSTALL_DATA
) -D udevtrigger
.8 $(DESTDIR
)$(mandir)/man8
/udevtrigger
.8
249 $(INSTALL_DATA
) -D udevsettle
.8 $(DESTDIR
)$(mandir)/man8
/udevsettle
.8
250 $(INSTALL_DATA
) -D udevmonitor
.8 $(DESTDIR
)$(mandir)/man8
/udevmonitor
.8
251 - ln
-f
-s udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevcontrol
.8
252 @extras
="$(EXTRAS)"; for target in
$$extras; do \
253 $(MAKE
) -C
$$target $@ || exit
1; \
258 - rm -f
$(DESTDIR
)$(mandir)/man7
/udev
.7
259 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevinfo
.8
260 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevtest
.8
261 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevd
.8
262 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevtrigger
.8
263 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevsettle
.8
264 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevmonitor
.8
265 - rm -f
$(DESTDIR
)$(mandir)/man8
/udevcontrol
.8
266 @ extras
="$(EXTRAS)"; for target in
$$extras; do \
267 $(MAKE
) -C
$$target $@ || exit
1; \
269 .PHONY
: uninstall-man
272 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
273 $(INSTALL_PROGRAM
) -D udevtrigger
$(DESTDIR
)$(sbindir
)/udevtrigger
274 $(STRIP
) $(DESTDIR
)$(sbindir
)/udevtrigger
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
315 uninstall: uninstall-bin uninstall-man
319 @ cd
test && .
/udev-test.pl
320 @ cd
test && .
/udevstart-test.pl
324 test/simple-build-check.sh
328 head
-1 $@ | grep
-q
"to v$(shell echo $$(($(VERSION) - 1)))"
330 @ echo
"Summary of changes from v$(shell echo $$(($(VERSION) - 1))) to v$(VERSION)" >> $@
331 @ echo
"============================================" >> $@
333 @ git log
--pretty
=short
$(shell echo
$$(($(VERSION
) - 1)))..HEAD | git shortlog
>> $@
338 head
-1 $@ | grep
-q
"to v$(VERSION)"
343 $(Q
) - rm -f udev-
$(VERSION
).
tar.gz
344 $(Q
) - rm -f udev-
$(VERSION
).
tar.bz2
345 head
-1 ChangeLog | grep
-q
"to v$(VERSION)"
346 head
-1 RELEASE-NOTES | grep
-q
"udev $(VERSION)"
347 git commit
-a
-m
"release $(VERSION)"
348 cat .git
/refs
/heads
/master
> .git
/refs
/tags/$(VERSION
)
350 git-archive
--format
=tar --prefix=udev-
$(VERSION
)/ HEAD | gzip
-9v
> udev-
$(VERSION
).
tar.gz
351 git-archive
--format
=tar --prefix=udev-
$(VERSION
)/ HEAD | bzip2
-9v
> udev-
$(VERSION
).
tar.bz2
355 $(MAKE
) clean all USE_GCOV
=true
357 @ echo
"binaries built with gcov support."
358 @ echo
"run the tests and analyze with 'make udev_gcov.txt'"
361 # see docs/README-gcov_for_udev
362 udev_gcov.txt
: $(wildcard *.gcda
) $(wildcard *.gcno
)
363 for file in
`find -maxdepth 1 -name "*.gcno"`; do \
364 name
=`basename $$file .gcno`; \
365 echo
"################" >> $@
; \
366 echo
"$$name.c" >> $@
; \
367 echo
"################" >> $@
; \
368 if
[ -e
"$$name.gcda" ]; then \
369 gcov
-l
"$$name.c" >> $@
2>&1; \
371 echo
"code for $$name.c was never executed" >> $@
2>&1; \
375 echo
"view $@ for the result"