OSDN Git Service

Peter Kjellerstedt writes:
[uclinux-h8/uClibc.git] / test / Rules.mak
1 # Rules.make for uClibc test apps.
2 #
3 # Copyright (C) 2001 by Lineo, inc.
4 #
5 #
6 #Note: This does not read the top level Rules.mak file
7 #
8
9 -include $(TESTDIR)../.config
10 include $(TESTDIR)Config
11
12 #--------------------------------------------------------
13 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. 
14 LC_ALL:= C
15 export LC_ALL
16
17 ifeq ($(strip $(TARGET_ARCH)),)
18 TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
19                 -e 's/i.86/i386/' \
20                 -e 's/sparc.*/sparc/' \
21                 -e 's/arm.*/arm/g' \
22                 -e 's/m68k.*/m68k/' \
23                 -e 's/ppc/powerpc/g' \
24                 -e 's/v850.*/v850/g' \
25                 -e 's/sh[234]/sh/' \
26                 -e 's/mips-.*/mips/' \
27                 -e 's/mipsel-.*/mipsel/' \
28                 -e 's/cris.*/cris/' \
29                 )
30 endif
31 export TARGET_ARCH
32
33
34 #--------------------------------------------------------
35 # If you are running a cross compiler, you will want to set 'CROSS'
36 # to something more interesting...  Target architecture is determined
37 # by asking the CC compiler what arch it compiles things for, so unless
38 # your compiler is broken, you should not need to specify TARGET_ARCH
39 #
40 # Most people will set this stuff on the command line, i.e.
41 #        make CROSS=mipsel-linux-
42 # will build uClibc for 'mipsel'.
43
44 CROSS=../$(TESTDIR)extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-
45 CC= $(CROSS)gcc
46 STRIPTOOL=strip
47 LDD=../$(TESTDIR)ldso/util/ldd
48
49 RM= rm -f
50
51 # Select the compiler needed to build binaries for your development system
52 HOSTCC=gcc
53 HOSTCFLAGS=-O2 -Wall
54
55
56 #--------------------------------------------------------
57 # Check if 'ls -sh' works or not
58 LSFLAGS = -l
59
60 # A nifty macro to make testing gcc features easier
61 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
62         then echo "$(1)"; else echo "$(2)"; fi)
63
64 # use '-Os' optimization if available, else use -O2, allow Config to override
65 OPTIMIZATION+=$(call check_gcc,-Os,-O2)
66 # Override optimization settings when debugging
67 ifeq ($(DODEBUG),true)
68 OPTIMIZATION=-O0
69 endif
70
71 XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
72 XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
73 CFLAGS=--uclibc-use-build-dir $(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
74 GLIBC_CFLAGS+=$(XWARNINGS) $(OPTIMIZATION)
75 LDFLAGS=--uclibc-use-build-dir
76
77 ifeq ($(DODEBUG),true)
78     CFLAGS+=-g
79     GLIBC_CFLAGS+=-g
80     LDFLAGS += -g -Wl,-warn-common
81     GLIBC_LDFLAGS =-g -Wl,-warn-common 
82     STRIPTOOL =true -Since_we_are_debugging
83 else
84     LDFLAGS  +=-s -Wl,-warn-common
85     GLIBC_LDFLAGS  =-s -Wl,-warn-common
86     STRIP    = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
87 endif
88
89 ifneq ($(DODYNAMIC),true)
90     LDFLAGS +=-static
91     GLIBC_LDFLAGS +=-static
92 endif