-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
196 lines (139 loc) · 4.23 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#
# ARGweaver
# Matt Rasmussen
# Copyright 2012-2013
#
# Makefile
#
# install prefix paths
prefix = /usr
# programs
CXX = g++
PYTHON = python
# C++ compiler options
CFLAGS := $(CFLAGS) \
-Wall -fPIC \
-Isrc
GTEST_URL = 'http://googletest.googlecode.com/files/gtest-1.7.0.zip'
GTEST_DIR = gtest-1.7.0
#=============================================================================
# optional CFLAGS
# profiling
ifdef PROFILE
CFLAGS := $(CFLAGS) -pg
endif
# debugging
ifdef DEBUG
CFLAGS := $(CFLAGS) -g
else
CFLAGS := $(CFLAGS) -O3 -funroll-loops
endif
#=============================================================================
# ARGweaver files
# package
PKG_VERSION:=$(shell $(PYTHON) -c 'import argweaver; print argweaver.PROGRAM_VERSION_TEXT' 2>/dev/null)
PKG_NAME=argweaver
DIST=dist
PKG=$(DIST)/$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_DIR=$(DIST)/$(PKG_NAME)-$(PKG_VERSION)
# program files
SCRIPTS = bin/*
PROGS = bin/arg-sample bin/arg-summarize bin/smc2bed
BINARIES = $(PROGS) $(SCRIPTS)
ARGWEAVER_SRC = $(shell ls src/argweaver/*.cpp)
# src/prior.cpp
# src/expm/matrix_exponential.cpp
# src/expm/r8lib.cpp
ALL_SRC = \
$(ARGWEAVER_SRC) \
src/arg-sample.cpp \
src/arg-summarize.cpp \
src/smc2bed.cpp
ARGWEAVER_OBJS = $(ARGWEAVER_SRC:.cpp=.o)
ALL_OBJS = $(ALL_SRC:.cpp=.o)
LIBS =
# `gsl-config --libs`
#-lgsl -lgslcblas -lm
# ARGweaver C-library files
LIBARGWEAVER = lib/libargweaver.a
LIBARGWEAVER_SHARED_NAME = libargweaver.so
LIBARGWEAVER_SHARED = lib/$(LIBARGWEAVER_SHARED_NAME)
LIBARGWEAVER_SHARED_INSTALL = $(prefix)/lib/$(LIBARGWEAVER_SHARED_NAME)
LIBARGWEAVER_OBJS = $(ARGWEAVER_OBJS)
# ARGweaver C++ tests
CFLAGS_TEST = -I $(GTEST_DIR)/include
LIBS_TEST = -Llib -lgtest -lgtest_main -lpthread
GTEST_SRC = gtest-1.7.0
TEST_SRC = \
src/tests/test.cpp \
src/tests/test_local_tree.cpp \
src/tests/test_prob.cpp
TEST_OBJS = $(TEST_SRC:.cpp=.o)
#=============================================================================
# targets
.PHONY: all pkg test ctest cq install clean cleanobj lib pylib gtest
# default targets
all: $(PROGS) $(LIBARGWEAVER) $(LIBARGWEAVER_SHARED)
bin/arg-sample: src/arg-sample.o $(LIBARGWEAVER)
$(CXX) $(CFLAGS) -o bin/arg-sample src/arg-sample.o $(LIBARGWEAVER)
bin/smc2bed: src/smc2bed.o $(LIBARGWEAVER)
$(CXX) $(CFLAGS) -o bin/smc2bed src/smc2bed.o $(LIBARGWEAVER)
bin/arg-summarize: src/arg-summarize.o $(LIBARGWEAVER)
$(CXX) $(CFLAGS) -o bin/arg-summarize src/arg-summarize.o $(LIBARGWEAVER)
#-----------------------------
# ARGWEAVER C-library
lib: $(LIBARGWEAVER) $(LIBARGWEAVER_SHARED)
$(LIBARGWEAVER): $(LIBARGWEAVER_OBJS)
mkdir -p lib
$(AR) -r $(LIBARGWEAVER) $(LIBARGWEAVER_OBJS)
$(LIBARGWEAVER_SHARED): $(LIBARGWEAVER_OBJS)
mkdir -p lib
$(CXX) -o $(LIBARGWEAVER_SHARED) -shared $(LIBARGWEAVER_OBJS) $(LIBS)
#-----------------------------
# packaging
pkg: $(PKG)
$(PKG):
mkdir -p $(DIST)
git archive --format=tar --prefix=$(PKG_NAME)-$(PKG_VERSION)/ HEAD | \
gzip > $(PKG)
#-----------------------------
# testing
test: $(LIBARGWEAVER_SHARED)
nosetests -v test
cq:
nosetests -v test/test_codequality.py
ctest: src/tests/test
src/tests/test
src/tests/test: $(TEST_OBJS) $(LIBARGWEAVER)
$(CXX) -o src/tests/test $(TEST_OBJS) $(LIBS_TEST) $(LIBARGWEAVER)
$(TEST_OBJS): %.o: %.cpp
$(CXX) -c $(CFLAGS) $(CFLAGS_TEST) -o $@ $<
# Download and install gtest unit-testing framework.
gtest:
wget $(GTEST_URL) -O gtest.zip
rm -rf $(GTEST_SRC)
unzip gtest
cd $(GTEST_SRC) && ./configure && make
cp $(GTEST_SRC)/lib/.libs/libgtest_main.a lib/
cp $(GTEST_SRC)/lib/.libs/libgtest.a lib/
#-----------------------------
# install
install: $(BINARIES)
mkdir -p $(prefix)/bin
cp $(BINARIES) $(prefix)/bin
$(PYTHON) setup.py install --prefix=$(prefix)
pylib: $(LIBARGWEAVER_SHARED_INSTALL)
$(PYTHON) setup.py install --prefix=$(prefix)
$(LIBARGWEAVER_SHARED_INSTALL): $(LIBARGWEAVER_SHARED)
mkdir -p $(prefix)/lib
cp $(LIBARGWEAVER_SHARED) $(LIBARGWEAVER_SHARED_INSTALL)
#=============================================================================
# basic rules
$(ALL_OBJS): %.o: %.cpp
$(CXX) -c $(CFLAGS) -o $@ $<
clean:
rm -f $(ALL_OBJS) $(LIBARGWEAVER) $(LIBARGWEAVER_SHARED) $(TEST_OBJS) $(PROGS)
clean-test:
rm -f $(TEST_OBJS)
clean-obj:
rm -f $(ALL_OBJS) $(TEST_OBJS)