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.
40 INSTALL_DIR
= /usr
/local
/bin
41 RELEASE_NAME
= $(ROOT
)-$(VERSION
)
42 LOCAL_CFG_DIR
= etc
/udev
43 HOTPLUG_EXEC
= $(ROOT
)
47 KERNEL_DIR
= /lib
/modules
/${shell uname
-r
}/build
49 # override this to make udev look in a different location for it's config files
51 exec_prefix = ${prefix}
52 etcdir
= ${prefix}/etc
53 sbindir
= ${exec_prefix}/sbin
54 usrbindir
= ${exec_prefix}/usr
/bin
55 mandir = ${prefix}/usr
/share
/man
56 hotplugdir
= ${etcdir}/hotplug.d
/default
57 dbusdir
= ${etcdir}/dbus-1
/system.d
58 configdir
= ${etcdir}/udev
/
59 initdir
= ${etcdir}/init.d
/
62 INSTALL
= /usr
/bin
/install -c
63 INSTALL_PROGRAM
= ${INSTALL}
64 INSTALL_DATA
= ${INSTALL} -m
644
65 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
67 # To build any of the extras programs, run with:
68 # make EXTRAS="extras/a extras/b"
71 # place to put our device nodes
72 udevdir
= ${prefix}/udev
74 # Comment out this line to build with something other
75 # than the local version of klibc
78 # set up PWD so that older versions of make will work with our build.
81 # If you are running a cross compiler, you may want to set this
82 # to something more interesting, like "arm-linux-". If you want
83 # to compile vs uClibc, that can be done here as well.
84 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
89 RANLIB
= $(CROSS
)ranlib
91 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
93 # code taken from uClibc to determine the current arch
94 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
95 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
97 # code taken from uClibc to determine the gcc include dir
98 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
100 # code taken from uClibc to determine the libgcc.a filename
101 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
103 # use '-Os' optimization if available, else use -O2
104 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
105 then echo
"-Os"; else echo
"-O2" ; fi
}
107 # add -Wredundant-decls when libsysfs gets cleaned up
110 # Some nice architecture specific optimizations
111 ifeq ($(strip $(TARGET_ARCH
)),arm
)
112 OPTIMIZATION
+=-fstrict-aliasing
114 ifeq ($(strip $(TARGET_ARCH
)),i386
)
115 OPTIMIZATION
+=-march
=i386
116 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
117 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
118 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
119 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
125 ifeq ($(strip $(USE_LOG
)),true
)
129 # if DEBUG is enabled, then we do not strip or optimize
130 ifeq ($(strip $(DEBUG
)),true
)
131 CFLAGS
+= -O1
-g
-DDEBUG
-D_GNU_SOURCE
132 LDFLAGS
+= -Wl
,-warn-common
133 STRIPCMD
= /bin
/true
-Since_we_are_debugging
135 CFLAGS
+= $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
136 LDFLAGS
+= -s
-Wl
,-warn-common
137 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
140 # If we are using our version of klibc, then we need to build, link it, and then
141 # link udev against it statically.
142 # Otherwise, use glibc and link dynamically.
143 ifeq ($(strip $(USE_KLIBC
)),true
)
144 KLIBC_BASE
= $(PWD
)/klibc
145 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
146 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
147 LINUX_INCLUDE_DIR
:= $(KERNEL_DIR
)/include
148 # LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
149 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
150 # arch specific objects
155 CRT0
= $(KLIBC_DIR
)/crt0.o
156 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
157 CFLAGS
+= $(WARNINGS
) -nostdinc \
159 -D__KLIBC__
-fno-builtin-printf \
161 -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
162 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) \
164 -I
$(LINUX_INCLUDE_DIR
)
166 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
168 WARNINGS
+= -Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
171 CFLAGS
+= $(WARNINGS
) -I
$(GCCINCDIR
)
176 CFLAGS
+= -I
$(PWD
)/libsysfs
178 all: $(ROOT
) $(SENDER
) $(DAEMON
) $(INFO
) $(TESTER
) $(STARTER
)
179 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
181 $(MAKE
) prefix=$(prefix) \
184 KERNEL_DIR
="$(KERNEL_DIR)" \
188 $(ARCH_LIB_OBJS
) : $(CRT0
)
191 $(MAKE
) -C klibc KERNEL_DIR
=$(KERNEL_DIR
)
196 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
197 $(PWD
)/libsysfs
/sysfs_class.o \
198 $(PWD
)/libsysfs
/sysfs_device.o \
199 $(PWD
)/libsysfs
/sysfs_dir.o \
200 $(PWD
)/libsysfs
/sysfs_driver.o \
201 $(PWD
)/libsysfs
/sysfs_utils.o \
202 $(PWD
)/libsysfs
/dlist.o
204 OBJS
= udev_config.o \
222 ifeq ($(strip $(USE_KLIBC
)),true
)
223 OBJS
+= klibc_fixups.o
226 ifeq ($(USE_DBUS
), true
)
228 CFLAGS
+= $(shell pkg-config
--cflags dbus-1
)
229 LDFLAGS
+= $(shell pkg-config
--libs dbus-1
)
233 # if USE_SELINUX is enabled, then we do not strip or optimize
234 ifeq ($(strip $(USE_SELINUX
)),true
)
235 CFLAGS
+= -DUSE_SELINUX
236 OBJS
+= udev_selinux.o
237 LIB_OBJS
+= -lselinux
241 # header files automatically generated
242 GEN_HEADERS
= udev_version.h
244 # Rules on how to create the generated header files
246 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
247 @echo \
#define UDEV_ROOT \"$(udevdir)/\" >> $@
248 @echo \
#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
249 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
250 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
251 @echo \
#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
252 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
253 @echo \
#define UDEV_LOG_DEFAULT \"yes\" >> $@
254 @echo \
#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
255 @echo \
#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
257 # config files automatically generated
258 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
260 # Rules on how to create the generated config files
261 $(LOCAL_CFG_DIR
)/udev.conf
:
262 sed
-e
"s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
265 $(OBJS
): $(GEN_HEADERS
)
266 $(ROOT
).o
: $(GEN_HEADERS
)
267 $(TESTER
).o
: $(GEN_HEADERS
)
268 $(INFO
).o
: $(GEN_HEADERS
)
269 $(DAEMON
).o
: $(GEN_HEADERS
)
270 $(SENDER
).o
: $(GEN_HEADERS
)
271 $(STARTER
).o
: $(GEN_HEADERS
)
273 $(ROOT
): $(ROOT
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
274 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udev.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
277 $(TESTER
): $(TESTER
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
278 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevtest.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
281 $(INFO
): $(INFO
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
282 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevinfo.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
285 $(DAEMON
): $(DAEMON
).o udevd.h
$(LIBC
)
286 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevd.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
289 $(SENDER
): $(SENDER
).o udevd.h
$(LIBC
)
290 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevsend.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
293 $(STARTER
): $(STARTER
).o
$(HEADERS
) $(LIBC
)
294 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevstart.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
298 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
300 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
) $(INFO
) $(DAEMON
) $(SENDER
) $(TESTER
) $(STARTER
)
301 $(MAKE
) -C klibc
clean
302 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
304 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
310 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 )
311 DISTDIR
:= $(RELEASE_NAME
)
318 tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
320 @echo
"$(RELEASE_NAME).tar.gz created"
323 small_release
: $(DISTFILES
) clean
327 @
-chmod
777 $(DISTDIR
)
328 @for file in
$(DISTFILES
); do \
329 if
test -d
$$file; then \
330 mkdir
$(DISTDIR
)/$$file; \
332 cp
-p
$$file $(DISTDIR
)/$$file; \
335 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
337 @echo
"Built $(RELEASE_NAME).tar.gz"
340 ifeq ($(USE_DBUS
), true
)
342 $(INSTALL
) -d
$(DESTDIR
)$(dbusdir
)
343 $(INSTALL_DATA
) etc
/dbus-1
/system.d
/udev_sysbus_policy.conf
$(DESTDIR
)$(dbusdir
)
345 uninstall-dbus-policy
:
346 - rm $(DESTDIR
)$(dbusdir
)/udev_sysbus_policy.conf
350 uninstall-dbus-policy
:
354 install-initscript
: etc
/init.d
/udev etc
/init.d
/udev.debian etc
/init.d
/udev.init.LSB
355 @if
[ -f
/etc
/redhat-release
]; then \
356 $(INSTALL_DATA
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
357 elif
[ -f
/etc
/SuSE-release
]; then \
358 $(INSTALL_DATA
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
359 elif
[ -f
/etc
/debian_version
]; then \
360 $(INSTALL_DATA
) -D etc
/init.d
/udev.debian
$(DESTDIR
)$(initdir
)/udev
; \
363 install-config
: $(GEN_CONFIGS
)
364 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)
365 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.conf
]; then \
366 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
367 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
369 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.rules
]; then \
370 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
371 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
373 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.permissions
]; then \
374 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
375 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
378 install: install-initscript install-config install-dbus-policy
all
379 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
380 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
381 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
382 $(INSTALL_PROGRAM
) -D
$(DAEMON
) $(DESTDIR
)$(sbindir
)/$(DAEMON
)
383 $(INSTALL_PROGRAM
) -D
$(SENDER
) $(DESTDIR
)$(sbindir
)/$(SENDER
)
384 $(INSTALL_PROGRAM
) -D
$(INFO
) $(DESTDIR
)$(usrbindir
)/$(INFO
)
385 $(INSTALL_PROGRAM
) -D
$(TESTER
) $(DESTDIR
)$(sbindir
)/$(TESTER
)
386 $(INSTALL_PROGRAM
) -D
$(STARTER
) $(DESTDIR
)$(sbindir
)/$(STARTER
)
387 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
388 $(INSTALL_DATA
) -D udevinfo
.8 $(DESTDIR
)$(mandir)/man8
/udevinfo
.8
389 $(INSTALL_DATA
) -D udevstart
.8 $(DESTDIR
)$(mandir)/man8
/udevstart
.8
390 $(INSTALL_DATA
) -D udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevd
.8
391 - ln
-f
-s udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevsend
.8
392 - ln
-f
-s
$(sbindir
)/$(SENDER
) $(DESTDIR
)$(hotplugdir
)/$(ROOT
).hotplug
395 - rm -f
$(udevdir
)/.udev.tdb
397 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
399 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
403 uninstall: uninstall-dbus-policy
404 - rm $(hotplugdir
)/udev.hotplug
405 - rm $(configdir
)/udev.permissions
406 - rm $(configdir
)/udev.rules
407 - rm $(configdir
)/udev.conf
409 - rm $(mandir)/man8
/udev
.8
410 - rm $(mandir)/man8
/udevinfo
.8
411 - rm $(sbindir
)/$(ROOT
)
412 - rm $(sbindir
)/$(DAEMON
)
413 - rm $(sbindir
)/$(SENDER
)
414 - rm $(usrbindir
)/$(INFO
)
415 - rmdir
$(hotplugdir
)
417 - rm $(udevdir
)/.udev.tdb
419 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
421 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \