5 # The shell used to execute the commands
19 SHARED_LIB
:= libc
++.so
21 ifneq ($(SHARED_LIB_NAME
),)
22 SHARED_LIB_NAME
:= -Xlinker
-h
$(SHARED_LIB_NAME
)
25 ifeq ($(CXXFLAGS_SHARED
),)
26 CXXFLAGS_SHARED
:= -fpic
29 # Files from the host environment
30 LIBC
:= $(shell $(CXX
) -print-file-name
=libc.so
)
31 LIBGCC
:= $(shell $(CXX
) -print-libgcc-file-name
)
33 SRC
:= $(shell [ -d source
] && find source
-name
"*.cpp")
34 OBJ
:= $(SRC
:%.
cpp=%.o
)
35 OBJ_SHARED
:= $(SRC
:%.
cpp=%-shared.o
)
36 DEP
:= $(SRC
:%.
cpp=%.dep
)
37 DEP_SHARED
:= $(SRC
:%.
cpp=%-shared.dep
)
38 TESTCASE_SRC
:= $(shell [ -d testcase
] && find testcase
-name
"*.cpp")
39 TESTCASE
:= $(TESTCASE_SRC
:%.
cpp=%)
40 TESTCASE_DEP
:= $(TESTCASE_SRC
:%.
cpp=%.dep
)
41 TESTCASE_HOST
:= $(TESTCASE_SRC
:%.
cpp=%-host
)
42 TESTCASE_HOST_DEP
:= $(TESTCASE_SRC
:%.
cpp=%-host.dep
)
44 CXXFLAGS_COMMON_HOST
:= -std
=c
++0x
-Wall
-Werror
-Wextra
-pedantic-errors
45 CXXFLAGS_COMMON
:= $(CXXFLAGS_COMMON_HOST
) -fno-exceptions
-nostdinc
++
46 CXXFLAGS
:= $(CXXFLAGS
) $(CXXFLAGS_COMMON
) $(INCLUDE
)
47 CXXFLAGS_SHARED
:= $(CXXFLAGS_SHARED
) $(CXXFLAGS_COMMON
) $(INCLUDE
)
48 CXXFLAGS_TESTCASE
:= $(CXXFLAGS_COMMON
) $(INCLUDE
) -nodefaultlibs
49 LIBS_TESTCASE
:= -Xlinker
--start-group
-Xlinker
$(STATIC_LIB
) -Xlinker
$(LIBGCC
) -Xlinker
$(LIBC
) -Xlinker
--end-group
52 -include $(TESTCASE_DEP
) $(TESTCASE_HOST_DEP
)
54 all: $(STATIC_LIB
) $(SHARED_LIB
)
56 testcases
: $(STATIC_LIB
) $(TESTCASE
)
58 testcases-host
: $(TESTCASE_HOST
)
61 @
rm -f
$(DEP
) $(DEP_SHARED
) $(OBJ
) $(OBJ_SHARED
) $(STATIC_LIB
) $(SHARED_LIB
) $(TESTCASE_DEP
) $(TESTCASE_HOST_DEP
) $(TESTCASE
) $(TESTCASE_HOST
) $(TESTCASE
:%=%.gcc
) $(TESTCASE
:%=%.out
) $(TESTCASE_HOST
:%=%.gcc
) $(TESTCASE_HOST
:%=%.out
)
69 @grep
-r
-H
-n
--exclude
=Doxyfile
--exclude
=Makefile
--exclude-dir
=doc
-e TODO
*
72 @sloccount
include source testcase
75 @echo
" C++ lightlibc++/$(@:%.o=%.cpp)"
76 @
$(CXX
) $(CXXFLAGS
) -MMD
-MF
$(@
:%.o
=%.dep
) -MT
$@
-c
$(@
:%.o
=%.
cpp) -o
$@
78 $(OBJ_SHARED
): Makefile
79 @echo
" C++ lightlibc++/$(@:%-shared.o=%.cpp)"
80 @
$(CXX
) $(CXXFLAGS_SHARED
) -MMD
-MF
$(@
:%.o
=%.dep
) -MT
$@
-c
$(@
:%-shared.o
=%.
cpp) -o
$@
84 @
$(AR
) rc
$(STATIC_LIB
) $(OBJ
)
86 $(SHARED_LIB
): $(OBJ_SHARED
)
88 @
$(CXX
) -nostdlib
-shared
$(OBJ_SHARED
) -o
$@
$(SHARED_LIB_NAME
) $(LIBGCC
) $(LIBC
)
90 $(TESTCASE
): $(STATIC_LIB
) Makefile
91 @
( $(CXX
) $(CXXFLAGS_TESTCASE
) -MMD
-MF
$(@
:%=%.dep
) -MT
$@
$(@
:%=%.
cpp) $(LIBS_TESTCASE
) -o
$@
2> $(@
:%=%.gcc
) && .
/testcase.sh
$@
$@
) || echo
-e
"\033[01;31mfailed to compile\033[m: $@"
93 $(TESTCASE_HOST
): Makefile
94 @
( $(CXX
) $(CXXFLAGS_COMMON_HOST
) -MMD
-MF
$(@
:%=%.dep
) -MT
$@
$(@
:%-host
=%.
cpp) -o
$@
2> $(@
:%=%.gcc
) && .
/testcase.sh
$@
$(@
:%-host
=%) ) || echo
-e
"\033[01;31mfailed to compile\033[m: $(@:%-host=%)"