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