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.
35 INSTALL_DIR
= /usr
/local
/bin
36 RELEASE_NAME
= $(ROOT
)-$(VERSION
)
37 LOCAL_CFG_DIR
= etc
/udev
40 # override this to make udev look in a different location for it's config files
42 exec_prefix = ${prefix}
43 etcdir
= ${prefix}/etc
44 sbindir
= ${exec_prefix}/sbin
45 mandir = ${prefix}/usr
/share
/man
46 hotplugdir
= ${etcdir}/hotplug.d
/default
47 dbusdir
= ${etcdir}/dbus-1
/system.d
48 configdir
= ${etcdir}/udev
/
49 initdir
= ${etcdir}/init.d
/
52 INSTALL
= /usr
/bin
/install -c
53 INSTALL_PROGRAM
= ${INSTALL}
54 INSTALL_DATA
= ${INSTALL} -m
644
55 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
57 # To build any of the extras programs, run with:
58 # make EXTRAS="extras/a extras/b"
61 # place to put our device nodes
62 udevdir
= ${prefix}/udev
64 # Comment out this line to build with something other
65 # than the local version of klibc
68 # If you are running a cross compiler, you may want to set this
69 # to something more interesting, like "arm-linux-". If you want
70 # to compile vs uClibc, that can be done here as well.
71 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
76 RANLIB
= $(CROSS
)ranlib
78 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
80 # code taken from uClibc to determine the current arch
81 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
82 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
84 # code taken from uClibc to determine the gcc include dir
85 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
87 # code taken from uClibc to determine the libgcc.a filename
88 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
90 # use '-Os' optimization if available, else use -O2
91 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
92 then echo
"-Os"; else echo
"-O2" ; fi
}
94 # add -Wredundant-decls when libsysfs gets cleaned up
95 WARNINGS
:= -Wall
-Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
97 # Some nice architecture specific optimizations
98 ifeq ($(strip $(TARGET_ARCH
)),arm
)
99 OPTIMIZATION
+=-fstrict-aliasing
101 ifeq ($(strip $(TARGET_ARCH
)),i386
)
102 OPTIMIZATION
+=-march
=i386
103 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
104 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
105 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
106 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
112 ifeq ($(strip $(USE_LOG
)),true
)
116 # if DEBUG is enabled, then we do not strip or optimize
117 ifeq ($(strip $(DEBUG
)),true
)
118 CFLAGS
+= $(WARNINGS
) -O1
-g
-DDEBUG
-D_GNU_SOURCE
119 LDFLAGS
+= -Wl
,-warn-common
120 STRIPCMD
= /bin
/true
-Since_we_are_debugging
122 CFLAGS
+= $(WARNINGS
) $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
123 LDFLAGS
+= -s
-Wl
,-warn-common
124 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
127 # If we are using our version of klibc, then we need to build, link it, and then
128 # link udev against it statically.
129 # Otherwise, use glibc and link dynamically.
130 ifeq ($(strip $(USE_KLIBC
)),true
)
131 KLIBC_BASE
= $(PWD
)/klibc
132 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
133 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
134 LINUX_INCLUDE_DIR
:= $(KLIBC_BASE
)/linux
/include
135 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
136 # arch specific objects
141 CRT0
= $(KLIBC_DIR
)/crt0.o
142 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
143 CFLAGS
+= -nostdinc
-I
$(INCLUDE_DIR
) -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
144 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) -I
$(GCCINCDIR
) -I
$(LINUX_INCLUDE_DIR
) \
145 -D__KLIBC__
-fno-builtin-printf
147 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
151 CFLAGS
+= -I
$(GCCINCDIR
)
156 CFLAGS
+= -I
$(PWD
)/libsysfs
159 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
161 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
167 $(ARCH_LIB_OBJS
) : $(CRT0
)
175 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
176 $(PWD
)/libsysfs
/sysfs_class.o \
177 $(PWD
)/libsysfs
/sysfs_device.o \
178 $(PWD
)/libsysfs
/sysfs_dir.o \
179 $(PWD
)/libsysfs
/sysfs_driver.o \
180 $(PWD
)/libsysfs
/sysfs_utils.o \
181 $(PWD
)/libsysfs
/dlist.o
194 ifeq ($(strip $(USE_KLIBC
)),true
)
195 OBJS
+= klibc_fixups.o
198 ifeq ($(USE_DBUS
), true
)
200 CFLAGS
+= $(shell pkg-config
--cflags dbus-1
)
201 LDFLAGS
+= $(shell pkg-config
--libs dbus-1
)
205 # header files automatically generated
206 GEN_HEADERS
= udev_version.h
208 # Rules on how to create the generated header files
210 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
211 @echo \
#define UDEV_ROOT \"$(udevdir)/\" >> $@
212 @echo \
#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
213 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
214 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
215 @echo \
#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
216 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
218 # config files automatically generated
219 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
221 # Rules on how to create the generated config files
222 $(LOCAL_CFG_DIR
)/udev.conf
:
223 sed
-e
"s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
226 $(OBJS
): $(GEN_HEADERS
)
228 $(ROOT
): $(OBJS
) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h logging.h list.h
229 $(LD
) $(LDFLAGS
) -o
$(ROOT
) $(CRT0
) $(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
233 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
235 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
)
236 $(MAKE
) -C klibc
clean
237 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
239 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
243 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 )
244 DISTDIR
:= $(RELEASE_NAME
)
247 @echo
"--------------------------cut here------------------------"
249 @echo
"rm -rf $(DISTDIR)"
250 @echo
"mkdir $(DISTDIR)"
251 @echo
"chmod 777 $(DISTDIR)"
252 @echo
"cp -avr udev/* $(DISTDIR)"
253 @echo
"tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
254 @echo
"rm -rf $(DISTDIR)"
255 @echo
"--------------------------cut here------------------------"
258 small_release
: $(DISTFILES
) clean
262 @
-chmod
777 $(DISTDIR
)
263 @for file in
$(DISTFILES
); do \
264 if
test -d
$$file; then \
265 mkdir
$(DISTDIR
)/$$file; \
267 cp
-p
$$file $(DISTDIR
)/$$file; \
270 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
272 @echo
"Built $(RELEASE_NAME).tar.gz"
275 ifeq ($(USE_DBUS
), true
)
277 $(INSTALL
) -d
$(DESTDIR
)$(dbusdir
)
278 $(INSTALL_DATA
) etc
/dbus-1
/system.d
/udev_sysbus_policy.conf
$(DESTDIR
)$(dbusdir
)
280 uninstall-dbus-policy
:
281 - rm $(DESTDIR
)$(dbusdir
)/udev_sysbus_policy.conf
285 uninstall-dbus-policy
:
289 install-config
: $(GEN_CONFIGS
)
290 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)
291 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.conf
]; then \
292 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
293 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
295 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.rules
]; then \
296 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
297 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
299 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.permissions
]; then \
300 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
301 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
304 install: install-config install-dbus-policy
all
305 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
306 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
307 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
308 @if
[ "x$(USE_LSB)" = "xtrue" ]; then \
309 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
310 ln
-s
$(DESTDIR
)$(initdir
)/udev
$(sbin_dir
)/rcudev
; \
312 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
314 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
315 - rm -f
$(DESTDIR
)$(hotplugdir
)/udev.hotplug
316 - ln
-f
-s
$(sbindir
)/$(ROOT
) $(DESTDIR
)$(hotplugdir
)/udev.hotplug
317 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
319 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
323 uninstall: uninstall-dbus-policy
324 - rm $(hotplugdir
)/udev.hotplug
325 - rm $(configdir
)/udev.permissions
326 - rm $(configdir
)/udev.rules
327 - rm $(configdir
)/udev.conf
329 - rm $(mandir)/man8
/udev
.8
330 - rm $(sbindir
)/$(ROOT
)
331 - rmdir
$(hotplugdir
)
334 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
336 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \