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