-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (52 loc) · 1.35 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
65
66
67
68
TARGET ?= triangle-solve
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DATADIR ?= $(PREFIX)/share
CXX ?= cxx
CXXFLAGS ?= -Wall -O3 -std=c++14
CXXFLAGS += -DDATA_DIR=\"$(DATADIR)/$(TARGET)/\"
#can fix some std::basic_string linker errors
#CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
INCPATH += -I/usr/include
LIBPATH += -L/usr/lib
LIBS += -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ -lm
# If the first argument is "debug"...
ifeq (debug,$(firstword $(MAKECMDGOALS)))
CFLAGS += -g -O0
CXXFLAGS += -g -O0
endif
OBJECTS = main.o Triangle.o Shapes.o Message.o Arc.o
DEPS = $(OBJECTS:.o=.d)
.PHONY: all
all: $(TARGET)
-include $(DEPS)
.PHONY: debug
debug: $(TARGET)
.PHONY: clean
clean:
rm -f $(OBJECTS) $(TARGET) $(DEPS)
%.d: %.cpp
@$(CXX) $(CXXFLAGS) $(INCPATH) $< -MM -MT $(@:.d=.o) >$@
%.o:
@echo "Compiling $@"
$(CXX) $(CXXFLAGS) $(INCPATH) -c -o $@ $<
$(TARGET): $(OBJECTS)
@echo "Linking $@"
$(CXX) $(CXXFLAGS) $(INCPATH) -o $@ $^ $(LIBPATH) $(LIBS)
.PHONY: compile
compile: $(OBJECTS)
.PHONY: run
run: $(TARGET)
./$(TARGET)
makefile := $(current_makefile)
#install should recompile header that uses DATADIR
.PHONY: install
install:
touch files.h
make .install
.PHONY: .install
.install: $(TARGET)
@echo "Installing to $(BINDIR)"
mkdir -p "$(BINDIR)" "$(DATADIR)/$(TARGET)"
cp $(TARGET) "$(BINDIR)"
cp -r data/* "$(DATADIR)/$(TARGET)"