Makefile.libc
2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Makefile for building libc
#include $(TOP)/Makefile.tools
# library specific compilation flags
CFLAGS=-ffreestanding -ffunction-sections -fdata-sections -Wno-unknown-pragmas $(LIBFLAGS)
all: $(LIBFILE) $(DSTDIR)/../include
@echo "NEWLIB (C/M) library is prepared"
# ------------------------------------------------------------------------------
# libc: from newlib
# build with configure/make
NEWLIB_SRCPATH=$(abspath ./newlib/newlib)
#C_SRCPATH=$(abspath ./newlib/newlib/libc)
#M_SRCPATH=$(abspath ./newlib/newlib/libm)
SRCPATH=$(abspath ./newlib/newlib/$(LIB))
NEWLIB_DSTDIR=$(DSTDIR)/../../newlib/$(ARCHID)
$(NEWLIB_DSTDIR):
mkdir -p $(NEWLIB_DSTDIR)
$(DSTDIR):
mkdir -p $(DSTDIR)
# run building
$(DSTDIR)/libc.a: $(DSTDIR) $(NEWLIB_DSTDIR) $(NEWLIB_DSTDIR)/libc.a
cp $(NEWLIB_DSTDIR)/libc.a $@
$(DSTDIR)/libm.a: $(DSTDIR) $(NEWLIB_DSTDIR) $(NEWLIB_DSTDIR)/libm.a
cp $(NEWLIB_DSTDIR)/libm.a $@
$(NEWLIB_DSTDIR)/libc.a: $(NEWLIB_DSTDIR)/Makefile
(cd $(NEWLIB_DSTDIR); AR_FLAGS=r make;)
$(NEWLIB_DSTDIR)/libm.a: $(NEWLIB_DSTDIR)/Makefile
(cd $(NEWLIB_DSTDIR); AR_FLAGS=r make;)
# run configure
$(NEWLIB_DSTDIR)/Makefile: $(NEWLIB_SRCPATH)/configure
(cd $(NEWLIB_DSTDIR); CC=$(CC) CFLAGS="$(CCARCH) $(CFLAGS) -I$(SRCPATH)/include -I$(SRCPATH)/../libc/machine/riscv --sysroot=$(NEWLIB_DSTDIR)/sysroot64" RANLIB=$(RANLIB) AR=$(AR) $(NEWLIB_SRCPATH)/configure --build=$(TOOLCHAIN) --prefix=$(NEWLIB_DSTDIR)/sysroot64 --disable-newlib-fno-builtin --enable-silent-rules --enable-newlib-nano-malloc;)
# --enable-newlib-nano-formatted-io
# --disable-newlib-io-float --enable-newlib-nano-malloc --enable-newlib-nano-formatted-io
# -Werror
# run preparing copy of directory 'include' (libc)
ifeq ($(LIB),libc)
$(DSTDIR)/../include: $(SRCPATH)
cp -r $(SRCPATH)/include $(DSTDIR)/../include
cp $(SRCPATH)/machine/riscv/sys/*.h $(DSTDIR)/../include/sys
endif
ifeq ($(LIB),libm) # run copying include (libm)
$(DSTDIR)/../include:
mkdir -p $@
cp $(SRCPATH)/machine/riscv/*.h $@
endif
# ------------------------------------------------------------------------------
clean:
rm `find $(DSTDIR) $(DSTDIR) -name "*.o"`
rm `find $(DSTDIR) -name "*.a"`