freebsd-ports/math/lcalc/files/patch-src_Makefile
Thierry Thomas fea6dcf1c7 - A dd a SONAME to libLfunction.so;
- strip lcalc.
2020-04-07 09:26:41 +00:00

235 lines
9 KiB
Text

--- src/Makefile.orig 2012-08-08 21:21:56 UTC
+++ src/Makefile
@@ -8,12 +8,13 @@
#the c compiler, that will generate options which are specific to the
#compilers, optimization options depending on the chip, etc
+# + Patches borrowed from SageMath.
# Comment out the following line to remove the use of pari's
# elliptic curve routines. Doing so disables the -e option.
# g++ with -DINCLUDE_PARI sends a #define INCLUDE_PARI to the preprocessor.
-#PARI_DEFINE = -DINCLUDE_PARI
+PARI_DEFINE = -DINCLUDE_PARI
#PREPROCESSOR_DEFINE = -DUSE_LONG_DOUBLE
#OPENMP_FLAG = -fopenmp
@@ -29,11 +30,21 @@ endif
OS_NAME := $(shell uname)
-CC = g++
+#CC = g++
#cc = /home/mrubinst/local/bin/gcc
#CC = /home/mrubinst/local/bin/g++
#LD = /home/mrubinst/local/bin/g++
+ifneq (,$(findstring CYGWIN,$(OS_NAME)))
+ OS_NAME := CYGWIN
+endif
+
+# Note: I've also changed various rules to use $CXX instead of $CC,
+# since we mostly compile C++, not C, and $CC is by convention
+# used for the *C* compiler.
+#CC ?= gcc
+#CXX ?= g++
+
#CC = /Users/michaelrubinstein/math/L/packages/gcc4.3/usr/local/bin/g++
#EXTRA= -pg
#EXTRA = -ftree-vectorize -ftree-vectorizer-verbose=5 -funroll-loops
@@ -58,59 +69,27 @@ ifeq ($(G5),TRUE)
#MACHINE_SPECIFIC_FLAGS = -mpowerpc -mpowerpc64 -m64
endif
-CCFLAGS = -Wa,-W -O3 $(OPENMP_FLAG) -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
-#CCFLAGS = -Wa,-W -O3 $(OPENMP_FLAG) $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
-#CCFLAGS = -Wa,-W -O2 -fno-exceptions -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
+CXXFLAGS := $(OPENMP_FLAG) $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA) $(CXXFLAGS)
#warning- O2 doesn't help with -DUSE_LONG_DOUBLE on mac, and actually seems to hurt, making runtime longer
#by a factor of 1.5
-ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
- #location of pari.h.
- LOCATION_PARI_H = /usr/local/include/pari #usual location
- #location of libpari.a or of libpari.so
- #depending on whether static or dynamic libraries are being used.
- #On mac os x it's the former, on linux I think usually the latter.
- LOCATION_PARI_LIBRARY = /usr/local/lib #usual location
-else
- #supplied as a dummy so as to avoid more ifeq's below
- LOCATION_PARI_H = .
- LOCATION_PARI_LIBRARY = .
-endif
-
-
-
#INCLUDEFILES= -I../include -I../../packages/gcc4.3/usr/local/include
INCLUDEFILES= -I../include
#For Mac os x we omit shared library options
ifeq ($(OS_NAME),Darwin)
- LDFLAGS2 =
- DYN_OPTION=dynamiclib
+ DYN_OPTION=dynamiclib -Wl,-headerpad_max_install_names
else
- LDFLAGS1 = -Xlinker -export-dynamic #not sure why pari calls these when linking but on the web I found
- #'Libtool provides the `-export-dynamic' link flag (see section Link mode), which does this declaration.
- #You need to use this flag if you are linking a shared library that will be dlopened'
- #see notes below
- #ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
- LDFLAGS2 = $(LDFLAGS1) -Xlinker -rpath -Xlinker $(LOCATION_PARI_LIBRARY)
- #else
- # LDFLAGS2 = $(LDFLAGS1)
- #endif
DYN_OPTION=shared
endif
-ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
- LDFLAGS = $(LDFLAGS2) -L$(LOCATION_PARI_LIBRARY) -lpari
-else
- LDFLAGS = $(LDFLAGS2)
-endif
+PARI_LIBS = -L$(LOCALBASE)/lib -lpari -lgmp -lm
-
#NOTES:
#for caedmon: the shared pari library is in a funny location: /usr/local/pari/pari-2.1.5/lib
#At compile time we need to specify that location with:
@@ -129,47 +108,63 @@ endif
#become clear which libraries the computer can find.
-INSTALL_DIR= /usr/local
+INSTALL_DIR = $(STAGEDIR)$(PREFIX)
+#binary and library files extensions
+LIBEXT := .so
+EXEEXT :=
+
+ifeq ($(OS_NAME),Darwin)
+ LIBEXT := .dylib
+ EXEEXT :=
+endif
+
+ifeq ($(OS_NAME),CYGWIN)
+ LIBEXT := .dll
+ EXEEXT := .exe
+endif
+
#object files for the libLfunction library
OBJ_L = Lglobals.o Lgamma.o Lriemannsiegel.o Lriemannsiegel_blfi.o Ldokchitser.o
#object files for the command line program
-OBJ2=$(OBJ_L) Lcommandline_globals.o Lcommandline_misc.o Lcommandline_numbertheory.o Lcommandline_values_zeros.o
-OBJ3=$(OBJ2) Lcommandline_elliptic.o Lcommandline_twist.o Lcommandline.o cmdline.o
+OBJ2 = $(OBJ_L) Lcommandline_globals.o Lcommandline_misc.o Lcommandline_numbertheory.o Lcommandline_values_zeros.o
+OBJ3 = $(OBJ2) Lcommandline_elliptic.o Lcommandline_twist.o Lcommandline.o cmdline.o
OBJECTS = $(OBJ3)
all:
-# make print_vars
- make libLfunction.so
- make lcalc
- make examples
-# make find_L
-# make test
+# $(MAKE) print_vars
+ $(MAKE) libLfunction$(LIBEXT)
+ $(MAKE) lcalc$(EXEEXT)
+ $(MAKE) examples$(EXEEXT)
+# $(MAKE) find_L
+# $(MAKE) test
print_vars:
@echo OS_NAME = $(OS_NAME)
-lcalc: $(OBJECTS)
- $(CC) $(CCFLAGS) $(INCLUDEFILES) $(OBJECTS) $(LDFLAGS) -o lcalc $(GMP_FLAGS)
+lcalc$(EXEEXT): $(OBJECTS)
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) $(LDFLAGS) $(OBJECTS) -o lcalc$(EXEEXT) $(PARI_LIBS) $(GMP_FLAGS)
-examples:
- $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/example.cc libLfunction.so -o example_programs/example $(GMP_FLAGS)
+examples$(EXEEXT):
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) example_programs/example.cc $(LDFLAGS) libLfunction$(LIBEXT) -o example_programs/example$(EXEEXT) $(PARI_LIBS) $(GMP_FLAGS)
-proc:
- $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/proc.cc libLfunction.so -o example_programs/proc $(GMP_FLAGS)
+proc$(EXEEXT):
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) example_programs/proc.cc $(LDFLAGS) libLfunction$(LIBEXT) -o example_programs/proc$(EXEEXT) $(PARI_LIBS) $(GMP_FLAGS)
-test:
- $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/test.cc libLfunction.so -o example_programs/test $(GMP_FLAGS)
+test$(EXEEXT):
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) example_programs/test.cc $(LDFLAGS) libLfunction$(LIBEXT) -o example_programs/test$(EXEEXT) $(PARI_LIBS) $(GMP_FLAGS)
-find_L:
- $(CC) $(CCFLAGS) $(INCLUDEFILES) find_L_functions/find_L_functions.cc libLfunction.so -o find_L_functions/find_L $(GMP_FLAGS)
+find_L$(EXEEXT):
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) find_L_functions/find_L_functions.cc $(LDFLAGS) libLfunction$(LIBEXT) -o find_L_functions/find_L$(EXEEXT) $(PARI_LIBS) $(GMP_FLAGS)
.cc.o:
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -c $<
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) -c $<
+
+# Warning: We (Sage) add $CXXFLAGS to CXXFLAGS above.
.c.o:
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -c $<
+ $(CC) $(CFLAGS) $(INCLUDEFILES) -c $<
Lglobals.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
@@ -227,7 +222,7 @@ Lcommandline_elliptic.o: ../include/Lnumberzeros.h ../
Lcommandline_elliptic.o: ../include/Lvalue.h ../include/Lfind_zeros.h
Lcommandline_elliptic.o: ../include/Lcommandline_numbertheory.h
Lcommandline_elliptic.o: ../include/Lcommandline_globals.h
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_elliptic.cc
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) $(PARI_DEFINE) -c Lcommandline_elliptic.cc
Lcommandline_twist.o: ../include/Lcommandline_twist.h ../include/L.h
Lcommandline_twist.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
@@ -239,7 +234,7 @@ Lcommandline_twist.o: ../include/Lvalue.h ../include/L
Lcommandline_twist.o: ../include/Lcommandline_numbertheory.h
Lcommandline_twist.o: ../include/Lcommandline_globals.h
Lcommandline_twist.o: ../include/Lcommandline_elliptic.h
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_twist.cc
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) $(PARI_DEFINE) -c Lcommandline_twist.cc
cmdline.o: ../include/cmdline.h ../include/getopt.h
#$(CC) $(CCFLAGS) $(INCLUDEFILES) -DHAVE_LONG_LONG -c cmdline.c
@@ -258,21 +253,21 @@ Lcommandline.o: ../include/Lcommandline_misc.h
Lcommandline.o: ../include/Lcommandline_elliptic.h
Lcommandline.o: ../include/Lcommandline_twist.h
Lcommandline.o: ../include/Lcommandline_values_zeros.h
- $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline.cc
+ $(CXX) $(CXXFLAGS) $(INCLUDEFILES) $(PARI_DEFINE) -c Lcommandline.cc
-libLfunction.so: $(OBJ_L)
- g++ -$(DYN_OPTION) -o libLfunction.so $(OBJ_L)
+libLfunction$(LIBEXT): $(OBJ_L)
+ $(CXX) -$(DYN_OPTION) $(CXXFLAGS) -o libLfunction$(LIBEXT) $(LDFLAGS) -Wl,-soname,$@ $(OBJ_L) $(PARI_LIBS)
clean:
- rm -f *.o lcalc libLfunction.so example_programs/example
+ rm -f *.o lcalc$(EXEEXT) libLfunction$(LIBEXT) example_programs/example$(EXEEXT)
install:
- cp -f lcalc $(INSTALL_DIR)/bin/.
- cp -f libLfunction.so $(INSTALL_DIR)/lib/.
+ cp -f lcalc$(EXEEXT) $(INSTALL_DIR)/bin/.
+ cp -f libLfunction$(LIBEXT) $(INSTALL_DIR)/lib/.
cp -rf ../include $(INSTALL_DIR)/include/Lfunction
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
depend:
- makedepend -f depends -- $(CCFLAGS) -Y../include -- $(SRCS)
+ makedepend -f depends -- $(CXXFLAGS) -Y../include -- $(SRCS)