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
/
45 INSTALL
= /usr
/bin
/install -c
46 INSTALL_PROGRAM
= ${INSTALL}
47 INSTALL_DATA
= ${INSTALL} -m
644
48 INSTALL_SCRIPT
= ${INSTALL_PROGRAM}
50 # To build any of the extras programs, run with:
51 # make EXTRAS="extras/a extras/b"
54 # place to put our device nodes
55 udevdir
= ${prefix}/udev
/
57 # Comment out this line to build with something other
58 # than the local version of klibc
61 # If you are running a cross compiler, you may want to set this
62 # to something more interesting, like "arm-linux-". I you want
63 # to compile vs uClibc, that can be done here as well.
64 CROSS
= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
69 RANLIB
= $(CROSS
)ranlib
71 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
73 # code taken from uClibc to determine the current arch
74 ARCH
:= ${shell $(CC
) -dumpmachine | sed
-e s
'/-.*//' -e
's/i.86/i386/' -e
's/sparc.*/sparc/' \
75 -e
's/arm.*/arm/g' -e
's/m68k.*/m68k/' -e
's/powerpc/ppc/g'}
77 # code taken from uClibc to determine the gcc include dir
78 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
80 # code taken from uClibc to determine the libgcc.a filename
81 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
83 # use '-Os' optimization if available, else use -O2
84 OPTIMIZATION
:= ${shell if
$(CC
) -Os
-S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1; \
85 then echo
"-Os"; else echo
"-O2" ; fi
}
87 # add -Wredundant-decls when libsysfs gets cleaned up
88 WARNINGS
:= -Wall
-Wshadow
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
90 # Some nice architecture specific optimizations
91 ifeq ($(strip $(TARGET_ARCH
)),arm
)
92 OPTIMIZATION
+=-fstrict-aliasing
94 ifeq ($(strip $(TARGET_ARCH
)),i386
)
95 OPTIMIZATION
+=-march
=i386
96 OPTIMIZATION
+= ${shell if
$(CC
) -mpreferred-stack-boundary
=2 -S
-o
/dev
/null
-xc \
97 /dev
/null
>/dev
/null
2>&1; then echo
"-mpreferred-stack-boundary=2"; fi
}
98 OPTIMIZATION
+= ${shell if
$(CC
) -malign-functions
=0 -malign-jumps
=0 -S
-o
/dev
/null
-xc \
99 /dev
/null
>/dev
/null
2>&1; then echo
"-malign-functions=0 -malign-jumps=0"; fi
}
105 # if DEBUG is enabled, then we do not strip or optimize
106 ifeq ($(strip $(DEBUG
)),true
)
107 CFLAGS
+= $(WARNINGS
) -O1
-g
-DDEBUG
-D_GNU_SOURCE
108 LDFLAGS
+= -Wl
,-warn-common
109 STRIPCMD
= /bin
/true
-Since_we_are_debugging
111 CFLAGS
+= $(WARNINGS
) $(OPTIMIZATION
) -fomit-frame-pointer
-D_GNU_SOURCE
112 LDFLAGS
+= -s
-Wl
,-warn-common
113 STRIPCMD
= $(STRIP
) -s
--remove-section
=.note
--remove-section
=.comment
116 # If we are using our version of klibc, then we need to build and link it.
117 # Otherwise, use glibc and link statically.
118 ifeq ($(strip $(KLIBC
)),true
)
119 KLIBC_BASE
= $(PWD
)/klibc
120 KLIBC_DIR
= $(KLIBC_BASE
)/klibc
121 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
122 LINUX_INCLUDE_DIR
:= $(KLIBC_BASE
)/linux
/include
123 include $(KLIBC_DIR
)/arch
/$(ARCH
)/MCONFIG
124 # arch specific objects
129 CRT0
= $(KLIBC_DIR
)/crt0.o
130 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
) $(CRT0
)
131 CFLAGS
+= -nostdinc
-I
$(INCLUDE_DIR
) -I
$(KLIBC_DIR
)/arch
/$(ARCH
)/include \
132 -I
$(INCLUDE_DIR
)/bits
$(BITSIZE
) -I
$(GCCINCDIR
) -I
$(LINUX_INCLUDE_DIR
) \
135 LDFLAGS
= --static
--nostdlib
-nostartfiles
-nodefaultlibs
139 CFLAGS
+= -I
$(GCCINCDIR
)
144 CFLAGS
+= -I
$(PWD
)/libsysfs
147 @for target in
$(EXTRAS
) ; do \
149 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
155 $(ARCH_LIB_OBJS
) : $(CRT0
)
163 SYSFS
= $(PWD
)/libsysfs
/sysfs_bus.o \
164 $(PWD
)/libsysfs
/sysfs_class.o \
165 $(PWD
)/libsysfs
/sysfs_device.o \
166 $(PWD
)/libsysfs
/sysfs_dir.o \
167 $(PWD
)/libsysfs
/sysfs_driver.o \
168 $(PWD
)/libsysfs
/sysfs_utils.o \
169 $(PWD
)/libsysfs
/dlist.o
182 ifeq ($(strip $(KLIBC
)),true
)
183 OBJS
+= klibc_fixups.o
188 CFLAGS
+= $(shell pkg-config
--cflags dbus-1
)
189 LDFLAGS
+= $(shell pkg-config
--libs dbus-1
)
193 # header files automatically generated
194 GEN_HEADERS
= udev_version.h
196 # Rules on how to create the generated header files
198 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
199 @echo \
#define UDEV_ROOT \"$(udevdir)\" >> $@
200 @echo \
#define UDEV_DB \"$(udevdir)\.udev.tdb\" >> $@
201 @echo \
#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
202 @echo \
#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
203 @echo \
#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
204 @echo \
#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
206 $(OBJS
): $(GEN_HEADERS
)
209 $(LD
) $(LDFLAGS
) -o
$(ROOT
) $(CRT0
) $(OBJS
) $(LIB_OBJS
) $(ARCH_LIB_OBJS
)
213 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
215 -rm -f core
$(ROOT
) $(GEN_HEADERS
)
216 $(MAKE
) -C klibc
clean
217 @for target in
$(EXTRAS
) ; do \
219 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
223 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 )
224 DISTDIR
:= $(RELEASE_NAME
)
227 @echo
"--------------------------cut here------------------------"
229 @echo
"rm -rf $(DISTDIR)"
230 @echo
"mkdir $(DISTDIR)"
231 @echo
"chmod 777 $(DISTDIR)"
232 @echo
"cp -avr udev/* $(DISTDIR)"
233 @echo
"tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
234 @echo
"rm -rf $(DISTDIR)"
235 @echo
"--------------------------cut here------------------------"
238 small_release
: $(DISTFILES
) clean
242 @
-chmod
777 $(DISTDIR
)
243 @for file in
$(DISTFILES
); do \
244 if
test -d
$$file; then \
245 mkdir
$(DISTDIR
)/$$file; \
247 cp
-p
$$file $(DISTDIR
)/$$file; \
250 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
252 @echo
"Built $(RELEASE_NAME).tar.gz"
257 $(INSTALL
) -d
$(DESTDIR
)$(dbusdir
)
258 $(INSTALL_DATA
) udev_sysbus_policy.conf
$(DESTDIR
)$(dbusdir
)
259 uninstall-dbus-policy
:
260 - rm $(DESTDIR
)$(dbusdir
)/udev_sysbus_policy.conf
264 uninstall-dbus-policy
:
268 install: install-dbus-policy
all
269 $(INSTALL
) -d
$(DESTDIR
)$(udevdir
)
270 $(INSTALL
) -d
$(DESTDIR
)$(configdir
)
271 $(INSTALL
) -d
$(DESTDIR
)$(hotplugdir
)
272 $(INSTALL_PROGRAM
) -D
$(ROOT
) $(DESTDIR
)$(sbindir
)/$(ROOT
)
273 $(INSTALL_DATA
) -D udev
.8 $(DESTDIR
)$(mandir)/man8
/udev
.8
274 $(INSTALL_DATA
) udev.conf
$(DESTDIR
)$(configdir
)
275 $(INSTALL_DATA
) udev.rules
$(DESTDIR
)$(configdir
)
276 $(INSTALL_DATA
) udev.permissions
$(DESTDIR
)$(configdir
)
277 - rm -f
$(DESTDIR
)$(hotplugdir
)/udev.hotplug
278 - ln
-s
$(sbindir
)/$(ROOT
) $(DESTDIR
)$(hotplugdir
)/udev.hotplug
279 @for target in
$(EXTRAS
) ; do \
281 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \
285 uninstall: uninstall-dbus-policy
286 - rm $(hotplugdir
)/udev.hotplug
287 - rm $(configdir
)/udev.permissions
288 - rm $(configdir
)/udev.rules
289 - rm $(configdir
)/udev.conf
290 - rm $(mandir)/man8
/udev
.8
291 - rm $(sbindir
)/$(ROOT
)
292 - rmdir
$(hotplugdir
)
295 @for target in
$(EXTRAS
) ; do \
297 $(MAKE
) prefix=$(prefix) LD
="$(LD)" SYSFS
="$(SYSFS)" \