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
97 WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
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 += $(WARNINGS) -O1 -g -DDEBUG -D_GNU_SOURCE
121 LDFLAGS += -Wl,-warn-common
122 STRIPCMD = /bin/true -Since_we_are_debugging
124 CFLAGS += $(WARNINGS) $(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 += -nostdinc -I$(INCLUDE_DIR) -I$(KLIBC_DIR)/arch/$(ARCH)/include \
146 -I$(INCLUDE_DIR)/bits$(BITSIZE) -I$(GCCINCDIR) -I$(LINUX_INCLUDE_DIR) \
147 -D__KLIBC__ -fno-builtin-printf
149 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
153 CFLAGS += -I$(GCCINCDIR)
158 CFLAGS += -I$(PWD)/libsysfs
160 all: $(ROOT) $(DAEMON) $(SENDER)
161 @extras="$(EXTRAS)" ; for target in $$extras ; do \
163 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
169 $(ARCH_LIB_OBJS) : $(CRT0)
177 SYSFS = $(PWD)/libsysfs/sysfs_bus.o \
178 $(PWD)/libsysfs/sysfs_class.o \
179 $(PWD)/libsysfs/sysfs_device.o \
180 $(PWD)/libsysfs/sysfs_dir.o \
181 $(PWD)/libsysfs/sysfs_driver.o \
182 $(PWD)/libsysfs/sysfs_utils.o \
183 $(PWD)/libsysfs/dlist.o
196 ifeq ($(strip $(USE_KLIBC)),true)
197 OBJS += klibc_fixups.o
200 ifeq ($(USE_DBUS), true)
202 CFLAGS += $(shell pkg-config --cflags dbus-1)
203 LDFLAGS += $(shell pkg-config --libs dbus-1)
207 # header files automatically generated
208 GEN_HEADERS = udev_version.h
210 # Rules on how to create the generated header files
212 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
213 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
214 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
215 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
216 @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
217 @echo \#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
218 @echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
220 # config files automatically generated
221 GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
223 # Rules on how to create the generated config files
224 $(LOCAL_CFG_DIR)/udev.conf:
225 sed -e "s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR)/udev.conf.in > $@
228 $(OBJS): $(GEN_HEADERS)
230 $(ROOT): $(OBJS) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h logging.h list.h
231 $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
234 $(DAEMON): $(ROOT) udevd.h udevd.o
235 $(LD) $(LDFLAGS) -o $(DAEMON) $(CRT0) udevd.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
238 $(SENDER): $(ROOT) udevd.h udevsend.o
239 $(LD) $(LDFLAGS) -o $(SENDER) $(CRT0) udevsend.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
243 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
245 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(DAEMON) $(SENDER)
246 $(MAKE) -C klibc clean
247 @extras="$(EXTRAS)" ; for target in $$extras ; do \
249 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
253 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 )
254 DISTDIR := $(RELEASE_NAME)
257 @echo "--------------------------cut here------------------------"
259 @echo "rm -rf $(DISTDIR)"
260 @echo "mkdir $(DISTDIR)"
261 @echo "chmod 777 $(DISTDIR)"
262 @echo "cp -avr udev/* $(DISTDIR)"
263 @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
264 @echo "rm -rf $(DISTDIR)"
265 @echo "--------------------------cut here------------------------"
268 small_release: $(DISTFILES) clean
272 @-chmod 777 $(DISTDIR)
273 @for file in $(DISTFILES); do \
274 if test -d $$file; then \
275 mkdir $(DISTDIR)/$$file; \
277 cp -p $$file $(DISTDIR)/$$file; \
280 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
282 @echo "Built $(RELEASE_NAME).tar.gz"
285 ifeq ($(USE_DBUS), true)
287 $(INSTALL) -d $(DESTDIR)$(dbusdir)
288 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
290 uninstall-dbus-policy:
291 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
295 uninstall-dbus-policy:
299 install-config: $(GEN_CONFIGS)
300 $(INSTALL) -d $(DESTDIR)$(configdir)
301 @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
302 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
303 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
305 @if [ ! -r $(DESTDIR)$(configdir)udev.rules ]; then \
306 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
307 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
309 @if [ ! -r $(DESTDIR)$(configdir)udev.permissions ]; then \
310 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
311 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
314 install: install-config install-dbus-policy all
315 $(INSTALL) -d $(DESTDIR)$(udevdir)
316 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
317 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
318 @if [ "x$(USE_LSB)" = "xtrue" ]; then \
319 $(INSTALL_PROGRAM) -D etc/init.d/udev.init.LSB $(DESTDIR)$(initdir)/udev; \
320 ln -s $(DESTDIR)$(initdir)/udev $(sbin_dir)/rcudev; \
322 $(INSTALL_PROGRAM) -D etc/init.d/udev $(DESTDIR)$(initdir)/udev; \
324 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
325 - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
326 - ln -f -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
327 @extras="$(EXTRAS)" ; for target in $$extras ; do \
329 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
333 uninstall: uninstall-dbus-policy
334 - rm $(hotplugdir)/udev.hotplug
335 - rm $(configdir)/udev.permissions
336 - rm $(configdir)/udev.rules
337 - rm $(configdir)/udev.conf
339 - rm $(mandir)/man8/udev.8
340 - rm $(sbindir)/$(ROOT)
341 - rmdir $(hotplugdir)
344 @extras="$(EXTRAS)" ; for target in $$extras ; do \
346 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \