rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | ### |
| 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 | ## |
| 11 | GCC ?= $(CROSS)gcc |
| 12 | CC ?= $(GCC) |
| 13 | CXX ?= $(CROSS)g++ |
| 14 | OBJDUMP = $(CROSS)objdump |
| 15 | OBJCOPY = $(CROSS)objcopy |
| 16 | AR = $(CROSS)ar |
| 17 | |
| 18 | SUBLPATH?= $(SUBVPATH) |
| 19 | INCLUDE ?= $(DEF_INCLUDE) |
| 20 | CFLAGS ?= $(DEF_CFLAGS) |
| 21 | ASFLAGS ?= $(DEF_ASFLAGS) |
| 22 | LDFLAGS ?= $(DEF_LDFLAGS) |
| 23 | DOC_GEN ?= $(PREFIX)/APITemp.txt |
| 24 | |
| 25 | VPATH ?= src $(SUBVPATH) |
| 26 | VOBJ ?= $(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 | |
| 36 | LPATH ?= src $(SUBLPATH) |
| 37 | LOBJ ?= $(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))))))) |
| 46 | COBJ ?= $(patsubst %.c,%.o, \ |
| 47 | $(patsubst %.cpp, %.o, \ |
| 48 | $(notdir $(foreach DIR,$(VPATH),\ |
| 49 | $(wildcard $(DIR)/*.c) \ |
| 50 | $(wildcard $(DIR)/*.cpp))))) |
| 51 | DEP = $(COBJ:%.o=%.d) |
| 52 | TEST = $(COBJ:%.o=%.x) |
| 53 | RUNS = $(COBJ:%.o=%.x.run) |
| 54 | |
| 55 | MIN ?=1 |
| 56 | |
| 57 | default: all |
| 58 | |
| 59 | all: |
| 60 | |
| 61 | gen_dir: |
| 62 | mkdir -p $(ROOT)/bin |
| 63 | mkdir -p $(ROOT)/${base_libdir} |
| 64 | mkdir -p $(ROOT)/$(includedir)/$(NAME) |
| 65 | ifeq ($(strip $(MIN)),1) |
| 66 | mkdir -p $(ROOT)/doc |
| 67 | else |
| 68 | mkdir -p $(ROOT)/doc/$(NAME) |
| 69 | endif |
| 70 | |
| 71 | mkdir -p $(ROOT)/test/$(NAME) |
| 72 | |
| 73 | install: gen_dir $(INSTALL) |
| 74 | rm -f $(ROOT)/${base_libdir}/lib$(NAME).* $(ROOT)/${base_libdir}/$(NAME).dll |
| 75 | |
| 76 | ifdef LIB |
| 77 | ifneq ($(strip $(LIB)), dummy) |
| 78 | ifneq ($(strip $(base_libdir)),"") |
| 79 | install -p ./$(base_libdir)/lib$(NAME).* $(ROOT)/$(base_libdir)/ |
| 80 | endif |
| 81 | endif |
| 82 | endif |
| 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' |
| 85 | ifeq ($(strip $(MIN)),1) |
| 86 | else |
| 87 | install -p doc/html/* $(ROOT)/doc/$(NAME)/ |
| 88 | endif |
| 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 | |
| 93 | uninstall: $(UNINSTALL) |
| 94 | rm -rf $(ROOT)/$(includedir)/$(NAME) |
| 95 | rm -rf $(ROOT)/test/$(NAME) |
| 96 | ifneq ($(strip $(LIB)), dummy) |
| 97 | cd $(ROOT)/$(base_libdir)/ && rm -f $(LIB) |
| 98 | endif |
| 99 | rm -f $(ROOT)/doc/$(NAME).files |
| 100 | rm -f $(ROOT)/doc/$(NAME).info |
| 101 | |
| 102 | |
| 103 | |