Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/build/pkgs/lcalc/patches/Makefile.patch
8820 views
1
--- src.orig/src/Makefile 2012-08-08 23:21:56.274799100 +0200
2
+++ src/src/Makefile 2012-08-08 23:21:45.430581000 +0200
3
@@ -13,7 +13,7 @@
4
# elliptic curve routines. Doing so disables the -e option.
5
# g++ with -DINCLUDE_PARI sends a #define INCLUDE_PARI to the preprocessor.
6
7
-#PARI_DEFINE = -DINCLUDE_PARI
8
+PARI_DEFINE = -DINCLUDE_PARI
9
#PREPROCESSOR_DEFINE = -DUSE_LONG_DOUBLE
10
11
#OPENMP_FLAG = -fopenmp
12
@@ -29,7 +29,17 @@
13
14
OS_NAME := $(shell uname)
15
16
-CC = g++
17
+ifneq (,$(findstring CYGWIN,$(OS_NAME)))
18
+ OS_NAME := CYGWIN
19
+endif
20
+
21
+#CC = g++
22
+# Note: I've also changed various rules to use $CXX instead of $CC,
23
+# since we mostly compile C++, not C, and $CC is by convention
24
+# used for the *C* compiler.
25
+CC ?= gcc
26
+CXX ?= g++
27
+
28
#cc = /home/mrubinst/local/bin/gcc
29
#CC = /home/mrubinst/local/bin/g++
30
#LD = /home/mrubinst/local/bin/g++
31
@@ -58,9 +68,7 @@
32
#MACHINE_SPECIFIC_FLAGS = -mpowerpc -mpowerpc64 -m64
33
endif
34
35
-CCFLAGS = -Wa,-W -O3 $(OPENMP_FLAG) -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
36
-#CCFLAGS = -Wa,-W -O3 $(OPENMP_FLAG) $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
37
-#CCFLAGS = -Wa,-W -O2 -fno-exceptions -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
38
+CXXFLAGS := -O3 $(OPENMP_FLAG) $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA) $(CXXFLAGS)
39
40
#warning- O2 doesn't help with -DUSE_LONG_DOUBLE on mac, and actually seems to hurt, making runtime longer
41
#by a factor of 1.5
42
@@ -68,12 +76,12 @@
43
44
ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
45
#location of pari.h.
46
- LOCATION_PARI_H = /usr/local/include/pari #usual location
47
+ LOCATION_PARI_H = $(SAGE_LOCAL)/include/pari
48
49
#location of libpari.a or of libpari.so
50
#depending on whether static or dynamic libraries are being used.
51
#On mac os x it's the former, on linux I think usually the latter.
52
- LOCATION_PARI_LIBRARY = /usr/local/lib #usual location
53
+ LOCATION_PARI_LIBRARY = $(SAGE_LOCAL)/lib
54
else
55
#supplied as a dummy so as to avoid more ifeq's below
56
LOCATION_PARI_H = .
57
@@ -88,26 +96,12 @@
58
#For Mac os x we omit shared library options
59
60
ifeq ($(OS_NAME),Darwin)
61
- LDFLAGS2 =
62
DYN_OPTION=dynamiclib
63
else
64
- LDFLAGS1 = -Xlinker -export-dynamic #not sure why pari calls these when linking but on the web I found
65
- #'Libtool provides the `-export-dynamic' link flag (see section Link mode), which does this declaration.
66
- #You need to use this flag if you are linking a shared library that will be dlopened'
67
- #see notes below
68
- #ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
69
- LDFLAGS2 = $(LDFLAGS1) -Xlinker -rpath -Xlinker $(LOCATION_PARI_LIBRARY)
70
- #else
71
- # LDFLAGS2 = $(LDFLAGS1)
72
- #endif
73
DYN_OPTION=shared
74
endif
75
76
-ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
77
- LDFLAGS = $(LDFLAGS2) -L$(LOCATION_PARI_LIBRARY) -lpari
78
-else
79
- LDFLAGS = $(LDFLAGS2)
80
-endif
81
+LDFLAGS := -L$(LOCATION_PARI_LIBRARY) -lpari -lgmp $(LDFLAGS)
82
83
84
85
@@ -129,47 +123,64 @@
86
#become clear which libraries the computer can find.
87
88
89
-INSTALL_DIR= /usr/local
90
+INSTALL_DIR ?= /usr/local
91
+
92
+#binary and library files extensions
93
+LIBEXT := .so
94
+EXEEXT :=
95
+
96
+ifeq ($(OS_NAME),Darwin)
97
+ LIBEXT := .dylib
98
+ EXEEXT :=
99
+endif
100
+
101
+ifeq ($(OS_NAME),CYGWIN)
102
+ LIBEXT := .dll
103
+ EXEEXT := .exe
104
+endif
105
106
#object files for the libLfunction library
107
OBJ_L = Lglobals.o Lgamma.o Lriemannsiegel.o Lriemannsiegel_blfi.o Ldokchitser.o
108
109
#object files for the command line program
110
-OBJ2=$(OBJ_L) Lcommandline_globals.o Lcommandline_misc.o Lcommandline_numbertheory.o Lcommandline_values_zeros.o
111
-OBJ3=$(OBJ2) Lcommandline_elliptic.o Lcommandline_twist.o Lcommandline.o cmdline.o
112
+OBJ2 = $(OBJ_L) Lcommandline_globals.o Lcommandline_misc.o Lcommandline_numbertheory.o Lcommandline_values_zeros.o
113
+OBJ3 = $(OBJ2) Lcommandline_elliptic.o Lcommandline_twist.o Lcommandline.o cmdline.o
114
OBJECTS = $(OBJ3)
115
116
all:
117
-# make print_vars
118
- make libLfunction.so
119
- make lcalc
120
- make examples
121
-# make find_L
122
-# make test
123
+# $(MAKE) print_vars
124
+ $(MAKE) libLfunction$(LIBEXT)
125
+ $(MAKE) lcalc$(EXEEXT)
126
+ $(MAKE) examples
127
+# $(MAKE) find_L
128
+# $(MAKE) test
129
130
print_vars:
131
@echo OS_NAME = $(OS_NAME)
132
133
-lcalc: $(OBJECTS)
134
- $(CC) $(CCFLAGS) $(INCLUDEFILES) $(OBJECTS) $(LDFLAGS) -o lcalc $(GMP_FLAGS)
135
+lcalc$(EXEEXT): $(OBJECTS)
136
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) $(OBJECTS) $(LDFLAGS) -o lcalc$(EXEEXT) $(GMP_FLAGS)
137
138
examples:
139
- $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/example.cc libLfunction.so -o example_programs/example $(GMP_FLAGS)
140
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) example_programs/example.cc libLfunction$(LIBEXT) -o example_programs/example$(EXEEXT) $(GMP_FLAGS)
141
+
142
143
+proc$(EXEEXT):
144
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) example_programs/proc.cc libLfunction$(LIBEXT) -o example_programs/proc$(EXEEXT) $(GMP_FLAGS)
145
146
-proc:
147
- $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/proc.cc libLfunction.so -o example_programs/proc $(GMP_FLAGS)
148
+test$(EXEEXT):
149
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) example_programs/test.cc libLfunction$(LIBEXT) -o example_programs/test$(EXEEXT) $(GMP_FLAGS)
150
151
-test:
152
- $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/test.cc libLfunction.so -o example_programs/test $(GMP_FLAGS)
153
+find_L$(EXEEXT):
154
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) find_L_functions/find_L_functions.cc libLfunction$(LIBEXT) -o find_L_functions/find_L$(EXEEXT) $(GMP_FLAGS)
155
156
-find_L:
157
- $(CC) $(CCFLAGS) $(INCLUDEFILES) find_L_functions/find_L_functions.cc libLfunction.so -o find_L_functions/find_L $(GMP_FLAGS)
158
159
.cc.o:
160
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -c $<
161
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) -c $<
162
+
163
+# Warning: We (Sage) add $CXXFLAGS to CXXFLAGS above.
164
.c.o:
165
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -c $<
166
+ $(CC) $(CXXFLAGS) $(INCLUDEFILES) -c $<
167
168
169
Lglobals.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
170
@@ -227,7 +238,7 @@
171
Lcommandline_elliptic.o: ../include/Lvalue.h ../include/Lfind_zeros.h
172
Lcommandline_elliptic.o: ../include/Lcommandline_numbertheory.h
173
Lcommandline_elliptic.o: ../include/Lcommandline_globals.h
174
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_elliptic.cc
175
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_elliptic.cc
176
177
Lcommandline_twist.o: ../include/Lcommandline_twist.h ../include/L.h
178
Lcommandline_twist.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
179
@@ -239,10 +250,10 @@
180
Lcommandline_twist.o: ../include/Lcommandline_numbertheory.h
181
Lcommandline_twist.o: ../include/Lcommandline_globals.h
182
Lcommandline_twist.o: ../include/Lcommandline_elliptic.h
183
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_twist.cc
184
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_twist.cc
185
186
cmdline.o: ../include/cmdline.h ../include/getopt.h
187
-#$(CC) $(CCFLAGS) $(INCLUDEFILES) -DHAVE_LONG_LONG -c cmdline.c
188
+#$(CC) $(CXXFLAGS) $(INCLUDEFILES) -DHAVE_LONG_LONG -c cmdline.c
189
190
191
Lcommandline.o: ../include/Lcommandline.h ../include/L.h
192
@@ -258,21 +269,21 @@
193
Lcommandline.o: ../include/Lcommandline_elliptic.h
194
Lcommandline.o: ../include/Lcommandline_twist.h
195
Lcommandline.o: ../include/Lcommandline_values_zeros.h
196
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline.cc
197
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline.cc
198
199
200
-libLfunction.so: $(OBJ_L)
201
- g++ -$(DYN_OPTION) -o libLfunction.so $(OBJ_L)
202
+libLfunction$(LIBEXT): $(OBJ_L)
203
+ $(CXX) -$(DYN_OPTION) $(CXXFLAG64) -o libLfunction$(LIBEXT) $(OBJ_L)
204
205
clean:
206
- rm -f *.o lcalc libLfunction.so example_programs/example
207
+ rm -f *.o lcalc libLfunction$(LIBEXT) example_programs/example
208
209
install:
210
- cp -f lcalc $(INSTALL_DIR)/bin/.
211
- cp -f libLfunction.so $(INSTALL_DIR)/lib/.
212
- cp -rf ../include $(INSTALL_DIR)/include/Lfunction
213
+ cp -f lcalc$(EXEEXT) $(INSTALL_DIR)/bin/.
214
+ cp -f libLfunction$(LIBEXT) $(INSTALL_DIR)/lib/.
215
+ cp -rf ../include $(INSTALL_DIR)/include/libLfunction
216
217
218
SRCS = Lcommandline.cc Lcommandline_elliptic.cc Lcommandline_globals.cc Lcommandline_misc.cc Lcommandline_numbertheory.cc Lcommandline_twist.cc Lcommandline_values_zeros.cc Lgamma.cc Lglobals.cc Lmisc.cc Lriemannsiegel.cc Lriemannsiegel_blfi.cc cmdline.c
219
depend:
220
- makedepend -f depends -- $(CCFLAGS) -Y../include -- $(SRCS)
221
+ makedepend -f depends -- $(CXXFLAGS) -Y../include -- $(SRCS)
222
223