-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile
More file actions
75 lines (55 loc) · 2.27 KB
/
makefile
File metadata and controls
75 lines (55 loc) · 2.27 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
70
71
72
73
74
75
#--------------------------------------------
# Makefile based on the following tutorial: http://make.mad-scientist.net/papers/multi-architecture-builds/
# If new target required just duplicate one of the *.mk file and modify it. Then just execute the make command in the folder.
# This makefile will call all *.mk file in the current folder and compile all targets defined in *.mk files.
#--------------------------------------------
# Global config may be changed
NUM_OF_PARALLEL_JOBS := 4
LIB_OUT_DIR_PATH := dist/
# compilers
XC32_CC := "C:\Program Files\Microchip\xc32\v4.35\bin\xc32-gcc.exe"
XC32_AR := "C:\Program Files\Microchip\xc32\v4.35\bin\xc32-ar.exe"
XCDSC_CC := "C:\Program Files\Microchip\xc-dsc\v3.20\bin\xc-dsc-gcc.exe"
XCDSC_AR := "C:\Program Files\Microchip\xc-dsc\v3.20\bin\xc-dsc-ar.exe"
#----------------------------------
# do not change the rest
# Output dirs start with underscore
ifeq (,$(filter _%,$(notdir $(CURDIR))))
# execute all *.mk files
export LIB_OUT_DIR_PATH XC16_CC XC16_AR XC32_CC XC32_AR XCDSC_CC XCDSC_AR
TARGETS = $(wildcard *.mk)
TOPTARGETS := all clean
$(TOPTARGETS): $(TARGETS) combine
$(TARGETS):
$(MAKE) -f $@ $(MAKECMDGOALS)
#XCDSC specific
combine:
$(info Combining XCDSC libs)
$(eval XC_DSC_OBJ_FILES := ${wildcard _OBJXCDSC/*.o})
$(info obj files to combine: ${XC_DSC_OBJ_FILES})
${XCDSC_AR} cvq ${LIB_OUT_DIR_PATH}libx2cscope2-generic-pic24-dspic33-elf.a ${XC_DSC_OBJ_FILES}
.PHONY: $(TOPTARGETS) $(TARGETS)
else
#----- Do not change the rest
# relative to _OBJ dir
SRC_DIR := ../X2Cscope/src
INC_DIR := ../X2Cscope/inc
VPATH = $(SRC_DIR)
# Remove -mcu= and -mprocessor from SET_PROCESSOR and store it in SET_ARCH
SET_ARCH := $(subst -mcpu=,,$(SET_PROCESSOR))
SET_ARCH := $(subst -mprocessor=,,$(SET_ARCH))
SRC_FILES := $(wildcard $(SRC_DIR)/*.c)
SRC_FILES_WODIR := $(notdir ${SRC_FILES})
OBJ_FILES := $(SRC_FILES_WODIR:%.c=${SET_ARCH}%.o)
$(info OBJ_FILES ${OBJ_FILES})
$(TARGET_FILENAME): $(OBJ_FILES)
$(info ${OBJ_FILES})
# relative to obj dir
gnumkdir -p ../$(LIB_OUT_DIR_PATH)
${AR} -omf=elf -r ../$(LIB_OUT_DIR_PATH)$(TARGET_FILENAME) $^
#create MCU specific obj files
${SET_ARCH}%.o: %.c
$(info Compiling)
${CC} ${SET_PROCESSOR} -D${DEFINE_X2C_MCU_FAMILY} -I${INC_DIR} ${OPTIMISATION} -c $< -o $@
#----- Begin Boilerplate
endif