]>
Commit | Line | Data |
---|---|---|
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 | 21 | DEBUG = true |
f0083e3d GKH |
22 | |
23 | ||
24 | ROOT = udev | |
cee360d3 | 25 | VERSION = 0.2 |
f0083e3d | 26 | INSTALL_DIR = /usr/local/bin |
1e7a3f9e | 27 | RELEASE_NAME = $(ROOT)-$(VERSION) |
f0083e3d GKH |
28 | |
29 | ||
30 | # Comment out this line to build with something other | |
31 | # than the local version of klibc | |
32 | #KLIBC = 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. | |
37 | CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- | |
38 | CC = $(CROSS)gcc | |
39 | AR = $(CROSS)ar | |
40 | STRIP = $(CROSS)strip | |
41 | ||
42 | ||
43 | # code taken from uClibc to determine the current arch | |
44 | ARCH := ${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 | |
48 | GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"} | |
49 | ||
50 | # code taken from uClibc to determine the libgcc.a filename | |
51 | GCC_LIB := $(shell $(CC) -print-libgcc-file-name ) | |
52 | ||
53 | # use '-Os' optimization if available, else use -O2 | |
54 | OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ | |
55 | then echo "-Os"; else echo "-O2" ; fi} | |
56 | ||
57 | WARNINGS := -Wall -Wshadow -Wstrict-prototypes | |
58 | ||
59 | # Some nice architecture specific optimizations | |
60 | ifeq ($(strip $(TARGET_ARCH)),arm) | |
61 | OPTIMIZATION+=-fstrict-aliasing | |
62 | endif | |
63 | ifeq ($(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 | |
70 | else | |
71 | CFLAGS+=-pipe | |
72 | endif | |
73 | ||
74 | # if DEBUG is enabled, then we do not strip or optimize | |
75 | ifeq ($(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 | |
79 | else | |
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 | |
83 | endif | |
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. | |
87 | ifeq ($(strip $(KLIBC)),true) | |
88 | KLIBC_DIR = klibc | |
89 | INCLUDE_DIR := $(KLIBC_DIR)/include | |
90 | # arch specific objects | |
91 | ARCH_LIB_OBJS = \ | |
92 | $(KLIBC_DIR)/bin-$(ARCH)/start.o \ | |
93 | $(KLIBC_DIR)/bin-$(ARCH)/klibc.a | |
94 | ||
95 | LIB_OBJS = $(GCC_LIB) | |
96 | ||
97 | LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) | |
98 | CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(GCCINCDIR) | |
99 | LDFLAGS = --static --nostdlib -nostartfiles | |
100 | else | |
101 | LIBC = | |
102 | CFLAGS += -I$(GCCINCDIR) | |
103 | LIB_OBJS = -lc | |
104 | LDFLAGS = --static | |
105 | endif | |
106 | ||
28972fe8 GKH |
107 | LIB=libsysfs |
108 | ||
f0083e3d GKH |
109 | all: $(LIBC) $(ROOT) |
110 | ||
111 | $(ARCH_LIB_OBJS) : | |
112 | $(MAKE) -C klibc | |
113 | ||
114 | OBJS = udev.o \ | |
ea733a2f GKH |
115 | udev-add.o \ |
116 | udev-remove.o \ | |
2232cac8 GKH |
117 | logging.o \ |
118 | namedev.o | |
f0083e3d | 119 | |
28972fe8 GKH |
120 | LIBSYSFS = libsysfs/libsysfs.a |
121 | ||
122 | libsysfs/libsysfs.a: | |
123 | $(MAKE) -C libsysfs | |
f0083e3d GKH |
124 | |
125 | # header files automatically generated | |
126 | GEN_HEADERS = udev_version.h | |
127 | ||
128 | # Rules on how to create the generated header files | |
129 | udev_version.h: | |
130 | @echo \#define UDEV_VERSION \"$(VERSION)\" > $@ | |
131 | ||
132 | ||
28972fe8 GKH |
133 | $(ROOT): $(GEN_HEADERS) $(OBJS) $(LIBSYSFS) |
134 | $(MAKE) -C libsysfs | |
135 | $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) -lsysfs $(LIB_OBJS) -L$(LIB) $(ARCH_LIB_OBJS) | |
f0083e3d GKH |
136 | $(STRIPCMD) $(ROOT) |
137 | ||
138 | clean: | |
139 | -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ | |
140 | | xargs rm -f | |
141 | -rm -f core $(ROOT) $(GEN_HEADERS) | |
142 | $(MAKE) -C klibc clean | |
28972fe8 | 143 | $(MAKE) -C libsysfs clean |
f0083e3d GKH |
144 | |
145 | DISTFILES = $(shell find . \( -not -name '.' \) -print | grep -v CVS | grep -v "\.tar\.gz" | grep -v "\/\." | grep -v releases | grep -v BitKeeper | grep -v SCCS ) | |
146 | DISTDIR := $(RELEASE_NAME) | |
147 | srcdir = . | |
148 | release: $(DISTFILES) clean | |
149 | # @echo $(DISTFILES) | |
150 | @-rm -rf $(DISTDIR) | |
151 | @mkdir $(DISTDIR) | |
152 | @-chmod 777 $(DISTDIR) | |
153 | @for file in $(DISTFILES); do \ | |
154 | if test -d $$file; then \ | |
155 | mkdir $(DISTDIR)/$$file; \ | |
156 | else \ | |
157 | cp -p $$file $(DISTDIR)/$$file; \ | |
158 | fi; \ | |
159 | done | |
160 | @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz | |
161 | @rm -rf $(DISTDIR) | |
162 | @echo "Built $(RELEASE_NAME).tar.gz" |