]> git.ipfire.org Git - thirdparty/systemd.git/blame - Makefile
[PATCH] move udevinfo into the main build and clean up the main Makefile a bit.
[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
869fc2f1 36HELPERS = udevinfo
bb513a06 37VERSION = 014_bk
f0083e3d 38INSTALL_DIR = /usr/local/bin
1e7a3f9e 39RELEASE_NAME = $(ROOT)-$(VERSION)
6d88260a 40LOCAL_CFG_DIR = etc/udev
f0083e3d 41
4360a56d 42DESTDIR =
6739707d 43# override this to make udev look in a different location for it's config files
9f53b06a
GKH
44prefix =
45exec_prefix = ${prefix}
46etcdir = ${prefix}/etc
47sbindir = ${exec_prefix}/sbin
48mandir = ${prefix}/usr/share/man
49hotplugdir = ${etcdir}/hotplug.d/default
5aebfbcb 50dbusdir = ${etcdir}/dbus-1/system.d
9f53b06a 51configdir = ${etcdir}/udev/
dbc9b3f3 52initdir = ${etcdir}/init.d/
9f53b06a
GKH
53srcdir = .
54
55INSTALL = /usr/bin/install -c
56INSTALL_PROGRAM = ${INSTALL}
57INSTALL_DATA = ${INSTALL} -m 644
58INSTALL_SCRIPT = ${INSTALL_PROGRAM}
59
eadb1bbc
PM
60# To build any of the extras programs, run with:
61# make EXTRAS="extras/a extras/b"
62EXTRAS=
6739707d
GKH
63
64# place to put our device nodes
18a0d652 65udevdir = ${prefix}/udev
f0083e3d
GKH
66
67# Comment out this line to build with something other
68# than the local version of klibc
66626948 69#USE_KLIBC = true
f0083e3d
GKH
70
71# If you are running a cross compiler, you may want to set this
e64280b8 72# to something more interesting, like "arm-linux-". If you want
f0083e3d
GKH
73# to compile vs uClibc, that can be done here as well.
74CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
75CC = $(CROSS)gcc
74894b53 76LD = $(CROSS)gcc
f0083e3d
GKH
77AR = $(CROSS)ar
78STRIP = $(CROSS)strip
b137e367 79RANLIB = $(CROSS)ranlib
f0083e3d 80
eadb1bbc 81export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
f0083e3d
GKH
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/' \
bfd8a5d0 85 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
f0083e3d
GKH
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
7bfd1a56 97# add -Wredundant-decls when libsysfs gets cleaned up
eea34a0e 98WARNINGS := -Wall
f0083e3d
GKH
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
05230184 115ifeq ($(strip $(USE_LOG)),true)
54988802
KS
116 CFLAGS += -DLOG
117endif
118
f0083e3d
GKH
119# if DEBUG is enabled, then we do not strip or optimize
120ifeq ($(strip $(DEBUG)),true)
eea34a0e 121 CFLAGS += -O1 -g -DDEBUG -D_GNU_SOURCE
f0083e3d
GKH
122 LDFLAGS += -Wl,-warn-common
123 STRIPCMD = /bin/true -Since_we_are_debugging
124else
eea34a0e 125 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
f0083e3d
GKH
126 LDFLAGS += -s -Wl,-warn-common
127 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
128endif
129
fb43c2b2
GKH
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.
66626948 133ifeq ($(strip $(USE_KLIBC)),true)
eadb1bbc
PM
134 KLIBC_BASE = $(PWD)/klibc
135 KLIBC_DIR = $(KLIBC_BASE)/klibc
f0083e3d 136 INCLUDE_DIR := $(KLIBC_DIR)/include
eadb1bbc 137 LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
74894b53 138 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
f0083e3d
GKH
139 # arch specific objects
140 ARCH_LIB_OBJS = \
eadb1bbc 141 $(KLIBC_DIR)/libc.a
f0083e3d 142
f0083e3d 143
2d5b6886 144 CRT0 = $(KLIBC_DIR)/crt0.o
74894b53 145 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
eea34a0e
GKH
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)
2d5b6886 153 LIB_OBJS =
7f2ea6a3 154 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
a695feae 155 UDEVD =
f0083e3d 156else
eea34a0e 157 WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
2d5b6886 158 CRT0 =
f0083e3d 159 LIBC =
eea34a0e 160 CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
f0083e3d 161 LIB_OBJS = -lc
fb43c2b2 162 LDFLAGS =
a695feae 163 UDEVD = $(DAEMON) $(SENDER)
f0083e3d
GKH
164endif
165
eadb1bbc
PM
166CFLAGS += -I$(PWD)/libsysfs
167
869fc2f1 168all: $(ROOT) $(UDEVD) $(HELPERS)
49cd31b3 169 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
170 echo $$target ; \
171 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
172 -C $$target $@ ; \
173 done ; \
f0083e3d 174
871ea775
PM
175$(ROOT): $(LIBC)
176
177$(ARCH_LIB_OBJS) : $(CRT0)
178
179$(CRT0):
f0083e3d
GKH
180 $(MAKE) -C klibc
181
5c75a3ec
GKH
182TDB = tdb/tdb.o \
183 tdb/spinlock.o
184
eadb1bbc
PM
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
a2822451 192
869fc2f1 193OBJS = udev_config.o \
ea733a2f
GKH
194 udev-add.o \
195 udev-remove.o \
a2822451 196 udevdb.o \
2232cac8 197 logging.o \
a2822451 198 namedev.o \
19feb351 199 namedev_parse.o \
5c75a3ec 200 $(SYSFS) \
a2822451 201 $(TDB)
28972fe8 202
869fc2f1
GKH
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
66626948 213ifeq ($(strip $(USE_KLIBC)),true)
6a670d61
GKH
214 OBJS += klibc_fixups.o
215endif
216
66626948 217ifeq ($(USE_DBUS), true)
bbd063b5
GKH
218 CFLAGS += -DUSE_DBUS
219 CFLAGS += $(shell pkg-config --cflags dbus-1)
62adf3f7 220 LDFLAGS += $(shell pkg-config --libs dbus-1)
bbd063b5
GKH
221 OBJS += udev_dbus.o
222endif
223
f0083e3d
GKH
224# header files automatically generated
225GEN_HEADERS = udev_version.h
226
227# Rules on how to create the generated header files
228udev_version.h:
6739707d 229 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
18a0d652
OH
230 @echo \#define UDEV_ROOT \"$(udevdir)/\" >> $@
231 @echo \#define UDEV_DB \"$(udevdir)/\.udev.tdb\" >> $@
3836a3c4
GKH
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\" >> $@
f0083e3d 236
71896b56 237# config files automatically generated
6d88260a 238GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
71896b56
GKH
239
240# Rules on how to create the generated config files
6d88260a
GKH
241$(LOCAL_CFG_DIR)/udev.conf:
242 sed -e "s:@udevdir@:$(udevdir):" < $(LOCAL_CFG_DIR)/udev.conf.in > $@
71896b56
GKH
243
244
871ea775 245$(OBJS): $(GEN_HEADERS)
f0083e3d 246
869fc2f1
GKH
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) $@
f0083e3d 254
a695feae 255$(DAEMON): udevd.h udevd.o udevd.o logging.o
869fc2f1
GKH
256 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevd.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
257 $(STRIPCMD) $@
7fafc032 258
a695feae 259$(SENDER): udevd.h udevsend.o udevd.o logging.o
869fc2f1
GKH
260 $(LD) $(LDFLAGS) -o $@ $(CRT0) udevsend.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
261 $(STRIPCMD) $@
7fafc032 262
f0083e3d
GKH
263clean:
264 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
265 | xargs rm -f
7fafc032 266 -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(DAEMON) $(SENDER)
f0083e3d 267 $(MAKE) -C klibc clean
49cd31b3 268 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
269 echo $$target ; \
270 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
271 -C $$target $@ ; \
272 done ; \
f0083e3d 273
e64280b8 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 )
f0083e3d
GKH
275DISTDIR := $(RELEASE_NAME)
276srcdir = .
54e3a5d3
GKH
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
f0083e3d
GKH
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"
9f53b06a
GKH
304
305
66626948 306ifeq ($(USE_DBUS), true)
5aebfbcb
DZ
307install-dbus-policy:
308 $(INSTALL) -d $(DESTDIR)$(dbusdir)
8ccd82e0
GKH
309 $(INSTALL_DATA) etc/dbus-1/system.d/udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
310
5aebfbcb
DZ
311uninstall-dbus-policy:
312 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
313else
314install-dbus-policy:
315 -
316uninstall-dbus-policy:
317 -
318endif
319
7591c18a 320install-config: $(GEN_CONFIGS)
4360a56d 321 $(INSTALL) -d $(DESTDIR)$(configdir)
7591c18a 322 @if [ ! -r $(DESTDIR)$(configdir)udev.conf ]; then \
6d88260a
GKH
323 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
324 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.conf $(DESTDIR)$(configdir); \
7591c18a
KS
325 fi
326 @if [ ! -r $(DESTDIR)$(configdir)udev.rules ]; then \
6d88260a
GKH
327 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
328 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.rules $(DESTDIR)$(configdir); \
7591c18a
KS
329 fi
330 @if [ ! -r $(DESTDIR)$(configdir)udev.permissions ]; then \
6d88260a
GKH
331 echo $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
332 $(INSTALL_DATA) $(LOCAL_CFG_DIR)/udev.permissions $(DESTDIR)$(configdir); \
7591c18a
KS
333 fi
334
7591c18a
KS
335install: install-config install-dbus-policy all
336 $(INSTALL) -d $(DESTDIR)$(udevdir)
4360a56d
OH
337 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
338 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
e64280b8 339 @if [ "x$(USE_LSB)" = "xtrue" ]; then \
606143c8
KS
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; \
e64280b8 344 fi
4360a56d 345 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
ed839137 346 - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
7591c18a 347 - ln -f -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
49cd31b3 348 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
349 echo $$target ; \
350 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
351 -C $$target $@ ; \
352 done ; \
6785820d 353
5aebfbcb 354uninstall: uninstall-dbus-policy
6785820d 355 - rm $(hotplugdir)/udev.hotplug
d4112087 356 - rm $(configdir)/udev.permissions
e8baccca
GKH
357 - rm $(configdir)/udev.rules
358 - rm $(configdir)/udev.conf
316c5150 359 - rm $(initdir)/udev
6785820d
GKH
360 - rm $(mandir)/man8/udev.8
361 - rm $(sbindir)/$(ROOT)
362 - rmdir $(hotplugdir)
363 - rmdir $(configdir)
364 - rmdir $(udevdir)
49cd31b3 365 @extras="$(EXTRAS)" ; for target in $$extras ; do \
eadb1bbc
PM
366 echo $$target ; \
367 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
368 -C $$target $@ ; \
369 done ; \