File: Makefile

package info (click to toggle)
ffindex 0.9.9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 488 kB
  • sloc: ansic: 2,382; makefile: 163; perl: 86; python: 56; sh: 21; ruby: 6
file content (154 lines) | stat: -rw-r--r-- 6,379 bytes parent folder | download
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
PREFIX?=/usr
INSTALL_DIR=$(DESTDIR)$(PREFIX)
libdir=lib
LANG=C
#CC=musl-gcc
#OMPI_CC=musl-gcc
#CC=gcc
#CC=icc
#CC=clang
PKG_CONFIG?=pkg-config
CFLAGS+=-std=c99 -O2 -g -fPIC -Wall -pedantic -D_GNU_SOURCE=1 -I. $(CPPFLAGS)
CFLAGS_MPI=$(shell $(PKG_CONFIG) --cflags mpi)
LDFLAGS_MPI=$(shell $(PKG_CONFIG) --libs mpi)
SOCURRENT=2
SOREVISION=0
SOAGE=2
SOVERSION=$(SOCURRENT).$(SOREVISION).$(SOAGE)
SOMAJORV=$(shell echo $$(( $(SOCURRENT)-$(SOAGE) )) )

OS:= $(shell uname)

FFINDEX_LIBS=libffindex.so libffindex.so.$(SOVERSION) libffindex.a

FFINDEX_HEADERS=ffindex.h ffindex_posix_search.h ffutil.h
FFINDEX_OBJECTS=$(FFINDEX_HEADERS:.h=.o)

FFINDEX_PROGRAMS=ffindex_apply ffindex_from_fasta ffindex_get ffindex_build ffindex_modify ffindex_unpack ffindex_from_tsv

ifdef HAVE_MPI
FFINDEX_PROGRAMS+=ffindex_apply_mpi
endif

all: $(FFINDEX_LIBS) $(FFINDEX_PROGRAMS)

# for Darwin only
ext/fmemopen.o: ext/fmemopen.c
	make -C ext

ffindex.o: ffindex.c $(FFINDEX_HEADERS)

libffindex.a: $(FFINDEX_OBJECTS)
	ar rcs libffindex.a $^

ifeq ($(OS), Darwin)
libffindex.so.$(SOVERSION): $(FFINDEX_OBJECTS) ext/fmemopen.o
		$(CC) -shared -o libffindex.so.$(SOVERSION) $^
else

# Hack in needed linker options into unneeded variable STATIC
STATIC=-L. -lffindex

libffindex.so.$(SOVERSION): $(FFINDEX_OBJECTS)
		$(CC) $(LDFLAGS) -Wl,-z,defs -Wl,-soname,libffindex.so.$(SOVERSION) -shared -o libffindex.so.$(SOVERSION) $^

endif

libffindex.so: libffindex.so.$(SOVERSION)
	ln -sf libffindex.so.$(SOVERSION) libffindex.so

ffindex_apply.o: ffindex_apply_mpi.c $(FFINDEX_LIBS)
	$(CC) $(CFLAGS) -c ffindex_apply_mpi.c -o $@ 

ffindex_apply: ffindex_apply.o $(FFINDEX_LIBS)
	$(CC) $(CFLAGS) -o $@  ffindex_apply.o $(LDFLAGS) -L. -lffindex

ffindex_apply_mpi: ffindex_apply_mpi.o $(FFINDEX_LIBS)
	$(CC) $(CFLAGS_MPI) $(LDFLAGS_MPI) $(CFLAGS) -DHAVE_MPI -o $@  ffindex_apply_mpi.o $(LDFLAGS) -L. -lffindex

ffindex_apply_mpi.o: ffindex_apply_mpi.c $(FFINDEX_HEADERS)
	$(CC) $(CFLAGS_MPI) $(CFLAGS) -DHAVE_MPI -c ffindex_apply_mpi.c -o $@ 

ffindex_apply_mpi_spawn: ffindex_apply_mpi_spawn.o $(FFINDEX_LIBS)
	$(CC) $(CFLAGS_MPI) $(LDFLAGS_MPI) $(CFLAGS) -o $@  ffindex_apply_mpi_spawn.o $(LDFLAGS)

ffindex_apply_mpi_spawn.o: ffindex_apply_mpi_spawn.o $(FFINDEX_HEADERS)
	$(CC) $(CFLAGS_MPI) $(CFLAGS) -c ffindex_apply_mpi_spawn.c -o $@ 

ffindex_from_fasta: ffindex_from_fasta.o $(FFINDEX_LIBS)
	$(CC) -o $@ ffindex_from_fasta.o $(LDFLAGS) $(STATIC)

ffindex_from_tsv: ffindex_from_tsv.o $(FFINDEX_LIBS)
	$(CC) -o $@ ffindex_from_tsv.o $(LDFLAGS) $(STATIC)

ffindex_get: ffindex_get.o $(FFINDEX_LIBS)
	$(CC) -o $@ ffindex_get.o $(LDFLAGS) $(STATIC)

ffindex_build: ffindex_build.o $(FFINDEX_LIBS)
	$(CC) -o $@ ffindex_build.o $(LDFLAGS) $(STATIC)

