-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
137 lines (102 loc) · 3.38 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Makefile for Astrometry package.
# The only executables to be made are the tests, there are no "subs"
#
# These site-dependent items should be defined in environment:
# CXX
# CXXFLAGS
# TMV_DIR -or- EIGEN_DIR
# GBUTILS_DIR
# YAML_DIR
# MKL_DIR (optional, used w/EIGEN)
INCLUDES :=
LIBS := -lm
EXTDIRS :=
# Collect the includes and libraries we need
ifdef YAML_DIR
INCLUDES += -I $(YAML_DIR)/include -D USE_YAML
LIBS += -L $(YAML_DIR)/lib -lyaml-cpp
else
$(warning WARNING: Compiling astrometry without YAML serializations)
endif
ifdef GBUTIL_DIR
INCLUDES += -I $(GBUTIL_DIR)/include
EXTDIRS += $(GBUTIL_DIR)
GBUTIL_OBJ = $(GBUTIL_DIR)/obj
else
$(error Require GBUTIL_DIR in environment)
endif
# Use either TMV or EIGEN, not both (prefer TMV)
ifdef TMV_DIR
INCLUDES += -I $(TMV_DIR)/include -D USE_TMV
LIBS += $(shell cat $(TMV_DIR)/share/tmv/tmv-link) -ltmv_symband
else
ifdef EIGEN_DIR
INCLUDES += -I $(EIGEN_DIR) -D USE_EIGEN
endif
endif
# Check that either TMV or EIGEN are available (ok to have both)
$(if $(or $(TMV_DIR),$(EIGEN_DIR)), , $(error Need either TMV_DIR or EIGEN_DIR))
ifdef MKL_DIR
INCLUDES += -I $(MKL_DIR)/include -D USE_MKL
LIBS += -L$(MKL_DIR)/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl
CXXFLAGS += -m64
endif
# Object files found in external packages, :
EXTOBJS =$(GBUTIL_OBJ)/StringStuff.o $(GBUTIL_OBJ)/Poly2d.o $(GBUTIL_OBJ)/Lookup1d.o
#####
BINDIR = bin
OBJDIR = obj
SRCDIR = src
SUBDIR = src
INCLUDEDIR = include
TESTDIR = tests
TESTBINDIR = testbin
# INCLUDES can be relative paths, and will not be exported to subdirectory makes.
INCLUDES += -I $(INCLUDEDIR)
# Executable C++ programs - none
# C++ subroutines
SUBS := $(wildcard $(SUBDIR)/*.cpp)
SUBOBJS := $(SUBS:$(SUBDIR)/%.cpp=$(OBJDIR)/%.o)
CP = /bin/cp -p
RM = /bin/rm -f
#######################
# Rules - ?? dependencies on INCLUDES ??
#######################
all: $(SUBOBJS)
# Compilation
$(SUBOBJS): $(OBJDIR)/%.o : $(SUBDIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Remake external packages to update external objects
# Shut off default rule for this; can I do it only when out of date??
$(EXTOBJS): exts ;
######### Test programs
TESTSRC := $(wildcard $(TESTDIR)/*.cpp)
TESTINCLUDE := -I $(TESTDIR)
TESTOBJS := $(TESTSRC:$(TESTDIR)/%.cpp=$(OBJDIR)/%.o)
TESTTARGETS := $(TESTSRC:$(TESTDIR)/%.cpp=$(TESTBINDIR)/%)
TESTSPY := $(wildcard $(TESTDIR)/*.py)
tests: $(TESTTARGETS)
$(TESTOBJS): $(OBJDIR)/%.o : $(TESTDIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) $(TESTINCLUDE) -c $^ -o $@
$(TESTTARGETS): $(TESTBINDIR)/% : $(OBJDIR)/%.o $(SUBOBJS) $(EXTOBJS)
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
###############################################################
## Standard stuff:
###############################################################
exts:
for dir in $(EXTDIRS); do (cd $$dir && $(MAKE)); done
depend: local-depend
for dir in $(EXTDIRS); do (cd $$dir && $(MAKE) depend); done
local-depend:
$(RM) .depend
for src in $(SUBS:%.cpp=%) $(EXECS:%.cpp=%); \
do $(CXX) $(CXXFLAGS) $(INCLUDES) -MM $$src.cpp -MT obj/$$src.o >> .depend; \
done
clean: local-clean
for dir in $(EXTDIRS); do (cd $$dir && $(MAKE) clean); done
local-clean:
rm -rf $(OBJDIR)/*.o $(BINDIR)/* $(TESTBINDIR)/* *~ *.dvi *.aux core .depend
ifeq (.depend, $(wildcard .depend))
include .depend
endif
.PHONY: all install dist depend clean local-clean local-depend exts tests