@@ -15,27 +15,19 @@ include ../phoenix-rtos-build/Makefile.common
1515SYSROOT := $(shell $(CC ) $(CFLAGS ) -print-sysroot)
1616MULTILIB_DIR := $(shell $(CC ) $(CFLAGS ) -print-multi-directory)
1717LIBC_INSTALL_DIR := $(SYSROOT ) /lib/$(MULTILIB_DIR )
18- LIBC_INSTALL_NAMES := libc.a libm.a libg.a libpthread.a libubsan.a
18+ LIBC_INSTALL_NAMES_A := libc.a libm.a libg.a libpthread.a libubsan.a
1919HEADERS_INSTALL_DIR := $(SYSROOT ) /usr/include
20- LIBNAME := libphoenix.a
2120
2221ifeq (,$(filter-out /,$(SYSROOT ) ) )
2322$(error SYSROOT is not supported by the toolchain. Use cross-toolchain to compile.)
2423endif
2524
2625CFLAGS += -Iinclude -fno-builtin-malloc
2726
28- ifeq ($(LIBPHOENIX_PIC ) , y)
29- CFLAGS += $(TARGET_PIC_FLAG )
30- endif
31-
3227OBJS :=
3328# crt0.o should have all necessary initialization + call to main()
3429CRT0_OBJS := $(PREFIX_O ) crt0-common.o
3530
36- LIB_TARGETS := $(PREFIX_A ) libphoenix.a $(PREFIX_A ) crt0.o
37-
38- all : $(LIB_TARGETS )
3931
4032ifneq (,$(findstring arm,$(TARGET_SUFF ) ) )
4133 include arch/arm/Makefile
@@ -67,7 +59,20 @@ include unistd/Makefile
6759include wchar/Makefile
6860include ubsan/Makefile
6961
70- # include test/Makefile
62+
63+ LIB_TARGETS := $(PREFIX_A ) libphoenix.a $(PREFIX_A ) crt0.o
64+ INSTALL_TARGETS := install-headers install-libs
65+
66+ ifeq ($(LIBPHOENIX_PIC ) , y)
67+ CFLAGS += $(TARGET_PIC_FLAG )
68+ ifeq ($(LIBPHOENIX_SHARED ) , y)
69+ include shared.mk
70+ endif
71+ endif
72+
73+
74+ all : $(LIB_TARGETS )
75+
7176
7277$(PREFIX_A ) libphoenix.a : $(OBJS )
7378 $(ARCH )
@@ -78,7 +83,8 @@ $(PREFIX_A)crt0.o: $(CRT0_OBJS)
7883
7984SRCHEADERS := $(shell find include -name \* .h)
8085
81- install : install-headers install-libs
86+
87+ install : $(INSTALL_TARGETS )
8288
8389install-headers : $(SRCHEADERS )
8490 @echo INSTALL " $( HEADERS_INSTALL_DIR) /*" ; \
@@ -87,16 +93,16 @@ install-headers: $(SRCHEADERS)
8793
8894# TODO: remove `rm crt0.o` when we will be sure it's not a symlink to libphoenix.a anymore
8995install-libs : $(LIB_TARGETS )
90- @ echo INSTALL " $( LIBC_INSTALL_DIR) /*" ; \
96+ $( SIL ) echo INSTALL " $( LIBC_INSTALL_DIR) /*" ; \
9197 mkdir -p " $( LIBC_INSTALL_DIR) " ; \
9298 rm -rf " $( LIBC_INSTALL_DIR) /crt0.o" ; \
9399 cp -a $^ " $( LIBC_INSTALL_DIR) " ; \
94100 (cd $( LIBC_INSTALL_DIR) && \
95- for lib in $( LIBC_INSTALL_NAMES ) ; do \
101+ for lib in $( LIBC_INSTALL_NAMES_A ) ; do \
96102 if [ ! -e " $$ lib" ]; then \
97103 ln -sf " libphoenix.a" " $$ lib" ; \
98104 fi \
99- done)
105+ done)
100106
101107.PHONY : clean install install-headers install-libs
102108clean :
0 commit comments