-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (48 loc) · 1.7 KB
/
Makefile
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
# jason.dahlstrom@gmail.com
TARGET = Debug
# Include each /../include directory in the include paths
INCLUDE_PATHS = ./include
INCDIR = $(foreach d, $(INCLUDE_PATHS), -I$d)
BINDIR =/opt/Xilinx/SDK/2016.2/gnu/arm/lin/bin
AS = ${BINDIR}/arm-xilinx-eabi-as
CC = ${BINDIR}/arm-xilinx-eabi-gcc
LD = ${BINDIR}/arm-xilinx-eabi-ld
SZ = ${BINDIR}/arm-xilinx-eabi-size
ASFLAGS = -g -mcpu=cortex-a9
CCFLAGS = ${INCDIR} -MMD -MP -nostdinc -mthumb-interwork -fno-builtin -O0 -g -Wall -Werror -mcpu=cortex-a9 -c
LDFLAGS = -nostdlib -TZynq.ld
LIBDIR = lib
LIBS = -lgcc
${TARGET}/obj/%.o: %.S
mkdir -p ${TARGET}/obj/
${AS} ${ASFLAGS} -o ${TARGET}/obj/${@F} $<
${TARGET}/obj/%.o: %.c
mkdir -p ${TARGET}/obj/
${CC} ${CCFLAGS} -o ${TARGET}/obj/${@F} $<
VPATH = ./asm ./src
S_SRCS = $(shell find ${VPATH} -maxdepth 1 -name "*.S")
S_OBJS = ${S_SRCS:.S=.o}
C_SRCS = $(shell find ${VPATH} -maxdepth 1 -name "*.c")
C_OBJS = ${C_SRCS:.c=.o}
OBJS = $(addprefix ${TARGET}/obj/, $(notdir ${S_OBJS} ${C_OBJS}))
all: image
image : ${OBJS}
${LD} ${LDFLAGS} -L${LIBDIR} -o ${TARGET}/$@.elf ${OBJS} ${LIBS}
@${SZ} ${TARGET}/$@.elf
#
# Remove all build output
#
clean : force
rm -rf Debug/
#
# Bring in header file dependencies. These are gnerated with the -MMD and -MP
# flags to gcc below. If the .d file doesn't exist that means the .o file
# doesn't exist, so the target is built. If a .o file is built, then a
# corresponding .d file also exists so this will read in correct dependencies
#
-include $(OBJS:.o=.d)
#
# Indicate that 'force' is never up to date, so the dependent rule always
# executes even if the file "force" exists and appears up to date...
#
.PHONY : force