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.
37 INSTALL_DIR = /usr/local/bin
38 RELEASE_NAME = $(ROOT)-$(VERSION)
39 LOCAL_CFG_DIR = etc/udev
42 # override this to make udev look in a different location for it's config files
44 exec_prefix = ${prefix}
45 etcdir = ${prefix}/etc
46 sbindir = ${exec_prefix}/sbin
47 mandir = ${prefix}/usr/share/man
48 hotplugdir = ${etcdir}/hotplug.d/default
49 dbusdir = ${etcdir}/dbus-1/system.d
50 configdir = ${etcdir}/udev/
51 initdir = ${etcdir}/init.d/
54 INSTALL = /usr/bin/install -c
55 INSTALL_PROGRAM = ${INSTALL}
56 INSTALL_DATA = ${INSTALL} -m 644
57 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
59 # To build any of the extras programs, run with:
60 # make EXTRAS="extras/a extras/b"
63 # place to put our device nodes
64 udevdir = ${prefix}/udev
66 # Comment out this line to build with something other
67 # than the local version of klibc
70 # If you are running a cross compiler, you may want to set this
71 # to something more interesting, like "arm-linux-". If you want
72 # to compile vs uClibc, that can be done here as well.
73 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
78 RANLIB = $(CROSS)ranlib
80 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
82 # code taken from uClibc to determine the current arch
83 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
84 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
86 # code taken from uClibc to determine the gcc include dir
87 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
89 # code taken from uClibc to determine the libgcc.a filename
90 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
92 # use '-Os' optimization if available, else use -O2
93 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
94 then echo "-Os"; else echo "-O2" ; fi}
96 # add -Wredundant-decls when libsysfs gets cleaned up
99 # Some nice architecture specific optimizations
100 ifeq ($(strip $(TARGET_ARCH)),arm)
101 OPTIMIZATION+=-fstrict-aliasing
103 ifeq ($(strip $(TARGET_ARCH)),i386)
104 OPTIMIZATION+=-march=i386
105 OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
106 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
107 OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
108 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
114 ifeq ($(strip $(USE_LOG)),true)
118 # if DEBUG is enabled, then we do not strip or optimize
119 ifeq ($(strip $(DEBUG)),true)
120 CFLAGS += -O1 -g -DDEBUG -D_GNU_SOURCE
121 LDFLAGS += -Wl,-warn-common
122 STRIPCMD = /bin/true -Since_we_are_debugging
124 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
125 LDFLAGS += -s -Wl,-warn-common
126 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
129 # If we are using our version of klibc, then we need to build, link it, and then
130 # link udev against it statically.
131 # Otherwise, use glibc and link dynamically.
132 ifeq ($(strip $(USE_KLIBC)),true)
133 KLIBC_BASE = $(PWD)/klibc
134 KLIBC_DIR = $(KLIBC_BASE)/klibc
135 INCLUDE_DIR := $(KLIBC_DIR)/include
136 LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
137 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
138 # arch specific objects
143 CRT0 = $(KLIBC_DIR)/crt0.o
144 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
145 CFLAGS += $(WARNINGS) -nostdinc \
146 -D__KLIBC__ -fno-builtin-printf \
148 -I$(KLIBC_DIR)/arch/$(ARCH)/include \
149 -I$(INCLUDE_DIR)/bits$(BITSIZE) \
151 -I$(LINUX_INCLUDE_DIR)
153 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
156 WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
159 CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
162 UDEVD = $(DAEMON) $(SENDER)
165 CFLAGS += -I$(PWD)/libsysfs
167 all: $(ROOT) $(UDEVD)
168 @extras="$(EXTRAS)" ; for target in $$extras ; do \
170 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
176 $(ARCH_LIB_OBJS) : $(CRT0)
184 SYSFS = $(PWD)/libsysfs/sysfs_bus.o \
185 $(PWD)/libsysfs/sysfs_class.o \
186 $(PWD)/libsysfs/sysfs_device.o \
187 $(PWD)/libsysfs/sysfs_dir.o \
188 $(PWD)/libsysfs/sysfs_driver.o \
189 $(PWD)/libsysfs/sysfs_utils.o \
190 $(PWD)/libsysfs/dlist.o
203 ifeq ($(strip $(USE_KLIBC)),true)
204 OBJS += klibc_fixups.o
207 ifeq ($(USE_DBUS), true)
209 CFLAGS += $(shell pkg-config --cflags dbus-1)
210 LDFLAGS += $(shell pkg-config --libs dbus-1)
214 # header files automatically generated
215 GEN_HEADERS = udev_version.h
217 # Rules on how to create the generated header files
219 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
220 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
221 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
222 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
223 @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
224 @echo \#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
225 @echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
227 # config files automatically generated
228 GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
230 # Rules on how to create the generated config files
231 $(LOCAL_CFG_DIR)/udev.conf:
232 sed -e "s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR)/udev.conf.in > $@
235 $(OBJS): $(GEN_HEADERS)
237 $(ROOT): $(OBJS) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h logging.h list.h
238 $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
241 $(DAEMON): udevd.h udevd.o udevd.o logging.o
242 $(LD) $(LDFLAGS) -o $(DAEMON) $(CRT0) udevd.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
245 $(SENDER): udevd.h udevsend.o udevd.o logging.o
246 $(LD) $(LDFLAGS) -o $(SENDER) $(CRT0) udevsend.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
250 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
252 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(DAEMON) $(SENDER)
253 $(MAKE) -C klibc clean
254 @extras="$(EXTRAS)" ; for target in $$extras ; do \
256 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
260 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 )
261 DISTDIR := $(RELEASE_NAME)
264 @echo "--------------------------cut here------------------------"
266 @echo "rm -rf $(DISTDIR)"
267 @echo "mkdir $(DISTDIR)"
268 @echo "chmod 777 $(DISTDIR)"
269 @echo "cp -avr udev/* $(DISTDIR)"
270 @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
271 @echo "rm -rf $(DISTDIR)"
272 @echo "--------------------------cut here------------------------"
275 small_release: $(DISTFILES) clean
279 @-chmod 777 $(DISTDIR)
280 @for file in $(DISTFILES); do \
281 if test -d $$file; then \
282 mkdir $(DISTDIR)/$$file; \
284 cp -p $$file $(DISTDIR)/$$file; \
287 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
289 @echo "Built $(RELEASE_NAME).tar.gz"
292 ifeq ($(USE_DBUS), true)
294 $(INSTALL) -d $(DESTDIR)$(dbusdir)
295 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
297 uninstall-dbus-policy:
298 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
302 uninstall-dbus-policy:
306 install-config: $(GEN_CONFIGS)
307 $(INSTALL) -d $(DESTDIR)$(configdir)
308 @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
309 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
310 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
312 @if [ ! -r $(DESTDIR)$(configdir)udev.rules ]; then \
313 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
314 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
316 @if [ ! -r $(DESTDIR)$(configdir)udev.permissions ]; then \
317 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
318 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
321 install: install-config install-dbus-policy all
322 $(INSTALL) -d $(DESTDIR)$(udevdir)
323 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
324 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
325 @if [ "x$(USE_LSB)" = "xtrue" ]; then \
326 $(INSTALL_PROGRAM) -D etc/init.d/udev.init.LSB $(DESTDIR)$(initdir)/udev; \
327 ln -s $(DESTDIR)$(initdir)/udev $(sbin_dir)/rcudev; \
329 $(INSTALL_PROGRAM) -D etc/init.d/udev $(DESTDIR)$(initdir)/udev; \
331 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
332 - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
333 - ln -f -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
334 @extras="$(EXTRAS)" ; for target in $$extras ; do \
336 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
340 uninstall: uninstall-dbus-policy
341 - rm $(hotplugdir)/udev.hotplug
342 - rm $(configdir)/udev.permissions
343 - rm $(configdir)/udev.rules
344 - rm $(configdir)/udev.conf
346 - rm $(mandir)/man8/udev.8
347 - rm $(sbindir)/$(ROOT)
348 - rmdir $(hotplugdir)
351 @extras="$(EXTRAS)" ; for target in $$extras ; do \
353 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \