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