Allow IPv6 address entry in tools>ping - Loosens valid character check
[tomato/davidwu.git] / release / src / router / udev / Makefile
blobb1e360465106bb05d1f0c444899aa7c5d0f0460c
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.
19 VERSION = 113
21 # set this to make use of syslog
22 USE_LOG = true
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)
27 DEBUG = false
29 # compile with gcc's code coverage option
30 USE_GCOV = false
32 # include Security-Enhanced Linux support
33 USE_SELINUX = false
35 # set this to create statically linked binaries
36 USE_STATIC = false
38 # to build any of the extras programs pass:
39 # make EXTRAS="extras/<extra1> extras/<extra2>"
40 EXTRAS =
42 # make the build silent
43 V =
45 PROGRAMS = \
46 udevd \
47 udevtrigger \
48 udevsettle \
49 udevcontrol \
50 udevmonitor \
51 udevinfo \
52 udevtest \
53 test-udev \
54 udevstart
56 HEADERS = \
57 udev.h \
58 udevd.h \
59 udev_rules.h \
60 logging.h \
61 udev_sysdeps.h \
62 udev_selinux.h \
63 list.h
65 UDEV_OBJS = \
66 udev_device.o \
67 udev_config.o \
68 udev_node.o \
69 udev_db.o \
70 udev_sysfs.o \
71 udev_rules.o \
72 udev_rules_parse.o \
73 udev_utils.o \
74 udev_utils_string.o \
75 udev_utils_file.o \
76 udev_utils_run.o \
77 udev_sysdeps.o
78 LIBUDEV = libudev.a
80 MAN_PAGES = \
81 udev.7 \
82 udevmonitor.8 \
83 udevd.8 \
84 udevtrigger.8 \
85 udevsettle.8 \
86 udevtest.8 \
87 udevinfo.8 \
88 udevstart.8
90 GEN_HEADERS = \
91 udev_version.h
93 prefix ?=
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
101 udevdir = /dev
102 DESTDIR =
104 INSTALL = install
105 INSTALL_PROGRAM = ${INSTALL}
106 INSTALL_DATA = ${INSTALL} -m 644
107 INSTALL_SCRIPT = ${INSTALL}
108 PWD = $(shell pwd)
110 CROSS_COMPILE ?=
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
124 OPTFLAGS = -Os
125 CFLAGS += $(OPTFLAGS)
127 ifeq ($(strip $(USE_LOG)),true)
128 CFLAGS += -DUSE_LOG
129 endif
131 # if DEBUG is enabled, then we do not strip
132 ifeq ($(strip $(DEBUG)),true)
133 CFLAGS += -DDEBUG
134 endif
136 ifeq ($(strip $(USE_GCOV)),true)
137 CFLAGS += -fprofile-arcs -ftest-coverage
138 LDFLAGS += -fprofile-arcs
139 endif
141 ifeq ($(strip $(USE_SELINUX)),true)
142 UDEV_OBJS += udev_selinux.o
143 LIB_OBJS += -lselinux -lsepol
144 CFLAGS += -DUSE_SELINUX
145 endif
147 ifeq ($(strip $(USE_STATIC)),true)
148 CFLAGS += -DUSE_STATIC
149 LDFLAGS += -static
150 endif
152 ifeq ($(strip $(V)),)
153 E = @echo
154 Q = @
155 else
156 E = @\#
158 endif
159 export E Q
161 all: $(PROGRAMS)
162 $(Q) extras="$(EXTRAS)"; for target in $$extras; do \
163 $(MAKE) CC="$(CC)" \
164 CFLAGS="$(CFLAGS)" \
165 LD="$(LD)" \
166 LDFLAGS="$(LDFLAGS)" \
167 AR="$(AR)" \
168 RANLIB="$(RANLIB)" \
169 LIB_OBJS="$(LIB_OBJS)" \
170 LIBUDEV="$(PWD)/$(LIBUDEV)" \
171 -C $$target $@ || exit 1; \
172 done;
173 .PHONY: all
174 .DEFAULT: all
176 # clear implicit rules
177 .SUFFIXES:
179 # build the objects
180 %.o: %.c $(HEADERS) $(GEN_HEADERS)
181 $(E) " CC " $@
182 $(Q) $(CC) -c $(CFLAGS) $< -o $@
184 # "Static Pattern Rule" to build all programs
185 $(PROGRAMS): %: $(HEADERS) $(GEN_HEADERS) $(LIBUDEV) %.o
186 $(E) " LD " $@
187 $(Q) $(LD) $(LDFLAGS) $@.o -o $@ $(LIBUDEV) $(LIB_OBJS)
189 $(LIBUDEV): $(HEADERS) $(GEN_HEADERS) $(UDEV_OBJS)
190 $(Q) rm -f $@
191 $(E) " AR " $@
192 $(Q) $(AR) cq $@ $(UDEV_OBJS)
193 $(E) " RANLIB " $@
194 $(Q) $(RANLIB) $@
196 udev_version.h:
197 $(E) " GENHDR " $@
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\" >> $@
204 # man pages
205 %.8 %.7: %.xml
206 $(E) " XMLTO " $@
207 $(Q) xmlto man $?
208 .PRECIOUS: %.8
210 clean:
211 $(E) " CLEAN "
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; \
225 done;
226 .PHONY: clean
228 install-config:
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 \
234 echo; \
235 echo "pick a udev rules file from the etc/udev directory that matches your distribution"; \
236 echo; \
238 @ extras="$(EXTRAS)"; for target in $$extras; do \
239 $(MAKE) -C $$target $@ || exit 1; \
240 done;
241 .PHONY: install-config
243 install-man:
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; \
254 done;
255 .PHONY: install-man
257 uninstall-man:
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; \
268 done;
269 .PHONY: uninstall-man
271 install-udevtrigger:
272 $(INSTALL) -d $(DESTDIR)$(udevdir)
273 $(INSTALL_PROGRAM) -D udevtrigger $(DESTDIR)$(sbindir)/udevtrigger
274 $(STRIP) $(DESTDIR)$(sbindir)/udevtrigger
276 install-bin:
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; \
287 done;
288 ifndef DESTDIR
289 - killall udevd
290 - rm -rf /dev/.udev
291 - $(sbindir)/udevd --daemon
292 endif
293 .PHONY: install-bin
295 uninstall-bin:
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
303 ifndef DESTDIR
304 - killall udevd
305 - rm -rf /dev/.udev
306 endif
307 @extras="$(EXTRAS)"; for target in $$extras; do \
308 $(MAKE) -C $$target $@ || exit 1; \
309 done;
310 .PHONY: uninstall-bin
312 install: all install-bin
313 .PHONY: install
315 uninstall: uninstall-bin uninstall-man
316 .PHONY: uninstall
318 test tests: all
319 @ cd test && ./udev-test.pl
320 @ cd test && ./udevstart-test.pl
321 .PHONY: test tests
323 buildtest:
324 test/simple-build-check.sh
325 .PHONY: buildtest
327 ChangeLog:
328 head -1 $@ | grep -q "to v$(shell echo $$(($(VERSION) - 1)))"
329 @ mv $@ $@.tmp
330 @ echo "Summary of changes from v$(shell echo $$(($(VERSION) - 1))) to v$(VERSION)" >> $@
331 @ echo "============================================" >> $@
332 @ echo >> $@
333 @ git log --pretty=short $(shell echo $$(($(VERSION) - 1)))..HEAD | git shortlog >> $@
334 @ echo >> $@
335 @ cat $@
336 @ cat $@.tmp >> $@
337 @ rm $@.tmp
338 head -1 $@ | grep -q "to v$(VERSION)"
339 .PHONY: ChangeLog
340 .PRECIOUS: ChangeLog
342 release:
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)
349 @ echo
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
352 .PHONY: release
354 gcov-all:
355 $(MAKE) clean all USE_GCOV=true
356 @ echo
357 @ echo "binaries built with gcov support."
358 @ echo "run the tests and analyze with 'make udev_gcov.txt'"
359 .PHONY: gcov-all
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; \
370 else \
371 echo "code for $$name.c was never executed" >> $@ 2>&1; \
372 fi; \
373 echo >> $@; \
374 done; \
375 echo "view $@ for the result"