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.
38 INSTALL_DIR = /usr/local/bin
39 RELEASE_NAME = $(ROOT)-$(VERSION)
40 LOCAL_CFG_DIR = etc/udev
41 HOTPLUG_EXEC = $(ROOT)
44 # override this to make udev look in a different location for it's config files
46 exec_prefix = ${prefix}
47 etcdir = ${prefix}/etc
48 sbindir = ${exec_prefix}/sbin
49 mandir = ${prefix}/usr/share/man
50 hotplugdir = ${etcdir}/hotplug.d/default
51 dbusdir = ${etcdir}/dbus-1/system.d
52 configdir = ${etcdir}/udev/
53 initdir = ${etcdir}/init.d/
56 INSTALL = /usr/bin/install -c
57 INSTALL_PROGRAM = ${INSTALL}
58 INSTALL_DATA = ${INSTALL} -m 644
59 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
61 # To build any of the extras programs, run with:
62 # make EXTRAS="extras/a extras/b"
65 # place to put our device nodes
66 udevdir = ${prefix}/udev
68 # Comment out this line to build with something other
69 # than the local version of klibc
72 # If you are running a cross compiler, you may want to set this
73 # to something more interesting, like "arm-linux-". If you want
74 # to compile vs uClibc, that can be done here as well.
75 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
80 RANLIB = $(CROSS)ranlib
82 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
84 # code taken from uClibc to determine the current arch
85 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
86 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
88 # code taken from uClibc to determine the gcc include dir
89 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
91 # code taken from uClibc to determine the libgcc.a filename
92 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
94 # use '-Os' optimization if available, else use -O2
95 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
96 then echo "-Os"; else echo "-O2" ; fi}
98 # add -Wredundant-decls when libsysfs gets cleaned up
101 # Some nice architecture specific optimizations
102 ifeq ($(strip $(TARGET_ARCH)),arm)
103 OPTIMIZATION+=-fstrict-aliasing
105 ifeq ($(strip $(TARGET_ARCH)),i386)
106 OPTIMIZATION+=-march=i386
107 OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
108 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
109 OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
110 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
116 ifeq ($(strip $(USE_LOG)),true)
120 # if DEBUG is enabled, then we do not strip or optimize
121 ifeq ($(strip $(DEBUG)),true)
122 CFLAGS += -O1 -g -DDEBUG -D_GNU_SOURCE
123 LDFLAGS += -Wl,-warn-common
124 STRIPCMD = /bin/true -Since_we_are_debugging
126 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
127 LDFLAGS += -s -Wl,-warn-common
128 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
131 # If we are using our version of klibc, then we need to build, link it, and then
132 # link udev against it statically.
133 # Otherwise, use glibc and link dynamically.
134 ifeq ($(strip $(USE_KLIBC)),true)
135 KLIBC_BASE = $(PWD)/klibc
136 KLIBC_DIR = $(KLIBC_BASE)/klibc
137 INCLUDE_DIR := $(KLIBC_DIR)/include
138 LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
139 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
140 # arch specific objects
145 CRT0 = $(KLIBC_DIR)/crt0.o
146 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
147 CFLAGS += $(WARNINGS) -nostdinc \
148 -D__KLIBC__ -fno-builtin-printf \
150 -I$(KLIBC_DIR)/arch/$(ARCH)/include \
151 -I$(INCLUDE_DIR)/bits$(BITSIZE) \
153 -I$(LINUX_INCLUDE_DIR)
155 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
158 WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
161 CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
167 CFLAGS += -I$(PWD)/libsysfs
169 all: $(ROOT) $(SENDER) $(UDEVD) $(HELPER)
170 @extras="$(EXTRAS)" ; for target in $$extras ; do \
172 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
178 $(ARCH_LIB_OBJS) : $(CRT0)
186 SYSFS = $(PWD)/libsysfs/sysfs_bus.o \
187 $(PWD)/libsysfs/sysfs_class.o \
188 $(PWD)/libsysfs/sysfs_device.o \
189 $(PWD)/libsysfs/sysfs_dir.o \
190 $(PWD)/libsysfs/sysfs_driver.o \
191 $(PWD)/libsysfs/sysfs_utils.o \
192 $(PWD)/libsysfs/dlist.o
194 OBJS = udev_config.o \
212 ifeq ($(strip $(USE_KLIBC)),true)
213 OBJS += klibc_fixups.o
216 ifeq ($(USE_DBUS), true)
218 CFLAGS += $(shell pkg-config --cflags dbus-1)
219 LDFLAGS += $(shell pkg-config --libs dbus-1)
223 # header files automatically generated
224 GEN_HEADERS = udev_version.h
226 # Rules on how to create the generated header files
228 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
229 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
230 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
231 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
232 @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
233 @echo \#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
234 @echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
235 @echo \#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
236 @echo \#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
237 @echo \#define UDEVD_SOCK \"$(udevdir)/\.udevd.sock\" >> $@
238 @echo \#define UDEVD_LOCK \"$(udevdir)/\.udevd.lock\" >> $@
240 # config files automatically generated
241 GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
243 # Rules on how to create the generated config files
244 $(LOCAL_CFG_DIR)/udev.conf:
245 sed -e "s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR)/udev.conf.in > $@
248 $(OBJS): $(GEN_HEADERS)
249 udev.o: $(GEN_HEADERS)
251 $(ROOT): udev.o $(OBJS) $(HEADERS) $(GEN_HEADERS)
252 $(LD) $(LDFLAGS) -o $@ $(CRT0) udev.o $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
255 $(HELPER): udevinfo.o $(OBJS) $(HEADERS)
256 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevinfo.o udev_config.o udevdb.o $(SYSFS) $(TDB) $(LIB_OBJS) $(ARCH_LIB_OBJS)
259 $(DAEMON): udevd.h udevd.o
260 $(LD) $(LDFLAGS) -lpthread -o $@ $(CRT0) udevd.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
263 $(SENDER): udevd.h udevsend.o
264 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevsend.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
268 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
270 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(HELPER) $(DAEMON) $(SENDER)
271 $(MAKE) -C klibc clean
272 @extras="$(EXTRAS)" ; for target in $$extras ; do \
274 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
278 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 )
279 DISTDIR := $(RELEASE_NAME)
282 @echo "--------------------------cut here------------------------"
284 @echo "rm -rf $(DISTDIR)"
285 @echo "mkdir $(DISTDIR)"
286 @echo "chmod 777 $(DISTDIR)"
287 @echo "cp -avr udev/* $(DISTDIR)"
288 @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
289 @echo "rm -rf $(DISTDIR)"
290 @echo "--------------------------cut here------------------------"
293 small_release: $(DISTFILES) clean
297 @-chmod 777 $(DISTDIR)
298 @for file in $(DISTFILES); do \
299 if test -d $$file; then \
300 mkdir $(DISTDIR)/$$file; \
302 cp -p $$file $(DISTDIR)/$$file; \
305 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
307 @echo "Built $(RELEASE_NAME).tar.gz"
310 ifeq ($(USE_DBUS), true)
312 $(INSTALL) -d $(DESTDIR)$(dbusdir)
313 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
315 uninstall-dbus-policy:
316 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
320 uninstall-dbus-policy:
324 install-config: $(GEN_CONFIGS)
325 $(INSTALL) -d $(DESTDIR)$(configdir)
326 @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
327 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
328 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
330 @if [ ! -r $(DESTDIR)$(configdir)udev.rules ]; then \
331 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
332 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
334 @if [ ! -r $(DESTDIR)$(configdir)udev.permissions ]; then \
335 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
336 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
339 install: install-config install-dbus-policy all
340 $(INSTALL) -d $(DESTDIR)$(udevdir)
341 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
342 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
343 $(INSTALL_PROGRAM) -D $(DAEMON) $(DESTDIR)$(sbindir)/$(DAEMON)
344 $(INSTALL_PROGRAM) -D $(SENDER) $(DESTDIR)$(sbindir)/$(SENDER)
345 $(INSTALL_PROGRAM) -D $(HELPER) $(DESTDIR)$(sbindir)/$(HELPER)
346 @if [ "x$(USE_LSB)" = "xtrue" ]; then \
347 $(INSTALL_PROGRAM) -D etc/init.d/udev.init.LSB $(DESTDIR)$(initdir)/udev; \
348 ln -s $(DESTDIR)$(initdir)/udev $(sbindir)/rcudev; \
350 $(INSTALL_PROGRAM) -D etc/init.d/udev $(DESTDIR)$(initdir)/udev; \
352 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
353 $(INSTALL_DATA) -D udevinfo.8 $(DESTDIR)$(mandir)/man8/udevinfo.8
354 - rm -f $(DESTDIR)$(hotplugdir)/$(HOTPLUG_EXEC).hotplug
355 - ln -f -s $(sbindir)/$(HOTPLUG_EXEC) $(DESTDIR)$(hotplugdir)/udev.hotplug
356 @extras="$(EXTRAS)" ; for target in $$extras ; do \
358 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
362 uninstall: uninstall-dbus-policy
363 - rm $(hotplugdir)/udev.hotplug
364 - rm $(configdir)/udev.permissions
365 - rm $(configdir)/udev.rules
366 - rm $(configdir)/udev.conf
368 - rm $(mandir)/man8/udev.8
369 - rm $(mandir)/man8/udevinfo.8
370 - rm $(sbindir)/$(ROOT)
371 - rm $(sbindir)/$(DAEMON)
372 - rm $(sbindir)/$(SENDER)
373 - rm $(sbindir)/$(HELPER)
374 - rmdir $(hotplugdir)
377 @extras="$(EXTRAS)" ; for target in $$extras ; do \
379 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \