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