ffindex_modify: ffindex_modify.o $(FFINDEX_LIBS)
	$(CC) -o $@ ffindex_modify.o $(LDFLAGS) $(STATIC)

ffindex_unpack: ffindex_unpack.o $(FFINDEX_LIBS)
	$(CC) -o $@ ffindex_unpack.o $(LDFLAGS) $(STATIC)

ffindex_order: ffindex_order.o $(FFINDEX_LIBS)
	$(CC) -o $@ ffindex_unpack.o $(LDFLAGS) $(STATIC)

check:
	rm -f /tmp/test.data /tmp/test.ffindex
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_build -s /tmp/test.data /tmp/test.ffindex ../test/data ../test/data2
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_get  /tmp/test.data /tmp/test.ffindex a b foo | tee /tmp/test.out
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_modify -u /tmp/test.ffindex b
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_get  /tmp/test.data /tmp/test.ffindex a b foo | tee /tmp/test-unlink.out
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_build -a -s /tmp/test.data /tmp/test.ffindex ../test/testfile
	@echo ======== compare results =========
	diff /tmp/test.out test.should
	diff /tmp/test-unlink.out test-unlink.should
	@echo ======== error handling ==========
	@echo
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_get  /tmp/test.data /tmp/test.ffindex nonexistquery b foo || echo
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_get  /nonexist/data /tmp/test.ffindex a foo || echo
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./ffindex_get  /tmp/test.data /nonexist/index a foo || echo

time:
	LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" zsh -c "time ./ffindex_get  ../test_big/nr20_11Jan10_a3m_db ../test_big/nr20_11Jan10_a3m_db.ffindex BABBAMIBA.a3m KARDUZEBA.a3m HARPAQIBA.a3m WOQQATEBA.a3m BEBRAQIBA.a3m GIRSAKEBA.a3m NAQTIFIBA.a3m BIWCIQABA.a3m > /dev/null"

clean:
	rm -f $(FFINDEX_PROGRAMS) $(FFINDEX_OBJECTS) $(FFINDEX_LIBS) \
		libffindex.so libffindex.so.$(SOVERSION) libffindex.a \
		ffindex_build.o ffindex_get.o ffindex_modify.o ffindex_from_fasta.o ffindex_apply_mpi.o \
		ffindex_apply.o ffindex_from_tsv.o ffindex_unpack.o ffindex_posix_search.o ffindex_apply_mpi_spawn.o \
		$(OBJECTS) $(OBJECTS:%=%.o)

install:
	mkdir -p $(INSTALL_DIR)/bin
	mkdir -p $(INSTALL_DIR)/$(libdir)
	mkdir -p $(INSTALL_DIR)/include
	install ffindex_get $(INSTALL_DIR)/bin/ffindex_get
	install ffindex_build $(INSTALL_DIR)/bin/ffindex_build
	install ffindex_modify $(INSTALL_DIR)/bin/ffindex_modify
	install ffindex_from_fasta $(INSTALL_DIR)/bin/ffindex_from_fasta
	install ffindex_from_tsv $(INSTALL_DIR)/bin/ffindex_from_tsv
	install ffindex_apply $(INSTALL_DIR)/bin/ffindex_apply
	install ffindex_unpack $(INSTALL_DIR)/bin/ffindex_unpack
	install libffindex.so.$(SOVERSION) $(INSTALL_DIR)/$(libdir)/libffindex.so.$(SOVERSION)
	install libffindex.a $(INSTALL_DIR)/$(libdir)/libffindex.a
	ln -sf libffindex.so.$(SOVERSION) $(INSTALL_DIR)/$(libdir)/libffindex.so.$(SOMAJORV)
	ln -sf libffindex.so.$(SOVERSION) $(INSTALL_DIR)/$(libdir)/libffindex.so
	install ffindex.h $(INSTALL_DIR)/include/ffindex.h
	install ffutil.h $(INSTALL_DIR)/include/ffutil.h
	install ffindex_posix_search.h $(INSTALL_DIR)/include/ffindex_posix_search.h
ifdef HAVE_MPI
	install ffindex_apply_mpi $(INSTALL_DIR)/bin/ffindex_apply_mpi
endif

deinstall:
	rm -f $(INSTALL_DIR)/bin/ffindex_get $(INSTALL_DIR)/bin/ffindex_build $(INSTALL_DIR)/bin/ffindex_modify \
		$(INSTALL_DIR)/$(libdir)/libffindex.so.$(SOVERSION) $(INSTALL_DIR)/$(libdir)/libffindex.a \
		$(INSTALL_DIR)/$(libdir)/libffindex.so $(INSTALL_DIR)/include/ffindex.h $(INSTALL_DIR)/include/ffutil.h\
		$(INSTALL_DIR)/include/ffindex_posix_search.h $(INSTALL_DIR)/bin/ffindex_from_fasta $(INSTALL_DIR)/bin/ffindex_from_tsv
	rmdir $(INSTALL_DIR)/bin || true
	rmdir $(INSTALL_DIR)/$(libdir) || true
	rmdir $(INSTALL_DIR)/include || true