]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - Makefile
[PATCH] move udevinfo into the main build and clean up the main Makefile a bit.
[thirdparty/systemd.git] / Makefile
... / ...
CommitLineData
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
21USE_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.
26DEBUG = false
27
28# Set the following to `true' to make udev emit a D-BUS signal when a
29# new node is created.
30USE_DBUS = false
31
32
33ROOT = udev
34DAEMON = udevd
35SENDER = udevsend
36HELPERS = udevinfo
37VERSION = 014_bk
38INSTALL_DIR = /usr/local/bin
39RELEASE_NAME = $(ROOT)-$(VERSION)
40LOCAL_CFG_DIR = etc/udev
41
42DESTDIR =
43# override this to make udev look in a different location for it's config files
44prefix =
45exec_prefix = ${prefix}
46etcdir = ${prefix}/etc
47sbindir = ${exec_prefix}/sbin
48mandir = ${prefix}/usr/share/man
49hotplugdir = ${etcdir}/hotplug.d/default
50dbusdir = ${etcdir}/dbus-1/system.d
51configdir = ${etcdir}/udev/
52initdir = ${etcdir}/init.d/
53srcdir = .
54
55INSTALL = /usr/bin/install -c
56INSTALL_PROGRAM = ${INSTALL}
57INSTALL_DATA = ${INSTALL} -m 644
58INSTALL_SCRIPT = ${INSTALL_PROGRAM}
59
60# To build any of the extras programs, run with:
61# make EXTRAS="extras/a extras/b"
62EXTRAS=
63
64# place to put our device nodes
65udevdir = ${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.
74CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
75CC = $(CROSS)gcc
76LD = $(CROSS)gcc
77AR = $(CROSS)ar
78STRIP = $(CROSS)strip
79RANLIB = $(CROSS)ranlib
80
81export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
82
83# code taken from uClibc to determine the current arch
84ARCH := ${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
88GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
89
90# code taken from uClibc to determine the libgcc.a filename
91GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
92
93# use '-Os' optimization if available, else use -O2
94OPTIMIZATION := ${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
98WARNINGS := -Wall
99
100# Some nice architecture specific optimizations
101ifeq ($(strip $(TARGET_ARCH)),arm)
102 OPTIMIZATION+=-fstrict-aliasing
103endif
104ifeq ($(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
111else
112 CFLAGS+=-pipe
113endif
114
115ifeq ($(strip $(USE_LOG)),true)
116 CFLAGS += -DLOG
117endif
118
119# if DEBUG is enabled, then we do not strip or optimize
120ifeq ($(strip $(DEBUG)),true)
121 CFLAGS += -O1 -g -DDEBUG -D_GNU_SOURCE
122 LDFLAGS += -Wl,-warn-common
123 STRIPCMD = /bin/true -Since_we_are_debugging
124else
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
128endif
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.
133ifeq ($(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 =
156else
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)
164endif
165
166CFLAGS += -I$(PWD)/libsysfs
167
168all: $(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
182TDB = tdb/tdb.o \
183 tdb/spinlock.o
184
185SYSFS = $(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
193OBJS = 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
203HEADERS = $(GEN_HEADERS) \
204 udev.h \
205 namedev.h \
206 udev_version.h \
207 udev_dbus.h \
208 udevdb.h \
209 klibc_fixups.h \
210 logging.h \
211 list.h
212
213ifeq ($(strip $(USE_KLIBC)),true)
214 OBJS += klibc_fixups.o
215endif
216
217ifeq ($(USE_DBUS), true)
218 CFLAGS += -DUSE_DBUS
219 CFLAGS += $(shell pkg-config --cflags dbus-1)
220 LDFLAGS += $(shell pkg-config --libs dbus-1)
221 OBJS += udev_dbus.o
222endif
223
224# header files automatically generated
225GEN_HEADERS = udev_version.h
226
227# Rules on how to create the generated header files
228udev_version.h:
229 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
230 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
231 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
232 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
233 @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
234 @echo \#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
235 @echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
236
237# config files automatically generated
238GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
239
240# Rules on how to create the generated config files
241$(LOCAL_CFG_DIR)/udev.conf:
242 sed -e "s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR)/udev.conf.in > $@
243
244
245$(OBJS): $(GEN_HEADERS)
246
247$(ROOT): udev.o $(OBJS) $(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 $(OBJS) $(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
263clean:
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
274DISTFILES = $(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 )
275DISTDIR := $(RELEASE_NAME)
276srcdir = .
277release: 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
289small_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
306ifeq ($(USE_DBUS), true)
307install-dbus-policy:
308 $(INSTALL) -d $(DESTDIR)$(dbusdir)
309 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
310
311uninstall-dbus-policy:
312 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
313else
314install-dbus-policy:
315 -
316uninstall-dbus-policy:
317 -
318endif
319
320install-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
335install: 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
354uninstall: 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 ; \