3 # Copyright (C) 2003 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 the following to `true' to make udev emit a D-BUS signal when a
29 # new node is created.
41 INSTALL_DIR
= /usr
/local
/bin
42 RELEASE_NAME
= $(ROOT
)-$(VERSION
)
43 LOCAL_CFG_DIR
= etc
/udev
44 HOTPLUG_EXEC
= $(ROOT
)
48 KERNEL_DIR
= /lib
/modules
/${shell uname
-r
}/build
50 # override this to make udev look in a different location for it's config files
52 exec_prefix = ${prefix}
53 etcdir
= ${prefix}/etc
54 sbindir
= ${exec_prefix}/sbin
55 usrbindir
= ${exec_prefix}/usr
/bin
56 mandir = ${prefix}/usr
/share
/man
57 hotplugdir
= ${etcdir}/hotplug.d
/default
58 dbusdir
= ${etcdir}/dbus-1
/system.d
59 configdir
= ${etcdir}/udev
/
60 initdir
= ${etcdir}/init.d
/
63 INSTALL
= /usr
/bin
/install -c
64 INSTALL_PROGRAM
= ${INSTALL}
65 INSTALL_DATA
= ${INSTALL} -m
644
66 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
68 # To build any of the extras programs, run with:
69 # make EXTRAS="extras/a extras/b"
72 # place to put our device nodes
73 udevdir
= ${prefix}/udev
75 # Comment out this line to build with something other
76 # than the local version of klibc
79 # set up PWD so that older versions of make will work with our build.
82 # If you are running a cross compiler, you may want to set this
83 # to something more interesting, like "arm-linux-". If you want
84 # to compile vs uClibc, that can be done here as well.
85 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
90 RANLIB
= $(CROSS
)ranlib
92 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
94 # code taken from uClibc to determine the current arch
95 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
96 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
98 # code taken from uClibc to determine the gcc include dir
99 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
101 # code taken from uClibc to determine the libgcc.a filename
102 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
104 # use '-Os' optimization if available, else use -O2
105 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
106 then echo
"-Os"; else echo
"-O2" ; fi
}
108 # add -Wredundant-decls when libsysfs gets cleaned up
111 # Some nice architecture specific optimizations
112 ifeq ($(strip $(TARGET_ARCH
)),arm
)
113 OPTIMIZATION
+=-fstrict-aliasing
115 ifeq ($(strip $(TARGET_ARCH
)),i386
)
116 OPTIMIZATION
+=-march
=i386
117 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
118 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
119 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
120 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
126 ifeq ($(strip $(USE_LOG
)),true
)
130 # if DEBUG is enabled, then we do not strip or optimize
131 ifeq ($(strip $(DEBUG
)),true
)
132 CFLAGS
+= -O1
-g
-DDEBUG
-D_GNU_SOURCE
133 LDFLAGS
+= -Wl
,-warn-common
134 STRIPCMD
= /bin
/true
-Since_we_are_debugging
136 CFLAGS
+= $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
137 LDFLAGS
+= -s
-Wl
,-warn-common
138 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
141 # If we are using our version of klibc, then we need to build, link it, and then
142 # link udev against it statically.
143 # Otherwise, use glibc and link dynamically.
144 ifeq ($(strip $(USE_KLIBC
)),true
)
145 KLIBC_BASE
= $(PWD
)/klibc
146 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
147 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
148 LINUX_INCLUDE_DIR
:= $(KERNEL_DIR
)/include
149 # LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
150 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
151 # arch specific objects
156 CRT0
= $(KLIBC_DIR
)/crt0.o
157 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
158 CFLAGS
+= $(WARNINGS
) -nostdinc \
160 -D__KLIBC__
-fno-builtin-printf \
162 -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
163 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) \
165 -I
$(LINUX_INCLUDE_DIR
)
167 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
169 WARNINGS
+= -Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
172 CFLAGS
+= $(WARNINGS
) -I
$(GCCINCDIR
)
177 CFLAGS
+= -I
$(PWD
)/libsysfs
179 all: $(ROOT
) $(SENDER
) $(DAEMON
) $(INFO
) $(TESTER
) $(STARTER
)
180 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
182 $(MAKE
) prefix=$(prefix) \
185 KERNEL_DIR
="$(KERNEL_DIR)" \
189 $(ARCH_LIB_OBJS
) : $(CRT0
)
192 $(MAKE
) -C klibc KERNEL_DIR
=$(KERNEL_DIR
)
197 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
198 $(PWD
)/libsysfs
/sysfs_class.o \
199 $(PWD
)/libsysfs
/sysfs_device.o \
200 $(PWD
)/libsysfs
/sysfs_dir.o \
201 $(PWD
)/libsysfs
/sysfs_driver.o \
202 $(PWD
)/libsysfs
/sysfs_utils.o \
203 $(PWD
)/libsysfs
/dlist.o
225 ifeq ($(strip $(USE_KLIBC
)),true
)
226 OBJS
+= klibc_fixups.o
229 ifeq ($(USE_DBUS
), true
)
231 CFLAGS
+= $(shell pkg-config
--cflags dbus-1
)
232 LDFLAGS
+= $(shell pkg-config
--libs dbus-1
)
236 # if USE_SELINUX is enabled, then we do not strip or optimize
237 ifeq ($(strip $(USE_SELINUX
)),true
)
238 CFLAGS
+= -DUSE_SELINUX
239 OBJS
+= udev_selinux.o
240 LIB_OBJS
+= -lselinux
244 # header files automatically generated
245 GEN_HEADERS
= udev_version.h
247 # Rules on how to create the generated header files
249 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
250 @echo \
#define UDEV_ROOT \"$(udevdir)/\" >> $@
251 @echo \
#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
252 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
253 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
254 @echo \
#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
255 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
256 @echo \
#define UDEV_LOG_DEFAULT \"yes\" >> $@
257 @echo \
#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
258 @echo \
#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
260 # config files automatically generated
261 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
263 # Rules on how to create the generated config files
264 $(LOCAL_CFG_DIR
)/udev.conf
:
265 sed
-e
"s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
268 $(OBJS
): $(GEN_HEADERS
)
269 $(ROOT
).o
: $(GEN_HEADERS
)
270 $(TESTER
).o
: $(GEN_HEADERS
)
271 $(INFO
).o
: $(GEN_HEADERS
)
272 $(DAEMON
).o
: $(GEN_HEADERS
)
273 $(SENDER
).o
: $(GEN_HEADERS
)
274 $(STARTER
).o
: $(GEN_HEADERS
)
276 $(ROOT
): $(ROOT
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
277 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udev.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
280 $(TESTER
): $(TESTER
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
281 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevtest.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
284 $(INFO
): $(INFO
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
285 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevinfo.o udev_lib.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
288 $(DAEMON
): $(DAEMON
).o udevd.h
$(LIBC
)
289 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevd.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
292 $(SENDER
): $(SENDER
).o udevd.h
$(LIBC
)
293 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevsend.o udev_lib.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
296 $(STARTER
): $(STARTER
).o
$(HEADERS
) $(LIBC
)
297 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevstart.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
300 $(RULER
): $(RULER
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
301 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevruler.o udev_lib.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
) -lnewt
305 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
307 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
) $(INFO
) $(DAEMON
) $(SENDER
) $(TESTER
) $(STARTER
) $(RULER
)
308 $(MAKE
) -C klibc
clean
309 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
311 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
316 $(MAKE
) -C klibc spotless
318 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 )
319 DISTDIR
:= $(RELEASE_NAME
)
326 tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
328 @echo
"$(RELEASE_NAME).tar.gz created"
331 small_release
: $(DISTFILES
) clean
335 @
-chmod
777 $(DISTDIR
)
336 @for file in
$(DISTFILES
); do \
337 if
test -d
$$file; then \
338 mkdir
$(DISTDIR
)/$$file; \
340 cp
-p
$$file $(DISTDIR
)/$$file; \
343 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
345 @echo
"Built $(RELEASE_NAME).tar.gz"
348 ifeq ($(USE_DBUS
), true
)
350 $(INSTALL
) -d
$(DESTDIR
)$(dbusdir
)
351 $(INSTALL_DATA
) etc
/dbus-1
/system.d
/udev_sysbus_policy.conf
$(DESTDIR
)$(dbusdir
)
353 uninstall-dbus-policy
:
354 - rm $(DESTDIR
)$(dbusdir
)/udev_sysbus_policy.conf
358 uninstall-dbus-policy
:
362 install-initscript
: etc
/init.d
/udev etc
/init.d
/udev.debian etc
/init.d
/udev.init.LSB
363 @if
[ -f
/etc
/redhat-release
]; then \
364 $(INSTALL_DATA
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
365 elif
[ -f
/etc
/SuSE-release
]; then \
366 $(INSTALL_DATA
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
367 elif
[ -f
/etc
/debian_version
]; then \
368 $(INSTALL_DATA
) -D etc
/init.d
/udev.debian
$(DESTDIR
)$(initdir
)/udev
; \
371 install-config
: $(GEN_CONFIGS
)
372 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)
373 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.conf
]; then \
374 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
375 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
377 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.rules
]; then \
378 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
379 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
381 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.permissions
]; then \
382 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
383 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
386 install: install-initscript install-config install-dbus-policy
all
387 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
388 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
389 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
390 $(INSTALL_PROGRAM
) -D
$(DAEMON
) $(DESTDIR
)$(sbindir
)/$(DAEMON
)
391 $(INSTALL_PROGRAM
) -D
$(SENDER
) $(DESTDIR
)$(sbindir
)/$(SENDER
)
392 $(INSTALL_PROGRAM
) -D
$(INFO
) $(DESTDIR
)$(usrbindir
)/$(INFO
)
393 $(INSTALL_PROGRAM
) -D
$(TESTER
) $(DESTDIR
)$(usrbindir
)/$(TESTER
)
394 $(INSTALL_PROGRAM
) -D
$(STARTER
) $(DESTDIR
)$(sbindir
)/$(STARTER
)
395 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
396 $(INSTALL_DATA
) -D udevinfo
.8 $(DESTDIR
)$(mandir)/man8
/udevinfo
.8
397 $(INSTALL_DATA
) -D udevtest
.8 $(DESTDIR
)$(mandir)/man8
/udevtest
.8
398 $(INSTALL_DATA
) -D udevstart
.8 $(DESTDIR
)$(mandir)/man8
/udevstart
.8
399 $(INSTALL_DATA
) -D udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevd
.8
400 - ln
-f
-s udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevsend
.8
401 - ln
-f
-s
$(sbindir
)/$(SENDER
) $(DESTDIR
)$(hotplugdir
)/$(ROOT
).hotplug
404 - rm -f
$(udevdir
)/.udev.tdb
406 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
408 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
412 uninstall: uninstall-dbus-policy
413 - rm $(hotplugdir
)/udev.hotplug
414 - rm $(configdir
)/udev.permissions
415 - rm $(configdir
)/udev.rules
416 - rm $(configdir
)/udev.conf
418 - rm $(mandir)/man8
/udev
.8
419 - rm $(mandir)/man8
/udevinfo
.8
420 - rm $(mandir)/man8
/udevtest
.8
421 - rm $(mandir)/man8
/udevstart
.8
422 - rm $(mandir)/man8
/udevd
.8
423 - rm $(mandir)/man8
/udevsend
.8
424 - rm $(sbindir
)/$(ROOT
)
425 - rm $(sbindir
)/$(DAEMON
)
426 - rm $(sbindir
)/$(SENDER
)
427 - rm $(usrbindir
)/$(INFO
)
428 - rmdir
$(hotplugdir
)
430 - rm $(udevdir
)/.udev.tdb
432 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
434 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \