summaryrefslogtreecommitdiff
path: root/libtommath/makefile_include.mk
diff options
context:
space:
mode:
Diffstat (limited to 'libtommath/makefile_include.mk')
-rw-r--r--libtommath/makefile_include.mk112
1 files changed, 80 insertions, 32 deletions
diff --git a/libtommath/makefile_include.mk b/libtommath/makefile_include.mk
index 580a478..711b630 100644
--- a/libtommath/makefile_include.mk
+++ b/libtommath/makefile_include.mk
@@ -3,9 +3,9 @@
#
#version of library
-VERSION=1.0.1
-VERSION_PC=1.0.1
-VERSION_SO=1:1
+VERSION=1.2.0
+VERSION_PC=1.2.0
+VERSION_SO=3:0:2
PLATFORM := $(shell uname | sed -e 's/_.*//')
@@ -17,67 +17,116 @@ ifndef CROSS_COMPILE
CROSS_COMPILE=
endif
+# We only need to go through this dance of determining the right compiler if we're using
+# cross compilation, otherwise $(CC) is fine as-is.
+ifneq (,$(CROSS_COMPILE))
+ifeq ($(origin CC),default)
+CSTR := "\#ifdef __clang__\nCLANG\n\#endif\n"
+ifeq ($(PLATFORM),FreeBSD)
+ # XXX: FreeBSD needs extra escaping for some reason
+ CSTR := $$$(CSTR)
+endif
+ifneq (,$(shell echo $(CSTR) | $(CC) -E - | grep CLANG))
+ CC := $(CROSS_COMPILE)clang
+else
+ CC := $(CROSS_COMPILE)gcc
+endif # Clang
+endif # cc is Make's default
+endif # CROSS_COMPILE non-empty
+
# Dropbear passes these down
-#ifeq ($(CC),cc)
-# CC = $(CROSS_COMPILE)gcc
-#endif
#LD=$(CROSS_COMPILE)ld
#AR=$(CROSS_COMPILE)ar
#RANLIB=$(CROSS_COMPILE)ranlib
ifndef MAKE
- MAKE=make
+# BSDs refer to GNU Make as gmake
+ifneq (,$(findstring $(PLATFORM),FreeBSD OpenBSD DragonFly NetBSD))
+ MAKE=gmake
+else
+ MAKE=make
+endif
endif
-CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
+LTM_CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
+
+# renamed for Dropbear to avoid clash with oss-fuzz $SANITIZER var
+ifdef LTM_SANITIZER
+LTM_CFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=float-divide-by-zero
+endif
ifndef NO_ADDTL_WARNINGS
# additional warnings
-CFLAGS += -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align
-CFLAGS += -Wstrict-prototypes -Wpointer-arith
+LTM_CFLAGS += -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align
+LTM_CFLAGS += -Wstrict-prototypes -Wpointer-arith
+endif
+
+ifdef CONV_WARNINGS
+LTM_CFLAGS += -std=c89 -Wconversion -Wsign-conversion
+ifeq ($(CONV_WARNINGS), strict)
+LTM_CFLAGS += -DMP_USE_ENUMS -Wc++-compat
+endif
+else
+LTM_CFLAGS += -Wsystem-headers
endif
ifdef COMPILE_DEBUG
#debug
-CFLAGS += -g3
-else
+LTM_CFLAGS += -g3
+endif
ifdef COMPILE_SIZE
#for size
-CFLAGS += -Os
+LTM_CFLAGS += -Os
else
ifndef IGNORE_SPEED
#for speed
-CFLAGS += -O3 -funroll-loops
+LTM_CFLAGS += -O3 -funroll-loops
#x86 optimizations [should be valid for any GCC install though]
-CFLAGS += -fomit-frame-pointer
+LTM_CFLAGS += -fomit-frame-pointer
endif
endif # COMPILE_SIZE
-endif # COMPILE_DEBUG
ifneq ($(findstring clang,$(CC)),)
-CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
+LTM_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
+endif
+ifneq ($(findstring mingw,$(CC)),)
+LTM_CFLAGS += -Wno-shadow
endif
ifeq ($(PLATFORM), Darwin)
-CFLAGS += -Wno-nullability-completeness
+LTM_CFLAGS += -Wno-nullability-completeness
+endif
+ifeq ($(PLATFORM), CYGWIN)
+LIBTOOLFLAGS += -no-undefined
+endif
+
+# add in the standard FLAGS
+LTM_CFLAGS += $(CFLAGS)
+LTM_LFLAGS += $(LFLAGS)
+LTM_LDFLAGS += $(LDFLAGS)
+LTM_LIBTOOLFLAGS += $(LIBTOOLFLAGS)
+
+
+ifeq ($(PLATFORM),FreeBSD)
+ _ARCH := $(shell sysctl -b hw.machine_arch)
+else
+ _ARCH := $(shell uname -m)
endif
# adjust coverage set
-ifneq ($(filter $(shell arch), i386 i686 x86_64 amd64 ia64),)
+ifneq ($(filter $(_ARCH), i386 i686 x86_64 amd64 ia64),)
COVERAGE = test_standalone timing
- COVERAGE_APP = ./test && ./ltmtest
+ COVERAGE_APP = ./test && ./timing
else
COVERAGE = test_standalone
COVERAGE_APP = ./test
endif
-HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h
-HEADERS=tommath_private.h $(HEADERS_PUB)
-
-test_standalone: CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0
+HEADERS_PUB=tommath.h
+HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
#LIBPATH The directory for libtommath to be installed to.
#INCPATH The directory to install the header files for libtommath.
@@ -90,9 +139,9 @@ DATAPATH ?= $(PREFIX)/share/doc/libtommath/pdf
#make the code coverage of the library
#
-coverage: CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
-coverage: LFLAGS += -lgcov
-coverage: LDFLAGS += -lgcov
+coverage: LTM_CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
+coverage: LTM_LFLAGS += -lgcov
+coverage: LTM_LDFLAGS += -lgcov
coverage: $(COVERAGE)
$(COVERAGE_APP)
@@ -111,8 +160,7 @@ cleancov-clean:
cleancov: cleancov-clean clean
clean:
- rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \
- *.idx *.toc *.log *.aux *.dvi *.lof *.ind *.ilg *.ps *.log *.s mpi.c *.da *.dyn *.dpi tommath.tex `find . -type f | grep [~] | xargs` *.lo *.la
- rm -rf .libs/
- #${MAKE} -C etc/ clean MAKE=${MAKE}
- #${MAKE} -C doc/ clean MAKE=${MAKE}
+ rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o \
+ demo/*.o test timing mtest_opponent mtest/mtest mtest/mtest.exe tuning_list \
+ *.s mpi.c *.da *.dyn *.dpi tommath.tex `find . -type f | grep [~] | xargs` *.lo *.la
+ rm -rf .libs/ demo/.libs