]> git.ipfire.org Git - thirdparty/systemd.git/blame - Makefile
[PATCH] added install target for makefile so people don't have to do it by hand anymore.
[thirdparty/systemd.git] / Makefile
CommitLineData
f0083e3d
GKH
1# Makefile for diethotplug
2#
3# Copyright (C) 2000,2001 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.
a507a015 21DEBUG = true
f0083e3d
GKH
22
23
24ROOT = udev
6739707d 25VERSION = 003
f0083e3d 26INSTALL_DIR = /usr/local/bin
1e7a3f9e 27RELEASE_NAME = $(ROOT)-$(VERSION)
f0083e3d 28
6739707d 29# override this to make udev look in a different location for it's config files
9f53b06a
GKH
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
6739707d
GKH
44
45# place to put our device nodes
9f53b06a 46udevdir = ${prefix}/udev/
f0083e3d
GKH
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.
55CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
56CC = $(CROSS)gcc
57AR = $(CROSS)ar
58STRIP = $(CROSS)strip
b137e367 59RANLIB = $(CROSS)ranlib
f0083e3d 60
b137e367 61export CROSS CC AR STRIP RANLIB
f0083e3d
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
77WARNINGS := -Wall -Wshadow -Wstrict-prototypes
78
79# Some nice architecture specific optimizations
80ifeq ($(strip $(TARGET_ARCH)),arm)
81 OPTIMIZATION+=-fstrict-aliasing
82endif
83ifeq ($(strip $(TARGET_ARCH)),i386)
84 OPTIMIZATION+=-march=i386
85 OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
86 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
87 OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
88 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
89 CFLAGS+=-pipe
90else
91 CFLAGS+=-pipe
92endif
93
94# if DEBUG is enabled, then we do not strip or optimize
95ifeq ($(strip $(DEBUG)),true)
96 CFLAGS += $(WARNINGS) -O1 -g -DDEBUG -D_GNU_SOURCE
97 LDFLAGS += -Wl,-warn-common
98 STRIPCMD = /bin/true -Since_we_are_debugging
99else
100 CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
101 LDFLAGS += -s -Wl,-warn-common
102 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
103endif
104
105# If we are using our version of klibc, then we need to build and link it.
106# Otherwise, use glibc and link statically.
107ifeq ($(strip $(KLIBC)),true)
108 KLIBC_DIR = klibc
109 INCLUDE_DIR := $(KLIBC_DIR)/include
110 # arch specific objects
111 ARCH_LIB_OBJS = \
112 $(KLIBC_DIR)/bin-$(ARCH)/start.o \
113 $(KLIBC_DIR)/bin-$(ARCH)/klibc.a
114
115 LIB_OBJS = $(GCC_LIB)
116
117 LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS)
118 CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(GCCINCDIR)
119 LDFLAGS = --static --nostdlib -nostartfiles
120else
121 LIBC =
122 CFLAGS += -I$(GCCINCDIR)
123 LIB_OBJS = -lc
124 LDFLAGS = --static
125endif
126
28972fe8
GKH
127LIB=libsysfs
128
f0083e3d
GKH
129all: $(LIBC) $(ROOT)
130
131$(ARCH_LIB_OBJS) :
132 $(MAKE) -C klibc
133
a2822451
GKH
134LIBSYSFS = libsysfs/libsysfs.a
135TDB = tdb/tdb.o tdb/spinlock.o
136
f0083e3d 137OBJS = udev.o \
ea733a2f
GKH
138 udev-add.o \
139 udev-remove.o \
a2822451 140 udevdb.o \
2232cac8 141 logging.o \
a2822451
GKH
142 namedev.o \
143 $(TDB)
28972fe8
GKH
144
145libsysfs/libsysfs.a:
146 $(MAKE) -C libsysfs
f0083e3d 147
a2822451
GKH
148tdb/tdb.o:
149 $(MAKE) -C tdb
150
f0083e3d
GKH
151# header files automatically generated
152GEN_HEADERS = udev_version.h
153
154# Rules on how to create the generated header files
155udev_version.h:
6739707d 156 @echo \#define UDEV_VERSION \"$(VERSION)\" > $@
9f53b06a
GKH
157 @echo \#define UDEV_CONFIG_DIR \"$(configdir)\" >> $@
158 @echo \#define UDEV_ROOT \"$(udevdir)\" >> $@
f0083e3d
GKH
159
160
a2822451 161$(ROOT): $(GEN_HEADERS) $(OBJS) $(LIBSYSFS) $(TDB)
28972fe8
GKH
162 $(MAKE) -C libsysfs
163 $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) -lsysfs $(LIB_OBJS) -L$(LIB) $(ARCH_LIB_OBJS)
f0083e3d
GKH
164 $(STRIPCMD) $(ROOT)
165
166clean:
167 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
168 | xargs rm -f
169 -rm -f core $(ROOT) $(GEN_HEADERS)
170 $(MAKE) -C klibc clean
28972fe8 171 $(MAKE) -C libsysfs clean
a2822451 172 $(MAKE) -C tdb clean
f0083e3d 173
9f53b06a 174DISTFILES = $(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" | sort )
f0083e3d
GKH
175DISTDIR := $(RELEASE_NAME)
176srcdir = .
177release: $(DISTFILES) clean
178# @echo $(DISTFILES)
179 @-rm -rf $(DISTDIR)
180 @mkdir $(DISTDIR)
181 @-chmod 777 $(DISTDIR)
182 @for file in $(DISTFILES); do \
183 if test -d $$file; then \
184 mkdir $(DISTDIR)/$$file; \
185 else \
186 cp -p $$file $(DISTDIR)/$$file; \
187 fi; \
188 done
189 @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
190 @rm -rf $(DISTDIR)
191 @echo "Built $(RELEASE_NAME).tar.gz"
9f53b06a
GKH
192
193
194install: all
195 $(INSTALL) -d $(udevdir)
196 $(INSTALL) -d $(configdir)
197 $(INSTALL) -d $(hotplugdir)
198 $(INSTALL_PROGRAM) -D $(ROOT) $(sbindir)/$(ROOT)
199 $(INSTALL_DATA) -D udev.8 $(mandir)/man8/udev.8
200 $(INSTALL_DATA) namedev.config $(configdir)
201 $(INSTALL_DATA) namedev.permissions $(configdir)
202 - ln -s $(sbindir)/$(ROOT) $(hotplugdir)/udev.hotplug