chiark / gitweb /
[PATCH] tweak replace_test
[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 `true' to make a debuggable build.
20 # Leave this set to `false' for production use.
21 DEBUG = true
22
23
24 ROOT =          udev
25 VERSION =       005_bk
26 INSTALL_DIR =   /usr/local/bin
27 RELEASE_NAME =  $(ROOT)-$(VERSION)
28
29 DESTDIR =
30 # override this to make udev look in a different location for it's config files
31 prefix =
32 exec_prefix =   ${prefix}
33 etcdir =        ${prefix}/etc
34 sbindir =       ${exec_prefix}/sbin
35 mandir =        ${prefix}/usr/share/man
36 hotplugdir =    ${etcdir}/hotplug.d/default
37 configdir =     ${etcdir}/udev/
38 srcdir = .
39
40 INSTALL = /usr/bin/install -c
41 INSTALL_PROGRAM = ${INSTALL}
42 INSTALL_DATA  = ${INSTALL} -m 644
43 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
44
45
46 # place to put our device nodes
47 udevdir = ${prefix}/udev/
48
49 # Comment out this line to build with something other 
50 # than the local version of klibc
51 #KLIBC = true
52
53 # If you are running a cross compiler, you may want to set this
54 # to something more interesting, like "arm-linux-".  I you want
55 # to compile vs uClibc, that can be done here as well.
56 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
57 CC = $(CROSS)gcc
58 AR = $(CROSS)ar
59 STRIP = $(CROSS)strip
60 RANLIB = $(CROSS)ranlib
61
62 export CROSS CC AR STRIP RANLIB
63
64 # code taken from uClibc to determine the current arch
65 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
66         -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/ppc/powerpc/g'}
67
68 # code taken from uClibc to determine the gcc include dir
69 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
70
71 # code taken from uClibc to determine the libgcc.a filename
72 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
73
74 # use '-Os' optimization if available, else use -O2
75 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
76                 then echo "-Os"; else echo "-O2" ; fi}
77
78 # add -Wredundant-decls when libsysfs gets cleaned up
79 WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
80
81 # Some nice architecture specific optimizations
82 ifeq ($(strip $(TARGET_ARCH)),arm)
83         OPTIMIZATION+=-fstrict-aliasing
84 endif
85 ifeq ($(strip $(TARGET_ARCH)),i386)
86         OPTIMIZATION+=-march=i386
87         OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
88                 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
89         OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
90                 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
91         CFLAGS+=-pipe
92 else
93         CFLAGS+=-pipe
94 endif
95
96 # if DEBUG is enabled, then we do not strip or optimize
97 ifeq ($(strip $(DEBUG)),true)
98         CFLAGS  += $(WARNINGS) -O1 -g -DDEBUG -D_GNU_SOURCE
99         LDFLAGS += -Wl,-warn-common
100         STRIPCMD = /bin/true -Since_we_are_debugging
101 else
102         CFLAGS  += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
103         LDFLAGS += -s -Wl,-warn-common
104         STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
105 endif
106
107 # If we are using our version of klibc, then we need to build and link it.
108 # Otherwise, use glibc and link statically.
109 ifeq ($(strip $(KLIBC)),true)
110         KLIBC_DIR       = klibc/klibc
111         INCLUDE_DIR     := $(KLIBC_DIR)/include
112         # arch specific objects
113         LIBGCC          = $(shell $(CC) --print-libgcc)
114         ARCH_LIB_OBJS = \
115                         $(KLIBC_DIR)/libc.a     \
116                         $(LIBGCC)
117
118
119         CRT0 = $(KLIBC_DIR)/crt0.o
120         LIBC =  $(ARCH_LIB_OBJS) $(LIB_OBJS)
121         CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/bits32 -I$(GCCINCDIR) -Iklibc/linux/include -D__KLIBC__
122         LIB_OBJS =
123         LDFLAGS = --static --nostdlib -nostartfiles
124 else
125         CRT0 =
126         LIBC = 
127         CFLAGS += -I$(GCCINCDIR)
128         LIB_OBJS = -lc
129         LDFLAGS = --static 
130 endif
131
132 all: $(LIBC) $(ROOT)
133
134 $(ARCH_LIB_OBJS) :
135         $(MAKE) -C klibc
136
137 TDB =   tdb/tdb.o       \
138         tdb/spinlock.o
139
140 SYSFS = libsysfs/sysfs_bus.o    \
141         libsysfs/sysfs_class.o  \
142         libsysfs/sysfs_device.o \
143         libsysfs/sysfs_dir.o    \
144         libsysfs/sysfs_driver.o \
145         libsysfs/sysfs_utils.o  \
146         libsysfs/dlist.o
147
148 OBJS =  udev.o          \
149         udev-add.o      \
150         udev-remove.o   \
151         udevdb.o        \
152         logging.o       \
153         namedev.o       \
154         klibc_fixups.o  \
155         $(SYSFS)        \
156         $(TDB)
157
158 # header files automatically generated
159 GEN_HEADERS =   udev_version.h
160
161 # Rules on how to create the generated header files
162 udev_version.h:
163         @echo \#define UDEV_VERSION     \"$(VERSION)\" > $@
164         @echo \#define UDEV_CONFIG_DIR  \"$(configdir)\" >> $@
165         @echo \#define UDEV_ROOT        \"$(udevdir)\" >> $@
166
167
168 $(ROOT): $(GEN_HEADERS) $(OBJS)
169         $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
170         $(STRIPCMD) $(ROOT)
171
172 clean:
173         -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
174          | xargs rm -f 
175         -rm -f core $(ROOT) $(GEN_HEADERS)
176         $(MAKE) -C klibc clean
177
178 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 )
179 DISTDIR := $(RELEASE_NAME)
180 srcdir = .
181 release: clean
182         @echo "--------------------------cut here------------------------"
183         @echo "cd .."
184         @echo "rm -rf $(DISTDIR)"
185         @echo "mkdir $(DISTDIR)"
186         @echo "chmod 777 $(DISTDIR)"
187         @echo "cp -avr udev/* $(DISTDIR)"
188         @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
189         @echo "rm -rf $(DISTDIR)"
190         @echo "--------------------------cut here------------------------"
191
192
193 small_release: $(DISTFILES) clean
194 #       @echo $(DISTFILES)
195         @-rm -rf $(DISTDIR)
196         @mkdir $(DISTDIR)
197         @-chmod 777 $(DISTDIR)
198         @for file in $(DISTFILES); do                   \
199                 if test -d $$file; then                 \
200                         mkdir $(DISTDIR)/$$file;        \
201                 else                                    \
202                         cp -p $$file $(DISTDIR)/$$file; \
203                 fi;                                     \
204         done
205         @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
206         @rm -rf $(DISTDIR)
207         @echo "Built $(RELEASE_NAME).tar.gz"
208
209
210 install: all
211         $(INSTALL) -d $(DESTDIR)$(udevdir)
212         $(INSTALL) -d $(DESTDIR)$(configdir)
213         $(INSTALL) -d $(DESTDIR)$(hotplugdir)
214         $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
215         $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
216         $(INSTALL_DATA) udev.config $(DESTDIR)$(configdir)
217         $(INSTALL_DATA) udev.permissions $(DESTDIR)$(configdir)
218         - rm $(DESTDIR)$(hotplugdir)/udev.hotplug
219         - ln -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
220
221 uninstall:
222         - rm $(hotplugdir)/udev.hotplug
223         - rm $(configdir)/udev.permissions
224         - rm $(configdir)/udev.config
225         - rm $(mandir)/man8/udev.8
226         - rm $(sbindir)/$(ROOT)
227         - rmdir $(hotplugdir)
228         - rmdir $(configdir)
229         - rmdir $(udevdir)
230
231