-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (41 loc) · 1.02 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
CXX = g++
CXXFLAGS = -g -std=c++0x -O2
RM = rm -f
MKDIR = mkdir
ECHO = echo
CP = cp
INSTALL = install
dir_guard=@mkdir -p $(@D)
PREFIX = /usr/local
SOURCEDIR = src
HEADERDIR = src
BUILDDIR = build
BINARYDIR = bin
SOURCES = $(wildcard $(SOURCEDIR)/*.cpp)
OBJECTS = $(patsubst $(SOURCEDIR)/%.cpp, $(BUILDDIR)/%.o, $(SOURCES))
LDFLAGS = -lz
# the build target executable:
BINARY = ska
all: $(BINARYDIR)/$(BINARY)
$(BINARYDIR)/$(BINARY): $(OBJECTS)
$(dir_guard)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
$(BUILDDIR)/%.o: $(SOURCEDIR)/%.cpp
$(dir_guard)
$(CXX) $(CXXFLAGS) -I$(HEADERDIR) -I$(SOURCEDIR) -c $< -o $@
.phony: install
install: all
$(INSTALL) -d $(PREFIX)/bin
$(INSTALL) $(BINARYDIR)/$(BINARY) $(PREFIX)/bin
.phony: clean
clean:
$(RM) $(OBJECTS)
.phony: distclean
distclean: clean
$(RM) $(BINARYDIR)/$(BINARY)
help:
@$(ECHO) "Targets:"
@$(ECHO) "all - build and compile what is necessary"
@$(ECHO) "install - install binary"
@$(ECHO) "clean - cleanup old .o files"
@$(ECHO) "distclean - cleanup old binary"