chiark / gitweb /
[PATCH] tell the user what mknod() we are trying to do.
[elogind.git] / Makefile
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.
21 DEBUG = true
22
23
24 ROOT =          udev
25 VERSION =       003
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 CONFIG_DIR = $(PREFIX)/etc/udev/
32
33 # place to put our device nodes
34 UDEV_DIR = /udev/
35
36 # Comment out this line to build with something other 
37 # than the local version of klibc
38 #KLIBC = true
39
40 # If you are running a cross compiler, you may want to set this
41 # to something more interesting, like "arm-linux-".  I you want
42 # to compile vs uClibc, that can be done here as well.
43 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
44 CC = $(CROSS)gcc
45 AR = $(CROSS)ar
46 STRIP = $(CROSS)strip
47 RANLIB = $(CROSS)ranlib
48
49 export CROSS CC AR STRIP RANLIB
50
51 # code taken from uClibc to determine the current arch
52 ARCH := ${shell $(CC) -dumpmachine | sed -e s'/-.*//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
53         -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/ppc/powerpc/g'}
54
55 # code taken from uClibc to determine the gcc include dir
56 GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
57
58 # code taken from uClibc to determine the libgcc.a filename
59 GCC_LIB := $(shell $(CC) -print-libgcc-file-name )
60
61 # use '-Os' optimization if available, else use -O2
62 OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
63                 then echo "-Os"; else echo "-O2" ; fi}
64
65 WARNINGS := -Wall -Wshadow -Wstrict-prototypes 
66
67 # Some nice architecture specific optimizations
68 ifeq ($(strip $(TARGET_ARCH)),arm)
69         OPTIMIZATION+=-fstrict-aliasing
70 endif
71 ifeq ($(strip $(TARGET_ARCH)),i386)
72         OPTIMIZATION+=-march=i386
73         OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
74                 /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
75         OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
76                 /dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi}
77         CFLAGS+=-pipe
78 else
79         CFLAGS+=-pipe
80 endif
81
82 # if DEBUG is enabled, then we do not strip or optimize
83 ifeq ($(strip $(DEBUG)),true)
84         CFLAGS  += $(WARNINGS) -O1 -g -DDEBUG -D_GNU_SOURCE
85         LDFLAGS += -Wl,-warn-common
86         STRIPCMD = /bin/true -Since_we_are_debugging
87 else
88         CFLAGS  += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
89         LDFLAGS += -s -Wl,-warn-common
90         STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
91 endif
92
93 # If we are using our version of klibc, then we need to build and link it.
94 # Otherwise, use glibc and link statically.
95 ifeq ($(strip $(KLIBC)),true)
96         KLIBC_DIR       = klibc
97         INCLUDE_DIR     := $(KLIBC_DIR)/include
98         # arch specific objects
99         ARCH_LIB_OBJS = \
100                         $(KLIBC_DIR)/bin-$(ARCH)/start.o        \
101                         $(KLIBC_DIR)/bin-$(ARCH)/klibc.a
102
103         LIB_OBJS =      $(GCC_LIB)
104
105         LIBC =  $(ARCH_LIB_OBJS) $(LIB_OBJS)
106         CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(GCCINCDIR)
107         LDFLAGS = --static --nostdlib -nostartfiles
108 else
109         LIBC = 
110         CFLAGS += -I$(GCCINCDIR)
111         LIB_OBJS = -lc
112         LDFLAGS = --static 
113 endif
114
115 LIB=libsysfs
116
117 all: $(LIBC) $(ROOT)
118
119 $(ARCH_LIB_OBJS) :
120         $(MAKE) -C klibc
121
122 LIBSYSFS = libsysfs/libsysfs.a
123 TDB = tdb/tdb.o tdb/spinlock.o
124
125 OBJS =  udev.o          \
126         udev-add.o      \
127         udev-remove.o   \
128         udevdb.o        \
129         logging.o       \
130         namedev.o       \
131         $(TDB)
132
133 libsysfs/libsysfs.a:
134         $(MAKE) -C libsysfs
135
136 tdb/tdb.o:
137         $(MAKE) -C tdb
138
139 # header files automatically generated
140 GEN_HEADERS =   udev_version.h
141
142 # Rules on how to create the generated header files
143 udev_version.h:
144         @echo \#define UDEV_VERSION     \"$(VERSION)\" > $@
145         @echo \#define UDEV_CONFIG_DIR  \"$(CONFIG_DIR)\" >> $@
146         @echo \#define UDEV_ROOT        \"$(UDEV_DIR)\" >> $@
147
148
149 $(ROOT): $(GEN_HEADERS) $(OBJS) $(LIBSYSFS) $(TDB)
150         $(MAKE) -C libsysfs
151         $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) -lsysfs $(LIB_OBJS) -L$(LIB) $(ARCH_LIB_OBJS)
152         $(STRIPCMD) $(ROOT)
153
154 clean:
155         -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
156          | xargs rm -f 
157         -rm -f core $(ROOT) $(GEN_HEADERS)
158         $(MAKE) -C klibc clean
159         $(MAKE) -C libsysfs clean
160         $(MAKE) -C tdb clean
161
162 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" )
163 DISTDIR := $(RELEASE_NAME)
164 srcdir = .
165 release: $(DISTFILES) clean
166 #       @echo $(DISTFILES)
167         @-rm -rf $(DISTDIR)
168         @mkdir $(DISTDIR)
169         @-chmod 777 $(DISTDIR)
170         @for file in $(DISTFILES); do                   \
171                 if test -d $$file; then                 \
172                         mkdir $(DISTDIR)/$$file;        \
173                 else                                    \
174                         cp -p $$file $(DISTDIR)/$$file; \
175                 fi;                                     \
176         done
177         @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
178         @rm -rf $(DISTDIR)
179         @echo "Built $(RELEASE_NAME).tar.gz"