-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
157 lines (115 loc) · 5.31 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#
# Makefile for Gtc classes
#
# Author: Jennifer Liddle (js10)
#
# $Id: Makefile 1512 2013-02-11 17:23:41Z js10 $
#
# Author: Jennifer Liddle <[email protected], [email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of Genome Research Ltd nor the names of the
# contributors may be used to endorse or promote products derived from
# software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL GENOME RESEARCH LTD. BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.PHONY: test # always run, regardless of timestamps
PREFIX=/usr/local
INSTALL_INC=$(PREFIX)/include
INSTALL_LIB=$(PREFIX)/lib
INSTALL_BIN=$(PREFIX)/bin
EXECUTABLES=gtc g2i g2v gtc_process sim simtools normalize_manifest
INCLUDES=Sim.h Gtc.h Manifest.h win2unix.h
LIBS=libsimtools.so libsimtools.a
PERL_MODULES=Gtc.pm Sim.pm
PERL_LIBS=Gtc.so Sim.so
TARGETS=$(EXECUTABLES) $(LIBS)
PERL_TARGETS=$(PERL_MODULES)
PERL_CC_OPTS=$(shell perl -MExtUtils::Embed -e ccopts)
PERL_LD_OPTS=$(shell perl -MExtUtils::Embed -e ldopts)
# To compile with debug information added, invoke as (say):
# make DEBUG='y'
# to build all targets with debug info.
# For just one target, say:
# make DEBUG='y' simtools
# do NOT use -ffast-math, as it causes errors in infinity/NaN handling
ifeq ($(DEBUG),y)
CXXFLAGS+=-g -O0
else
CXXFLAGS+=-O3
endif
CXXFLAGS+=-Wall -ffloat-store -fPIC -std=c++0x
# Set runpath instead of relying on LD_LIBRARY_PATH
LDFLAGS+=-L./
default: all
usage:
@echo -e "Usage: make install DIR=<destination directory>\nOther targets: make all, make test, make install_g2i"
clean:
rm -f *.o json/*.o *.so Gtc_wrap.cxx Gtc.pm Sim_wrap.cxx Sim.pm runner.cpp runner $(TARGETS)
test: Sim.o Egt.o Fcr.o Gtc.o Manifest.o QC.o win2unix.o json/json_reader.o json/json_writer.o json/json_value.o commands.o runner.o
$(CXX) $(CXXFLAGS) -Wno-deprecated $(LDFLAGS) -o runner $^
LD_LIBRARY_PATH=. ./runner # run "./runner -v" to print trace information
test_perl:
perl -e 'use Gtc; my $$g=new Gtc::Gtc()'
runner.cpp: test_simtools.h
cxxtestgen --error-printer -o runner.cpp test_simtools.h
runner.o: runner.cpp all
$(CXX) -c $(CXXFLAGS) -Wno-deprecated $(LDFLAGS) -o $@ runner.cpp
install: all
@echo "Installing to "$(PREFIX)
install -d $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_BIN)
install $(INCLUDES) $(INSTALL_INC)
install $(LIBS) $(INSTALL_LIB)
install $(PERL_MODULES:pm=so) $(INSTALL_LIB)
install $(PERL_MODULES) $(INSTALL_LIB)
install $(EXECUTABLES) $(INSTALL_BIN)
all: $(TARGETS) $(PERL_MODULES) $(PERL_LIBS)
perl: $(PERL_MODULES) $(PERL_LIBS)
gtc: gtc.o libsimtools.a
$(CXX) $< $(LDFLAGS) -o $@ -lm -Wl,-Bstatic -lsimtools -Wl,-Bdynamic
normalize_manifest: normalize_manifest.o libsimtools.a
$(CXX) $< $(LDFLAGS) -o $@ -lm -Wl,-Bstatic -lsimtools -Wl,-Bdynamic
sim: sim.o libsimtools.a
$(CXX) $< $(LDFLAGS) -o $@ -lm -Wl,-Bstatic -lsimtools -Wl,-Bdynamic
simtools: simtools.o commands.o libsimtools.a
$(CXX) simtools.o commands.o $(LDFLAGS) -o $@ -lm -Wl,-Bstatic -lsimtools -Wl,-Bdynamic
g2i: g2i.o libsimtools.a
$(CXX) $< $(LDFLAGS) -o $@ -lm -Wl,-Bstatic -lsimtools -Wl,-Bdynamic
g2v: g2v.o libsimtools.a
$(CXX) $< $(LDFLAGS) -o $@ -pthread -lm -Wl,-Bstatic -lsimtools -Wl,-Bdynamic
gtc_process: gtc_process.o libsimtools.a
$(CXX) $< $(LDFLAGS) -o $@ -lm -Wl,-Bstatic -lsimtools -Wl,-Bdynamic
gtc_process.o: gtc_process.cpp
$(CXX) -c -DTEST $(CXXFLAGS) -o $@ $<
%.o : %.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<
%.swig.o: %.cpp
$(CXX) -c -DSWIG $(CXXFLAGS) $(PERL_CC_OPTS) -o $@ $<
%.swig.o: %.cxx
$(CXX) -c -DSWIG $(CXXFLAGS) $(PERL_CC_OPTS) -o $@ $<
Gtc_wrap.cxx Gtc.pm: Gtc.i
swig -perl -c++ -shadow -Wall Gtc.i
Sim_wrap.cxx Sim.pm: Sim.i
swig -perl -c++ -shadow -Wall Sim.i
Gtc.so: Gtc_wrap.swig.o Gtc.swig.o Manifest.swig.o gtc_process.swig.o win2unix.swig.o
$(CXX) -shared $(PERL_LD_OPTS) -o $@ $^
Sim.so: Sim_wrap.swig.o Sim.swig.o
$(CXX) -shared $(PERL_LD_OPTS) -o $@ $^
libsimtools.so: Sim.o Gtc.o Manifest.o QC.o Fcr.o Egt.o json/json_reader.o json/json_writer.o json/json_value.o utilities.o plink_binary.o gtc_process.o win2unix.o
$(CXX) -shared $(LDFLAGS) -o $@ $^
libsimtools.a: Sim.o Gtc.o Manifest.o QC.o Fcr.o Egt.o json/json_reader.o json/json_writer.o json/json_value.o utilities.o plink_binary.o gtc_process.o win2unix.o
$(AR) rcs $@ $^