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.
37 INSTALL_DIR
= /usr
/local
/bin
38 RELEASE_NAME
= $(ROOT
)-$(VERSION
)
39 LOCAL_CFG_DIR
= etc
/udev
40 HOTPLUG_EXEC
= $(ROOT
)
44 KERNEL_DIR
= /lib
/modules
/${shell uname
-r
}/build
46 # override this to make udev look in a different location for it's config files
48 exec_prefix = ${prefix}
49 etcdir
= ${prefix}/etc
50 sbindir
= ${exec_prefix}/sbin
51 usrbindir
= ${exec_prefix}/usr
/bin
52 mandir = ${prefix}/usr
/share
/man
53 hotplugdir
= ${etcdir}/hotplug.d
/default
54 configdir
= ${etcdir}/udev
55 initdir
= ${etcdir}/init.d
56 dev_ddir
= ${etcdir}/dev.d
59 INSTALL
= /usr
/bin
/install -c
60 INSTALL_PROGRAM
= ${INSTALL}
61 INSTALL_DATA
= ${INSTALL} -m
644
62 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
64 # To build any of the extras programs, run with:
65 # make EXTRAS="extras/a extras/b"
68 # place to put our device nodes
69 udevdir
= ${prefix}/udev
71 # Comment out this line to build with something other
72 # than the local version of klibc
75 # set up PWD so that older versions of make will work with our build.
78 # If you are running a cross compiler, you may want to set this
79 # to something more interesting, like "arm-linux-". If you want
80 # to compile vs uClibc, that can be done here as well.
81 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
86 RANLIB
= $(CROSS
)ranlib
88 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
90 # code taken from uClibc to determine the current arch
91 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
92 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
94 # code taken from uClibc to determine the gcc include dir
95 GCCINCDIR
:= ${shell LC_ALL
=C
$(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
97 # code taken from uClibc to determine the libgcc.a filename
98 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
100 # use '-Os' optimization if available, else use -O2
101 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
102 then echo
"-Os"; else echo
"-O2" ; fi
}
104 # add -Wredundant-decls when libsysfs gets cleaned up
107 # Some nice architecture specific optimizations
108 ifeq ($(strip $(TARGET_ARCH
)),arm
)
109 OPTIMIZATION
+=-fstrict-aliasing
111 ifeq ($(strip $(TARGET_ARCH
)),i386
)
112 OPTIMIZATION
+=-march
=i386
113 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
114 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
115 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
116 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
117 CFLAGS
+=-pipe
-Dasmlinkage
=__attribute__
((regparm
(0)))
119 CFLAGS
+=-pipe
-Dasmlinkage
=
122 ifeq ($(strip $(USE_LOG
)),true
)
126 # if DEBUG is enabled, then we do not strip or optimize
127 ifeq ($(strip $(DEBUG
)),true
)
128 CFLAGS
+= -O1
-g
-DDEBUG
-D_GNU_SOURCE
129 LDFLAGS
+= -Wl
,-warn-common
130 STRIPCMD
= /bin
/true
-Since_we_are_debugging
132 CFLAGS
+= $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
133 LDFLAGS
+= -s
-Wl
,-warn-common
134 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
137 # If we are using our version of klibc, then we need to build, link it, and then
138 # link udev against it statically.
139 # Otherwise, use glibc and link dynamically.
140 ifeq ($(strip $(USE_KLIBC
)),true
)
141 KLIBC_BASE
= $(PWD
)/klibc
142 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
143 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
144 LINUX_INCLUDE_DIR
:= $(KERNEL_DIR
)/include
145 # LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
146 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
147 # arch specific objects
152 CRT0
= $(KLIBC_DIR
)/crt0.o
153 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
154 CFLAGS
+= $(WARNINGS
) -nostdinc \
156 -D__KLIBC__
-fno-builtin-printf \
158 -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
159 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) \
161 -I
$(LINUX_INCLUDE_DIR
)
163 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
165 WARNINGS
+= -Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
168 CFLAGS
+= $(WARNINGS
) -I
$(GCCINCDIR
)
173 CFLAGS
+= -I
$(PWD
)/libsysfs
175 all: $(ROOT
) $(SENDER
) $(DAEMON
) $(INFO
) $(TESTER
)
176 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
178 $(MAKE
) prefix=$(prefix) \
181 KERNEL_DIR
="$(KERNEL_DIR)" \
185 $(ARCH_LIB_OBJS
) : $(CRT0
)
188 $(MAKE
) -C klibc KERNEL_DIR
=$(KERNEL_DIR
)
193 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
194 $(PWD
)/libsysfs
/sysfs_class.o \
195 $(PWD
)/libsysfs
/sysfs_device.o \
196 $(PWD
)/libsysfs
/sysfs_dir.o \
197 $(PWD
)/libsysfs
/sysfs_driver.o \
198 $(PWD
)/libsysfs
/sysfs_utils.o \
199 $(PWD
)/libsysfs
/dlist.o
221 ifeq ($(strip $(USE_KLIBC
)),true
)
222 OBJS
+= klibc_fixups.o
223 KLIBC_FIXUP
= klibc_fixups.o
226 # header files automatically generated
227 GEN_HEADERS
= udev_version.h
229 # Rules on how to create the generated header files
231 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
232 @echo \
#define UDEV_ROOT \"$(udevdir)/\" >> $@
233 @echo \
#define UDEV_DB \"$(udevdir)/.udev.tdb\" >> $@
234 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
235 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@
236 @echo \
#define UDEV_RULES_FILE \"$(configdir)/rules.d\" >> $@
237 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)/permissions.d\" >> $@
238 @echo \
#define UDEV_LOG_DEFAULT \"yes\" >> $@
239 @echo \
#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
240 @echo \
#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
242 # config files automatically generated
243 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
245 # Rules on how to create the generated config files
246 $(LOCAL_CFG_DIR
)/udev.conf
:
247 sed
-e
"s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
249 GEN_MANPAGES
= udev
.8
250 GEN_MANPAGESIN
= udev
.8.in
251 # Rules on how to create the man pages
252 $(GEN_MANPAGES
): $(GEN_MANPAGESIN
)
253 sed
-e
"s:@udevdir@:$(udevdir):" < $@.in
> $@
256 $(OBJS
): $(GEN_HEADERS
)
257 $(ROOT
).o
: $(GEN_HEADERS
)
258 $(TESTER
).o
: $(GEN_HEADERS
)
259 $(INFO
).o
: $(GEN_HEADERS
)
260 $(DAEMON
).o
: $(GEN_HEADERS
)
261 $(SENDER
).o
: $(GEN_HEADERS
)
262 $(STARTER
).o
: $(GEN_HEADERS
)
264 $(ROOT
): $(ROOT
).o
$(STARTER
).o
$(OBJS
) $(HEADERS
) $(LIBC
) $(GEN_MANPAGES
)
265 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udev.o udevstart.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
268 $(TESTER
): $(TESTER
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
269 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevtest.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
272 $(INFO
): $(INFO
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
273 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevinfo.o udev_lib.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
276 $(DAEMON
): $(DAEMON
).o
$(OBJS
) udevd.h
$(LIBC
)
277 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevd.o udev_lib.o
$(KLIBC_FIXUP
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
280 $(SENDER
): $(SENDER
).o
$(OBJS
) udevd.h
$(LIBC
)
281 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevsend.o udev_lib.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
284 $(RULER
): $(RULER
).o
$(OBJS
) $(HEADERS
) $(LIBC
)
285 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevruler.o udev_lib.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
) -lnewt
289 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
291 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
) $(GEN_MANPAGES
) $(INFO
) $(DAEMON
) $(SENDER
) $(TESTER
) $(RULER
)
292 $(MAKE
) -C klibc
clean
293 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
295 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
300 $(MAKE
) -C klibc spotless
302 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 )
303 DISTDIR
:= $(RELEASE_NAME
)
310 tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
312 @echo
"$(RELEASE_NAME).tar.gz created"
315 small_release
: $(DISTFILES
) clean
319 @
-chmod
777 $(DISTDIR
)
320 @for file in
$(DISTFILES
); do \
321 if
test -d
$$file; then \
322 mkdir
$(DISTDIR
)/$$file; \
324 cp
-p
$$file $(DISTDIR
)/$$file; \
327 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
329 @echo
"Built $(RELEASE_NAME).tar.gz"
332 install-initscript
: etc
/init.d
/udev etc
/init.d
/udev.debian etc
/init.d
/udev.init.LSB
333 @if
[ -f
/etc
/redhat-release
]; then \
334 $(INSTALL_DATA
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
335 elif
[ -f
/etc
/SuSE-release
]; then \
336 $(INSTALL_DATA
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
337 elif
[ -f
/etc
/debian_version
]; then \
338 $(INSTALL_DATA
) -D etc
/init.d
/udev.debian
$(DESTDIR
)$(initdir
)/udev
; \
341 install-config
: $(GEN_CONFIGS
)
342 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)/rules.d
343 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)/permissions.d
344 @if
[ ! -r
$(DESTDIR
)$(configdir
)/udev.conf
]; then \
345 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
346 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
348 @if
[ ! -r
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
]; then \
349 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
; \
350 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
)/rules.d
/50-udev.rules
; \
352 @if
[ ! -r
$(DESTDIR
)$(configdir
)/permissions.d
/50-udev.permissions
]; then \
353 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
)/permissions.d
/50-udev.permissions
; \
354 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
)/permissions.d
/50-udev.permissions
; \
358 $(INSTALL
) -d
$(DESTDIR
)$(dev_ddir
)/default
359 $(INSTALL_PROGRAM
) -D etc
/dev.d
/net
/hotplug.dev
$(DESTDIR
)$(dev_ddir
)/net
/hotplug.dev
362 - rm $(dev_ddir
)/net
/hotplug.dev
363 - rmdir
$(dev_ddir
)/net
364 - rmdir
$(dev_ddir
)/default
368 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
369 $(INSTALL_DATA
) -D udevinfo
.8 $(DESTDIR
)$(mandir)/man8
/udevinfo
.8
370 $(INSTALL_DATA
) -D udevtest
.8 $(DESTDIR
)$(mandir)/man8
/udevtest
.8
371 $(INSTALL_DATA
) -D udevstart
.8 $(DESTDIR
)$(mandir)/man8
/udevstart
.8
372 $(INSTALL_DATA
) -D udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevd
.8
373 - ln
-f
-s udevd
.8 $(DESTDIR
)$(mandir)/man8
/udevsend
.8
376 - rm $(mandir)/man8
/udev
.8
377 - rm $(mandir)/man8
/udevinfo
.8
378 - rm $(mandir)/man8
/udevtest
.8
379 - rm $(mandir)/man8
/udevstart
.8
380 - rm $(mandir)/man8
/udevd
.8
381 - rm $(mandir)/man8
/udevsend
.8
383 install: install-initscript install-config install-man install-dev.d
all
384 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
385 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
386 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
387 $(INSTALL_PROGRAM
) -D
$(DAEMON
) $(DESTDIR
)$(sbindir
)/$(DAEMON
)
388 $(INSTALL_PROGRAM
) -D
$(SENDER
) $(DESTDIR
)$(sbindir
)/$(SENDER
)
389 $(INSTALL_PROGRAM
) -D
$(INFO
) $(DESTDIR
)$(usrbindir
)/$(INFO
)
390 $(INSTALL_PROGRAM
) -D
$(TESTER
) $(DESTDIR
)$(usrbindir
)/$(TESTER
)
391 ln
-sf
$(sbindir
)/udev
$(DESTDIR
)$(sbindir
)/$(STARTER
)
392 - ln
-f
-s
$(sbindir
)/$(SENDER
) $(DESTDIR
)$(hotplugdir
)/10-udev.hotplug
395 - rm -f
$(udevdir
)/.udev.tdb
397 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
399 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
403 uninstall: uninstall-man uninstall-dev.d
404 - rm $(hotplugdir
)/10-udev.hotplug
405 - rm $(configdir
)/rules.d
/50-udev.rules
406 - rm $(configdir
)/permissions.d
/50-udev.permissions
407 - rm $(configdir
)/udev.conf
408 - rmdir
$(configdir
)/rules.d
409 - rmdir
$(configdir
)/permissions.d
412 - rm $(sbindir
)/$(ROOT
)
413 - rm $(sbindir
)/$(DAEMON
)
414 - rm $(sbindir
)/$(SENDER
)
415 - rm $(sbindir
)/$(STARTER
)
416 - rm $(usrbindir
)/$(INFO
)
417 - rm $(usrbindir
)/$(TESTER
)
418 - rmdir
$(hotplugdir
)
419 - rm $(udevdir
)/.udev.tdb
421 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
423 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \