forked from os-vector/vector-gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (47 loc) · 1.9 KB
/
Makefile
File metadata and controls
59 lines (47 loc) · 1.9 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
COMPILEFILE := ./examples/body/readout.go
ABSPATH := $(shell pwd)
ifeq ($(GCC),)
TOOLCHAIN_DIR := $(HOME)/.anki/vicos-sdk/dist/5.3.0-r07/prebuilt/bin
TOOLCHAIN := $(TOOLCHAIN_DIR)/arm-oe-linux-gnueabi-
GCC := ${TOOLCHAIN}clang
GPP := ${TOOLCHAIN}clang++
ifeq ($(shell test -d $(dir $(TOOLCHAIN_DIR)) && echo yes),)
$(error The directory $(dir $(TOOLCHAIN_DIR)) does not exist. You must define a $$TOOLCHAIN or follow the README instructions to get a toolchain.)
endif
endif
ifneq (,$(findstring gnueabihf,$(TOOLCHAIN)))
COMMON_FLAGS := -O3 -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -ffast-math -fpermissive
else ifneq (,$(findstring gnueabi,$(TOOLCHAIN)))
COMMON_FLAGS := -O3 -mfpu=neon-vfpv4 -mfloat-abi=softfp -mcpu=cortex-a7 -ffast-math
else ifneq (,$(findstring aarch64,$(TOOLCHAIN)))
COMMON_FLAGS := -O3 -ffast-math
else
COMMON_FLAGS := -O3 -ffast-math -fpermissive
endif
GPP_FLAGS := -w -shared -Iinclude -fPIC -std=c++11 -Wno-c++11-narrowing
GCC_FLAGS := -w -shared -Iinclude -fPIC
all: vector-gobot
echo "Successfully compiled libvector-gobot.so and libjpeg_interface.so to ./build."
vector-gobot:
mkdir -p build
$(GPP) $(GPP_FLAGS) $(COMMON_FLAGS) -fPIC -c c_src/*.cpp c_src/libs/*.cpp
$(GCC) $(GCC_FLAGS) $(COMMON_FLAGS) -fPIC -c c_src/libs/*.c
$(GPP) $(GPP_FLAGS) $(COMMON_FLAGS) -shared -latomic -o build/libvector-gobot.so *.o
rm -f *.o
libjpeg-turbo:
mkdir -p build
./make-turbojpeg.sh
jpeg_interface:
mkdir -p build
$(GPP) $(GPP_FLAGS) $(COMMON_FLAGS) -o build/libjpeg_interface.so c_src/jpeg/jpeg.cpp -Ilibjpeg-turbo -fopenmp -static-libstdc++
example:
CC="$(GCC)" \
CGO_LDFLAGS="-Lbuild" \
GOARM=7 \
GOARCH=arm \
CGO_ENABLED=1 \
go build -o build/main $(COMPILEFILE)
clean:
mkdir -p build
rm -f build/libvector-gobot.so build/libjpeg_interface.so build/libjpeg_turbo build/main
.PHONY: all librobot.so vector-gobot jpeg_interface example clean libjpeg-turbo