-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (52 loc) · 1.3 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
CC := g++
CFLAGS := -std=c++17 -Wall -Wextra -g
BIN := bin
SRC := src
TEST := test
INCLUDE := include
DEV_IMAGE=mercury
DEV_CONTAINER=$(DEV_IMAGE)-dev
ifeq ($(OS),Windows_NT)
EXECUTABLE := mercury.exe
SOURCEDIRS := $(SRC)
else
EXECUTABLE := mercury
SOURCEDIRS := $(shell find $(SRC) -type d)
TESTDIRS := $(shell find $(TEST) -type d)
endif
SOURCES := $(wildcard $(patsubst %,%/*.cpp, $(SOURCEDIRS)))
TESTS := ./test/test_mercury.cpp
OBJECTS := $(SOURCES:.cpp=.o)
all: $(BIN)/$(EXECUTABLE)
.PHONY: clean
clean:
-$(RM) $(BIN)/$(EXECUTABLE)
-$(RM) $(OBJECTS)
.PHONY: clean-dev
clean-dev:
-docker kill $(DEV_CONTAINER)
-docker rm $(DEV_CONTAINER)
-docker rmi ($DEV_IMAGE)
.PHONY: dev
dev:
ifeq (, $(shell which docker-compose 2> /dev/null))
$(error docker-compose not in $(PATH), make sure both docker and docker-compose are installed)
else
@docker-compose run mercury bash
endif
.PHONY: package
package:
ifeq (, $(shell which python3 2> /dev/null))
$(error python3 is needed to package Mercury)
else
@mkdir -p ./single_include
@python3 -m quom src/mercury.hpp single_include/mercury.hpp -g MERCURY_.+_HPP
endif
.PHONY: test
test:
$(CC) $(CFLAGS) $(TESTS) -I single_include -o ./bin/test
@./$(BIN)/test
run: all
./$(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE): $(OBJECTS)
$(CC) $(CFLAGS) $^ -o $@