-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (92 loc) · 3.56 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
# The executable name is suffix depending on the target
OUT = rich-view
HOST_SUFFIX = _host
TARGET_SUFFIX = _target
TARGETSIM_SUFFIX = _sim_target
# Disable make's built-in rules
MAKEFLAGS += -r
# this includes the framework configuration
-include .config
# decide whether we are building or dooing something other like cleaning or configuring
ifeq ($(filter $(MAKECMDGOALS), clean distclean config), )
# check whether a .config file has been found
ifeq ($(filter .config, $(MAKEFILE_LIST)), )
$(error "Cannot make the target '$(MAKECMDGOALS)' without configuring the application. Please run make config to do this.")
endif
endif
# Host-Compiler executables and flags
HOST_CC = gcc
HOST_CFLAGS = $(HOST_FEATURES) -Wall -pedantic -Wno-long-long -DOSC_HOST -g
HOST_LDFLAGS = -lm
# Cross-Compiler executables and flags
TARGET_CC = bfin-uclinux-gcc
TARGET_CFLAGS = -Wall -pedantic -Wno-long-long -O2 -DOSC_TARGET
TARGETDBG_CFLAGS = -Wall -pedantic -Wno-long-long -ggdb3 -DOSC_TARGET
TARGETSIM_CFLAGS = -Wall -pedantic -Wno-long-long -O2 -DOSC_TARGET -DOSC_SIM
TARGET_LDFLAGS = -Wl,-elf2flt="-s 1048576" -lbfdsp
# Source files of the application
SOURCES = main.c mainstate.c communication.c
# Default target
all : $(OUT)
$(OUT) : target host
# this target ensures that the application has beeb built prior to deployment
$(OUT)_% :
@ echo "Please use make {target,targetdbg,targetsim} to build the application first"; exit 1
# Compiles the executable
target: $(SOURCES) inc/*.h lib/libosc_target.a
@echo "Compiling for target.."
$(TARGET_CC) $(SOURCES) lib/libosc_target.a $(TARGET_CFLAGS) \
$(TARGET_LDFLAGS) -o $(OUT)$(TARGET_SUFFIX)
@echo "Target executable done."
[ -d /tftpboot ] && cp $(OUT)$(TARGET_SUFFIX) /tftpboot/$(OUT); exit 0
targetdbg: $(SOURCES) inc/*.h lib/libosc_target.a
@echo "Compiling for target.."
$(TARGET_CC) $(SOURCES) lib/libosc_target.a $(TARGETDBG_CFLAGS) \
$(TARGET_LDFLAGS) -o $(OUT)$(TARGET_SUFFIX)
@echo "Target executable done."
[ -d /tftpboot ] && cp $(OUT)$(TARGET_SUFFIX) /tftpboot/$(OUT); exit 0
targetsim: $(SOURCES) inc/*.h lib/libosc_target_sim.a
@echo "Compiling for target.."
$(TARGET_CC) $(SOURCES) lib/libosc_target_sim.a $(TARGETSIM_CFLAGS) \
$(TARGET_LDFLAGS) -o $(OUT)$(TARGETSIM_SUFFIX)
@echo "Target executable done."
[ -d /tftpboot ] && cp $(OUT)$(TARGETSIM_SUFFIX) /tftpboot/$(OUT); exit 0
host: $(SOURCES) inc/*.h lib/libosc_host.a
@echo "Compiling for host.."
$(HOST_CC) $(SOURCES) lib/libosc_host.a $(HOST_CFLAGS) \
$(HOST_LDFLAGS) -o $(OUT)$(HOST_SUFFIX)
@echo "Host executable done."
cp $(OUT)$(HOST_SUFFIX) $(OUT)
# Target to explicitly start the configuration process
.PHONY : config
config :
@ ./configure
@ $(MAKE) --no-print-directory get
# Set symlinks to the framework
.PHONY : get
get :
@ rm -rf inc lib
@ ln -s $(CONFIG_FRAMEWORK)/staging/inc ./inc
@ ln -s $(CONFIG_FRAMEWORK)/staging/lib ./lib
@ echo "Configured Oscar framework."
# deploying to the device
.PHONY : deploy
deploy : $(OUT)$(TARGET_SUFFIX)
@ scp -rp $(OUT)$(TARGET_SUFFIX) root@$(CONFIG_TARGET_IP):/mnt/app/ || echo -n ""
@ echo "Application deployed."
# deploying the simulation binary to the device
.PHONY : deploysim
deploysim : $(OUT)$(TARGETSIM_SUFFIX)
@scp -rp $(OUT)$(TARGETSIM_SUFFIX) root@$(CONFIG_TARGET_IP):/mnt/app/ || echo -n ""
@ echo "Application deployed."
# Cleanup
.PHONY : clean
clean :
rm -f $(OUT)$(HOST_SUFFIX) $(OUT)$(TARGET_SUFFIX) $(OUT)$(TARGETSIM_SUFFIX)
rm -f *.o *.gdb
@ echo "Directory cleaned"
# Cleans everything not intended for source distribution
.PHONY : distclean
distclean : clean
rm -f .config
rm -rf inc lib