]> git.ipfire.org Git - thirdparty/systemd.git/blame - Makefile
[PATCH] minor patch for devfs rules
[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
19# Set the following to `true' to make a debuggable build.
20# Leave this set to `false' for production use.
29b82deb 21DEBUG = false
f0083e3d 22
5aebfbcb
DZ
23# Set the following to `true' to make udev emit a D-BUS signal when a
24# new node is created.
66626948 25USE_DBUS = false
5aebfbcb 26
f0083e3d
GKH
27
28ROOT = udev
78812b99 29VERSION = 013_bk
f0083e3d 30INSTALL_DIR = /usr/local/bin
1e7a3f9e 31RELEASE_NAME = $(ROOT)-$(VERSION)
6d88260a 32LOCAL_CFG_DIR = etc/udev
f0083e3d 33
4360a56d 34DESTDIR =
6739707d 35# override this to make udev look in a different location for it's config files
9f53b06a
GKH
36prefix =
37exec_prefix = ${prefix}
38etcdir = ${prefix}/etc
39sbindir = ${exec_prefix}/sbin
40mandir = ${prefix}/usr/share/man
41hotplugdir = ${etcdir}/hotplug.d/default
5aebfbcb 42dbusdir = ${etcdir}/dbus-1/system.d
9f53b06a 43configdir = ${etcdir}/udev/
dbc9b3f3 44initdir = ${etcdir}/init.d/
9f53b06a
GKH
45srcdir = .
46
47INSTALL = /usr/bin/install -c
48INSTALL_PROGRAM = ${INSTALL}
49INSTALL_DATA = ${INSTALL} -m 644
50INSTALL_SCRIPT = ${INSTALL_PROGRAM}
51
eadb1bbc
PM
52# To build any of the extras programs, run with:
53# make EXTRAS="extras/a extras/b"
54EXTRAS=
6739707d
GKH
55
56# place to put our device nodes
18a0d652 57udevdir = ${prefix}/udev
f0083e3d
GKH
58
59# Comment out this line to build with something other
60# than the local version of klibc
66626948 61#USE_KLIBC = true
f0083e3d
GKH
62
63# If you are running a cross compiler, you may want to set this
e64280b8 64# to something more interesting, like "arm-linux-". If you want
f0083e3d
GKH
65# to compile vs uClibc, that can be done here as well.
66CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
67CC = $(CROSS)gcc
74894b53 68LD = $(CROSS)gcc
f0083e3d
GKH
69AR = $(CROSS)ar
70STRIP = $(CROSS)strip
b137e367 71RANLIB = $(CROSS)ranlib
f0083e3d 72
eadb1bbc 73export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
f0083e3d
GKH
74
75# code taken from uClibc to determine the current arch
76ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
bfd8a5d0 77 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
f0083e3d
GKH
78
79# code taken from uClibc to determine the gcc include dir
80GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
81
82# code taken from uClibc to determine the libgcc.a filename
83GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
84
85# use '-Os' optimization if available, else use -O2
86OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
87 then echo "-Os"; else echo "-O2" ; fi}
88
7bfd1a56
GKH
89# add -Wredundant-decls when libsysfs gets cleaned up
90WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
f0083e3d
GKH
91
92# Some nice architecture specific optimizations
93ifeq ($(strip $(TARGET_ARCH)),arm)
94 OPTIMIZATION+=-fstrict-aliasing
95endif
96ifeq ($(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
103else
104 CFLAGS+=-pipe
105endif
106
107# if DEBUG is enabled, then we do not strip or optimize
108ifeq ($(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
112else
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
116endif
117
fb43c2b2
GKH
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.
66626948 121ifeq ($(strip $(USE_KLIBC)),true)
eadb1bbc
PM
122 KLIBC_BASE = $(PWD)/klibc
123 KLIBC_DIR = $(KLIBC_BASE)/klibc
f0083e3d 124 INCLUDE_DIR := $(KLIBC_DIR)/include
eadb1bbc 125 LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
74894b53 126 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
f0083e3d
GKH
127 # arch specific objects
128 ARCH_LIB_OBJS = \
eadb1bbc 129 $(KLIBC_DIR)/libc.a
f0083e3d 130
f0083e3d 131
2d5b6886 132 CRT0 = $(KLIBC_DIR)/crt0.o
74894b53
AB
133 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
134 CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(KLIBC_DIR)/arch/$(ARCH)/include \
eadb1bbc 135 -I$(INCLUDE_DIR)/bits$(BITSIZE) -I$(GCCINCDIR) -I$(LINUX_INCLUDE_DIR) \
68e07a2b 136 -D__KLIBC__ -fno-builtin-printf
2d5b6886 137 LIB_OBJS =
7f2ea6a3 138 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
f0083e3d 139else
2d5b6886 140 CRT0 =
f0083e3d
GKH
141 LIBC =
142 CFLAGS += -I$(GCCINCDIR)
143 LIB_OBJS = -lc
fb43c2b2 144 LDFLAGS =
f0083e3d
GKH
145endif
146
eadb1bbc
PM
147CFLAGS += -I$(PWD)/libsysfs
148
871ea775 149all: $(ROOT)
49cd31b3 150 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
151 echo $$target ; \
152 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
153 -C $$target $@ ; \
154 done ; \
f0083e3d 155
871ea775
PM
156$(ROOT): $(LIBC)
157
158$(ARCH_LIB_OBJS) : $(CRT0)
159
160$(CRT0):
f0083e3d
GKH
161 $(MAKE) -C klibc
162
5c75a3ec
GKH
163TDB = tdb/tdb.o \
164 tdb/spinlock.o
165
eadb1bbc
PM
166SYSFS = $(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
a2822451 173
f0083e3d 174OBJS = udev.o \
e8baccca 175 udev_config.o \
ea733a2f
GKH
176 udev-add.o \
177 udev-remove.o \
a2822451 178 udevdb.o \
2232cac8 179 logging.o \
a2822451 180 namedev.o \
19feb351 181 namedev_parse.o \
5c75a3ec 182 $(SYSFS) \
a2822451 183 $(TDB)
28972fe8 184
66626948 185ifeq ($(strip $(USE_KLIBC)),true)
6a670d61
GKH
186 OBJS += klibc_fixups.o
187endif
188
66626948 189ifeq ($(USE_DBUS), true)
bbd063b5
GKH
190 CFLAGS += -DUSE_DBUS
191 CFLAGS += $(shell pkg-config --cflags dbus-1)
62adf3f7 192 LDFLAGS += $(shell pkg-config --libs dbus-1)
bbd063b5
GKH
193 OBJS += udev_dbus.o
194endif
195
f0083e3d
GKH
196# header files automatically generated
197GEN_HEADERS = udev_version.h
198
199# Rules on how to create the generated header files
200udev_version.h:
6739707d 201 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
18a0d652
OH
202 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
203 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
3836a3c4
GKH
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\" >> $@
f0083e3d 208
71896b56 209# config files automatically generated
6d88260a 210GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
71896b56
GKH
211
212# Rules on how to create the generated config files
6d88260a
GKH
213$(LOCAL_CFG_DIR)/udev.conf:
214 sed -e "s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR)/udev.conf.in > $@
71896b56
GKH
215
216
871ea775 217$(OBJS): $(GEN_HEADERS)
f0083e3d 218
c78cb204 219$(ROOT): $(OBJS) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h list.h
74894b53 220 $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
f0083e3d
GKH
221 $(STRIPCMD) $(ROOT)
222
223clean:
224 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
225 | xargs rm -f
71896b56 226 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS)
f0083e3d 227 $(MAKE) -C klibc clean
49cd31b3 228 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
229 echo $$target ; \
230 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
231 -C $$target $@ ; \
232 done ; \
f0083e3d 233
e64280b8 234DISTFILES = $(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
235DISTDIR := $(RELEASE_NAME)
236srcdir = .
54e3a5d3
GKH
237release: 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
249small_release: $(DISTFILES) clean
f0083e3d
GKH
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"
9f53b06a
GKH
264
265
66626948 266ifeq ($(USE_DBUS), true)
5aebfbcb
DZ
267install-dbus-policy:
268 $(INSTALL) -d $(DESTDIR)$(dbusdir)
8ccd82e0
GKH
269 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
270
5aebfbcb
DZ
271uninstall-dbus-policy:
272 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
273else
274install-dbus-policy:
275 -
276uninstall-dbus-policy:
277 -
278endif
279
7591c18a 280install-config: $(GEN_CONFIGS)
4360a56d 281 $(INSTALL) -d $(DESTDIR)$(configdir)
7591c18a 282 @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
6d88260a
GKH
283 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
284 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
7591c18a
KS
285 fi
286 @if [ ! -r $(DESTDIR)$(configdir)udev.rules ]; then \
6d88260a
GKH
287 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
288 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
7591c18a
KS
289 fi
290 @if [ ! -r $(DESTDIR)$(configdir)udev.permissions ]; then \
6d88260a
GKH
291 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
292 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
7591c18a
KS
293 fi
294
7591c18a
KS
295install: install-config install-dbus-policy all
296 $(INSTALL) -d $(DESTDIR)$(udevdir)
4360a56d
OH
297 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
298 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
e64280b8 299 @if [ "x$(USE_LSB)" = "xtrue" ]; then \
606143c8
KS
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; \
e64280b8 304 fi
4360a56d 305 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
ed839137 306 - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
7591c18a 307 - ln -f -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
49cd31b3 308 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
309 echo $$target ; \
310 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
311 -C $$target $@ ; \
312 done ; \
6785820d 313
5aebfbcb 314uninstall: uninstall-dbus-policy
6785820d 315 - rm $(hotplugdir)/udev.hotplug
d4112087 316 - rm $(configdir)/udev.permissions
e8baccca
GKH
317 - rm $(configdir)/udev.rules
318 - rm $(configdir)/udev.conf
316c5150 319 - rm $(initdir)/udev
6785820d
GKH
320 - rm $(mandir)/man8/udev.8
321 - rm $(sbindir)/$(ROOT)
322 - rmdir $(hotplugdir)
323 - rmdir $(configdir)
324 - rmdir $(udevdir)
49cd31b3 325 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
326 echo $$target ; \
327 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
328 -C $$target $@ ; \
329 done ; \