]> git.ipfire.org Git - thirdparty/systemd.git/blame - Makefile
[PATCH] update udev extras/scsi_id to version 0.2
[thirdparty/systemd.git] / Makefile
CommitLineData
8dfc8dbe 1# Makefile for udev
f0083e3d 2#
8dfc8dbe 3# Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
f0083e3d
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.
29b82deb 21DEBUG = false
f0083e3d
GKH
22
23
24ROOT = udev
da146a3e 25VERSION = 008_bk
f0083e3d 26INSTALL_DIR = /usr/local/bin
1e7a3f9e 27RELEASE_NAME = $(ROOT)-$(VERSION)
f0083e3d 28
4360a56d 29DESTDIR =
6739707d 30# override this to make udev look in a different location for it's config files
9f53b06a
GKH
31prefix =
32exec_prefix = ${prefix}
33etcdir = ${prefix}/etc
34sbindir = ${exec_prefix}/sbin
35mandir = ${prefix}/usr/share/man
36hotplugdir = ${etcdir}/hotplug.d/default
37configdir = ${etcdir}/udev/
38srcdir = .
39
40INSTALL = /usr/bin/install -c
41INSTALL_PROGRAM = ${INSTALL}
42INSTALL_DATA = ${INSTALL} -m 644
43INSTALL_SCRIPT = ${INSTALL_PROGRAM}
44
6739707d
GKH
45
46# place to put our device nodes
9f53b06a 47udevdir = ${prefix}/udev/
f0083e3d
GKH
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.
56CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
57CC = $(CROSS)gcc
74894b53 58LD = $(CROSS)gcc
f0083e3d
GKH
59AR = $(CROSS)ar
60STRIP = $(CROSS)strip
b137e367 61RANLIB = $(CROSS)ranlib
f0083e3d 62
b137e367 63export CROSS CC AR STRIP RANLIB
f0083e3d
GKH
64
65# code taken from uClibc to determine the current arch
66ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
bfd8a5d0 67 -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/powerpc/ppc/g'}
f0083e3d
GKH
68
69# code taken from uClibc to determine the gcc include dir
70GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
71
72# code taken from uClibc to determine the libgcc.a filename
73GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
74
75# use '-Os' optimization if available, else use -O2
76OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
77 then echo "-Os"; else echo "-O2" ; fi}
78
7bfd1a56
GKH
79# add -Wredundant-decls when libsysfs gets cleaned up
80WARNINGS := -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
f0083e3d
GKH
81
82# Some nice architecture specific optimizations
83ifeq ($(strip $(TARGET_ARCH)),arm)
84 OPTIMIZATION+=-fstrict-aliasing
85endif
86ifeq ($(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
93else
94 CFLAGS+=-pipe
95endif
96
97# if DEBUG is enabled, then we do not strip or optimize
98ifeq ($(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
102else
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
106endif
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.
110ifeq ($(strip $(KLIBC)),true)
2d5b6886 111 KLIBC_DIR = klibc/klibc
f0083e3d 112 INCLUDE_DIR := $(KLIBC_DIR)/include
74894b53 113 include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
f0083e3d 114 # arch specific objects
2d5b6886 115 LIBGCC = $(shell $(CC) --print-libgcc)
f0083e3d 116 ARCH_LIB_OBJS = \
2d5b6886
GKH
117 $(KLIBC_DIR)/libc.a \
118 $(LIBGCC)
f0083e3d 119
f0083e3d 120
2d5b6886 121 CRT0 = $(KLIBC_DIR)/crt0.o
74894b53
AB
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__
2d5b6886 126 LIB_OBJS =
7f2ea6a3 127 LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
f0083e3d 128else
2d5b6886 129 CRT0 =
f0083e3d
GKH
130 LIBC =
131 CFLAGS += -I$(GCCINCDIR)
132 LIB_OBJS = -lc
133 LDFLAGS = --static
134endif
135
871ea775 136all: $(ROOT)
f0083e3d 137
871ea775
PM
138$(ROOT): $(LIBC)
139
140$(ARCH_LIB_OBJS) : $(CRT0)
141
142$(CRT0):
f0083e3d
GKH
143 $(MAKE) -C klibc
144
5c75a3ec
GKH
145TDB = tdb/tdb.o \
146 tdb/spinlock.o
147
148SYSFS = 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
a2822451 155
f0083e3d 156OBJS = udev.o \
e8baccca 157 udev_config.o \
ea733a2f
GKH
158 udev-add.o \
159 udev-remove.o \
a2822451 160 udevdb.o \
2232cac8 161 logging.o \
a2822451 162 namedev.o \
19feb351 163 namedev_parse.o \
5c75a3ec 164 $(SYSFS) \
a2822451 165 $(TDB)
28972fe8 166
6a670d61
GKH
167ifeq ($(strip $(KLIBC)),true)
168 OBJS += klibc_fixups.o
169endif
170
f0083e3d
GKH
171# header files automatically generated
172GEN_HEADERS = udev_version.h
173
174# Rules on how to create the generated header files
175udev_version.h:
6739707d 176 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
9f53b06a 177 @echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
3836a3c4
GKH
178 @echo \#define UDEV_DB \"$(udevdir)\.udev.tdb\" >> $@
179 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
180 @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
181 @echo \#define UDEV_RULES_FILE \"$(configdir)\udev.rules\" >> $@
182 @echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
f0083e3d 183
871ea775 184$(OBJS): $(GEN_HEADERS)
f0083e3d 185
871ea775 186$(ROOT): $(OBJS)
74894b53 187 $(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
f0083e3d
GKH
188 $(STRIPCMD) $(ROOT)
189
190clean:
191 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
192 | xargs rm -f
193 -rm -f core $(ROOT) $(GEN_HEADERS)
194 $(MAKE) -C klibc clean
195
6c0eae77 196DISTFILES = $(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 )
f0083e3d
GKH
197DISTDIR := $(RELEASE_NAME)
198srcdir = .
54e3a5d3
GKH
199release: clean
200 @echo "--------------------------cut here------------------------"
201 @echo "cd .."
202 @echo "rm -rf $(DISTDIR)"
203 @echo "mkdir $(DISTDIR)"
204 @echo "chmod 777 $(DISTDIR)"
205 @echo "cp -avr udev/* $(DISTDIR)"
206 @echo "tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz"
207 @echo "rm -rf $(DISTDIR)"
208 @echo "--------------------------cut here------------------------"
209
210
211small_release: $(DISTFILES) clean
f0083e3d
GKH
212# @echo $(DISTFILES)
213 @-rm -rf $(DISTDIR)
214 @mkdir $(DISTDIR)
215 @-chmod 777 $(DISTDIR)
216 @for file in $(DISTFILES); do \
217 if test -d $$file; then \
218 mkdir $(DISTDIR)/$$file; \
219 else \
220 cp -p $$file $(DISTDIR)/$$file; \
221 fi; \
222 done
223 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
224 @rm -rf $(DISTDIR)
225 @echo "Built $(RELEASE_NAME).tar.gz"
9f53b06a
GKH
226
227
228install: all
4360a56d
OH
229 $(INSTALL) -d $(DESTDIR)$(udevdir)
230 $(INSTALL) -d $(DESTDIR)$(configdir)
231 $(INSTALL) -d $(DESTDIR)$(hotplugdir)
232 $(INSTALL_PROGRAM) -D $(ROOT) $(DESTDIR)$(sbindir)/$(ROOT)
233 $(INSTALL_DATA) -D udev.8 $(DESTDIR)$(mandir)/man8/udev.8
e8baccca
GKH
234 $(INSTALL_DATA) udev.conf $(DESTDIR)$(configdir)
235 $(INSTALL_DATA) udev.rules $(DESTDIR)$(configdir)
4360a56d 236 $(INSTALL_DATA) udev.permissions $(DESTDIR)$(configdir)
ed839137 237 - rm -f $(DESTDIR)$(hotplugdir)/udev.hotplug
4360a56d 238 - ln -s $(sbindir)/$(ROOT) $(DESTDIR)$(hotplugdir)/udev.hotplug
6785820d
GKH
239
240uninstall:
241 - rm $(hotplugdir)/udev.hotplug
d4112087 242 - rm $(configdir)/udev.permissions
e8baccca
GKH
243 - rm $(configdir)/udev.rules
244 - rm $(configdir)/udev.conf
6785820d
GKH
245 - rm $(mandir)/man8/udev.8
246 - rm $(sbindir)/$(ROOT)
247 - rmdir $(hotplugdir)
248 - rmdir $(configdir)
249 - rmdir $(udevdir)
250
251