chiark / gitweb /
[PATCH] turn debugging messages off by default.
[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 = false
22
23
24 ROOT =          udev
25 VERSION =       007_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 LD = $(CROSS)gcc
59 AR = $(CROSS)ar
60 STRIP = $(CROSS)strip
61 RANLIB = $(CROSS)ranlib
62
63 export CROSS CC AR STRIP RANLIB
64
65 # code taken from uClibc to determine the current arch
66 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
67         -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
68
69 # code taken from uClibc to determine the gcc include dir
70 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
71
72 # code taken from uClibc to determine the libgcc.a filename
73 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
74
75 # use '-Os' optimization if available, else use -O2
76 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
77                 then echo "-Os"; else echo "-O2" ; fi}
78
79 # add -Wredundant-decls when libsysfs gets cleaned up
80 WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
81
82 # Some nice architecture specific optimizations
83 ifeq ($(strip $(TARGET_ARCH)),arm)
84         OPTIMIZATION+=-fstrict-aliasing
85 endif
86 ifeq ($(strip $(TARGET_ARCH)),i386)
87         OPTIMIZATION+=-march=i386
88         OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
89                 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
90         OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
91                 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
92         CFLAGS+=-pipe
93 else
94         CFLAGS+=-pipe
95 endif
96
97 # if DEBUG is enabled, then we do not strip or optimize
98 ifeq ($(strip $(DEBUG)),true)
99         CFLAGS  += $(WARNINGS) -O1 -g -DDEBUG -D_GNU_SOURCE
100         LDFLAGS += -Wl,-warn-common
101         STRIPCMD = /bin/true -Since_we_are_debugging
102 else
103         CFLAGS  += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
104         LDFLAGS += -s -Wl,-warn-common
105         STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
106 endif
107
108 # If we are using our version of klibc, then we need to build and link it.
109 # Otherwise, use glibc and link statically.
110 ifeq ($(strip $(KLIBC)),true)
111         KLIBC_DIR       = klibc/klibc
112         INCLUDE_DIR     := $(KLIBC_DIR)/include
113         include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
114         # arch specific objects
115         LIBGCC          = $(shell $(CC) --print-libgcc)
116         ARCH_LIB_OBJS = \
117                         $(KLIBC_DIR)/libc.a     \
118                         $(LIBGCC)
119
120
121         CRT0 = $(KLIBC_DIR)/crt0.o
122         LIBC =  $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0)
123         CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(KLIBC_DIR)/arch/$(ARCH)/include \
124                 -I$(INCLUDE_DIR)/bits$(BITSIZE) -I$(GCCINCDIR) -Iklibc/linux/include \
125                 -D__KLIBC__
126         LIB_OBJS =
127         LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
128 else
129         CRT0 =
130         LIBC = 
131         CFLAGS += -I$(GCCINCDIR)
132         LIB_OBJS = -lc
133         LDFLAGS = --static 
134 endif
135
136 all: $(ROOT)
137
138 $(ROOT): $(LIBC)
139
140 $(ARCH_LIB_OBJS) : $(CRT0)
141
142 $(CRT0):
143         $(MAKE) -C klibc
144
145 TDB =   tdb/tdb.o       \
146         tdb/spinlock.o
147
148 SYSFS = libsysfs/sysfs_bus.o    \
149         libsysfs/sysfs_class.o  \
150         libsysfs/sysfs_device.o \
151         libsysfs/sysfs_dir.o    \
152         libsysfs/sysfs_driver.o \
153         libsysfs/sysfs_utils.o  \
154         libsysfs/dlist.o
155
156 OBJS =  udev.o          \
157         udev-add.o      \
158         udev-remove.o   \
159         udevdb.o        \
160         logging.o       \
161         namedev.o       \
162         namedev_parse.o \
163         $(SYSFS)        \
164         $(TDB)
165
166 ifeq ($(strip $(KLIBC)),true)
167         OBJS += klibc_fixups.o
168 endif
169
170 # header files automatically generated
171 GEN_HEADERS =   udev_version.h
172
173 # Rules on how to create the generated header files
174 udev_version.h:
175         @echo \#define UDEV_VERSION     \"$(VERSION)\" > $@
176         @echo \#define UDEV_CONFIG_DIR  \"$(configdir)\" >> $@
177         @echo \#define UDEV_ROOT        \"$(udevdir)\" >> $@
178
179 $(OBJS): $(GEN_HEADERS)
180
181 $(ROOT): $(OBJS)
182         $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
183         $(STRIPCMD) $(ROOT)
184
185 clean:
186         -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
187          | xargs rm -f 
188         -rm -f core $(ROOT) $(GEN_HEADERS)
189         $(MAKE) -C klibc clean
190
191 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 )
192 DISTDIR := $(RELEASE_NAME)
193 srcdir = .
194 release: clean
195         @echo "--------------------------cut here------------------------"
196         @echo "cd .."
197         @echo "rm -rf $(DISTDIR)"
198         @echo "mkdir $(DISTDIR)"
199         @echo "chmod 777 $(DISTDIR)"
200         @echo "cp -avr udev/* $(DISTDIR)"
201         @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
202         @echo "rm -rf $(DISTDIR)"
203         @echo "--------------------------cut here------------------------"
204
205
206 small_release: $(DISTFILES) clean
207 #       @echo $(DISTFILES)
208         @-rm -rf $(DISTDIR)
209         @mkdir $(DISTDIR)
210         @-chmod 777 $(DISTDIR)
211         @for file in $(DISTFILES); do                   \
212                 if test -d $$file; then                 \
213                         mkdir $(DISTDIR)/$$file;        \
214                 else                                    \
215                         cp -p $$file $(DISTDIR)/$$file; \
216                 fi;                                     \
217         done
218         @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
219         @rm -rf $(DISTDIR)
220         @echo "Built $(RELEASE_NAME).tar.gz"
221
222
223 install: all
224         $(INSTALL) -d $(DESTDIR)$(udevdir)
225         $(INSTALL) -d $(DESTDIR)$(configdir)
226         $(INSTALL) -d $(DESTDIR)$(hotplugdir)
227         $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
228         $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
229         $(INSTALL_DATA) udev.config $(DESTDIR)$(configdir)
230         $(INSTALL_DATA) udev.permissions $(DESTDIR)$(configdir)
231         - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
232         - ln -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
233
234 uninstall:
235         - rm $(hotplugdir)/udev.hotplug
236         - rm $(configdir)/udev.permissions
237         - rm $(configdir)/udev.config
238         - rm $(mandir)/man8/udev.8
239         - rm $(sbindir)/$(ROOT)
240         - rmdir $(hotplugdir)
241         - rmdir $(configdir)
242         - rmdir $(udevdir)
243
244