-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathMakefile
202 lines (174 loc) · 7.05 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
197
198
199
200
201
202
##############################################################################
# PUBLIC DOMAIN NOTICE This software/database is "United States Government
# Work" under the terms of the United States Copyright Act. It was written as
# part of the authors' official duties for the United States Government and
# thus cannot be copyrighted. This software/database is freely available to the
# public for use without a copyright notice. Restrictions cannot be placed on
# its present or future use.
#
# Although all reasonable efforts have been taken to ensure the accuracy and
# reliability of the software and data, the National Center for Biotechnology
# Information (NCBI) and the U.S. Government do not and cannot warrant the
# performance or results that may be obtained by using this software or data.
# NCBI, NLM, and the U.S. Government disclaim all warranties as to performance,
# merchantability or fitness for any particular purpose.
#
# In any work or product derived from this material, proper attribution of the
# authors as the source of the software or data should be made, using:
# https://ncbi.nlm.nih.gov/pathogens/antimicrobial-resistance/AMRFinder/ as the
# citation.
###############################################################################
# the SVNREV is set automatically here for convenience,
# but when actually building we should override it like:
# make all SVNREV=-D\'SVN_REV=\"$VERSION\"\' or use
# a version.txt file
ifeq ($(wildcard version.txt),)
VERSION_STRING := $(shell git describe --tags)
else
VERSION_STRING := $(shell cat version.txt)
endif
SVNREV := -D'SVN_REV="$(VERSION_STRING)"'
INSTALL=install
# make it possible to hard define a database directory
# Define default paths
# This is a little convoluted because I broke things and don't want
# to change two different ways of defining the paths. This could
# be simplified in a later release
PREFIX ?= /usr/local
ifneq '$(INSTALL_DIR)' ''
bindir=$(INSTALL_DIR)
endif
bindir ?= $(PREFIX)/bin
ifneq '$(CONDA_DB_DIR)' ''
DBDIR := -D'CONDA_DB_DIR="$(CONDA_DB_DIR)"'
endif
ifneq '$(DEFAULT_DB_DIR)' ''
DBDIR := -D'CONDA_DB_DIR="$(DEFAULT_DB_DIR)"'
endif
# for testing database updates using
ifdef TEST_UPDATE
TEST_UPDATE_DB := '-D TEST_UPDATE'
endif
# detect system architecture and set appropriate flags
# this is probably not the best way (i.e. M1 Mac would be arm64)
# but it works for Nvidia Jetson boards (aarch64)
ARCH := $(shell uname -m)
OS := $(shell uname -s)
# "hack": if amd64 we can set to aarch64
# as AArch64 and ARM64 refer to the same thing
# this should build for Mac M1 and other arm64 chips
ifeq ($(ARCH),arm64)
ARCH := aarch64
endif
# report detected OS and arch in stdout
$(info Dectected architecture: $(OS) $(ARCH))
# set CFLAGS based on arch
ifeq ($(ARCH),aarch64)
# set arm CFLAGS
CPPFLAGS = -std=gnu++17 -pthread --signed-char -falign-jumps -fno-math-errno -O3
else
# set x86_x64 CFLAGS
CPPFLAGS = -std=gnu++17 -pthread -malign-double -fno-math-errno -O3
endif
# was: -std=gnu++14
CXX=g++
COMPILE.cpp= $(CXX) $(CPPFLAGS) $(SVNREV) $(DBDIR) $(TEST_UPDATE_DB) -c
.PHONY: all clean install release stxtyper test
BINARIES= amr_report amrfinder amrfinder_index amrfinder_update fasta_check \
fasta_extract fasta2parts gff_check dna_mutation mutate
all: $(BINARIES) stxtyper
release: clean
svnversion . > version.txt
make all
common.o: common.hpp common.inc
curl_easy.o: curl_easy.hpp common.hpp common.inc
gff.o: gff.hpp common.hpp common.inc
alignment.o: alignment.hpp alignment.hpp common.inc
seq.o: seq.hpp common.hpp common.inc
amr_report.o: common.hpp common.inc gff.hpp alignment.hpp tsv.hpp columns.hpp version.txt
amr_reportOBJS=amr_report.o common.o gff.o alignment.o
amr_report: $(amr_reportOBJS)
$(CXX) $(LDFLAGS) -o $@ $(amr_reportOBJS)
amrfinder.o: common.hpp common.inc gff.hpp tsv.hpp columns.hpp version.txt
amrfinderOBJS=amrfinder.o common.o gff.o tsv.o
amrfinder: $(amrfinderOBJS)
$(CXX) $(LDFLAGS) -o $@ $(amrfinderOBJS) -pthread $(DBDIR)
amrfinder_update.o: common.hpp common.inc curl_easy.hpp version.txt
amrfinder_updateOBJS=amrfinder_update.o common.o curl_easy.o
amrfinder_update: $(amrfinder_updateOBJS)
@if [ "$(TEST_UPDATE)" != "" ] ; \
then \
touch amrfinder_update.cpp ;\
fi # make sure the next make command rebuilds amrfinder_update
$(CXX) $(LDFLAGS) -o $@ $(amrfinder_updateOBJS) -lcurl
amrfinder_index.o: common.hpp common.inc version.txt
amrfinder_indexOBJS=amrfinder_index.o common.o
amrfinder_index: $(amrfinder_indexOBJS)
$(CXX) $(LDFLAGS) -o $@ $(amrfinder_indexOBJS)
fasta_check.o: common.hpp common.inc version.txt
fasta_checkOBJS=fasta_check.o common.o
fasta_check: $(fasta_checkOBJS)
$(CXX) $(LDFLAGS) -o $@ $(fasta_checkOBJS)
fasta_extract.o: common.hpp common.inc version.txt
fasta_extractOBJS=fasta_extract.o common.o
fasta_extract: $(fasta_extractOBJS)
$(CXX) $(LDFLAGS) -o $@ $(fasta_extractOBJS)
fasta2parts.o: common.hpp common.inc version.txt
fasta2partsOBJS=fasta2parts.o common.o
fasta2parts: $(fasta2partsOBJS)
$(CXX) $(LDFLAGS) -o $@ $(fasta2partsOBJS)
gff_check.o: common.hpp common.inc gff.hpp version.txt
gff_checkOBJS=gff_check.o common.o gff.o
gff_check: $(gff_checkOBJS)
$(CXX) $(LDFLAGS) -o $@ $(gff_checkOBJS)
dna_mutation.o: common.hpp common.inc alignment.hpp tsv.hpp columns.hpp version.txt
dna_mutationOBJS=dna_mutation.o common.o alignment.o
dna_mutation: $(dna_mutationOBJS)
$(CXX) $(LDFLAGS) -o $@ $(dna_mutationOBJS)
mutate.o: common.hpp common.inc alignment.hpp seq.hpp version.txt
mutateOBJS=mutate.o common.o alignment.o seq.o
mutate: $(mutateOBJS)
$(CXX) -o $@ $(mutateOBJS)
stxtyper:
$(MAKE) -C stx
clean:
rm -f *.o
rm -f $(BINARIES)
$(MAKE) -C stx clean
install:
@if [ ! -e $(DESTDIR)$(bindir) ]; \
then \
mkdir -p $(DESTDIR)$(bindir); \
fi
$(INSTALL) $(BINARIES) $(DESTDIR)$(bindir)
make -C stx install PREFIX=$(PREFIX) bindir=$(bindir)
mkdir $(DESTDIR)$(bindir)/stx
ln -s ../stxtyper $(DESTDIR)$(bindir)/stx/stxtyper
# amrfinder binaries for github binary release
GITHUB_FILE=amrfinder_binaries_v$(VERSION_STRING)
GITHUB_FILES = test_amrfinder.sh test_*.expected test_*.fa test_*.gff $(BINARIES)
github_binaries:
@if [ ! -e version.txt ]; \
then \
echo >&2 "version.txt required to make a distribution file"; \
false; \
fi
# first recompile amrfinder.o to pick up the new version info
# and remove leaky NCBI paths
make clean
make all CXX=/usr/bin/g++ LD_RUN_PATH=
mkdir $(GITHUB_FILE)
echo $(VERSION_STRING) > $(GITHUB_FILE)/version.txt
cp $(GITHUB_FILES) $(GITHUB_FILE)
make -C stx
make -C stx install INSTALL_DIR=../$(GITHUB_FILE)/stx CXX=/usr/bin/g++ LD_RUN_PATH=
cp stx/test_stxtyper.sh stx/version.txt $(GITHUB_FILE)/stx
mkdir $(GITHUB_FILE)/stx/test
cp -R stx/test/*.fa stx/test/*.expected $(GITHUB_FILE)/stx/test
if [ -e $(GITHUB_FILE).tar.gz ]; then rm $(GITHUB_FILE).tar.gz; fi
cd $(GITHUB_FILE); ln -s stx/stxtyper .; tar cvfz ../$(GITHUB_FILE).tar.gz *
rm -r $(GITHUB_FILE)/*
rmdir $(GITHUB_FILE)
test: $(DISTFILES) Makefile *.cpp *.hpp *.inc test_dna.fa test_prot.fa test_prot.gff test_dna.fa test_dna.expected test_prot.expected test_both.expected
make -C stx test
./test_amrfinder.sh