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 `true' to make a debuggable build.
20 # Leave this set to `false' for production use.
23 # Set the following to `true' to make udev emit a D-BUS signal when a
24 # new node is created.
30 INSTALL_DIR = /usr/local/bin
31 RELEASE_NAME = $(ROOT)-$(VERSION)
34 # override this to make udev look in a different location for it's config files
36 exec_prefix = ${prefix}
37 etcdir = ${prefix}/etc
38 sbindir = ${exec_prefix}/sbin
39 mandir = ${prefix}/usr/share/man
40 hotplugdir = ${etcdir}/hotplug.d/default
41 dbusdir = ${etcdir}/dbus-1/system.d
42 configdir = ${etcdir}/udev/
43 initdir = ${etcdir}/init.d/
46 INSTALL = /usr/bin/install -c
47 INSTALL_PROGRAM = ${INSTALL}
48 INSTALL_DATA = ${INSTALL} -m 644
49 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
51 # To build any of the extras programs, run with:
52 # make EXTRAS="extras/a extras/b"
55 # place to put our device nodes
56 udevdir = ${prefix}/udev
58 # Comment out this line to build with something other
59 # than the local version of klibc
62 # If you are running a cross compiler, you may want to set this
63 # to something more interesting, like "arm-linux-". I you want
64 # to compile vs uClibc, that can be done here as well.
65 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
70 RANLIB = $(CROSS)ranlib
72 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
74 # code taken from uClibc to determine the current arch
75 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
76 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
78 # code taken from uClibc to determine the gcc include dir
79 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
81 # code taken from uClibc to determine the libgcc.a filename
82 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
84 # use '-Os' optimization if available, else use -O2
85 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
86 then echo "-Os"; else echo "-O2" ; fi}
88 # add -Wredundant-decls when libsysfs gets cleaned up
89 WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
91 # Some nice architecture specific optimizations
92 ifeq ($(strip $(TARGET_ARCH)),arm)
93 OPTIMIZATION+=-fstrict-aliasing
95 ifeq ($(strip $(TARGET_ARCH)),i386)
96 OPTIMIZATION+=-march=i386
97 OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
98 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
99 OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
100 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
106 # if DEBUG is enabled, then we do not strip or optimize
107 ifeq ($(strip $(DEBUG)),true)
108 CFLAGS += $(WARNINGS) -O1 -g -DDEBUG -D_GNU_SOURCE
109 LDFLAGS += -Wl,-warn-common
110 STRIPCMD = /bin/true -Since_we_are_debugging
112 CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
113 LDFLAGS += -s -Wl,-warn-common
114 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
117 # If we are using our version of klibc, then we need to build, link it, and then
118 # link udev against it statically.
119 # Otherwise, use glibc and link dynamically.
120 ifeq ($(strip $(USE_KLIBC)),true)
121 KLIBC_BASE = $(PWD)/klibc
122 KLIBC_DIR = $(KLIBC_BASE)/klibc
123 INCLUDE_DIR := $(KLIBC_DIR)/include
124 LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
125 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
126 # arch specific objects
131 CRT0 = $(KLIBC_DIR)/crt0.o
132 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
133 CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(KLIBC_DIR)/arch/$(ARCH)/include \
134 -I$(INCLUDE_DIR)/bits$(BITSIZE) -I$(GCCINCDIR) -I$(LINUX_INCLUDE_DIR) \
137 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
141 CFLAGS += -I$(GCCINCDIR)
146 CFLAGS += -I$(PWD)/libsysfs
149 @extras="$(EXTRAS)" ; for target in $$extras ; do \
151 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
157 $(ARCH_LIB_OBJS) : $(CRT0)
165 SYSFS = $(PWD)/libsysfs/sysfs_bus.o \
166 $(PWD)/libsysfs/sysfs_class.o \
167 $(PWD)/libsysfs/sysfs_device.o \
168 $(PWD)/libsysfs/sysfs_dir.o \
169 $(PWD)/libsysfs/sysfs_driver.o \
170 $(PWD)/libsysfs/sysfs_utils.o \
171 $(PWD)/libsysfs/dlist.o
184 ifeq ($(strip $(USE_KLIBC)),true)
185 OBJS += klibc_fixups.o
188 ifeq ($(USE_DBUS), true)
190 CFLAGS += $(shell pkg-config --cflags dbus-1)
191 LDFLAGS += $(shell pkg-config --libs dbus-1)
195 # header files automatically generated
196 GEN_HEADERS = udev_version.h
198 # Rules on how to create the generated header files
200 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
201 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
202 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
203 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
204 @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
205 @echo \#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
206 @echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
208 # config files automatically generated
209 GEN_CONFIGS = udev.conf
211 # Rules on how to create the generated config files
213 sed -e "s:@udevdir@:$(udevdir):" < udev.conf.in > $@
216 $(OBJS): $(GEN_HEADERS)
218 $(ROOT): $(OBJS) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h list.h
219 $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
223 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
225 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS)
226 $(MAKE) -C klibc clean
227 @extras="$(EXTRAS)" ; for target in $$extras ; do \
229 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
233 DISTFILES = $(shell find . \( -not -name '.' \) -print | grep -v CVS | grep -v "\.tar\.gz" | grep -v "\/\." | grep -v releases | grep -v BitKeeper | grep -v SCCS | grep -v "\.tdb" | grep -v "test\/sys" | sort )
234 DISTDIR := $(RELEASE_NAME)
237 @echo "--------------------------cut here------------------------"
239 @echo "rm -rf $(DISTDIR)"
240 @echo "mkdir $(DISTDIR)"
241 @echo "chmod 777 $(DISTDIR)"
242 @echo "cp -avr udev/* $(DISTDIR)"
243 @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
244 @echo "rm -rf $(DISTDIR)"
245 @echo "--------------------------cut here------------------------"
248 small_release: $(DISTFILES) clean
252 @-chmod 777 $(DISTDIR)
253 @for file in $(DISTFILES); do \
254 if test -d $$file; then \
255 mkdir $(DISTDIR)/$$file; \
257 cp -p $$file $(DISTDIR)/$$file; \
260 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
262 @echo "Built $(RELEASE_NAME).tar.gz"
265 ifeq ($(USE_DBUS), true)
267 $(INSTALL) -d $(DESTDIR)$(dbusdir)
268 $(INSTALL_DATA) udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
269 uninstall-dbus-policy:
270 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
274 uninstall-dbus-policy:
278 install-config: $(GEN_CONFIGS)
279 $(INSTALL) -d $(DESTDIR)$(configdir)
280 @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
281 echo $(INSTALL_DATA) udev.conf $(DESTDIR)$(configdir); \
282 $(INSTALL_DATA) udev.conf $(DESTDIR)$(configdir); \
284 @if [ ! -r $(DESTDIR)$(configdir)udev.rules ]; then \
285 echo $(INSTALL_DATA) udev.rules $(DESTDIR)$(configdir); \
286 $(INSTALL_DATA) udev.rules $(DESTDIR)$(configdir); \
288 @if [ ! -r $(DESTDIR)$(configdir)udev.permissions ]; then \
289 echo $(INSTALL_DATA) udev.permissions $(DESTDIR)$(configdir); \
290 $(INSTALL_DATA) udev.permissions $(DESTDIR)$(configdir); \
295 install: install-config install-dbus-policy all
296 $(INSTALL) -d $(DESTDIR)$(udevdir)
297 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
298 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
299 $(INSTALL_PROGRAM) -D etc/init.d/udev $(DESTDIR)$(initdir)/udev
300 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
301 - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
302 - ln -f -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
303 @extras="$(EXTRAS)" ; for target in $$extras ; do \
305 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
309 uninstall: uninstall-dbus-policy
310 - rm $(hotplugdir)/udev.hotplug
311 - rm $(configdir)/udev.permissions
312 - rm $(configdir)/udev.rules
313 - rm $(configdir)/udev.conf
315 - rm $(mandir)/man8/udev.8
316 - rm $(sbindir)/$(ROOT)
317 - rmdir $(hotplugdir)
320 @extras="$(EXTRAS)" ; for target in $$extras ; do \
322 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \