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