]> git.ipfire.org Git - thirdparty/systemd.git/blob - Makefile
[PATCH] finish syncing up with klibc
[thirdparty/systemd.git] / Makefile
1 # Makefile for udev
2 #
3 # Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
4 #
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.
8 #
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.
13 #
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
17 #
18
19 # Set the following to control the use of syslog
20 # Set it to `false' to remove all logging
21 USE_LOG = true
22
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.
26 DEBUG = false
27
28 # Set the following to `true' to make udev emit a D-BUS signal when a
29 # new node is created.
30 USE_DBUS = false
31
32
33 ROOT = udev
34 DAEMON = udevd
35 SENDER = udevsend
36 HELPER = udevinfo
37 VERSION = 016_bk
38 INSTALL_DIR = /usr/local/bin
39 RELEASE_NAME = $(ROOT)-$(VERSION)
40 LOCAL_CFG_DIR = etc/udev
41 HOTPLUG_EXEC = $(ROOT)
42
43 DESTDIR =
44
45 KERNEL_DIR = /lib/modules/${shell uname -r}/build
46
47 # override this to make udev look in a different location for it's config files
48 prefix =
49 exec_prefix = ${prefix}
50 etcdir = ${prefix}/etc
51 sbindir = ${exec_prefix}/sbin
52 mandir = ${prefix}/usr/share/man
53 hotplugdir = ${etcdir}/hotplug.d/default
54 dbusdir = ${etcdir}/dbus-1/system.d
55 configdir = ${etcdir}/udev/
56 initdir = ${etcdir}/init.d/
57 srcdir = .
58
59 INSTALL = /usr/bin/install -c
60 INSTALL_PROGRAM = ${INSTALL}
61 INSTALL_DATA = ${INSTALL} -m 644
62 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
63
64 # To build any of the extras programs, run with:
65 # make EXTRAS="extras/a extras/b"
66 EXTRAS=
67
68 # place to put our device nodes
69 udevdir = ${prefix}/udev
70
71 # Comment out this line to build with something other
72 # than the local version of klibc
73 #USE_KLIBC = true
74
75 # If you are running a cross compiler, you may want to set this
76 # to something more interesting, like "arm-linux-". If you want
77 # to compile vs uClibc, that can be done here as well.
78 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
79 CC = $(CROSS)gcc
80 LD = $(CROSS)gcc
81 AR = $(CROSS)ar
82 STRIP = $(CROSS)strip
83 RANLIB = $(CROSS)ranlib
84
85 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
86
87 # code taken from uClibc to determine the current arch
88 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
89 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
90
91 # code taken from uClibc to determine the gcc include dir
92 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
93
94 # code taken from uClibc to determine the libgcc.a filename
95 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
96
97 # use '-Os' optimization if available, else use -O2
98 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
99 then echo "-Os"; else echo "-O2" ; fi}
100
101 # add -Wredundant-decls when libsysfs gets cleaned up
102 WARNINGS := -Wall
103
104 # Some nice architecture specific optimizations
105 ifeq ($(strip $(TARGET_ARCH)),arm)
106 OPTIMIZATION+=-fstrict-aliasing
107 endif
108 ifeq ($(strip $(TARGET_ARCH)),i386)
109 OPTIMIZATION+=-march=i386
110 OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
111 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
112 OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
113 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
114 CFLAGS+=-pipe
115 else
116 CFLAGS+=-pipe
117 endif
118
119 ifeq ($(strip $(USE_LOG)),true)
120 CFLAGS += -DLOG
121 endif
122
123 # if DEBUG is enabled, then we do not strip or optimize
124 ifeq ($(strip $(DEBUG)),true)
125 CFLAGS += -O1 -g -DDEBUG -D_GNU_SOURCE
126 LDFLAGS += -Wl,-warn-common
127 STRIPCMD = /bin/true -Since_we_are_debugging
128 else
129 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
130 LDFLAGS += -s -Wl,-warn-common
131 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
132 endif
133
134 # If we are using our version of klibc, then we need to build, link it, and then
135 # link udev against it statically.
136 # Otherwise, use glibc and link dynamically.
137 ifeq ($(strip $(USE_KLIBC)),true)
138 KLIBC_BASE = $(PWD)/klibc
139 KLIBC_DIR = $(KLIBC_BASE)/klibc
140 INCLUDE_DIR := $(KLIBC_DIR)/include
141 LINUX_INCLUDE_DIR := $(KERNEL_DIR)/include
142 # LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
143 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
144 # arch specific objects
145 ARCH_LIB_OBJS = \
146 $(KLIBC_DIR)/libc.a
147
148
149 CRT0 = $(KLIBC_DIR)/crt0.o
150 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
151 CFLAGS += $(WARNINGS) -nostdinc \
152 -D__KLIBC__ -fno-builtin-printf \
153 -I$(INCLUDE_DIR) \
154 -I$(KLIBC_DIR)/arch/$(ARCH)/include \
155 -I$(INCLUDE_DIR)/bits$(BITSIZE) \
156 -I$(GCCINCDIR) \
157 -I$(LINUX_INCLUDE_DIR)
158 LIB_OBJS =
159 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
160 UDEVD =
161 else
162 WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
163 CRT0 =
164 LIBC =
165 CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
166 LIB_OBJS = -lc
167 LDFLAGS =
168 UDEVD = $(DAEMON)
169 endif
170
171 CFLAGS += -I$(PWD)/libsysfs
172
173 all: $(ROOT) $(SENDER) $(UDEVD) $(HELPER)
174 @extras="$(EXTRAS)" ; for target in $$extras ; do \
175 echo $$target ; \
176 $(MAKE) prefix=$(prefix) \
177 LD="$(LD)" \
178 SYSFS="$(SYSFS)" \
179 KERNEL_DIR="$(KERNEL_DIR)" \
180 -C $$target $@ ; \
181 done ; \
182
183 $(ROOT): $(LIBC)
184
185 $(ARCH_LIB_OBJS) : $(CRT0)
186
187 $(CRT0):
188 $(MAKE) -C klibc KERNEL_DIR=$(KERNEL_DIR)
189
190 TDB = tdb/tdb.o \
191 tdb/spinlock.o
192
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
200
201 OBJS = udev_config.o \
202 udev-add.o \
203 udev-remove.o \
204 udevdb.o \
205 namedev.o \
206 namedev_parse.o \
207 $(SYSFS) \
208 $(TDB)
209
210 HEADERS = udev.h \
211 namedev.h \
212 udev_version.h \
213 udev_dbus.h \
214 udevdb.h \
215 klibc_fixups.h \
216 logging.h \
217 list.h
218
219 ifeq ($(strip $(USE_KLIBC)),true)
220 OBJS += klibc_fixups.o
221 endif
222
223 ifeq ($(USE_DBUS), true)
224 CFLAGS += -DUSE_DBUS
225 CFLAGS += $(shell pkg-config --cflags dbus-1)
226 LDFLAGS += $(shell pkg-config --libs dbus-1)
227 OBJS += udev_dbus.o
228 endif
229
230 # header files automatically generated
231 GEN_HEADERS = udev_version.h
232
233 # Rules on how to create the generated header files
234 udev_version.h:
235 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
236 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
237 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
238 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
239 @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
240 @echo \#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
241 @echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
242 @echo \#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
243 @echo \#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
244
245 # config files automatically generated
246 GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
247
248 # Rules on how to create the generated config files
249 $(LOCAL_CFG_DIR)/udev.conf:
250 sed -e "s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR)/udev.conf.in > $@
251
252
253 $(OBJS): $(GEN_HEADERS)
254 udev.o: $(GEN_HEADERS)
255
256 $(ROOT): udev.o $(OBJS) $(HEADERS) $(GEN_HEADERS)
257 $(LD) $(LDFLAGS) -o $@ $(CRT0) udev.o $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
258 $(STRIPCMD) $@
259
260 $(HELPER): $(HEADERS) udevinfo.o $(OBJS)
261 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevinfo.o udev_config.o udevdb.o $(SYSFS) $(TDB) $(LIB_OBJS) $(ARCH_LIB_OBJS)
262 $(STRIPCMD) $@
263
264 $(DAEMON): udevd.h $(GEN_HEADERS) udevd.o
265 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevd.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
266 $(STRIPCMD) $@
267
268 $(SENDER): udevd.h $(GEN_HEADERS) udevsend.o
269 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevsend.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
270 $(STRIPCMD) $@
271
272 clean:
273 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
274 | xargs rm -f
275 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(HELPER) $(DAEMON) $(SENDER)
276 $(MAKE) -C klibc clean
277 @extras="$(EXTRAS)" ; for target in $$extras ; do \
278 echo $$target ; \
279 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
280 -C $$target $@ ; \
281 done ; \
282
283 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 )
284 DISTDIR := $(RELEASE_NAME)
285 srcdir = .
286 release: clean
287 @echo "--------------------------cut here------------------------"
288 @echo "cd .."
289 @echo "rm -rf $(DISTDIR)"
290 @echo "mkdir $(DISTDIR)"
291 @echo "chmod 777 $(DISTDIR)"
292 @echo "cp -avr udev/* $(DISTDIR)"
293 @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
294 @echo "rm -rf $(DISTDIR)"
295 @echo "--------------------------cut here------------------------"
296
297
298 small_release: $(DISTFILES) clean
299 # @echo $(DISTFILES)
300 @-rm -rf $(DISTDIR)
301 @mkdir $(DISTDIR)
302 @-chmod 777 $(DISTDIR)
303 @for file in $(DISTFILES); do \
304 if test -d $$file; then \
305 mkdir $(DISTDIR)/$$file; \
306 else \
307 cp -p $$file $(DISTDIR)/$$file; \
308 fi; \
309 done
310 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
311 @rm -rf $(DISTDIR)
312 @echo "Built $(RELEASE_NAME).tar.gz"
313
314
315 ifeq ($(USE_DBUS), true)
316 install-dbus-policy:
317 $(INSTALL) -d $(DESTDIR)$(dbusdir)
318 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
319
320 uninstall-dbus-policy:
321 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
322 else
323 install-dbus-policy:
324 -
325 uninstall-dbus-policy:
326 -
327 endif
328
329 install-config: $(GEN_CONFIGS)
330 $(INSTALL) -d $(DESTDIR)$(configdir)
331 @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
332 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
333 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
334 fi
335 @if [ ! -r $(DESTDIR)$(configdir)udev.rules ]; then \
336 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
337 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
338 fi
339 @if [ ! -r $(DESTDIR)$(configdir)udev.permissions ]; then \
340 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
341 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
342 fi
343
344 install: install-config install-dbus-policy all
345 $(INSTALL) -d $(DESTDIR)$(udevdir)
346 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
347 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
348 $(INSTALL_PROGRAM) -D $(DAEMON) $(DESTDIR)$(sbindir)/$(DAEMON)
349 $(INSTALL_PROGRAM) -D $(SENDER) $(DESTDIR)$(sbindir)/$(SENDER)
350 $(INSTALL_PROGRAM) -D $(HELPER) $(DESTDIR)$(sbindir)/$(HELPER)
351 @if [ "x$(USE_LSB)" = "xtrue" ]; then \
352 $(INSTALL_PROGRAM) -D etc/init.d/udev.init.LSB $(DESTDIR)$(initdir)/udev; \
353 ln -s $(DESTDIR)$(initdir)/udev $(sbindir)/rcudev; \
354 else \
355 $(INSTALL_PROGRAM) -D etc/init.d/udev $(DESTDIR)$(initdir)/udev; \
356 fi
357 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
358 $(INSTALL_DATA) -D udevinfo.8 $(DESTDIR)$(mandir)/man8/udevinfo.8
359 - rm -f $(DESTDIR)$(hotplugdir)/$(ROOT).hotplug
360 - ln -f -s $(sbindir)/$(SENDER) $(DESTDIR)$(hotplugdir)/$(ROOT).hotplug
361 @extras="$(EXTRAS)" ; for target in $$extras ; do \
362 echo $$target ; \
363 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
364 -C $$target $@ ; \
365 done ; \
366
367 uninstall: uninstall-dbus-policy
368 - rm $(hotplugdir)/udev.hotplug
369 - rm $(configdir)/udev.permissions
370 - rm $(configdir)/udev.rules
371 - rm $(configdir)/udev.conf
372 - rm $(initdir)/udev
373 - rm $(mandir)/man8/udev.8
374 - rm $(mandir)/man8/udevinfo.8
375 - rm $(sbindir)/$(ROOT)
376 - rm $(sbindir)/$(DAEMON)
377 - rm $(sbindir)/$(SENDER)
378 - rm $(sbindir)/$(HELPER)
379 - rmdir $(hotplugdir)
380 - rmdir $(configdir)
381 - rmdir $(udevdir)
382 @extras="$(EXTRAS)" ; for target in $$extras ; do \
383 echo $$target ; \
384 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
385 -C $$target $@ ; \
386 done ; \