]> git.ipfire.org Git - thirdparty/systemd.git/blob - Makefile
[PATCH] compatibility symlinks for udev
[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
29 ROOT = udev
30 DAEMON = udevd
31 SENDER = udevsend
32 INFO = udevinfo
33 TESTER = udevtest
34 STARTER = udevstart
35 RULER = udevruler
36 VERSION = 030
37 INSTALL_DIR = /usr/local/bin
38 RELEASE_NAME = $(ROOT)-$(VERSION)
39 LOCAL_CFG_DIR = etc/udev
40 HOTPLUG_EXEC = $(ROOT)
41
42 DESTDIR =
43
44 KERNEL_DIR = /lib/modules/${shell uname -r}/build
45
46 # override this to make udev look in a different location for it's config files
47 prefix =
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
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 # set up PWD so that older versions of make will work with our build.
76 PWD = $(shell pwd)
77
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-
82 CC = $(CROSS)gcc
83 LD = $(CROSS)gcc
84 AR = $(CROSS)ar
85 STRIP = $(CROSS)strip
86 RANLIB = $(CROSS)ranlib
87
88 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
89
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'}
93
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"}
96
97 # code taken from uClibc to determine the libgcc.a filename
98 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
99
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}
103
104 # add -Wredundant-decls when libsysfs gets cleaned up
105 WARNINGS := -Wall
106
107 # Some nice architecture specific optimizations
108 ifeq ($(strip $(TARGET_ARCH)),arm)
109 OPTIMIZATION+=-fstrict-aliasing
110 endif
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)))
118 else
119 CFLAGS+=-pipe -Dasmlinkage=
120 endif
121
122 ifeq ($(strip $(USE_LOG)),true)
123 CFLAGS += -DLOG
124 endif
125
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
131 else
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
135 endif
136
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
148 ARCH_LIB_OBJS = \
149 $(KLIBC_DIR)/libc.a
150
151
152 CRT0 = $(KLIBC_DIR)/crt0.o
153 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
154 CFLAGS += $(WARNINGS) -nostdinc \
155 $(OPTFLAGS) \
156 -D__KLIBC__ -fno-builtin-printf \
157 -I$(INCLUDE_DIR) \
158 -I$(KLIBC_DIR)/arch/$(ARCH)/include \
159 -I$(INCLUDE_DIR)/bits$(BITSIZE) \
160 -I$(GCCINCDIR) \
161 -I$(LINUX_INCLUDE_DIR)
162 LIB_OBJS =
163 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
164 else
165 WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
166 CRT0 =
167 LIBC =
168 CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
169 LIB_OBJS = -lc
170 LDFLAGS =
171 endif
172
173 CFLAGS += -I$(PWD)/libsysfs
174
175 all: $(ROOT) $(SENDER) $(DAEMON) $(INFO) $(TESTER)
176 @extras="$(EXTRAS)" ; for target in $$extras ; do \
177 echo $$target ; \
178 $(MAKE) prefix=$(prefix) \
179 LD="$(LD)" \
180 SYSFS="$(SYSFS)" \
181 KERNEL_DIR="$(KERNEL_DIR)" \
182 -C $$target $@ ; \
183 done ; \
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_lib.o \
202 udev_config.o \
203 udev-add.o \
204 udev-remove.o \
205 udevdb.o \
206 namedev.o \
207 namedev_parse.o \
208 dev_d.o \
209 $(SYSFS) \
210 $(TDB)
211
212 HEADERS = udev.h \
213 udev_lib.h \
214 namedev.h \
215 udev_version.h \
216 udevdb.h \
217 klibc_fixups.h \
218 logging.h \
219 list.h
220
221 ifeq ($(strip $(USE_KLIBC)),true)
222 OBJS += klibc_fixups.o
223 KLIBC_FIXUP = klibc_fixups.o
224 endif
225
226 # header files automatically generated
227 GEN_HEADERS = udev_version.h
228
229 # Rules on how to create the generated header files
230 udev_version.h:
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\" >> $@
241
242 # config files automatically generated
243 GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
244
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 > $@
248
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 > $@
254
255
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)
263
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)
266 $(STRIPCMD) $@
267
268 $(TESTER): $(TESTER).o $(OBJS) $(HEADERS) $(LIBC)
269 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevtest.o $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
270 $(STRIPCMD) $@
271
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)
274 $(STRIPCMD) $@
275
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)
278 $(STRIPCMD) $@
279
280 $(SENDER): $(SENDER).o $(OBJS) udevd.h $(LIBC)
281 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevsend.o udev_lib.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
282 $(STRIPCMD) $@
283
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
286 $(STRIPCMD) $@
287
288 clean:
289 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
290 | xargs rm -f
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 \
294 echo $$target ; \
295 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
296 -C $$target $@ ; \
297 done ; \
298
299 spotless: clean
300 $(MAKE) -C klibc spotless
301
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)
304 srcdir = .
305 release: clean
306 -rm -rf $(DISTDIR)
307 mkdir $(DISTDIR)
308 chmod 777 $(DISTDIR)
309 bk export $(DISTDIR)
310 tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
311 rm -rf $(DISTDIR)
312 @echo "$(RELEASE_NAME).tar.gz created"
313
314
315 small_release: $(DISTFILES) clean
316 # @echo $(DISTFILES)
317 @-rm -rf $(DISTDIR)
318 @mkdir $(DISTDIR)
319 @-chmod 777 $(DISTDIR)
320 @for file in $(DISTFILES); do \
321 if test -d $$file; then \
322 mkdir $(DISTDIR)/$$file; \
323 else \
324 cp -p $$file $(DISTDIR)/$$file; \
325 fi; \
326 done
327 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
328 @rm -rf $(DISTDIR)
329 @echo "Built $(RELEASE_NAME).tar.gz"
330
331
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; \
339 fi
340
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); \
347 fi
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; \
351 fi
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; \
355 fi
356
357 install-dev.d:
358 $(INSTALL) -d $(DESTDIR)$(dev_ddir)/default
359 $(INSTALL_PROGRAM) -D etc/dev.d/net/hotplug.dev $(DESTDIR)$(dev_ddir)/net/hotplug.dev
360
361 uninstall-dev.d:
362 - rm $(dev_ddir)/net/hotplug.dev
363 - rmdir $(dev_ddir)/net
364 - rmdir $(dev_ddir)/default
365 - rmdir $(dev_ddir)
366
367 install-man:
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
374
375 uninstall-man:
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
382
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
393 ifndef DESTDIR
394 - killall udevd
395 - rm -f $(udevdir)/.udev.tdb
396 endif
397 @extras="$(EXTRAS)" ; for target in $$extras ; do \
398 echo $$target ; \
399 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
400 -C $$target $@ ; \
401 done ; \
402
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
410 - rmdir $(configdir)
411 - rm $(initdir)/udev
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
420 - rmdir $(udevdir)
421 @extras="$(EXTRAS)" ; for target in $$extras ; do \
422 echo $$target ; \
423 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
424 -C $$target $@ ; \
425 done ; \