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