Makefile.libbuilt
1.25 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
# Makefile for building 'built' library (built-in llvm functions)
#include $(TOP)/Makefile.tools
# library specific compilation flags
CFLAGS=-ffunction-sections -fdata-sections $(LIBFLAGS)
# ------------------------------------------------------------------------------
# libbuilt: from llvm/builtin
C_SRCPATH:=$(abspath ./builtins)
C_SRCS=$(notdir $(wildcard $(C_SRCPATH)/*.c))
LIBOBJS=$(C_SRCS:%.c=$(DSTDIR)/%.o)
#$(info TEST >>>>)
#$(info $(C_SRCS))
#$(info $(LIBOBJS))
#$(info <<<< TEST)
all: $(DSTDIR)/../include $(DSTDIR)/libbuilt.a
echo "BUILTIN library is prepared"
# create library
$(DSTDIR)/libbuilt.a: $(LIBOBJS)
@$(AR) r $@ $(LIBOBJS)
# run preparing copy of directory 'include'
$(DSTDIR)/../include:
mkdir $@
# compile objects
define GEN_C2O_RULE
$(DSTDIR)/$(cfile:.c=.o) : $(DSTDIR)/$(cfile:.c=.c_S)
@echo "Assemble $$@ from $$<"
@$(AS) $(ASARCH) -gdwarf-5 -o $$@ $$<
$(DSTDIR)/$(cfile:.c=.c_S) : $(C_SRCPATH)/$(cfile)
@echo "Compile '$$<' to '$$@' $(C_SRCPATH)"
@$(CC) $(CCARCH) $(CFLAGS) -fno-addrsig -I$(C_SRCPATH) -S -o $$@ $$<
endef
$(foreach cfile, $(C_SRCS), \
$(eval $(GEN_C2O_RULE)) \
)
# ------------------------------------------------------------------------------
clean:
rm `find $(DSTDIR) -name "*.o"`
rm `find $(DSTDIR) -name "*.a"`