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