-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
executable file
·59 lines (42 loc) · 1.04 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
CC = clang++
FLAGS = -std=c++11 -pedantic -g -O3 -fPIC -ffinite-math-only -fopenmp -march=native \
-Werror=return-type -Werror=uninitialized -Wall -Werror -Wsign-compare -DDEBUG_OUTPUT
LNK = -L./ -larmadillo
INC = -I./
COMP = $(CC) $(FLAGS) $(INC)
LINK = $(CC) $(FLAGS) $(INC) $(LNK) -shared
EXE = librehuel.so
EXT = cpp
SRC = $(wildcard *.$(EXT))
SRC := $(subst main.cpp,,$(SRC))
# For windows:
#MAKE_DIR = $(if exist $(1),,mkdir $(1))
#S=\\
# Linux and Unix-like:
MAKE_DIR = mkdir -p $(1)
S=/
OBJ_DIR = obj_lib
OBJ = $(SRC:%.$(EXT)=$(OBJ_DIR)$(S)%.o)
OBJ_DIRS = $(dir $(OBJ))
DEPS = $(OBJ:%.o=%.d)
.PHONY: dirs all help clean install
all : dirs $(EXE)
install : $(EXE)
cp $(EXE) /usr/local/lib
dirs : $(OBJ_DIR)
$(OBJ_DIR) :
$(call $(MAKE_DIR),$@)
help :
@echo "SRC is $(SRC)"
@echo "OBJ is $(OBJ)"
@echo "DEPS is $(DEPS)"
$(EXE) : $(OBJ)
$(LINK) $(OBJ) -o $@
$(OBJ_DIR)$(S)%.o : %.$(EXT)
$(call MAKE_DIR,$(dir $@))
$(COMP) -c $< -o $@
$(COMP) -M -MT '$@' $< -MF $(@:%.o=%.d)
clean:
rm -r $(OBJ_DIR)
rm -f $(EXE)
-include $(DEPS)