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
)
32 LOCAL_CFG_DIR
= etc
/udev
35 # override this to make udev look in a different location for it's config files
37 exec_prefix = ${prefix}
38 etcdir
= ${prefix}/etc
39 sbindir
= ${exec_prefix}/sbin
40 mandir = ${prefix}/usr
/share
/man
41 hotplugdir
= ${etcdir}/hotplug.d
/default
42 dbusdir
= ${etcdir}/dbus-1
/system.d
43 configdir
= ${etcdir}/udev
/
44 initdir
= ${etcdir}/init.d
/
47 INSTALL
= /usr
/bin
/install -c
48 INSTALL_PROGRAM
= ${INSTALL}
49 INSTALL_DATA
= ${INSTALL} -m
644
50 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
52 # To build any of the extras programs, run with:
53 # make EXTRAS="extras/a extras/b"
56 # place to put our device nodes
57 udevdir
= ${prefix}/udev
59 # Comment out this line to build with something other
60 # than the local version of klibc
63 # If you are running a cross compiler, you may want to set this
64 # to something more interesting, like "arm-linux-". If you want
65 # to compile vs uClibc, that can be done here as well.
66 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
71 RANLIB
= $(CROSS
)ranlib
73 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
75 # code taken from uClibc to determine the current arch
76 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
77 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
79 # code taken from uClibc to determine the gcc include dir
80 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
82 # code taken from uClibc to determine the libgcc.a filename
83 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
85 # use '-Os' optimization if available, else use -O2
86 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
87 then echo
"-Os"; else echo
"-O2" ; fi
}
89 # add -Wredundant-decls when libsysfs gets cleaned up
90 WARNINGS
:= -Wall
-Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
92 # Some nice architecture specific optimizations
93 ifeq ($(strip $(TARGET_ARCH
)),arm
)
94 OPTIMIZATION
+=-fstrict-aliasing
96 ifeq ($(strip $(TARGET_ARCH
)),i386
)
97 OPTIMIZATION
+=-march
=i386
98 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
99 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
100 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
101 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
107 # if DEBUG is enabled, then we do not strip or optimize
108 ifeq ($(strip $(DEBUG
)),true
)
109 CFLAGS
+= $(WARNINGS
) -O1
-g
-DDEBUG
-D_GNU_SOURCE
110 LDFLAGS
+= -Wl
,-warn-common
111 STRIPCMD
= /bin
/true
-Since_we_are_debugging
113 CFLAGS
+= $(WARNINGS
) $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
114 LDFLAGS
+= -s
-Wl
,-warn-common
115 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
118 # If we are using our version of klibc, then we need to build, link it, and then
119 # link udev against it statically.
120 # Otherwise, use glibc and link dynamically.
121 ifeq ($(strip $(USE_KLIBC
)),true
)
122 KLIBC_BASE
= $(PWD
)/klibc
123 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
124 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
125 LINUX_INCLUDE_DIR
:= $(KLIBC_BASE
)/linux
/include
126 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
127 # arch specific objects
132 CRT0
= $(KLIBC_DIR
)/crt0.o
133 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
134 CFLAGS
+= -nostdinc
-I
$(INCLUDE_DIR
) -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
135 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) -I
$(GCCINCDIR
) -I
$(LINUX_INCLUDE_DIR
) \
138 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
142 CFLAGS
+= -I
$(GCCINCDIR
)
147 CFLAGS
+= -I
$(PWD
)/libsysfs
150 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
152 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
158 $(ARCH_LIB_OBJS
) : $(CRT0
)
166 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
167 $(PWD
)/libsysfs
/sysfs_class.o \
168 $(PWD
)/libsysfs
/sysfs_device.o \
169 $(PWD
)/libsysfs
/sysfs_dir.o \
170 $(PWD
)/libsysfs
/sysfs_driver.o \
171 $(PWD
)/libsysfs
/sysfs_utils.o \
172 $(PWD
)/libsysfs
/dlist.o
185 ifeq ($(strip $(USE_KLIBC
)),true
)
186 OBJS
+= klibc_fixups.o
189 ifeq ($(USE_DBUS
), true
)
191 CFLAGS
+= $(shell pkg-config
--cflags dbus-1
)
192 LDFLAGS
+= $(shell pkg-config
--libs dbus-1
)
196 # header files automatically generated
197 GEN_HEADERS
= udev_version.h
199 # Rules on how to create the generated header files
201 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
202 @echo \
#define UDEV_ROOT \"$(udevdir)/\" >> $@
203 @echo \
#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
204 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
205 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
206 @echo \
#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
207 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
209 # config files automatically generated
210 GEN_CONFIGS
= $(LOCAL_CFG_DIR
)/udev.conf
212 # Rules on how to create the generated config files
213 $(LOCAL_CFG_DIR
)/udev.conf
:
214 sed
-e
"s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR
)/udev.conf.in
> $@
217 $(OBJS
): $(GEN_HEADERS
)
219 $(ROOT
): $(OBJS
) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h list.h
220 $(LD
) $(LDFLAGS
) -o
$(ROOT
) $(CRT0
) $(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
224 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
226 -rm -f core
$(ROOT
) $(GEN_HEADERS
) $(GEN_CONFIGS
)
227 $(MAKE
) -C klibc
clean
228 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
230 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
234 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 )
235 DISTDIR
:= $(RELEASE_NAME
)
238 @echo
"--------------------------cut here------------------------"
240 @echo
"rm -rf $(DISTDIR)"
241 @echo
"mkdir $(DISTDIR)"
242 @echo
"chmod 777 $(DISTDIR)"
243 @echo
"cp -avr udev/* $(DISTDIR)"
244 @echo
"tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
245 @echo
"rm -rf $(DISTDIR)"
246 @echo
"--------------------------cut here------------------------"
249 small_release
: $(DISTFILES
) clean
253 @
-chmod
777 $(DISTDIR
)
254 @for file in
$(DISTFILES
); do \
255 if
test -d
$$file; then \
256 mkdir
$(DISTDIR
)/$$file; \
258 cp
-p
$$file $(DISTDIR
)/$$file; \
261 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
263 @echo
"Built $(RELEASE_NAME).tar.gz"
266 ifeq ($(USE_DBUS
), true
)
268 $(INSTALL
) -d
$(DESTDIR
)$(dbusdir
)
269 $(INSTALL_DATA
) etc
/dbus-1
/system.d
/udev_sysbus_policy.conf
$(DESTDIR
)$(dbusdir
)
271 uninstall-dbus-policy
:
272 - rm $(DESTDIR
)$(dbusdir
)/udev_sysbus_policy.conf
276 uninstall-dbus-policy
:
280 install-config
: $(GEN_CONFIGS
)
281 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)
282 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.conf
]; then \
283 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
284 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.conf
$(DESTDIR
)$(configdir
); \
286 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.rules
]; then \
287 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
288 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.rules
$(DESTDIR
)$(configdir
); \
290 @if
[ ! -r
$(DESTDIR
)$(configdir
)udev.permissions
]; then \
291 echo
$(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/udev.permissions
$(DESTDIR
)$(configdir
); \
292 $(INSTALL_DATA
) $(LOCAL_CFG_DIR
)/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 @if
[ "x$(USE_LSB)" = "xtrue" ]; then \
300 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev.init.LSB
$(DESTDIR
)$(initdir
)/udev
; \
301 ln
-s
$(DESTDIR
)$(initdir
)/udev
$(sbin_dir
)/rcudev
; \
303 $(INSTALL_PROGRAM
) -D etc
/init.d
/udev
$(DESTDIR
)$(initdir
)/udev
; \
305 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
306 - rm -f
$(DESTDIR
)$(hotplugdir
)/udev.hotplug
307 - ln
-f
-s
$(sbindir
)/$(ROOT
) $(DESTDIR
)$(hotplugdir
)/udev.hotplug
308 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
310 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
314 uninstall: uninstall-dbus-policy
315 - rm $(hotplugdir
)/udev.hotplug
316 - rm $(configdir
)/udev.permissions
317 - rm $(configdir
)/udev.rules
318 - rm $(configdir
)/udev.conf
320 - rm $(mandir)/man8
/udev
.8
321 - rm $(sbindir
)/$(ROOT
)
322 - rmdir
$(hotplugdir
)
325 @extras
="$(EXTRAS)" ; for target in
$$extras ; do \
327 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \