aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 80f59d09a79fe3030a0b2ecb341238b29a4e62f3 (plain) (blame)
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
# Copyright (c) 2020 Johannes Stoelp

ARCH ?= x86_64

ifeq ($(ARCH),arm64)
PREFIX := aarch64-linux-gnu-
endif

CXX      := $(PREFIX)g++
CXXFLAGS := -g -O0 -Wall -Wextra -I.

lib/libmatcha.a:
	make -C lib ARCH=$(ARCH)

%.o: %.cc
	$(CXX) -c -o $@ $^ $(CXXFLAGS)

fmt:
	fd --type f '.+\.h$$|.+\.cc$$' --exec clang-format -i {}

example/demo1: example/demo1.o lib/libmatcha.a
	$(CXX) -o $@ $^ $(LDFLAGS)
ifeq ($(ARCH),arm64)
	qemu-aarch64                                      \
	    -L /usr/aarch64-linux-gnu                     \
	    -E LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib \
	    example/demo1
else
	example/demo1
endif

gdb: example/demo1
ifeq ($(ARCH),arm64)
	qemu-aarch64                                      \
	    -L /usr/aarch64-linux-gnu                     \
	    -E LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib \
	    -g 1234                                       \
	    example/demo1 &
	gdb-multiarch -ex 'target remote :1234' -ex 'b main' -ex 'c' example/demo1
else
	which cgdb && cgdb -x util.gdb -ex 'start' example/demo1 \
	           ||  gdb -x util.gdb -ex 'start' example/demo1
endif

docker: docker/Dockerfile
	cd docker && ./build.sh
	docker run -it --rm -v $(PWD):/develop matcha-box:latest
.PHONY: docker


clean:
	make -C lib clean
	rm -f example/demo1 example/demo1.o