Package: plink1.9 / 1.90~b3.45-170113-1

01.Makefile_config.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
Author: Dylan Aïssi <bob.dybian@gmail.com>
Description: Config Makefile for Debian: dynamic linking and hardening.
Last-Update: 2016-11-20
Forwarded: No

--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,9 @@
 # passed into the linker; to use this, invoke 'make LINKFLAGS_EXTRA="<opts>"'.
 LINKFLAGS_EXTRA =
 
+# To enable dynamic linking
+DYNAMIC_LINK = 1
+
 .PHONY: clean
 
 # should autodetect system
@@ -24,10 +27,17 @@
   endif
 endif
 
-CFLAGS=-Wall -O2
-BLASFLAGS=-L/usr/lib64/atlas -llapack -lcblas -latlas
-LINKFLAGS=-lm -lpthread -ldl
-ZLIB=zlib-1.2.10/libz.so.1.2.10
+CFLAGS+=-Wall -O2
+CXXFLAGS+=-Wall -O2
+LINKFLAGS=-lm -lpthread -ldl $(LDFLAGS)
+ifdef DYNAMIC_LINK
+  BLASFLAGS=-llapack -lcblas -latlas
+  ZLIB=-lz
+  CFLAGS+=-DDYNAMIC_ZLIB
+else
+  BLASFLAGS=-L/usr/lib64/atlas -llapack -lcblas -latlas
+  ZLIB=-L. zlib-1.2.10/libz.so.1.2.10
+endif
 
 ifeq ($(SYS), MAC)
   GCC_GTEQ_43 := $(shell expr `g++ -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40300)
@@ -36,7 +46,7 @@
   endif
   BLASFLAGS=-framework Accelerate
   LINKFLAGS=-ldl
-  ZLIB=zlib-1.2.10/libz.1.2.10.dylib
+  ZLIB=-L. zlib-1.2.10/libz.1.2.10.dylib
 endif
 
 ifeq ($(SYS), WIN)
@@ -47,7 +57,7 @@
 # NO_LAPACK.
   BLASFLAGS=-L. lapack/liblapack.a -L. lapack/librefblas.a
   LINKFLAGS=-lm -static-libgcc
-  ZLIB=zlib-1.2.10/libz.a
+  ZLIB=-L. zlib-1.2.10/libz.a
 endif
 
 ifdef NO_LAPACK
@@ -62,10 +72,10 @@
 # lead to minor problems when PLINK 2.0 is released.)
 
 plink: $(OBJS)
-	g++ $^ $(LINKFLAGS_EXTRA) $(BLASFLAGS) $(LINKFLAGS) -L. $(ZLIB) -o $@
+	g++ $^ $(LINKFLAGS_EXTRA) $(BLASFLAGS) $(LINKFLAGS) $(ZLIB) -o $@
 
 plinkw: $(OBJS)
-	gfortran -O2 $^ $(LINKFLAGS_EXTRA) -Wl,-Bstatic $(BLASFLAGS) $(LINKFLAGS) -L. $(ZLIB) -o $@
+	gfortran -O2 $^ $(LINKFLAGS_EXTRA) -Wl,-Bstatic $(BLASFLAGS) $(LINKFLAGS) $(ZLIB) -o $@
 
 clean:
 	rm -f $(OBJS) plink plinkw
@@ -75,7 +85,7 @@
 # GNU make's built-in rules, except we explicitly use "g++" instead of $(CC).
 
 %.o: %.c
-	g++ -c $(CFLAGS) $< -o $@
+	g++ -c $(CFLAGS) $(CPPFLAGS) $< -o $@
 
 %.o: %.cc
-	g++ -x c++ -c $(CFLAGS) $< -o $@
+	g++ -x c++ -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@