-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
157 lines (118 loc) · 5.46 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
BASE_CFLAGS = -std=c99 -Wall -fomit-frame-pointer -fno-asynchronous-unwind-tables -Wno-unused-function -Isrc/
CFLAGS = -Wall -O3 -g $(BASE_CFLAGS)
# CFLAGS = -Wall -O3 $(BASE_CFLAGS)
# CC = clang
CC = gcc
ARM_CC ?= gcc
ARM_AR ?= ar
ARM_CFLAGS=-g -Os -ffunction-sections -Wall -Wno-unused-function -Isrc/ -fno-asynchronous-unwind-tables -Wa,-mimplicit-it=thumb
CORTEX_CC ?=
CORTEX_AR ?=
CORTEX_CFLAGS += -Isrc/ --std=c99 --specs=nosys.specs -Wa,-mimplicit-it=thumb
# PRU_LINKER_COMMAND_FILE=./AM335x_PRU.cmd
PINCLUDE=--include_path=src/ --include_path=$(PRU_LIB)/pru/include/ --include_path=$(PRU_LIB)/pru/include/am335x
PSTACK_SIZE=0x100
PHEAP_SIZE=0x100
#Common compiler and linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide)
PCFLAGS=-v3 -O3 --c99 -k --display_error_number --endian=little --hardware_mac=on --obj_directory=_build/beagle-pru/ --pp_directory=_build/beagle-pru/ -ppd -ppa -DFW_NO_CORE_MULTIPLY -DFORTHWITH_NO_CHECKS
#Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide)
PLFLAGS=--reread_libs --warn_sections --stack_size=$(PSTACK_SIZE) --heap_size=$(PHEAP_SIZE)
# Build for default arch
ARCH := $(shell uname -m)
IS_ARM :=$(filter arm,$(shell uname -m | cut -c1-3))
ifeq ($(ARCH), x86_64)
FW_TARGET=linux-x86-64
endif
ifneq ($(IS_ARM),)
FW_TARGET=linux-arm
endif
default: $(FW_TARGET)
cd _build/
ln -sf $(FW_TARGET)/forthwith.a _build/libforthwith.a
ln -sf ../src/forthwith.h _build/forthwith.h
ln -sf ../src/$(FW_TARGET)/forthwith-consts.h _build/forthwith-consts.h
pru: _build/beagle-pru/forthwith-pru.lib _build/beagle-pru/porting-guide-pru
linux-x86-64: _build/linux-x86-64/forthwith-linux _build/linux-x86-64/test-forthwith-linux _build/linux-x86-64/porting-guide _build/linux-x86-64/forthwith.a
linux-arm: _build/linux-arm/porting-guide _build/linux-arm/forthwith-linux _build/linux-arm/test-forthwith-linux _build/linux-arm/forthwith.a
arduino-cortex: _build/arduino-arm-cortex/porting-guide _build/arduino-arm-cortex/forthwith.a
# ======= Linux x86 ======= #
_build/linux-x86-64/forthwith.a: _build/linux-x86-64/forthwith-linux.o
ar rcs $@ $<
_build/linux-x86-64/forthwith-linux: _build/linux-x86-64/forthwith-main.o _build/linux-x86-64/forthwith-linux.o
$(CC) -o [email protected] $(CFLAGS) -S $^
$(CC) -o $@ $(CFLAGS) $^
_build/linux-x86-64/test-forthwith-linux: src/test/test.c _build/linux-x86-64/forthwith-linux.o
$(CC) -o $@ $(CFLAGS) -Isrc/ -Isrc/linux-x86-64/ $^
_build/linux-x86-64/porting-guide: src/linux-x86-64/porting-guide.c
${CC} ${CFLAGS} $< -E -o [email protected]
$(CC) -o $@ $(CFLAGS) $^
$(CC) -o [email protected] $(CFLAGS) -S $^
_build/linux-x86-64/%.o: src/linux-x86-64/%.c
${CC} ${CFLAGS} $< -E -o [email protected]
${CC} ${CFLAGS} $< -S -o [email protected]
${CC} ${CFLAGS} $< -c -o $@
# ======= Linux Arm ======= #
_build/linux-arm/forthwith.a: _build/linux-arm/forthwith-linux.o
$(ARM_AR) rcs $@ $<
_build/linux-arm/forthwith-linux: _build/linux-arm/forthwith-main.o _build/linux-arm/forthwith-linux.o
$(ARM_CC) -o [email protected] $(ARM_CFLAGS) -S $^
$(ARM_CC) -o $@ $(ARM_CFLAGS) $^
_build/linux-arm/test-forthwith-linux: src/test/test.c _build/linux-arm/forthwith-linux.o
$(ARM_CC) -o $@ $(ARM_CFLAGS) -Isrc/ -Isrc/linux-arm/ $^
$(ARM_CC) -S -o [email protected] $(ARM_CFLAGS) -Isrc/ -Isrc/linux-arm/ $^
_build/linux-arm/porting-guide: src/linux-arm/porting-guide.c
${ARM_CC} ${ARM_CFLAGS} $< -E -o [email protected]
$(ARM_CC) -o $@ $(ARM_CFLAGS) $^
$(ARM_CC) -o [email protected] $(ARM_CFLAGS) -S $^
_build/linux-arm/%.o: src/linux-arm/%.c
${ARM_CC} ${ARM_CFLAGS} $< -S -o [email protected]
${ARM_CC} ${ARM_CFLAGS} $< -E -o [email protected]
${ARM_CC} ${ARM_CFLAGS} $< -c -o $@
# ======= Arduino Arm Cortex ======= #
_build/arduino-arm-cortex/forthwith.a: _build/arduino-arm-cortex/forthwith-arduino-cortex.o
$(CORTEX_AR) rcs $@ $<
# _build/arduino-arm-cortex/test-forthwith-linux: src/test/test.c _build/arduino-arm-cortex/forthwith-linux.o
# $(CORTEX_CC) -o $@ $(CORTEX_CFLAGS) -Isrc/ -Isrc/arduino-arm-cortex/ $^
# $(CORTEX_CC) -S -o [email protected] $(CORTEX_CFLAGS) -Isrc/ -Isrc/arduino-arm-cortex/ $^
_build/arduino-arm-cortex/porting-guide: src/arduino-arm-cortex/porting-guide.c
${CORTEX_CC} ${CORTEX_CFLAGS} $< -E -o [email protected]
$(CORTEX_CC) -o $@ $(CORTEX_CFLAGS) $^
$(CORTEX_CC) -o [email protected] $(CORTEX_CFLAGS) -S $^
_build/arduino-arm-cortex/%.o: src/arduino-arm-cortex/%.c
${CORTEX_CC} ${CORTEX_CFLAGS} $< -S -o [email protected]
${CORTEX_CC} ${CORTEX_CFLAGS} $< -E -o [email protected]
${CORTEX_CC} ${CORTEX_CFLAGS} $< -c -o $@
# ======= Beagle PRU ======= #
_build/beagle-pru/porting-guide-pru: src/beagle-pru/porting-guide.c _build/beagle-pru/forthwith-pru.lib
$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(PINCLUDE) $(PCFLAGS) -fe $@ $<
$(PRU_CGT)/bin/dispru --all $@ > [email protected]
_build/beagle-pru/forthwith-pru.lib: _build/beagle-pru/forthwith-pru.o
$(PRU_CGT)/bin/arpru r $@ $^
_build/beagle-pru/%.o: src/beagle-pru/%.c
$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(PINCLUDE) $(PCFLAGS) -fe $@ $<
$(PRU_CGT)/bin/dispru --all $@ > [email protected]
src/core-lib.c: library/core.fth
library/update-core.sh
run: default
_build/$(FW_TARGET)/forthwith-linux
test: default
_build/$(FW_TARGET)/test-forthwith-linux
clean: src/core-lib.c
rm -Rf _build/*
mkdir _build/linux-x86-64/
mkdir _build/linux-arm/
mkdir _build/arduino-arm-cortex/
mkdir _build/beagle-pru/
clean-cortex:
rm -Rf _build/arduino-arm-cortex/
mkdir _build/arduino-arm-cortex/
clean-arm:
rm -Rf _build/linux-arm/
mkdir _build/linux-arm/
clean-x86:
rm -Rf _build/linux-x86/
mkdir _build/linux-x86/
clean-pru:
rm -Rf _build/beagle-pru/
mkdir _build/beagle-pru/
.PHONY: clean examples test