forked from jeizenga/structures
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
55 lines (40 loc) · 1.71 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
OBJDIR = obj
SRCDIR = src
INCSEARCHDIR = $(SRCDIR)/include
INCDIR = $(INCSEARCHDIR)/structures
BINDIR = bin
LIBDIR = lib
LIBOBJ = $(OBJDIR)/union_find.o $(OBJDIR)/suffix_tree.o $(OBJDIR)/stable_double.o
LIB = $(LIBDIR)/libstructures.a
TESTOBJ =$(OBJDIR)/tests.o
HEADERS = $(INCDIR)/suffix_tree.hpp $(INCDIR)/union_find.hpp $(INCDIR)/min_max_heap.hpp $(INCDIR)/immutable_list.hpp $(INCDIR)/stable_double.hpp $(INCDIR)/rank_pairing_heap.hpp
CXX = g++
CPPFLAGS += -std=c++11 -g -O3 -I$(INCSEARCHDIR)
all:
$(MAKE) $(BINDIR)/test
.PHONY: clean .pre_build
clean:
find $(BINDIR) $(OBJDIR) $(LIBDIR) -type f -delete
$(BINDIR)/test: $(TESTOBJ) $(HEADERS) $(LIB)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(BINDIR)/test $(TESTOBJ) $(LIB)
$(OBJDIR)/suffix_tree.o: $(SRCDIR)/suffix_tree.cpp $(INCDIR)/suffix_tree.hpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SRCDIR)/suffix_tree.cpp -o $(OBJDIR)/suffix_tree.o
$(OBJDIR)/union_find.o: $(SRCDIR)/union_find.cpp $(INCDIR)/union_find.hpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SRCDIR)/union_find.cpp -o $(OBJDIR)/union_find.o
$(OBJDIR)/stable_double.o: $(SRCDIR)/stable_double.cpp $(INCDIR)/stable_double.hpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SRCDIR)/stable_double.cpp -o $(OBJDIR)/stable_double.o
# MinMaxHeap is header-only
# RankPairingHeap is header-only
$(OBJDIR)/tests.o: $(SRCDIR)/tests.cpp $(HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SRCDIR)/tests.cpp -o $(OBJDIR)/tests.o
test: $(BINDIR)/test
./bin/test
$(LIB): $(LIBOBJ)
rm -f $@
ar rs $@ $(LIBOBJ)
.pre-build:
if [ ! -d $(BINDIR) ]; then mkdir -p $(BINDIR); fi
if [ ! -d $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi
if [ ! -d $(LIBDIR) ]; then mkdir -p $(LIBDIR); fi
# run .pre-build before we make anything at all.
-include .pre-build