summaryrefslogtreecommitdiff
blob: 2e8b77ae4b9289ed6e0a932227530b7fdfa6a497 (plain)
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
diff -Naur ntl-9.2.0.orig/src/DoConfig ntl-9.2.0/src/DoConfig
--- ntl-9.2.0.orig/src/DoConfig	2015-07-09 21:45:26.959930693 +1200
+++ ntl-9.2.0/src/DoConfig	2015-07-09 21:46:52.250122780 +1200
@@ -38,14 +38,16 @@
 
 'LDFLAGS'     => '',
 'LDLIBS'      => '-lm',
+'PICFLAG'     => '-fPIC',
 'CPPFLAGS'    => '',
 
-'DEF_PREFIX'  => '/usr/local',
+'DEF_PREFIX'  => '/usr',
 
 'PREFIX'      => '$(DEF_PREFIX)',
 'LIBDIR'      => '$(PREFIX)/lib',
 'INCLUDEDIR'  => '$(PREFIX)/include',
 'DOCDIR'      => '$(PREFIX)/share/doc',
+'SHMAKE'      => 'non-gld',
 
 'GMP_PREFIX'  => '$(DEF_PREFIX)',
 'GMP_INCDIR'  => '$(GMP_PREFIX)/include',
diff -Naur ntl-9.2.0.orig/src/mfile ntl-9.2.0/src/mfile
--- ntl-9.2.0.orig/src/mfile	2015-07-09 21:45:26.959930693 +1200
+++ ntl-9.2.0/src/mfile	2015-07-09 21:57:40.631583489 +1200
@@ -109,6 +109,16 @@
 WIZARD=@{WIZARD}
 # Set to off if you want to bypass the wizard; otherwise, set to on.
 
+###############################################################
+#
+# New addition for shared library building. With gcc you need to
+# choose the Position Indepent Code flag. You have a choice of 
+# -fpic better code but in rare case not available (ppc)
+# -fPIC slightly slower code but guaranted to work anywhere.
+#
+###############################################################
+
+PICFLAG=@{PICFLAG}
 
 #################################################################
 #
@@ -141,6 +151,8 @@
 
 OBJ=$(O19)
 
+SHOBJ=$(subst .o,.lo,$(OBJ))
+
 # library source files
 
 
@@ -314,6 +326,8 @@
 
 LINK = $(CXX) $(NTL_INCLUDE) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)
 
+.SUFFIXES: .lo
+
 
 
 # 'make all' does a complete make, including all setup.
@@ -322,11 +336,11 @@
 # again.
 
 all:
-	make setup1
-	make setup2
-	make setup3
-	make setup4
-	make ntl.a
+	${MAKE} setup1
+	${MAKE} setup2
+	${MAKE} setup3
+	${MAKE} setup4
+	${MAKE} ntl.a
 	touch all
 
 
@@ -373,22 +387,37 @@
 lip.o:	lip.c g_lip_impl.h c_lip_impl.h 
 	$(LCOMP) $(COMPILE) $(GMP_OPT_INCDIR) lip.c
 
+lip.lo:	lip.c g_lip_impl.h c_lip_impl.h 
+	$(LCOMP) $(COMPILE) $(PICFLAG) $(GMP_OPT_INCDIR) lip.c -o lip.lo
+
 ctools.o:	ctools.c
 	$(LCOMP) $(COMPILE) ctools.c
 
+ctools.lo:	ctools.c
+	$(LCOMP) $(COMPILE) $(PICFLAG) ctools.c -o ctools.lo
+
 
 GetTime.o: GetTime.c 
 	$(LCOMP) $(COMPILE) GetTime.c
 
+GetTime.lo: GetTime.c 
+	$(LCOMP) $(COMPILE) $(PICFLAG) GetTime.c -o GetTime.lo
+
 GetPID.o: GetPID.c 
 	$(LCOMP) $(COMPILE) GetPID.c
 
+GetPID.lo: GetPID.c 
+	$(LCOMP) $(COMPILE) $(PICFLAG) GetPID.c -o GetPID.lo
+
 CheckPCLMUL: CheckPCLMUL.c
 	$(LINK) -o  CheckPCLMUL CheckPCLMUL.c $(LDLIBS)
 
 .c.o: 
 	$(LCOMP) $(COMPILE) $(GF2X_OPT_INCDIR) $<
 
+.c.lo: 
+	$(LCOMP) $(COMPILE) $(PICFLAG) $(GF2X_OPT_INCDIR) -o $@ $<
+
 .c: 
 @{LSTAT}	$(LINK) -o $@ $< ntl.a $(GMP_OPT_LIBDIR) $(GMP_OPT_LIB) $(GF2X_OPT_LIBDIR) $(GF2X_OPT_LIB) $(LDLIBS) #LSTAT
 @{LSHAR}	$(LIBTOOL) --tag=CXX --mode=link $(LINK) -o $@ $< libntl.la #LSHAR
@@ -402,7 +431,7 @@
 
 check:
 	sh RemoveProg $(PROGS)
-	make QuickTest
+	${MAKE} QuickTest
 	./QuickTest
 	sh RemoveProg QuickTest
 	sh TestScript
@@ -459,21 +488,19 @@
 #
 #################################################################
 
-clobber:	
+clobber:	clean
 	rm -f ntl.a mach_desc.h ../include/NTL/mach_desc.h  GetTime.c GetPID.c
 	cp ../include/NTL/have_LL_no.h ../include/NTL/have_LL.h
 	cp ../include/NTL/have_builtin_clzl_no.h ../include/NTL/have_builtin_clzl.h
 	rm -f ../include/NTL/gmp_aux.h
-	sh RemoveProg $(PROGS) MakeDesc TestGetTime TestGetPID gen_gmp_aux
-	rm -f *.o
-	rm -rf small
+	sh RemoveProg $(PROGS)
 	rm -f cfileout mfileout
 	rm -rf .libs *.lo libntl.la
 	rm -f all
 
 clean:
 	sh RemoveProg MakeDesc TestGetTime TestGetPID gen_gmp_aux
-	rm -f *.o 
+	rm -f *.o *.lo
 	rm -rf small
 @{LSHAR}	- $(LIBTOOL) --mode=clean rm -f libntl.la *.lo #LSHAR
 
@@ -558,4 +585,11 @@
 
 
 
+sharedso: DIRNAME $(SHOBJ)
+	  $(LINK) $(PICFLAG) -shared -Wl,-soname,lib`cat DIRNAME`.so -o lib`cat DIRNAME`.so $(SHOBJ) $(GMP_OPT_LIBDIR) $(GMP_OPT_LIB) $(GF2X_OPT_LIBDIR) $(GF2X_OPT_LIB)
+	  ln -s lib`cat DIRNAME`.so libntl.so
+
+shareddylib: DIRNAME $(SHOBJ)
+	     $(LINK) $(PICFLAG) -dynamiclib -install_name $(LIBDIR)/lib`cat DIRNAME`.dylib -o lib`cat DIRNAME`.dylib $(SHOBJ) $(GMP_OPT_LIBDIR) $(GMP_OPT_LIB) $(GF2X_OPT_LIBDIR) $(GF2X_OPT_LIB)
+	     ln -s lib`cat DIRNAME`.dylib libntl.dylib