blob: 2b937243a63b1627751ef6159aa6ff019744ebbf [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001###
2# @file Makefile.prebuilt.template
3# @breif This is the file user has to setup locally for different host environment
4#
5# @param VOBJ object files applicable for compilation
6# @param LOBJ object files included in lib$(NAME).a
7# @param COBJ object files applicable to standard-make-targets
8#
9# @author Howard Chen
10##
11GCC ?= $(CROSS)gcc
12CC ?= $(GCC)
13CXX ?= $(CROSS)g++
14OBJDUMP = $(CROSS)objdump
15OBJCOPY = $(CROSS)objcopy
16AR = $(CROSS)ar
17
18SUBLPATH?= $(SUBVPATH)
19INCLUDE ?= $(DEF_INCLUDE)
20CFLAGS ?= $(DEF_CFLAGS)
21ASFLAGS ?= $(DEF_ASFLAGS)
22LDFLAGS ?= $(DEF_LDFLAGS)
23DOC_GEN ?= $(PREFIX)/APITemp.txt
24
25VPATH ?= src $(SUBVPATH)
26VOBJ ?= $(patsubst %.S,%.o, \
27 $(patsubst %.s,%.o, \
28 $(patsubst %.c,%.o, \
29 $(patsubst %.cpp, %.o, \
30 $(notdir $(foreach DIR,$(VPATH),\
31 $(wildcard $(DIR)/*.S) \
32 $(wildcard $(DIR)/*.s) \
33 $(wildcard $(DIR)/*.c) \
34 $(wildcard $(DIR)/*.cpp)))))))
35
36LPATH ?= src $(SUBLPATH)
37LOBJ ?= $(patsubst %.S,%.o, \
38 $(patsubst %.s,%.o, \
39 $(patsubst %.c,%.o, \
40 $(patsubst %.cpp, %.o, \
41 $(notdir $(foreach DIR,$(LPATH),\
42 $(wildcard $(DIR)/*.S) \
43 $(wildcard $(DIR)/*.s) \
44 $(wildcard $(DIR)/*.c) \
45 $(wildcard $(DIR)/*.cpp)))))))
46COBJ ?= $(patsubst %.c,%.o, \
47 $(patsubst %.cpp, %.o, \
48 $(notdir $(foreach DIR,$(VPATH),\
49 $(wildcard $(DIR)/*.c) \
50 $(wildcard $(DIR)/*.cpp)))))
51DEP = $(COBJ:%.o=%.d)
52TEST = $(COBJ:%.o=%.x)
53RUNS = $(COBJ:%.o=%.x.run)
54
55MIN ?=1
56
57default: all
58
59all:
60
61gen_dir:
62 mkdir -p $(ROOT)/bin
63 mkdir -p $(ROOT)/${base_libdir}
64 mkdir -p $(ROOT)/$(includedir)/$(NAME)
65ifeq ($(strip $(MIN)),1)
66 mkdir -p $(ROOT)/doc
67else
68 mkdir -p $(ROOT)/doc/$(NAME)
69endif
70
71 mkdir -p $(ROOT)/test/$(NAME)
72
73install: gen_dir $(INSTALL)
74 rm -f $(ROOT)/${base_libdir}/lib$(NAME).* $(ROOT)/${base_libdir}/$(NAME).dll
75
76ifdef LIB
77ifneq ($(strip $(LIB)), dummy)
78ifneq ($(strip $(base_libdir)),"")
79 install -p ./$(base_libdir)/lib$(NAME).* $(ROOT)/$(base_libdir)/
80endif
81endif
82endif
83 bash -c 'if ls *.x > /dev/null 2>&1 ; then install *.x $(ROOT)/test/$(NAME); fi'
84 bash -c 'if [ -e ./$(includedir)/$(NAME) ] && [ "$(shell ls -A "./$(includedir)/$(NAME)")" ]; then rm -rf $(ROOT)/$(includedir)/$(NAME)/*; cp -af ./$(includedir)/$(NAME)/* $(ROOT)/$(includedir)/$(NAME); fi'
85ifeq ($(strip $(MIN)),1)
86else
87 install -p doc/html/* $(ROOT)/doc/$(NAME)/
88endif
89 bash -c 'if [ -e ./doc/$(NAME).files ]; then cp ./doc/$(NAME).files $(ROOT)/doc/$(NAME).files; fi'
90 bash -c 'if [ -e ./doc/$(NAME).info ]; then cp ./doc/$(NAME).info $(ROOT)/doc/$(NAME).info; fi'
91
92
93uninstall: $(UNINSTALL)
94 rm -rf $(ROOT)/$(includedir)/$(NAME)
95 rm -rf $(ROOT)/test/$(NAME)
96ifneq ($(strip $(LIB)), dummy)
97 cd $(ROOT)/$(base_libdir)/ && rm -f $(LIB)
98endif
99 rm -f $(ROOT)/doc/$(NAME).files
100 rm -f $(ROOT)/doc/$(NAME).info
101
102
103