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.
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 mandir = ${prefix}/usr
/share
/man
54 hotplugdir
= ${etcdir}/hotplug.d
/default
55 dbusdir
= ${etcdir}/dbus-1
/system.d
56 configdir
= ${etcdir}/udev
/
57 initdir
= ${etcdir}/init.d
/
60 INSTALL
= /usr
/bin
/install -c
61 INSTALL_PROGRAM
= ${INSTALL}
62 INSTALL_DATA
= ${INSTALL} -m
644
63 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
65 # To build any of the extras programs, run with:
66 # make EXTRAS="extras/a extras/b"
69 # place to put our device nodes
70 udevdir
= ${prefix}/udev
72 # Comment out this line to build with something other
73 # than the local version of klibc
76 # If you are running a cross compiler, you may want to set this
77 # to something more interesting, like "arm-linux-". If you want
78 # to compile vs uClibc, that can be done here as well.
79 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
84 RANLIB
= $(CROSS
)ranlib
86 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
88 # code taken from uClibc to determine the current arch
89 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
90 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
92 # code taken from uClibc to determine the gcc include dir
93 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
95 # code taken from uClibc to determine the libgcc.a filename
96 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
98 # use '-Os' optimization if available, else use -O2
99 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
100 then echo
"-Os"; else echo
"-O2" ; fi
}
102 # add -Wredundant-decls when libsysfs gets cleaned up
105 # Some nice architecture specific optimizations
106 ifeq ($(strip $(TARGET_ARCH
)),arm
)
107 OPTIMIZATION
+=-fstrict-aliasing
109 ifeq ($(strip $(TARGET_ARCH
)),i386
)
110 OPTIMIZATION
+=-march
=i386
111 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
112 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
113 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
114 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
120 ifeq ($(strip $(USE_LOG
)),true
)
124 # if DEBUG is enabled, then we do not strip or optimize
125 ifeq ($(strip $(DEBUG
)),true
)
126 CFLAGS
+= -O1
-g
-DDEBUG
-D_GNU_SOURCE
127 LDFLAGS
+= -Wl
,-warn-common
128 STRIPCMD
= /bin
/true
-Since_we_are_debugging
130 CFLAGS
+= $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
131 LDFLAGS
+= -s
-Wl
,-warn-common
132 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
135 # If we are using our version of klibc, then we need to build, link it, and then
136 # link udev against it statically.
137 # Otherwise, use glibc and link dynamically.
138 ifeq ($(strip $(USE_KLIBC
)),true
)
139 KLIBC_BASE
= $(PWD
)/klibc
140 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
141 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
142 LINUX_INCLUDE_DIR
:= $(KERNEL_DIR
)/include
143 # LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
144 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
145 # arch specific objects
150 CRT0
= $(KLIBC_DIR
)/crt0.o
151 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
152 CFLAGS
+= $(WARNINGS
) -nostdinc \
153 -D__KLIBC__
-fno-builtin-printf \
155 -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
156 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) \
158 -I
$(LINUX_INCLUDE_DIR
)
160 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
162 WARNINGS
+= -Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
165 CFLAGS
+= $(WARNINGS
) -I
$(GCCINCDIR
)
170 CFLAGS
+= -I
$(PWD
)/libsysfs
172 all: $(ROOT
) $(SENDER
) $(DAEMON
) $(HELPER
) $(TESTER
)
173 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
175 $(MAKE
) prefix=$(prefix) \
178 KERNEL_DIR
="$(KERNEL_DIR)" \
182 $(ARCH_LIB_OBJS
) : $(CRT0
)
185 $(MAKE
) -C klibc KERNEL_DIR
=$(KERNEL_DIR
)
190 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
191 $(PWD
)/libsysfs
/sysfs_class.o \
192 $(PWD
)/libsysfs
/sysfs_device.o \
193 $(PWD
)/libsysfs
/sysfs_dir.o \
194 $(PWD
)/libsysfs
/sysfs_driver.o \
195 $(PWD
)/libsysfs
/sysfs_utils.o \
196 $(PWD
)/libsysfs
/dlist.o
198 OBJS
= udev_config.o \
216 ifeq ($(strip $(USE_KLIBC
)),true
)
217 OBJS
+= klibc_fixups.o
220 ifeq ($(USE_DBUS
), true
)
222 CFLAGS
+= $(shell pkg-config
--cflags dbus-1
)
223 LDFLAGS
+= $(shell pkg-config
--libs dbus-1
)
227 # header files automatically generated
228 GEN_HEADERS
= udev_version.h
230 # Rules on how to create the generated header files
232 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
233 @echo \
#define UDEV_ROOT \"$(udevdir)/\" >> $@
234 @echo \
#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
235 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
236 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
237 @echo \
#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
238 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
239 @echo \
#define UDEV_LOG_DEFAULT \"yes\" >> $@
240 @echo \
#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
241 @echo \
#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
243 # config files automatically generated
244 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
246 # Rules on how to create the generated config files
247 $(LOCAL_CFG_DIR
)/udev.conf
:
248 sed
-e
"s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
251 $(OBJS
): $(GEN_HEADERS
)
252 $(ROOT
).o
: $(GEN_HEADERS
)
253 $(TESTER
).o
: $(GEN_HEADERS
)
254 $(HELPER
).o
: $(GEN_HEADERS
)
255 $(DAEMON
).o
: $(GEN_HEADERS
)
256 $(SENDER
).o
: $(GEN_HEADERS
)
258 $(ROOT
): $(ROOT
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
259 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udev.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
262 $(TESTER
): $(TESTER
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
263 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevtest.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
266 $(HELPER
): $(HELPER
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
267 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevinfo.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
270 $(DAEMON
): $(DAEMON
).o udevd.h
$(LIBC
)
271 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevd.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
274 $(SENDER
): $(SENDER
).o udevd.h
$(LIBC
)
275 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevsend.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
279 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
281 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
) $(HELPER
) $(DAEMON
) $(SENDER
) $(TESTER
)
282 $(MAKE
) -C klibc
clean
283 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
285 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
289 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 )
290 DISTDIR
:= $(RELEASE_NAME
)
297 tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
299 @echo
"$(RELEASE_NAME).tar.gz created"
302 small_release
: $(DISTFILES
) clean
306 @
-chmod
777 $(DISTDIR
)
307 @for file in
$(DISTFILES
); do \
308 if
test -d
$$file; then \
309 mkdir
$(DISTDIR
)/$$file; \
311 cp
-p
$$file $(DISTDIR
)/$$file; \
314 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
316 @echo
"Built $(RELEASE_NAME).tar.gz"
319 ifeq ($(USE_DBUS
), true
)
321 $(INSTALL
) -d
$(DESTDIR
)$(dbusdir
)
322 $(INSTALL_DATA
) etc
/dbus-1
/system.d
/udev_sysbus_policy.conf
$(DESTDIR
)$(dbusdir
)
324 uninstall-dbus-policy
:
325 - rm $(DESTDIR
)$(dbusdir
)/udev_sysbus_policy.conf
329 uninstall-dbus-policy
:
333 install-config
: $(GEN_CONFIGS
)
334 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)
335 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.conf
]; then \
336 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
337 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
339 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.rules
]; then \
340 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
341 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
343 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.permissions
]; then \
344 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
345 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
348 install: install-config install-dbus-policy
all
349 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
350 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
351 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
352 $(INSTALL_PROGRAM
) -D
$(DAEMON
) $(DESTDIR
)$(sbindir
)/$(DAEMON
)
353 $(INSTALL_PROGRAM
) -D
$(SENDER
) $(DESTDIR
)$(sbindir
)/$(SENDER
)
354 $(INSTALL_PROGRAM
) -D
$(HELPER
) $(DESTDIR
)$(sbindir
)/$(HELPER
)
355 $(INSTALL_PROGRAM
) -D
$(TESTER
) $(DESTDIR
)$(sbindir
)/$(TESTER
)
356 @if
[ "x$(USE_LSB)" = "xtrue" ]; then \
357 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
358 ln
-s
$(DESTDIR
)$(initdir
)/udev
$(sbindir
)/rcudev
; \
360 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
362 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
363 $(INSTALL_DATA
) -D udevinfo
.8 $(DESTDIR
)$(mandir)/man8
/udevinfo
.8
364 $(INSTALL_DATA
) -D udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevd
.8
365 - ln
-f
-s .
/udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevsend
.8
366 - rm -f
$(DESTDIR
)$(hotplugdir
)/$(ROOT
).hotplug
367 - rm -f
$(DESTDIR
)$(udevdir
)/.udev.tdb
368 - ln
-f
-s
$(sbindir
)/$(SENDER
) $(DESTDIR
)$(hotplugdir
)/$(ROOT
).hotplug
369 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
371 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
375 uninstall: uninstall-dbus-policy
376 - rm $(hotplugdir
)/udev.hotplug
377 - rm $(configdir
)/udev.permissions
378 - rm $(configdir
)/udev.rules
379 - rm $(configdir
)/udev.conf
381 - rm $(mandir)/man8
/udev
.8
382 - rm $(mandir)/man8
/udevinfo
.8
383 - rm $(sbindir
)/$(ROOT
)
384 - rm $(sbindir
)/$(DAEMON
)
385 - rm $(sbindir
)/$(SENDER
)
386 - rm $(sbindir
)/$(HELPER
)
387 - rmdir
$(hotplugdir
)
389 - rm $(udevdir
)/.udev.tdb
391 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
393 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \