3 # Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
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 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # Set the following to control the use of syslog
20 # Set it to `false' to remove all logging
23 # Set the following to `true' to log the debug
24 # and make a unstripped, unoptimized binary.
25 # Leave this set to `false' for production use.
28 # Set this to compile with Security-Enhanced Linux support.
39 INSTALL_DIR
= /usr
/local
/bin
40 RELEASE_NAME
= $(ROOT
)-$(VERSION
)
41 LOCAL_CFG_DIR
= etc
/udev
42 HOTPLUG_EXEC
= $(ROOT
)
46 KERNEL_DIR
= /lib
/modules
/${shell uname
-r
}/build
48 # override this to make udev look in a different location for it's config files
50 exec_prefix = ${prefix}
51 etcdir
= ${prefix}/etc
52 sbindir
= ${exec_prefix}/sbin
53 usrbindir
= ${exec_prefix}/usr
/bin
54 mandir = ${prefix}/usr
/share
/man
55 hotplugdir
= ${etcdir}/hotplug.d
/default
56 configdir
= ${etcdir}/udev
57 initdir
= ${etcdir}/init.d
58 dev_ddir
= ${etcdir}/dev.d
61 INSTALL
= /usr
/bin
/install -c
62 INSTALL_PROGRAM
= ${INSTALL}
63 INSTALL_DATA
= ${INSTALL} -m
644
64 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
66 # To build any of the extras programs, run with:
67 # make EXTRAS="extras/a extras/b"
70 # place to put our device nodes
71 udevdir
= ${prefix}/udev
73 # Comment out this line to build with something other
74 # than the local version of klibc
77 # make the build silent (well, at least the udev part) Set this
78 # to something else to make it noisy again.
81 # set up PWD so that older versions of make will work with our build.
84 # If you are running a cross compiler, you may want to set this
85 # to something more interesting, like "arm-linux-". If you want
86 # to compile vs uClibc, that can be done here as well.
87 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
92 RANLIB
= $(CROSS
)ranlib
95 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
97 # code taken from uClibc to determine the current arch
98 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
99 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
101 # code taken from uClibc to determine the gcc include dir
102 GCCINCDIR
:= ${shell LC_ALL
=C
$(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
104 # code taken from uClibc to determine the libgcc.a filename
105 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
107 # use '-Os' optimization if available, else use -O2
108 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
109 then echo
"-Os"; else echo
"-O2" ; fi
}
111 # add -Wredundant-decls when libsysfs gets cleaned up
116 # set up the proper tdb spinlock code if we can
117 ifeq ($(strip $(ARCH
)),i386
)
118 CFLAGS
+= -DUSE_SPINLOCKS
-DINTEL_SPINLOCKS
121 ifeq ($(strip $(USE_LOG
)),true
)
125 # if DEBUG is enabled, then we do not strip or optimize
126 ifeq ($(strip $(DEBUG
)),true
)
127 CFLAGS
+= -O1
-g
-DDEBUG
-D_GNU_SOURCE
128 LDFLAGS
+= -Wl
,-warn-common
129 STRIPCMD
= /bin
/true
-Since_we_are_debugging
131 CFLAGS
+= $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
132 LDFLAGS
+= -s
-Wl
,-warn-common
133 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
136 # If we are using our version of klibc, then we need to build, link it, and then
137 # link udev against it statically.
138 # Otherwise, use glibc and link dynamically.
139 ifeq ($(strip $(USE_KLIBC
)),true
)
140 KLIBC_FIXUPS_DIR
= $(PWD
)/klibc_fixups
141 KLIBC_BASE
= $(PWD
)/klibc
142 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
143 INCLUDE_DIR
:= $(KLIBC_BASE
)/include
144 LINUX_INCLUDE_DIR
:= $(KERNEL_DIR
)/include
145 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
146 # arch specific objects
151 CRT0
= $(KLIBC_DIR
)/crt0.o
152 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
153 CFLAGS
+= $(WARNINGS
) -nostdinc \
155 -D__KLIBC__
-fno-builtin-printf \
156 -I
$(KLIBC_FIXUPS_DIR
) \
157 -include $(KLIBC_FIXUPS_DIR
)/klibc_fixups.h \
159 -I
$(INCLUDE_DIR
)/arch
/$(ARCH
) \
160 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) \
162 -I
$(LINUX_INCLUDE_DIR
)
164 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
166 WARNINGS
+= -Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
169 CFLAGS
+= $(WARNINGS
) -I
$(GCCINCDIR
)
174 ifeq ($(strip $(USE_SELINUX
)),true
)
175 CFLAGS
+= -DUSE_SELINUX
176 LIB_OBJS
+= -lselinux
179 CFLAGS
+= -I
$(PWD
)/libsysfs
/sysfs \
182 # config files automatically generated
183 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
185 all: $(ROOT
) $(SENDER
) $(DAEMON
) $(INFO
) $(TESTER
) $(WAIT
) $(GEN_CONFIGS
)
186 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
188 $(MAKE
) prefix=$(prefix) \
191 KERNEL_DIR
="$(KERNEL_DIR)" \
192 QUIET
="@$(PWD)/ccdv" \
196 $(ARCH_LIB_OBJS
) : $(CRT0
)
199 @if
[ ! -r klibc
/linux
]; then \
200 ln
-f
-s
$(KERNEL_DIR
) klibc
/linux
; \
202 $(MAKE
) -C klibc SUBDIRS
=klibc
207 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
208 $(PWD
)/libsysfs
/sysfs_class.o \
209 $(PWD
)/libsysfs
/sysfs_device.o \
210 $(PWD
)/libsysfs
/sysfs_dir.o \
211 $(PWD
)/libsysfs
/sysfs_driver.o \
212 $(PWD
)/libsysfs
/sysfs_utils.o \
213 $(PWD
)/libsysfs
/dlist.o
237 ifeq ($(strip $(USE_KLIBC
)),true
)
238 HEADERS
+= klibc_fixups
/klibc_fixups.h \
239 klibc_fixups
/mntent.h \
242 OBJS
+= klibc_fixups
/klibc_fixups.o
243 KLIBC_FIXUP
= klibc_fixups
/klibc_fixups.o
246 ifeq ($(strip $(V
)),false
)
254 # header files automatically generated
255 GEN_HEADERS
= udev_version.h
258 @echo
"Building ccdv"
259 @
$(HOSTCC
) -O1 ccdv.c
-o ccdv
261 # Rules on how to create the generated header files
263 @echo
"Creating udev_version.h"
264 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
265 @echo \
#define UDEV_ROOT \"$(udevdir)/\" >> $@
266 @echo \
#define UDEV_DB \"$(udevdir)/.udev.tdb\" >> $@
267 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
268 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
269 @echo \
#define UDEV_RULES_FILE \"$(configdir)/rules.d\" >> $@
270 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)/permissions.d\" >> $@
271 @echo \
#define UDEV_LOG_DEFAULT \"yes\" >> $@
272 @echo \
#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
273 @echo \
#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
275 # Rules on how to create the generated config files
276 $(LOCAL_CFG_DIR
)/udev.conf
:
277 sed
-e
"s:@udevdir@:$(udevdir):" -e
"s:@configdir@:$(configdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
279 GEN_MANPAGES
= udev
.8
280 GEN_MANPAGESIN
= udev
.8.in
281 # Rules on how to create the man pages
282 $(GEN_MANPAGES
): $(GEN_MANPAGESIN
)
283 sed
-e
"s:@udevdir@:$(udevdir):" < $@.in
> $@
285 $(OBJS
): $(GEN_HEADERS
) $(HOST_PROGS
)
286 $(ROOT
).o
: $(GEN_HEADERS
) $(HOST_PROGS
)
287 $(TESTER
).o
: $(GEN_HEADERS
) $(HOST_PROGS
)
288 $(INFO
).o
: $(GEN_HEADERS
) $(HOST_PROGS
)
289 $(DAEMON
).o
: $(GEN_HEADERS
) $(HOST_PROGS
)
290 $(SENDER
).o
: $(GEN_HEADERS
) $(HOST_PROGS
)
291 $(STARTER
).o
: $(GEN_HEADERS
) $(HOST_PROGS
)
292 $(WAIT
).o
: $(GEN_HEADERS
) $(HOST_PROGS
)
294 $(ROOT
): $(LIBC
) $(ROOT
).o
$(STARTER
).o
$(OBJS
) $(HEADERS
) $(GEN_MANPAGES
)
295 $(QUIET
) $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udev.o udevstart.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
296 $(QUIET
) $(STRIPCMD
) $@
298 $(TESTER
): $(LIBC
) $(TESTER
).o
$(OBJS
) $(HEADERS
)
299 $(QUIET
) $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevtest.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
300 $(QUIET
) $(STRIPCMD
) $@
302 $(INFO
): $(LIBC
) $(INFO
).o
$(OBJS
) $(HEADERS
)
303 $(QUIET
) $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevinfo.o udev_lib.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
304 $(QUIET
) $(STRIPCMD
) $@
306 $(DAEMON
): $(LIBC
) $(DAEMON
).o
$(OBJS
) udevd.h
307 $(QUIET
) $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevd.o udev_lib.o
$(KLIBC_FIXUP
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
308 $(QUIET
) $(STRIPCMD
) $@
310 $(SENDER
): $(LIBC
) $(SENDER
).o
$(OBJS
) udevd.h
311 $(QUIET
) $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevsend.o udev_lib.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
312 $(QUIET
) $(STRIPCMD
) $@
314 $(WAIT
): $(WAIT
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
315 $(QUIET
) $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) $(WAIT
).o udev_sysfs.o udev_lib.o udev_config.o
$(SYSFS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
316 $(QUIET
) $(STRIPCMD
) $@
319 # $(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) -c -o $@ $<
321 $(QUIET
) $(CC
) $(CFLAGS
) -c
-o
$@
$<
325 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
327 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
) $(GEN_MANPAGES
) $(INFO
) $(DAEMON
) $(SENDER
) $(TESTER
) $(WAIT
)
329 $(MAKE
) -C klibc
clean
330 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
332 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
337 $(MAKE
) -C klibc spotless
340 DISTFILES
= $(shell find . \
( -not
-name
'.' \
) -print | grep
-v
-e CVS
-e
"\.tar\.gz$" -e
"\/\." -e releases
-e BitKeeper
-e SCCS
-e
"\.tdb$" -e
test/sys |
sort )
341 DISTDIR
:= $(RELEASE_NAME
)
348 tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
350 @echo
"$(RELEASE_NAME).tar.gz created"
353 small_release
: $(DISTFILES
) clean
357 @
-chmod
777 $(DISTDIR
)
358 @for file in
$(DISTFILES
); do \
359 if
test -d
$$file; then \
360 mkdir
$(DISTDIR
)/$$file; \
362 cp
-p
$$file $(DISTDIR
)/$$file; \
365 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
367 @echo
"Built $(RELEASE_NAME).tar.gz"
370 install-initscript
: etc
/init.d
/udev etc
/init.d
/udev.init.LSB
371 @if
[ -f
/etc
/redhat-release
]; then \
372 $(INSTALL_DATA
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
373 elif
[ -f
/etc
/SuSE-release
]; then \
374 $(INSTALL_DATA
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
378 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)/rules.d
379 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)/permissions.d
380 @if
[ ! -r
$(DESTDIR
)$(configdir
)/udev.conf
]; then \
381 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
382 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
384 @if
[ ! -r
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
]; then \
385 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
; \
386 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
; \
388 @if
[ ! -r
$(DESTDIR
)$(configdir
)/permissions.d
/50-udev.permissions
]; then \
389 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
)/permissions.d
/50-udev.permissions
; \
390 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
)/permissions.d
/50-udev.permissions
; \
394 $(INSTALL
) -d
$(DESTDIR
)$(dev_ddir
)/default
395 $(INSTALL_PROGRAM
) -D etc
/dev.d
/net
/hotplug.dev
$(DESTDIR
)$(dev_ddir
)/net
/hotplug.dev
398 - rm $(dev_ddir
)/net
/hotplug.dev
399 - rmdir
$(dev_ddir
)/net
400 - rmdir
$(dev_ddir
)/default
404 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
405 $(INSTALL_DATA
) -D udevinfo
.8 $(DESTDIR
)$(mandir)/man8
/udevinfo
.8
406 $(INSTALL_DATA
) -D udevtest
.8 $(DESTDIR
)$(mandir)/man8
/udevtest
.8
407 $(INSTALL_DATA
) -D udevstart
.8 $(DESTDIR
)$(mandir)/man8
/udevstart
.8
408 $(INSTALL_DATA
) -D udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevd
.8
409 - ln
-f
-s udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevsend
.8
412 - rm $(mandir)/man8
/udev
.8
413 - rm $(mandir)/man8
/udevinfo
.8
414 - rm $(mandir)/man8
/udevtest
.8
415 - rm $(mandir)/man8
/udevstart
.8
416 - rm $(mandir)/man8
/udevd
.8
417 - rm $(mandir)/man8
/udevsend
.8
419 install: install-initscript install-config install-man install-dev.d
all
420 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
421 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
422 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
423 $(INSTALL_PROGRAM
) -D
$(DAEMON
) $(DESTDIR
)$(sbindir
)/$(DAEMON
)
424 $(INSTALL_PROGRAM
) -D
$(SENDER
) $(DESTDIR
)$(sbindir
)/$(SENDER
)
425 $(INSTALL_PROGRAM
) -D
$(INFO
) $(DESTDIR
)$(usrbindir
)/$(INFO
)
426 $(INSTALL_PROGRAM
) -D
$(TESTER
) $(DESTDIR
)$(usrbindir
)/$(TESTER
)
427 $(INSTALL_PROGRAM
) -D
$(WAIT
) $(DESTDIR
)$(sbindir
)/$(WAIT
)
428 - ln
-f
-s
$(sbindir
)/udev
$(DESTDIR
)$(sbindir
)/$(STARTER
)
429 - ln
-f
-s
$(sbindir
)/$(SENDER
) $(DESTDIR
)$(hotplugdir
)/10-udev.hotplug
430 - ln
-f
-s
$(sbindir
)/$(WAIT
) $(DESTDIR
)$(hotplugdir
)/05-wait_for_sysfs.hotplug
433 - rm -f
$(udevdir
)/.udev.tdb
435 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
437 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
441 uninstall: uninstall-man uninstall-dev.d
442 - rm $(hotplugdir
)/10-udev.hotplug
443 - rm $(hotplugdir
)/05-wait_for_sysfs.hotplug
444 - rm $(configdir
)/rules.d
/50-udev.rules
445 - rm $(configdir
)/permissions.d
/50-udev.permissions
446 - rm $(configdir
)/udev.conf
447 - rmdir
$(configdir
)/rules.d
448 - rmdir
$(configdir
)/permissions.d
451 - rm $(sbindir
)/$(ROOT
)
452 - rm $(sbindir
)/$(DAEMON
)
453 - rm $(sbindir
)/$(SENDER
)
454 - rm $(sbindir
)/$(STARTER
)
455 - rm $(usrbindir
)/$(INFO
)
456 - rm $(usrbindir
)/$(TESTER
)
457 - rm $(usrbindir
)/$(WAIT
)
458 - rmdir
$(hotplugdir
)
459 - rm $(udevdir
)/.udev.tdb
461 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
463 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
468 @ cd
test && .
/udev-test.pl