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