1 # Makefile for diethotplug
3 # Copyright (C) 2000,2001 Greg Kroah-Hartman <greg@kroah.com>
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.
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.
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
19 # Set the following to `true' to make a debuggable build.
20 # Leave this set to `false' for production use.
26 INSTALL_DIR
= /usr
/local
/bin
27 RELEASE_NAME
= $(ROOT
)-$(VERSION
)
30 # Comment out this line to build with something other
31 # than the local version of klibc
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-
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'}
47 # code taken from uClibc to determine the gcc include dir
48 GCCINCDIR
:= ${shell $(CC
) -print-search-dirs | sed
-ne
"s/install: \(.*\)/\1include/gp"}
50 # code taken from uClibc to determine the libgcc.a filename
51 GCC_LIB
:= $(shell $(CC
) -print-libgcc-file-name
)
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
}
57 WARNINGS
:= -Wall
-Wshadow
-Wstrict-prototypes
59 # Some nice architecture specific optimizations
60 ifeq ($(strip $(TARGET_ARCH
)),arm
)
61 OPTIMIZATION
+=-fstrict-aliasing
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
}
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
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
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
)
89 INCLUDE_DIR
:= $(KLIBC_DIR
)/include
90 # arch specific objects
92 $(KLIBC_DIR
)/bin-
$(ARCH
)/start.o \
93 $(KLIBC_DIR
)/bin-
$(ARCH
)/klibc.a
97 LIBC
= $(ARCH_LIB_OBJS
) $(LIB_OBJS
)
98 CFLAGS
+= -nostdinc
-I
$(INCLUDE_DIR
) -I
$(GCCINCDIR
)
99 LDFLAGS
= --static
--nostdlib
-nostartfiles
102 CFLAGS
+= -I
$(GCCINCDIR
)
120 LIBSYSFS
= libsysfs
/libsysfs.a
125 # header files automatically generated
126 GEN_HEADERS
= udev_version.h
128 # Rules on how to create the generated header files
130 @echo \
#define UDEV_VERSION \"$(VERSION)\" > $@
133 $(ROOT
): $(GEN_HEADERS
) $(OBJS
) $(LIBSYSFS
)
135 $(CC
) $(LDFLAGS
) -o
$(ROOT
) $(OBJS
) -lsysfs
$(LIB_OBJS
) -L
$(LIB
) $(ARCH_LIB_OBJS
)
139 -find . \
( -not
-type d \
) -and \
( -name
'*~' -o
-name
'*.[oas]' \
) -type f
-print \
141 -rm -f core
$(ROOT
) $(GEN_HEADERS
)
142 $(MAKE
) -C klibc
clean
143 $(MAKE
) -C libsysfs
clean
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
)
148 release
: $(DISTFILES
) clean
152 @
-chmod
777 $(DISTDIR
)
153 @for file in
$(DISTFILES
); do \
154 if
test -d
$$file; then \
155 mkdir
$(DISTDIR
)/$$file; \
157 cp
-p
$$file $(DISTDIR
)/$$file; \
160 @
tar -c
$(DISTDIR
) | gzip
-9 > $(RELEASE_NAME
).
tar.gz
162 @echo
"Built $(RELEASE_NAME).tar.gz"