-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
131 lines (107 loc) · 4.27 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
# Makefile for leanXzebra.
# Copyright (C) 2008 Supercomputing Systems AG
#
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this library; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Disable make's built-in rules.
MAKE += -RL --no-print-directory
SHELL := $(shell which bash)
# Generic flags for the C compiler.
CFLAGS := -c -std=gnu99 -Wall -Ioscar/include
# Include the file generated by te configuration process.
-include .config
ifeq '$(filter .config, $(MAKEFILE_LIST))' ''
$(error Please configure the application using './configure' prior to compilation.)
endif
# Name for the application to produce.
APP_NAME := leanXzebra
# Binary executables to generate.
PRODUCTS := app
# Listings of source files for the different executables.
SOURCES_app := $(wildcard *.c)
ifeq '$(CONFIG_ENABLE_SIMULATION)' 'y'
CC_host += -DOSC_SIM
CC_target += -DOSC_SIM
endif
ifeq '$(CONFIG_ENABLE_DEBUG)' 'y'
CC_host := gcc $(CFLAGS) -DOSC_HOST -g
CC_target := bfin-uclinux-gcc $(CFLAGS) -DOSC_TARGET -ggdb3
else
CC_host := gcc $(CFLAGS) -DOSC_HOST -O2
CC_target := bfin-uclinux-gcc $(CFLAGS) -DOSC_TARGET -O2
endif
LD_host := gcc -fPIC
LD_target := bfin-uclinux-gcc -elf2flt="-s 1048576"
# Listings of source files for the different applications.
SOURCES_$(APP_NAME) := $(wildcard *.c)
APPS := $(patsubst SOURCES_%, %, $(filter SOURCES_%, $(.VARIABLES)))
LIBS_host := oscar/library/libosc_host
LIBS_target := oscar/library/libosc_target
ifeq '$(CONFIG_ENABLE_SIMULATION)' 'y'
LIBS_target := $(LIBS_target)_sim
endif
ifeq '$(CONFIG_ENABLE_DEBUG)' 'y'
LIBS_host := $(LIBS_host)_dbg
LIBS_target := $(LIBS_target)_dbg
endif
LIBS_host := $(LIBS_host).a
LIBS_target := $(LIBS_target).a
BINARIES := $(addsuffix _host, $(PRODUCTS)) $(addsuffix _target, $(PRODUCTS))
.PHONY: all clean host target install deploy run reconfigure
all: $(BINARIES)
host target: %: $(addsuffix _%, $(PRODUCTS))
deploy: $(APP_NAME).app
tar c $< | ssh root@$(CONFIG_TARGET_IP) 'rm -rf $< && tar x' || true
run:
uxterm -e ssh root@$(CONFIG_TARGET_IP) /mnt/app/$(APP_NAME).app/run.sh || true
reconfigure:
ifeq '$(CONFIG_PRIVATE_FRAMEWORK)' 'n'
@ ! [ -e "oscar" ] || [ -h "oscar" ] && ln -sfn $(CONFIG_FRAMEWORK_PATH) oscar || echo "The symlink to the lgx module could not be created as the file ./lgx already exists and is something other than a symlink. Pleas remove it and run 'make reconfigure' to create the symlink."
endif
@ ! [ -d "oscar" ] || $(MAKE) -C oscar config
oscar/%:
$(MAKE) -C oscar $*
# Including depency files and optional local Makefile.
-include build/*.d
# Build targets.
build/%_host.o: %.c $(filter-out %.d, $(MAKEFILE_LIST))
@ mkdir -p $(dir $@)
$(CC_host) -MD $< -o $@
@ grep -oE '[^ \\]+' < $(@:.o=.d) | sed -r '/:$$/d; s|^.*$$|$@: \0\n\0:|' > $(@:.o=.d~) && mv -f $(@:.o=.d){~,}
build/%_target.o: %.c $(filter-out %.d, $(MAKEFILE_LIST))
@ mkdir -p $(dir $@)
$(CC_target) -MD $< -o $@
@ grep -oE '[^ \\]+' < $(@:.o=.d) | sed -r '/:$$/d; s|^.*$$|$@: \0\n\0:|' > $(@:.o=.d~) && mv -f $(@:.o=.d){~,}
# Link targets.
define LINK
$(1)_host: $(patsubst %.c, build/%_host.o, $(SOURCES_$(1))) $(LIBS_host)
$(LD_host) -o $$@ $$^
$(1)_target: $(patsubst %.c, build/%_target.o, $(SOURCES_$(1))) $(LIBS_target)
$(LD_target) -o $$@ $$^ -lm -lbfdsp
endef
$(foreach i, $(PRODUCTS), $(eval $(call LINK,$i)))
.PHONY: $(APP_NAME).app
$(APP_NAME).app: $(addsuffix _target, $(PRODUCTS))
rm -rf $@
cp -rL app $@
# Controlling the gdbserver on target
.PHONY : gdbserver-start
gdbserver-start:
uxterm -e ssh root@$(CONFIG_TARGET_IP) gdbserver :7777 /mnt/app/$(APP_NAME).app/app
.PHONY : gdbserver-kill
gdbserver-kill:
uxterm -e ssh root@$(CONFIG_TARGET_IP) killall gdbserver
# Cleans the module.
clean:
rm -rf build *.gdb $(BINARIES) $(APP_NAME).app