-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
203 lines (166 loc) · 6.66 KB
/
Makefile
File metadata and controls
203 lines (166 loc) · 6.66 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# Makefile for Applications using the Oscar Framework
# Copyright (C) 2008 Supercomputing Systems AG
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty. This file is offered as-is,
# without any warranty.
# Disable make's built-in rules.
MAKE += -RL --no-print-directory
SHELL := $(shell which bash)
# 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
##--------------------------------------------------------------------------
# Application specific part
##--------------------------------------------------------------------------
# Name for the application to produce.
APP_NAME := web_view_cpp
# Name of the directory the application should be deployed to on the target.
DEPLOY_DIR := /mnt/app/
# Binary executables to generate (make sure it's the same as in the run.sh script).
PRODUCTS := app
# subproduct folders: for each folder, make will be called
SUB_PRODUCTS := cgi
# Listings of source files for the different executables.
SOURCES_app := $(wildcard *.cpp) $(wildcard *.c)
# Listings of source files for the different applications.
SOURCES_$(APP_NAME) := $(wildcard *.cpp) $(wildcard *.c)
# statically linked libraries
LIBS_host := oscar/library/libosc_host
LIBS_target := oscar/library/libosc_target
##--------------------------------------------------------------------------
# Common part
##--------------------------------------------------------------------------
# Generic flags for the C/CPP compiler.
CFLAGS := -c -Wall -Ioscar/include
ifeq '$(CONFIG_USE_OPENCV)' 'y'
CFLAGS += -I$(CONFIG_OPENCV_PATH)/include/opencv
OPENCV_LIBS_host := -L$(CONFIG_OPENCV_PATH)/build-host/src/.libs -lcvaux -lcv -lcxcore -lpthread -ldl -lrt -lz
OPENCV_LIBS_target := -L$(CONFIG_OPENCV_PATH)/build-target/src/.libs -lbfdsp -lcvaux -lcv -lcxcore -lpthread -lrt
else
OPENCV_LIBS_host :=
OPENCV_LIBS_target :=
endif
#Oscar CC
ifeq '$(CONFIG_USE_OSCAR_CC)' 'y'
IS_ABSOLUTE_PATH := $(shell expr "$(CONFIG_FRAMEWORK_PATH)" : '/')
ifeq '$(IS_ABSOLUTE_PATH)' '0'
ABS_OSCAR_PATH := $(shell pwd)/$(CONFIG_FRAMEWORK_PATH)
else
ABS_OSCAR_PATH := $(CONFIG_FRAMEWORK_PATH)
endif
-include $(CONFIG_OSCAR_CC_PATH)/.config
#M_INC := -I$(CONFIG_OSCAR_CC_PATH)/modules/$mod/include
CFLAGS += $(addsuffix /include, $(addprefix -I$(CONFIG_OSCAR_CC_PATH)/modules/, $(CONFIG_CC_MODULES)))
OSC_CC_LIBS_host := $(addsuffix _host, $(addprefix -losc-cc_, $(CONFIG_CC_MODULES)))
OSC_CC_LIBS_target := $(addsuffix _target, $(addprefix -losc-cc_, $(CONFIG_CC_MODULES)))
OSC_CC_LIBS_INC := -L$(CONFIG_OSCAR_CC_PATH)/library
else
OSC_CC_LIBS_host :=
OSC_CC_LIBS_target :=
OSC_CC_LIBS_INC :=
endif # '$(CONFIG_USE_OSCAR_CC)' 'y'
ifeq '$(CONFIG_USE_GPP_COMPILER)' 'y'
GCC := g++
else
CFLAGS += -std=gnu99
GCC := gcc
endif
CC_host := $(GCC) $(CFLAGS) -DOSC_HOST -D'APP_NAME="$(APP_NAME)"'
CC_target := bfin-uclinux-$(GCC) $(CFLAGS) -DOSC_TARGET -D'APP_NAME="$(APP_NAME)"'
LD_host := $(GCC) -fPIC
LD_target := bfin-uclinux-$(GCC) -elf2flt="-s 1048576"
ifeq '$(CONFIG_ENABLE_DEBUG)' 'y'
CC_host += -g
CC_target += -ggdb3
else
CC_host += -O2
CC_target += -O2
endif
ifeq '$(CONFIG_ENABLE_SIMULATION)' 'y'
CC_host += -DOSC_SIM
CC_target += -DOSC_SIM
endif
ifeq '$(CONFIG_PRIVATE_FRAMEWORK)' 'y'
CONFIG_FRAMEWORK_PATH := ./oscar
endif
APPS := $(patsubst SOURCES_%, %, $(filter SOURCES_%, $(.VARIABLES)))
ifeq '$(CONFIG_ENABLE_SIMULATION)' 'y'
LIBS_target := $(LIBS_target)_sim
endif
ifeq '$(CONFIG_ENABLE_DEBUG)' 'y'
LIBS_host := $(addsuffix _dbg, $(LIBS_host))
LIBS_target := $(addsuffix _dbg, $(LIBS_target))
OSC_CC_LIBS_host := $(addsuffix _dbg, $(OSC_CC_LIBS_host))
OSC_CC_LIBS_target := $(addsuffix _dbg, $(OSC_CC_LIBS_target))
endif
LIBS_host := $(addsuffix .a, $(LIBS_host))
LIBS_target := $(addsuffix .a, $(LIBS_target))
BINARIES := $(addsuffix _host, $(PRODUCTS)) $(addsuffix _target, $(PRODUCTS))
.PHONY: all clean host target install deploy run reconfigure opencv oscar
all: $(BINARIES)
$(foreach i, $(SUB_PRODUCTS), make -C $i APP_NAME=$(APP_NAME) PRODUCT=$i)
host target: %: $(addsuffix _%, $(PRODUCTS))
opencv:
ifeq '$(CONFIG_USE_OPENCV)' 'y'
cd $(CONFIG_OPENCV_PATH) && ./do-build
endif
deploy: $(APP_NAME).app
tar c $< | ssh root@$(CONFIG_TARGET_IP) 'rm -rf $< && tar x -C $(DEPLOY_DIR)' || true
run:
ssh root@$(CONFIG_TARGET_IP) $(DEPLOY_DIR)$(APP_NAME).app/run.sh || true
install: cgi/cgi_host
#install only if folder exists
ifneq "$(wildcard www )" ""
cp -RL www/* /var/www
cp $< /var/www/cgi-bin/cgi
chmod -Rf a+rX /var/www/ || true
endif
reconfigure:
ifeq '$(CONFIG_USE_OSCAR_CC)' 'y'
cd $(CONFIG_OSCAR_CC_PATH) && ./configure CONFIG_CC_PRIVATE_FRAMEWORK=n CONFIG_CC_FRAMEWORK_PATH='$(ABS_OSCAR_PATH)'
endif
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
oscar/%:
$(MAKE) -C oscar $*
osc-cc:
ifeq '$(CONFIG_USE_OSCAR_CC)' 'y'
$(MAKE) -C $(CONFIG_OSCAR_CC_PATH) $*
endif
# Including depency files and optional local Makefile.
-include build/*.d
# Build targets.
build/%_host.o: $(filter-out %.d, $(MAKEFILE_LIST))
@ mkdir -p $(dir $@)
$(CC_host) -MD $(filter $*.c $*.cpp,$($(addsuffix $(PRODUCTS), SOURCES_))) -o $@
@ grep -oE '[^ \\]+' < $(@:.o=.d) | sed -r '/:$$/d; s|^.*$$|$@: \0\n\0:|' > $(@:.o=.d~) && mv -f $(@:.o=.d){~,}
build/%_target.o: $(filter-out %.d, $(MAKEFILE_LIST))
@ mkdir -p $(dir $@)
$(CC_target) -MD $(filter $*.c $*.cpp,$($(addsuffix $(PRODUCTS), SOURCES_))) -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 %.cpp, build/%_host.o, $(patsubst %.c, build/%_host.o, $(SOURCES_$(1)))) $(LIBS_host)
$(LD_host) -o $$@ $$^ $(OSC_CC_LIBS_INC) -lm $(OSC_CC_LIBS_host) $(OPENCV_LIBS_host)
$(1)_target: $(patsubst %.cpp, build/%_target.o, $(patsubst %.c, build/%_target.o, $(SOURCES_$(1)))) $(LIBS_target)
$(LD_target) -o $$@ $$^ $(OSC_CC_LIBS_INC) -lm -lbfdsp $(OSC_CC_LIBS_target) $(OPENCV_LIBS_target)
endef
$(foreach i, $(PRODUCTS), $(eval $(call LINK,$i)))
.PHONY: $(APP_NAME).app
$(APP_NAME).app: $(addsuffix _target, $(PRODUCTS))
rm -rf $@
cp -rL app $@
ifneq "$(wildcard www )" ""
tar c -h -C www . | gzip > $@/www.tar.gz
endif
# Cleans the module.
clean:
rm -rf build *.gdb $(BINARIES) $(APP_NAME).app
$(foreach i, $(SUB_PRODUCTS), make -C $i clean)