-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·90 lines (63 loc) · 1.95 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#
# TODO:
#
CC := g++
# Define source-code directory
SRCDIR := src
# Define build directory (for storing object files: will be removed on clean)
BUILDDIR := build
# Define binary directory (for storing object files: will be removed on clean)
BINDIR := bin
# Define executable name
TARGET := bin/lpsf
# Define my lib name
MYLIB := bin/lpsf.a
# Define libraries
SDSL_DIR := ./external/sdsl-lite/libsdsl
LIB := -L$(SDSL_DIR)/lib/ -lsdsl -ldivsufsort -ldivsufsort64 -Wl,-rpath=$(PWD)/$(SDSL_DIR)/lib
# Define include files (header <> file paths)
INC := -I include -I $(SDSL_DIR)/include/
#
# No need to edit below this line other than to remvove sdsl
#
# Define source files
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
# Define object files
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
CFLAGS := -g -std=c++11 -D_USE_32 -msse3 -fopenmp -O3 -fomit-frame-pointer -funroll-loops -fPIC
LFLAGS= -O3 -DNDEBUG --shared
# Main entry point
#
all: $(MYLIB) $(TARGET)
# For linking object file(s) to produce the library
#
$(MYLIB): $(OBJECTS)
ar -rs $@ $(OBJECTS )
# For linking object file(s) to produce the executable
#
$(TARGET): $(OBJECTS)
@mkdir -p $(BINDIR)
@echo "============"
@echo " Linking..."
$(CC) $^ -o $(TARGET) $(LFLAG) $(LIB)
@echo "============"
# For generating dependency
DEPS := $(OBJS:.o=.d)
-include $(DEPS)
# For compiling source file(s)
#
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(BUILDDIR)
@echo "============"
@echo "Compiling $<"
$(CC) $(CFLAGS) $(INC) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
# For cleaning up the project
#
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET) $(DEPS)"; $(RM) -r $(BUILDDIR) $(TARGET) $(DEPS)
clean-all:
@echo " Cleaning all...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET) $(DEPS)"; $(RM) -r $(BUILDDIR) $(TARGET) $(DEPS)