]> git.ipfire.org Git - thirdparty/systemd.git/blame - Makefile.klibc
[PATCH] add some documentation for the %b modifier to the default config file.
[thirdparty/systemd.git] / Makefile.klibc
CommitLineData
bb27dd9b 1# Makefile for udev
fe300433 2#
bb27dd9b 3# Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
fe300433
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.
38ebdcac 21DEBUG = true
fe300433
GKH
22
23
24ROOT = udev
8519ed1a 25VERSION = 005_bk
fe300433
GKH
26INSTALL_DIR = /usr/local/bin
27RELEASE_NAME = $(ROOT)-$(VERSION)
28
bb27dd9b
GKH
29# override this to make udev look in a different location for it's config files
30prefix =
31exec_prefix = ${prefix}
32etcdir = ${prefix}/etc
33sbindir = ${exec_prefix}/sbin
34mandir = ${prefix}/usr/share/man
35hotplugdir = ${etcdir}/hotplug.d/default
36configdir = ${etcdir}/udev/
37srcdir = .
38
39INSTALL = /usr/bin/install -c
40INSTALL_PROGRAM = ${INSTALL}
41INSTALL_DATA = ${INSTALL} -m 644
42INSTALL_SCRIPT = ${INSTALL_PROGRAM}
43
44
45# place to put our device nodes
46udevdir = ${prefix}/udev/
fe300433
GKH
47
48# Comment out this line to build with something other
49# than the local version of klibc
50KLIBC = 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.
55CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
56CC = $(CROSS)gcc
57AR = $(CROSS)ar
58STRIP = $(CROSS)strip
bb27dd9b 59RANLIB = $(CROSS)ranlib
fe300433 60
bb27dd9b 61export CROSS CC AR STRIP RANLIB
fe300433
GKH
62
63# code taken from uClibc to determine the current arch
64ARCH := ${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
68GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
69
70# code taken from uClibc to determine the libgcc.a filename
71GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
72
73# use '-Os' optimization if available, else use -O2
74OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
75 then echo "-Os"; else echo "-O2" ; fi}
76
bb27dd9b
GKH
77# add -Wredundant-decls when libsysfs gets cleaned up
78WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
fe300433
GKH
79
80# Some nice architecture specific optimizations
81ifeq ($(strip $(TARGET_ARCH)),arm)
82 OPTIMIZATION+=-fstrict-aliasing
83endif
84ifeq ($(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
91else
92 CFLAGS+=-pipe
93endif
94
95# if DEBUG is enabled, then we do not strip or optimize
96ifeq ($(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
100else
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
104endif
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.
108ifeq ($(strip $(KLIBC)),true)
1e959a4b 109 KLIBC_DIR = klibc/klibc
fe300433
GKH
110 INCLUDE_DIR := $(KLIBC_DIR)/include
111 # arch specific objects
112 LIBGCC = $(shell $(CC) --print-libgcc)
113 ARCH_LIB_OBJS = \
114 $(KLIBC_DIR)/libc.a \
38ebdcac 115 $(LIBGCC)
fe300433 116
fe300433 117
38ebdcac 118 CRT0 = $(KLIBC_DIR)/crt0.o
fe300433 119 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS)
6ea7aa72 120 CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/bits32 -I$(GCCINCDIR) -Iklibc/linux/include -D__KLIBC__
38ebdcac
GKH
121 LIB_OBJS =
122 LDFLAGS = --static --nostdlib -nostartfiles
fe300433 123else
38ebdcac
GKH
124# ARCH_LIB_OBJS = /usr/lib/libc.a
125 LIBGCC = $(shell $(CC) --print-libgcc)
126 CRT0 = /usr/lib/crt1.o /usr/lib/crti.o
fe300433
GKH
127 LIBC =
128 CFLAGS += -I$(GCCINCDIR)
129 LIB_OBJS = -lc
130 LDFLAGS = --static
131endif
132
133all: $(LIBC) $(ROOT)
134
135$(ARCH_LIB_OBJS) :
136 $(MAKE) -C klibc
137
1e959a4b
GKH
138TDB = tdb/tdb.o \
139 tdb/spinlock.o
140
141SYSFS = libsysfs/sysfs_bus.o \
142 libsysfs/sysfs_class.o \
143 libsysfs/sysfs_device.o \
144 libsysfs/sysfs_dir.o \
145 libsysfs/sysfs_driver.o \
146 libsysfs/sysfs_utils.o \
147 libsysfs/dlist.o
bb27dd9b 148
fe300433 149OBJS = udev.o \
bb27dd9b
GKH
150 udev-add.o \
151 udev-remove.o \
152 udevdb.o \
fe300433 153 logging.o \
bb27dd9b 154 namedev.o \
c94705b5 155 klibc_fixups.o \
1e959a4b 156 $(SYSFS) \
bb27dd9b
GKH
157 $(TDB)
158
fe300433
GKH
159# header files automatically generated
160GEN_HEADERS = udev_version.h
161
162# Rules on how to create the generated header files
163udev_version.h:
bb27dd9b
GKH
164 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
165 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
166 @echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
fe300433
GKH
167
168
169$(ROOT): $(GEN_HEADERS) $(OBJS)
38ebdcac 170 $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(LIBGCC) $(ARCH_LIB_OBJS)
fe300433
GKH
171 $(STRIPCMD) $(ROOT)
172
173clean:
174 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
175 | xargs rm -f
176 -rm -f core $(ROOT) $(GEN_HEADERS)
177 $(MAKE) -C klibc clean
178
38ebdcac
GKH
179DISTFILES = $(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 )
180DISTDIR := $(RELEASE_NAME)
181srcdir = .
182release: $(DISTFILES) clean
183# @echo $(DISTFILES)
184 @-rm -rf $(DISTDIR)
185 @mkdir $(DISTDIR)
186 @-chmod 777 $(DISTDIR)
187 @for file in $(DISTFILES); do \
188 if test -d $$file; then \
189 mkdir $(DISTDIR)/$$file; \
190 else \
191 cp -p $$file $(DISTDIR)/$$file; \
192 fi; \
193 done
194 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
195 @rm -rf $(DISTDIR)
196 @echo "Built $(RELEASE_NAME).tar.gz"
197
198
199install: all
200 $(INSTALL) -d $(udevdir)
201 $(INSTALL) -d $(configdir)
202 $(INSTALL) -d $(hotplugdir)
203 $(INSTALL_PROGRAM) -D $(ROOT) $(sbindir)/$(ROOT)
204 $(INSTALL_DATA) -D udev.8 $(mandir)/man8/udev.8
205 $(INSTALL_DATA) udev.config $(configdir)
206 $(INSTALL_DATA) udev.permissions $(configdir)
207 - ln -s $(sbindir)/$(ROOT) $(hotplugdir)/udev.hotplug
208
209uninstall:
210 - rm $(hotplugdir)/udev.hotplug
211 - rm $(configdir)/udev.permissions
212 - rm $(configdir)/udev.config
213 - rm $(mandir)/man8/udev.8
214 - rm $(sbindir)/$(ROOT)
215 - rmdir $(hotplugdir)
216 - rmdir $(configdir)
217 - rmdir $(udevdir)
218
219