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
43 # override this to make udev look in a different location for it's config files
45 exec_prefix = ${prefix}
46 etcdir
= ${prefix}/etc
47 sbindir
= ${exec_prefix}/sbin
48 mandir = ${prefix}/usr
/share
/man
49 hotplugdir
= ${etcdir}/hotplug.d
/default
50 dbusdir
= ${etcdir}/dbus-1
/system.d
51 configdir
= ${etcdir}/udev
/
52 initdir
= ${etcdir}/init.d
/
55 INSTALL
= /usr
/bin
/install -c
56 INSTALL_PROGRAM
= ${INSTALL}
57 INSTALL_DATA
= ${INSTALL} -m
644
58 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
60 # To build any of the extras programs, run with:
61 # make EXTRAS="extras/a extras/b"
64 # place to put our device nodes
65 udevdir
= ${prefix}/udev
67 # Comment out this line to build with something other
68 # than the local version of klibc
71 # If you are running a cross compiler, you may want to set this
72 # to something more interesting, like "arm-linux-". If you want
73 # to compile vs uClibc, that can be done here as well.
74 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
79 RANLIB
= $(CROSS
)ranlib
81 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
83 # code taken from uClibc to determine the current arch
84 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
85 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
87 # code taken from uClibc to determine the gcc include dir
88 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
90 # code taken from uClibc to determine the libgcc.a filename
91 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
93 # use '-Os' optimization if available, else use -O2
94 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
95 then echo
"-Os"; else echo
"-O2" ; fi
}
97 # add -Wredundant-decls when libsysfs gets cleaned up
100 # Some nice architecture specific optimizations
101 ifeq ($(strip $(TARGET_ARCH
)),arm
)
102 OPTIMIZATION
+=-fstrict-aliasing
104 ifeq ($(strip $(TARGET_ARCH
)),i386
)
105 OPTIMIZATION
+=-march
=i386
106 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
107 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
108 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
109 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
115 ifeq ($(strip $(USE_LOG
)),true
)
119 # if DEBUG is enabled, then we do not strip or optimize
120 ifeq ($(strip $(DEBUG
)),true
)
121 CFLAGS
+= -O1
-g
-DDEBUG
-D_GNU_SOURCE
122 LDFLAGS
+= -Wl
,-warn-common
123 STRIPCMD
= /bin
/true
-Since_we_are_debugging
125 CFLAGS
+= $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
126 LDFLAGS
+= -s
-Wl
,-warn-common
127 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
130 # If we are using our version of klibc, then we need to build, link it, and then
131 # link udev against it statically.
132 # Otherwise, use glibc and link dynamically.
133 ifeq ($(strip $(USE_KLIBC
)),true
)
134 KLIBC_BASE
= $(PWD
)/klibc
135 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
136 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
137 LINUX_INCLUDE_DIR
:= $(KLIBC_BASE
)/linux
/include
138 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
139 # arch specific objects
144 CRT0
= $(KLIBC_DIR
)/crt0.o
145 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
146 CFLAGS
+= $(WARNINGS
) -nostdinc \
147 -D__KLIBC__
-fno-builtin-printf \
149 -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
150 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) \
152 -I
$(LINUX_INCLUDE_DIR
)
154 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
157 WARNINGS
+= -Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
160 CFLAGS
+= $(WARNINGS
) -I
$(GCCINCDIR
)
163 UDEVD
= $(DAEMON
) $(SENDER
)
166 CFLAGS
+= -I
$(PWD
)/libsysfs
168 all: $(ROOT
) $(UDEVD
) $(HELPERS
)
169 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
171 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
177 $(ARCH_LIB_OBJS
) : $(CRT0
)
185 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
186 $(PWD
)/libsysfs
/sysfs_class.o \
187 $(PWD
)/libsysfs
/sysfs_device.o \
188 $(PWD
)/libsysfs
/sysfs_dir.o \
189 $(PWD
)/libsysfs
/sysfs_driver.o \
190 $(PWD
)/libsysfs
/sysfs_utils.o \
191 $(PWD
)/libsysfs
/dlist.o
193 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\" >> $@
236 # config files automatically generated
237 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
239 # Rules on how to create the generated config files
240 $(LOCAL_CFG_DIR
)/udev.conf
:
241 sed
-e
"s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
244 $(OBJS
): $(GEN_HEADERS
)
245 udev.o
: $(GEN_HEADERS
)
247 $(ROOT
): udev.o
$(OBJS
) $(HEADERS
) $(GEN_HEADERS
)
248 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udev.o
$(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
251 $(HELPERS
): udevinfo.o
$(OBJS
) $(HEADERS
)
252 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevinfo.o logging.o udev_config.o udevdb.o
$(SYSFS
) $(TDB
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
255 $(DAEMON
): udevd.h udevd.o udevd.o logging.o
256 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevd.o logging.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
259 $(SENDER
): udevd.h udevsend.o udevd.o logging.o
260 $(LD
) $(LDFLAGS
) -o
$@
$(CRT0
) udevsend.o logging.o
$(LIB_OBJS
) $(ARCH_LIB_OBJS
)
264 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
266 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
) $(DAEMON
) $(SENDER
)
267 $(MAKE
) -C klibc
clean
268 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
270 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
274 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 )
275 DISTDIR
:= $(RELEASE_NAME
)
278 @echo
"--------------------------cut here------------------------"
280 @echo
"rm -rf $(DISTDIR)"
281 @echo
"mkdir $(DISTDIR)"
282 @echo
"chmod 777 $(DISTDIR)"
283 @echo
"cp -avr udev/* $(DISTDIR)"
284 @echo
"tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
285 @echo
"rm -rf $(DISTDIR)"
286 @echo
"--------------------------cut here------------------------"
289 small_release
: $(DISTFILES
) clean
293 @
-chmod
777 $(DISTDIR
)
294 @for file in
$(DISTFILES
); do \
295 if
test -d
$$file; then \
296 mkdir
$(DISTDIR
)/$$file; \
298 cp
-p
$$file $(DISTDIR
)/$$file; \
301 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
303 @echo
"Built $(RELEASE_NAME).tar.gz"
306 ifeq ($(USE_DBUS
), true
)
308 $(INSTALL
) -d
$(DESTDIR
)$(dbusdir
)
309 $(INSTALL_DATA
) etc
/dbus-1
/system.d
/udev_sysbus_policy.conf
$(DESTDIR
)$(dbusdir
)
311 uninstall-dbus-policy
:
312 - rm $(DESTDIR
)$(dbusdir
)/udev_sysbus_policy.conf
316 uninstall-dbus-policy
:
320 install-config
: $(GEN_CONFIGS
)
321 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)
322 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.conf
]; then \
323 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
324 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
326 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.rules
]; then \
327 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
328 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
330 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.permissions
]; then \
331 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
332 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
335 install: install-config install-dbus-policy
all
336 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
337 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
338 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
339 @if
[ "x$(USE_LSB)" = "xtrue" ]; then \
340 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
341 ln
-s
$(DESTDIR
)$(initdir
)/udev
$(sbin_dir
)/rcudev
; \
343 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
345 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
346 - rm -f
$(DESTDIR
)$(hotplugdir
)/udev.hotplug
347 - ln
-f
-s
$(sbindir
)/$(ROOT
) $(DESTDIR
)$(hotplugdir
)/udev.hotplug
348 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
350 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
354 uninstall: uninstall-dbus-policy
355 - rm $(hotplugdir
)/udev.hotplug
356 - rm $(configdir
)/udev.permissions
357 - rm $(configdir
)/udev.rules
358 - rm $(configdir
)/udev.conf
360 - rm $(mandir)/man8
/udev
.8
361 - rm $(sbindir
)/$(ROOT
)
362 - rmdir
$(hotplugdir
)
365 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
367 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \