Package: ffindex / 0.9.9.9-2

Makefile.patch Patch series | 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
Description: Makefile fixes
  * make Makefile DESTDIR-aware
  * other changes to allow help2man to work better.
  * deinstall -> uninstall
  * pass CPPFLAGS and LDFLAGS for hardening
  .
  Upstream is aware but not interested in DESTDIR.
Forwarded: yes
Author: Laszlo Kajan <lkajan@debian.org>
Author: Graham Inggs <ginggs@debian.org>
Last-Update: 2017-06-29

--- a/src/Makefile
+++ b/src/Makefile
@@ -1,17 +1,22 @@
-INSTALL_DIR?=..
-libdir=`([ -d /usr/lib64 ] && echo lib64) || echo lib`
+PREFIX?=/usr
+INSTALL_DIR=$(DESTDIR)$(PREFIX)
+libdir=lib
 LANG=C
 #CC=musl-gcc
 #OMPI_CC=musl-gcc
 #CC=gcc
 #CC=icc
 #CC=clang
-CFLAGS+=-std=c99 -O2 -g -fPIC -Wall -pedantic -D_GNU_SOURCE=1 -I.
-LDFLAGS=-lffindex -L.
+CFLAGS+=-std=c99 -O2 -g -fPIC -Wall -pedantic -D_GNU_SOURCE=1 -I. $(CPPFLAGS)
+SOCURRENT=2
+SOREVISION=0
+SOAGE=2
+SOVERSION=$(SOCURRENT).$(SOREVISION).$(SOAGE)
+SOMAJORV=$(shell echo $$(( $(SOCURRENT)-$(SOAGE) )) )
 
 OS:= $(shell uname)
 
-FFINDEX_LIBS=libffindex.so libffindex.so.0.1 libffindex.a
+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)
@@ -34,30 +39,29 @@ libffindex.a: $(FFINDEX_OBJECTS)
 	ar rcs libffindex.a $^
 
 ifeq ($(OS), Darwin)
-libffindex.so.0.1: $(FFINDEX_OBJECTS) ext/fmemopen.o
-		$(CC) -shared -o libffindex.so.0.1 $^
+libffindex.so.$(SOVERSION): $(FFINDEX_OBJECTS) ext/fmemopen.o
+		$(CC) -shared -o libffindex.so.$(SOVERSION) $^
 else
 
- ifdef FFINDEX_STATIC
-STATIC=-static
- endif
+# Hack in needed linker options into unneeded variable STATIC
+STATIC=-L. -lffindex
 
-libffindex.so.0.1: $(FFINDEX_OBJECTS)
-		$(CC) -Wl,-z,defs -Wl,-soname,libffindex.so.0.1 -shared -o libffindex.so.0.1 $^
+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.0.1
-	ln -sf libffindex.so.0.1 libffindex.so
+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) $(STATIC)
+	$(CC) $(CFLAGS) -o $@  ffindex_apply.o $(LDFLAGS) -L. -lffindex
 
 ffindex_apply_mpi: ffindex_apply_mpi.o $(FFINDEX_LIBS)
-	mpicc $(CFLAGS) -DHAVE_MPI -o $@  ffindex_apply_mpi.o $(LDFLAGS)
+	mpicc $(CFLAGS) -DHAVE_MPI -o $@  ffindex_apply_mpi.o $(LDFLAGS) -L. -lffindex
 
 ffindex_apply_mpi.o: ffindex_apply_mpi.c $(FFINDEX_HEADERS)
 	mpicc $(CFLAGS) -DHAVE_MPI -c ffindex_apply_mpi.c -o $@ 
@@ -89,7 +93,7 @@ ffindex_unpack: ffindex_unpack.o $(FFIND
 ffindex_order: ffindex_order.o $(FFINDEX_LIBS)
 	$(CC) -o $@ ffindex_unpack.o $(LDFLAGS) $(STATIC)
 
-test:
+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
@@ -110,9 +114,10 @@ time:
 
 clean:
 	rm -f $(FFINDEX_PROGRAMS) $(FFINDEX_OBJECTS) $(FFINDEX_LIBS) \
-		libffindex.so libffindex.so.0.1 libffindex.a \
+		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
+		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
@@ -125,9 +130,10 @@ install:
 	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.0.1 $(INSTALL_DIR)/$(libdir)/libffindex.so.0.1
+	install libffindex.so.$(SOVERSION) $(INSTALL_DIR)/$(libdir)/libffindex.so.$(SOVERSION)
 	install libffindex.a $(INSTALL_DIR)/$(libdir)/libffindex.a
-	ln -sf libffindex.so.0.1 $(INSTALL_DIR)/$(libdir)/libffindex.so
+	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
@@ -137,7 +143,7 @@ endif
 
 deinstall:
 	rm -f $(INSTALL_DIR)/bin/ffindex_get $(INSTALL_DIR)/bin/ffindex_build $(INSTALL_DIR)/bin/ffindex_modify \
-		$(INSTALL_DIR)/$(libdir)/libffindex.so.0.1 $(INSTALL_DIR)/$(libdir)/libffindex.a \
+		$(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