-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
81 lines (60 loc) · 1.83 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
##
## @file makefile
## @brief PICSP makefile.
## @author Sayan Adhikari <sayan.adhikari@fys.uio.no>
##
####### UBUNTU ##########
INCHDF :=
LIBHDF :=
OS := $(shell lsb_release -si)
ifeq ($(OS),Ubuntu)
INCHDF = -I/usr/include/hdf5/serial/
LIBHDF = -L /usr/lib/x86_64-linux-gnu/hdf5/serial/
endif
###############################
CXX = g++
CXXLOCAL = -Ilib/iniparser/src
LLOCAL = -Ilib/iniparser/src
FFLAGS = -lfftw3 -lm
HFLAGS = -lhdf5 -lhdf5_cpp
EXEC = picsp
CXXFLAGS = -g -std=c++11 -Wall $(CXXLOCAL) $(INCHDF) # Flags for compiling
LFLAGS = -g -std=c++11 -Wall $(LLOCAL) $(LIBHDF) # Flags for linking
SDIR = src
ODIR = src/obj
#HDIR = src
LDIR = lib
OUTDIR = output
SRC_ = # Additional CPP files
OBJ_ = $(SRC_:.cpp=.o)
SRC = $(patsubst %,$(SDIR)/%,$(SRC_))
OBJ = $(patsubst %,$(ODIR)/%,$(OBJ_))
LIBOBJ_ = iniparser/libiniparser.a
LIBHEAD_= iniparser/src/iniparser.h
LIBOBJ = $(patsubst %,$(LDIR)/%,$(LIBOBJ_))
LIBHEAD = $(patsubst %,$(LDIR)/%,$(LIBHEAD_))
all: version $(EXEC)
$(EXEC): $(ODIR)/main.o $(OBJ) $(LIBOBJ)
@echo "Linking PICSP"
@$(CXX) $^ -o $@ $(LFLAGS) $(FFLAGS) $(HFLAGS)
@echo "PICSP is built"
$(ODIR)/%.o: $(SDIR)/%.cpp
@echo "Compiling $<"
@mkdir -p $(ODIR)
@mkdir -p $(OUTDIR)
@$(CXX) -c $< -o $@ $(CXXFLAGS)
$(LDIR)/iniparser/libiniparser.a: $(LIBHEAD)
@echo "Building iniparser"
@cd $(LDIR)/iniparser && $(MAKE) libiniparser.a > /dev/null 2>&1
.phony: version
version:
@echo "Embedding git version"
@echo "#define VERSION \"$(shell git describe --abbrev=4 --dirty --always --tags)\"" > $(SDIR)/version.h
clean:
@echo "Cleaning compiled files. (run 'make veryclean' to remove executables and more)"
@rm -f *~ $(ODIR)/*.o $(SDIR)/*.o $(SDIR)/*~
@rm -rf $(OUTDIR)
veryclean: clean
@echo "Cleaning executables and iniparser"
@rm -f $(EXEC)
@cd $(LDIR)/iniparser && $(MAKE) veryclean > /dev/null 2>&1