]> git.ipfire.org Git - thirdparty/systemd.git/blob - Makefile
[PATCH] added a devfs udev config file from Marco d'Itri <md@Linux.IT>
[thirdparty/systemd.git] / Makefile
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 `true' to make a debuggable build.
20 # Leave this set to `false' for production use.
21 DEBUG = false
22
23 # Set the following to `true' to make udev emit a D-BUS signal when a
24 # new node is created.
25 DBUS = false
26
27
28 ROOT = udev
29 VERSION = 008_bk
30 INSTALL_DIR = /usr/local/bin
31 RELEASE_NAME = $(ROOT)-$(VERSION)
32
33 DESTDIR =
34 # override this to make udev look in a different location for it's config files
35 prefix =
36 exec_prefix = ${prefix}
37 etcdir = ${prefix}/etc
38 sbindir = ${exec_prefix}/sbin
39 mandir = ${prefix}/usr/share/man
40 hotplugdir = ${etcdir}/hotplug.d/default
41 dbusdir = ${etcdir}/dbus-1/system.d
42 configdir = ${etcdir}/udev/
43 srcdir = .
44
45 INSTALL = /usr/bin/install -c
46 INSTALL_PROGRAM = ${INSTALL}
47 INSTALL_DATA = ${INSTALL} -m 644
48 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
49
50 # To build any of the extras programs, run with:
51 # make EXTRAS="extras/a extras/b"
52 EXTRAS=
53
54 # place to put our device nodes
55 udevdir = ${prefix}/udev/
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.
64 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
65 CC = $(CROSS)gcc
66 LD = $(CROSS)gcc
67 AR = $(CROSS)ar
68 STRIP = $(CROSS)strip
69 RANLIB = $(CROSS)ranlib
70
71 export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS ARCH_LIB_OBJS CRT0
72
73 # code taken from uClibc to determine the current arch
74 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
75 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
76
77 # code taken from uClibc to determine the gcc include dir
78 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
79
80 # code taken from uClibc to determine the libgcc.a filename
81 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
82
83 # use '-Os' optimization if available, else use -O2
84 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
85 then echo "-Os"; else echo "-O2" ; fi}
86
87 # add -Wredundant-decls when libsysfs gets cleaned up
88 WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
89
90 # Some nice architecture specific optimizations
91 ifeq ($(strip $(TARGET_ARCH)),arm)
92 OPTIMIZATION+=-fstrict-aliasing
93 endif
94 ifeq ($(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
101 else
102 CFLAGS+=-pipe
103 endif
104
105 # if DEBUG is enabled, then we do not strip or optimize
106 ifeq ($(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
110 else
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
114 endif
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.
118 ifeq ($(strip $(KLIBC)),true)
119 KLIBC_BASE = $(PWD)/klibc
120 KLIBC_DIR = $(KLIBC_BASE)/klibc
121 INCLUDE_DIR := $(KLIBC_DIR)/include
122 LINUX_INCLUDE_DIR := $(KLIBC_BASE)/linux/include
123 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
124 # arch specific objects
125 ARCH_LIB_OBJS = \
126 $(KLIBC_DIR)/libc.a
127
128
129 CRT0 = $(KLIBC_DIR)/crt0.o
130 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
131 CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(KLIBC_DIR)/arch/$(ARCH)/include \
132 -I$(INCLUDE_DIR)/bits$(BITSIZE) -I$(GCCINCDIR) -I$(LINUX_INCLUDE_DIR) \
133 -D__KLIBC__
134 LIB_OBJS =
135 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
136 else
137 CRT0 =
138 LIBC =
139 CFLAGS += -I$(GCCINCDIR)
140 LIB_OBJS = -lc
141 LDFLAGS = --static
142 endif
143
144 CFLAGS += -I$(PWD)/libsysfs
145
146 all: $(ROOT)
147 @for target in $(EXTRAS) ; do \
148 echo $$target ; \
149 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
150 -C $$target $@ ; \
151 done ; \
152
153 $(ROOT): $(LIBC)
154
155 $(ARCH_LIB_OBJS) : $(CRT0)
156
157 $(CRT0):
158 $(MAKE) -C klibc
159
160 TDB = tdb/tdb.o \
161 tdb/spinlock.o
162
163 SYSFS = $(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
170
171 OBJS = udev.o \
172 udev_config.o \
173 udev-add.o \
174 udev-remove.o \
175 udevdb.o \
176 logging.o \
177 namedev.o \
178 namedev_parse.o \
179 $(SYSFS) \
180 $(TDB)
181
182 ifeq ($(strip $(KLIBC)),true)
183 OBJS += klibc_fixups.o
184 endif
185
186 ifeq ($(DBUS), true)
187 CFLAGS += -DUSE_DBUS
188 CFLAGS += $(shell pkg-config --cflags dbus-1)
189 LDFLAGS += $(shell pkg-config --libs dbus-1)
190 OBJS += udev_dbus.o
191 endif
192
193 # header files automatically generated
194 GEN_HEADERS = udev_version.h
195
196 # Rules on how to create the generated header files
197 udev_version.h:
198 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
199 @echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
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\" >> $@
205
206 $(OBJS): $(GEN_HEADERS)
207
208 $(ROOT): $(OBJS)
209 $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
210 $(STRIPCMD) $(ROOT)
211
212 clean:
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
217 @for target in $(EXTRAS) ; do \
218 echo $$target ; \
219 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
220 -C $$target $@ ; \
221 done ; \
222
223 DISTFILES = $(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 )
224 DISTDIR := $(RELEASE_NAME)
225 srcdir = .
226 release: 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
238 small_release: $(DISTFILES) clean
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"
253
254
255 ifeq ($(DBUS), true)
256 install-dbus-policy:
257 $(INSTALL) -d $(DESTDIR)$(dbusdir)
258 $(INSTALL_DATA) udev_sysbus_policy.conf $(DESTDIR)$(dbusdir)
259 uninstall-dbus-policy:
260 - rm $(DESTDIR)$(dbusdir)/udev_sysbus_policy.conf
261 else
262 install-dbus-policy:
263 -
264 uninstall-dbus-policy:
265 -
266 endif
267
268 install: install-dbus-policy all
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
274 $(INSTALL_DATA) udev.conf $(DESTDIR)$(configdir)
275 $(INSTALL_DATA) udev.rules $(DESTDIR)$(configdir)
276 $(INSTALL_DATA) udev.permissions $(DESTDIR)$(configdir)
277 - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
278 - ln -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
279 @for target in $(EXTRAS) ; do \
280 echo $$target ; \
281 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
282 -C $$target $@ ; \
283 done ; \
284
285 uninstall: uninstall-dbus-policy
286 - rm $(hotplugdir)/udev.hotplug
287 - rm $(configdir)/udev.permissions
288 - rm $(configdir)/udev.rules
289 - rm $(configdir)/udev.conf
290 - rm $(mandir)/man8/udev.8
291 - rm $(sbindir)/$(ROOT)
292 - rmdir $(hotplugdir)
293 - rmdir $(configdir)
294 - rmdir $(udevdir)
295 @for target in $(EXTRAS) ; do \
296 echo $$target ; \
297 $(MAKE) prefix=$(prefix) LD="$(LD)" SYSFS="$(SYSFS)" \
298 -C $$target $@ ; \
299 done ; \
300
301