]> git.ipfire.org Git - thirdparty/systemd.git/blob - Makefile
[PATCH] fix udev directory for Debian init script
[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 `true' to make a debuggable build.
20 # Leave this set to `false' for production use.
21 DEBUG = false
22
23 # Set the following to `true' to make udev emit a D-BUS signal when a
24 # new node is created.
25 USE_DBUS = false
26
27
28 ROOT = udev
29 VERSION = 012_bk
30 INSTALL_DIR = /usr/local/bin
31 RELEASE_NAME = $(ROOT)-$(VERSION)
32 LOCAL_CFG_DIR = etc/udev
33
34 DESTDIR =
35 # override this to make udev look in a different location for it's config files
36 prefix =
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/
45 srcdir = .
46
47 INSTALL = /usr/bin/install -c
48 INSTALL_PROGRAM = ${INSTALL}
49 INSTALL_DATA = ${INSTALL} -m 644
50 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
51
52 # To build any of the extras programs, run with:
53 # make EXTRAS="extras/a extras/b"
54 EXTRAS=
55
56 # place to put our device nodes
57 udevdir = ${prefix}/udev
58
59 # Comment out this line to build with something other
60 # than the local version of klibc
61 #USE_KLIBC = true
62
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-
67 CC = $(CROSS)gcc
68 LD = $(CROSS)gcc
69 AR = $(CROSS)ar
70 STRIP = $(CROSS)strip
71 RANLIB = $(CROSS)ranlib
72
73 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
74
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'}
78
79 # code taken from uClibc to determine the gcc include dir
80 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
81
82 # code taken from uClibc to determine the libgcc.a filename
83 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
84
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}
88
89 # add -Wredundant-decls when libsysfs gets cleaned up
90 WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
91
92 # Some nice architecture specific optimizations
93 ifeq ($(strip $(TARGET_ARCH)),arm)
94 OPTIMIZATION+=-fstrict-aliasing
95 endif
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}
102 CFLAGS+=-pipe
103 else
104 CFLAGS+=-pipe
105 endif
106
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
112 else
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
116 endif
117
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
128 ARCH_LIB_OBJS = \
129 $(KLIBC_DIR)/libc.a
130
131
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) \
136 -D__KLIBC__
137 LIB_OBJS =
138 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
139 else
140 CRT0 =
141 LIBC =
142 CFLAGS += -I$(GCCINCDIR)
143 LIB_OBJS = -lc
144 LDFLAGS =
145 endif
146
147 CFLAGS += -I$(PWD)/libsysfs
148
149 all: $(ROOT)
150 @extras="$(EXTRAS)" ; for target in $$extras ; do \
151 echo $$target ; \
152 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
153 -C $$target $@ ; \
154 done ; \
155
156 $(ROOT): $(LIBC)
157
158 $(ARCH_LIB_OBJS) : $(CRT0)
159
160 $(CRT0):
161 $(MAKE) -C klibc
162
163 TDB = tdb/tdb.o \
164 tdb/spinlock.o
165
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
173
174 OBJS = udev.o \
175 udev_config.o \
176 udev-add.o \
177 udev-remove.o \
178 udevdb.o \
179 logging.o \
180 namedev.o \
181 namedev_parse.o \
182 $(SYSFS) \
183 $(TDB)
184
185 ifeq ($(strip $(USE_KLIBC)),true)
186 OBJS += klibc_fixups.o
187 endif
188
189 ifeq ($(USE_DBUS), true)
190 CFLAGS += -DUSE_DBUS
191 CFLAGS += $(shell pkg-config --cflags dbus-1)
192 LDFLAGS += $(shell pkg-config --libs dbus-1)
193 OBJS += udev_dbus.o
194 endif
195
196 # header files automatically generated
197 GEN_HEADERS = udev_version.h
198
199 # Rules on how to create the generated header files
200 udev_version.h:
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\" >> $@
208
209 # config files automatically generated
210 GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
211
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 > $@
215
216
217 $(OBJS): $(GEN_HEADERS)
218
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)
221 $(STRIPCMD) $(ROOT)
222
223 clean:
224 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
225 | xargs rm -f
226 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS)
227 $(MAKE) -C klibc clean
228 @extras="$(EXTRAS)" ; for target in $$extras ; do \
229 echo $$target ; \
230 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
231 -C $$target $@ ; \
232 done ; \
233
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)
236 srcdir = .
237 release: clean
238 @echo "--------------------------cut here------------------------"
239 @echo "cd .."
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------------------------"
247
248
249 small_release: $(DISTFILES) clean
250 # @echo $(DISTFILES)
251 @-rm -rf $(DISTDIR)
252 @mkdir $(DISTDIR)
253 @-chmod 777 $(DISTDIR)
254 @for file in $(DISTFILES); do \
255 if test -d $$file; then \
256 mkdir $(DISTDIR)/$$file; \
257 else \
258 cp -p $$file $(DISTDIR)/$$file; \
259 fi; \
260 done
261 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
262 @rm -rf $(DISTDIR)
263 @echo "Built $(RELEASE_NAME).tar.gz"
264
265
266 ifeq ($(USE_DBUS), true)
267 install-dbus-policy:
268 $(INSTALL) -d $(DESTDIR)$(dbusdir)
269 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
270
271 uninstall-dbus-policy:
272 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
273 else
274 install-dbus-policy:
275 -
276 uninstall-dbus-policy:
277 -
278 endif
279
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); \
285 fi
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); \
289 fi
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); \
293 fi
294
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; \
302 else \
303 $(INSTALL_PROGRAM) -D etc/init.d/udev $(DESTDIR)$(initdir)/udev; \
304 fi
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 \
309 echo $$target ; \
310 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
311 -C $$target $@ ; \
312 done ; \
313
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
319 - rm $(initdir)/udev
320 - rm $(mandir)/man8/udev.8
321 - rm $(sbindir)/$(ROOT)
322 - rmdir $(hotplugdir)
323 - rmdir $(configdir)
324 - rmdir $(udevdir)
325 @extras="$(EXTRAS)" ; for target in $$extras ; do \
326 echo $$target ; \
327 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
328 -C $$target $@ ; \
329 done ; \