forked from johnrsibert/ADMB_XML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
107 lines (83 loc) · 3.15 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
# A Generic Makefile for ADMB programs that also includes additonal libraries.
# Developed for Mac OSx using the clang++ compiler
# Author: Steve Martell & John Sibert
# —————————————————————— INSTRUCTIONS ———————————————————————— #
# 1. Set the EXEC variable to the name of the program. #
# 2. List additional .cpp files required by EXEC in SRCS macro #
# 3. Set the ADMB_HOME path to your distribution of ADMB. #
# 4. To make executables with ADMB "safe" library type: make #
# 5. Optimized executables type: make OPT=TRUE #
# ———————————————————————————————————————————————————————————— #
EXEC = pella-xml
SRCS = $(EXEC).cpp ADMB_XMLDoc.cpp
OBJS = $(SRCS:.cpp=.o)
TPLS = $(EXEC).tpl
DEPS = $(SRCS:.cpp=.depends)
# Export the path to your ADMB dist directory
export ADMB_HOME=/home/jsibert/admb/trunk/build/dist
# establish the C++ compiler (on Mac OSX use clang++)
CC=gcc
CXX=g++
# and linker
LL = $(CC)
LD = $(CXX)
# Remove macro
RM=rm -fv
# identify some extra file name suffixes
.SUFFIXES: .tpl .cpp .o .obj
# tell make not to delete these intermediate targets
.PRECIOUS: %.cpp %.o %.obj
# make some special PHONY targets
.PHONY: all help rules clean
# set up ADMB flags and appropriate libraries
# make the "safe" version by default
# to make "the optimized" version, type `make OPT=TRUE
ifeq ($(OPT),TRUE)
CC_OPT = -O3 -DOPT_LIB
LDFLAGS = -O3
LDLIBS = $(ADMB_HOME)/lib/libadmbo.a $(ADMB_HOME)/contrib/lib/libcontribo.a -lxml2
else
CC_OPT = -O3 -DSAFE_ALL -ggdb
LDFLAGS = -O3 -g
LDLIBS = $(ADMB_HOME)/lib/libadmb.a $(ADMB_HOME)/contrib/lib/libcontrib.a -lxml2
endif
# set general compiler flags
CXXFLAGS = $(CC_OPT) -D__GNUDOS__ -Dlinux -DUSE_LAPLACE -I. -I$(ADMB_HOME)/include -I$(ADMB_HOME)/contrib/include -I/usr/include/libxml2
# this is the default target
all: $(EXEC)
# link the object file into the executable
$(EXEC): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
# Advanced Auto Dependency Generation
# Check compiler options for generating phony targets (-MP -MD for clang compiler on OSX)
%.o : %.cpp
$(CXX) -MP -MD -c -o $@ $< $(CXXFLAGS)
-include $(OBJS:%.o=%.d)
# Build the cpp file from the tpl
$(EXEC).cpp: $(TPLS)
$(ADMB_HOME)/bin/tpl2cpp $(TPLS:.tpl=)
clean:
$(RM) $(OBJS) $(EXEC).htp $(EXEC).cpp
$(RM) $(EXEC).bar $(EXEC).cor $(EXEC).eva $(EXEC).log $(EXEC)-log.log $(EXEC).par $(EXEC).rep $(EXEC).std
$(RM) admodel.*
#$(RM) $(EXEC).x00 $(EXEC).x01
# generate some information about what your are doing
rules:
@echo EXEC = $(EXEC)
@echo OBJS = $(OBJS)
@echo SRCS = $(SRCS)
@echo TPLS = $(TPLS)
@echo OPT = $(OPT)
@echo CC_OPT = $(CC_OPT)
@echo PWD = $(PWD)
@echo ADMB_HOME = $(ADMB_HOME)
@echo CC = $(CC)
$(CC) --version
@echo LD = $(LD)
@echo CXXFLAGS = $(CXXFLAGS)
@echo LDFLAGS = $(LDFLAGS)
# Some help for the naive
help:
@echo Set: EXEC target to the BaseName of your tpl script.
@echo Usage: make <OPT=TRUE>
@echo specify OPT=TRUE to build optimized version