-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
145 lines (112 loc) · 3.77 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
OS := $(shell uname)
ARCH := $(shell arch)
OS := $(shell uname)
ifeq ($(OS), Darwin)
# mainly for dev builds using homebrew things
EXTRA_LDFLAGS ?= -L$(shell brew --prefix [email protected])/lib
ARGP ?= $(shell brew --prefix argp-standalone)/lib/libargp.a
ARGP_INCLUDE ?= -I$(shell brew --prefix argp-standalone)/include
else
ARGP ?=
ARGP_INCLUDE ?=
endif
CC ?= gcc
CFLAGS ?= -fpic -msse3 -O3 -std=c99
DEFLATE ?= $(PWD)/libdeflate
STATIC_HTSLIB ?= htslib/libhts.a
EXTRA_CFLAGS ?=
EXTRA_LDFLAGS ?=
EXTRA_LIBS ?=
HTS_CONF_ARGS ?=
HTS_CONF_ENV ?= CFLAGS="$(CFLAGS) $(EXTRA_CFLAGS)"
WITHDEFLATE ?=
DEFLATEREQ =
ifeq ($(WITHDEFLATE), 1)
CFLAGS += -I$(DEFLATE) -L$(DEFLATE)
HTS_CONF_ARGS += --with-libdeflate
HTS_CONF_ENV += LDFLAGS="-L$(DEFLATE)"
EXTRA_LIBS += -ldeflate
DEFLATEREQ = libdeflate/libdeflate.so.0
endif
NOTHREADS ?=
ifeq ($(NOTHREADS), 1)
CFLAGS += -DNOTHREADS
endif
VALGRIND ?= valgrind
.PHONY: default
default: modbam2bed
libdeflate/libdeflate.so.0:
@echo Compiling $(@F)
cd libdeflate && make
htslib/libhts.a: $(DEFLATEREQ)
@echo Compiling $(@F)
cd htslib/ \
&& autoreconf -i \
&& autoheader \
&& autoconf \
&& $(HTS_CONF_ENV) ./configure $(HTS_CONF_ARGS) \
&& make -j 4
.PHONY: clean_htslib
clean_htslib:
rm -rf htslib/autom4te.cache/
cd htslib && make clean || exit 0
%.o: src/%.c
mkdir -p obj && \
$(CC) -c -pthread -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 $(CFLAGS) \
-Isrc -Ihtslib $(ARGP_INCLUDE) $(EXTRA_CFLAGS) $^ -o $@
.PHONY: clean_obj
clean_obj:
rm -rf *.o
modbam2bed: modbam2bed.o common.o counts.o bamiter.o args.o $(STATIC_HTSLIB)
$(CC) -pthread -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 $(CFLAGS) \
-Isrc -Ihtslib $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS)\
$^ $(ARGP) \
-lm -lz -llzma -lbz2 -lpthread -lcurl -lcrypto $(EXTRA_LIBS) \
-o $(@)
.PHONY: clean
clean: clean_obj clean_htslib
rm -rf modbam2bed modbampy.egg-info pymod.a venv obj
.PHONY: mem_check
mem_check: modbam2bed
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./modbam2bed --threshold 0.66 -t 2 -r ecoli1 test_data/ecoli.fasta.gz test_data/400ecoli.bam test_data/400ecoli.bam > /dev/null
.PHONY: test_api
test_api: python
${IN_VENV} && pip install pytest
${IN_VENV} && pytest test --doctest-modules
### Python
PYTHON ?= python3
VENV ?= venv
venv: ${VENV}/bin/activate
IN_VENV=. ./${VENV}/bin/activate
$(VENV)/bin/activate:
test -d $(VENV) || $(PYTHON) -m venv $(VENV) --prompt "modbam"
${IN_VENV} && pip install pip==23.0.1 --upgrade
${IN_VENV} && pip install setuptools
.PHONY: python
python: htslib/libhts.a pymod.a $(VENV)/bin/activate
${IN_VENV} && pip install -r requirements.txt
${IN_VENV} && WITHDEFLATE=$(WITHDEFLATE) LDFLAGS=$(EXTRA_LDFLAGS) pip install -e .
.PHONY: clean_python
clean_python: clean_obj
rm -rf dist build modbampy.egg-info pymod.a libmodbampy.abi3.so ${VENV}
pymod.a: common.o bamiter.o counts.o
ar rcs $@ $^
test_python: python
${IN_VENV} && pip install flake8 flake8-rst-docstrings flake8-docstrings flake8-import-order
${IN_VENV} && flake8 modbampy \
--import-order-style google --application-import-names modbampy,libmodbampy \
--statistics
${IN_VENV} && modbampy test_data/400ecoli.bam ecoli1 0 4000000 | wc -l
${IN_VENV} && modbampy test_data/400ecoli.bam ecoli1 0 4000000 --pileup | wc -l
IN_BUILD=. ./pypi_build/bin/activate
pypi_build/bin/activate:
test -d pypi_build || $(PYTHON) -m venv pypi_build --prompt "(pypi) "
${IN_BUILD} && pip install pip --upgrade
${IN_BUILD} && pip install --upgrade pip setuptools twine wheel readme_renderer[md] keyrings.alt
.PHONY: sdist
sdist: pypi_build/bin/activate
${IN_BUILD} && python setup.py sdist
.PHONY: wheels
wheels: clean clean_python
docker run -v `pwd`:/io quay.io/pypa/manylinux2010_x86_64 /io/build-wheels.sh /io 6 7 8