-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (44 loc) · 1.8 KB
/
Copy pathMakefile
File metadata and controls
51 lines (44 loc) · 1.8 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
# Makefile in accordance with the docs on git management (to use in combination with meta)
.PHONY: build start clean test fetch-roverlib-c
BUILD_DIR=bin/
BINARY_NAME=SERVICE_NAME
# If not using VSCode's devcontainers, with docker installed you can run this command to
# build the service inside the container.
build-docker:
docker build -t ase-service-c -f .devcontainer/Dockerfile .
docker run -it --cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
--privileged \
--user=dev:dev \
-v "`pwd`":/workspaces/work \
-w /workspaces/work \
ase-service-c bash -ic 'make build -C /workspaces/work'
# This target clones roverlib-c so that it can be compiled along side the service
fetch-roverlib-c:
@if [ ! -d "lib" ] || [ -z "$$(ls -A lib 2>/dev/null)" ]; then \
echo "roverlib-c directory doesn't exist or is empty. Cloning into lib..."; \
git clone https://github.com/VU-ASE/roverlib-c.git lib; \
elif [ ! -d "lib/.git" ]; then \
echo "directory lib exists but is not a git repository. Recloning..."; \
rm -rf lib; \
git clone https://github.com/VU-ASE/roverlib-c.git lib; \
else \
echo "getting latest roverlib-c"; \
cd lib ; git restore . ; git pull; \
fi
build: fetch-roverlib-c
@echo "building ${BINARY_NAME}"
@mkdir -p $(BUILD_DIR)
gcc -o $(BUILD_DIR)$(BINARY_NAME) \
./src/*.c ./lib/src/*.c ./lib/src/rovercom/outputs/*.c ./lib/src/rovercom/tuning/*.c \
-lcjson -lzmq -lprotobuf-c -lhashtable -llist -I/usr/include/cjson -I./lib/include -g
start: build
@echo "starting ${BINARY_NAME}"
# Add /usr/local/lib as a possible location for shared libraries, fix for when
# working in a devcontainer
@LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ./${BUILD_DIR}${BINARY_NAME}
clean:
@echo "Cleaning all targets for ${BINARY_NAME}"
rm -rf $(BUILD_DIR)
test:
@echo "No tests configured"