libtommath/makefile_include.mk

176 lines
4.2 KiB
Makefile
Raw Normal View History

#
# Include makefile for libtommath
#
2015-12-12 19:19:15 +00:00
#version of library
2019-10-22 09:54:34 +00:00
VERSION=1.2.0-develop
2019-10-15 19:09:43 +00:00
VERSION_PC=1.2.0
2019-10-17 09:48:06 +00:00
VERSION_SO=3:0:2
2015-12-12 19:19:15 +00:00
2017-08-29 14:57:48 +00:00
PLATFORM := $(shell uname | sed -e 's/_.*//')
2015-12-12 19:19:15 +00:00
# default make target
default: ${LIBNAME}
2015-04-18 11:58:17 +00:00
# Compiler and Linker Names
2017-08-29 08:40:05 +00:00
ifndef CROSS_COMPILE
CROSS_COMPILE=
2015-04-18 11:58:17 +00:00
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)
2015-04-18 11:58:17 +00:00
endif
ifneq (,$(shell printf $(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
2017-08-29 08:40:05 +00:00
LD=$(CROSS_COMPILE)ld
AR=$(CROSS_COMPILE)ar
2015-04-18 11:58:17 +00:00
ifndef MAKE
# BSDs refer to GNU Make as gmake
ifneq (,$(findstring $(PLATFORM),FreeBSD OpenBSD DragonFly NetBSD))
MAKE=gmake
else
MAKE=make
endif
2015-04-18 11:58:17 +00:00
endif
LTM_CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
2019-05-10 22:19:28 +00:00
ifdef SANITIZER
LTM_CFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=float-divide-by-zero
2019-05-10 22:19:28 +00:00
endif
ifndef NO_ADDTL_WARNINGS
# additional warnings
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)
2019-10-16 07:26:04 +00:00
LTM_CFLAGS += -Wc++-compat
endif
else
LTM_CFLAGS += -Wsystem-headers
endif
ifdef COMPILE_DEBUG
#debug
LTM_CFLAGS += -g3
endif
ifdef COMPILE_SIZE
#for size
LTM_CFLAGS += -Os
else
ifndef IGNORE_SPEED
#for speed
LTM_CFLAGS += -O3 -funroll-loops
#x86 optimizations [should be valid for any GCC install though]
LTM_CFLAGS += -fomit-frame-pointer
endif
ifdef COMPILE_LTO
LTM_CFLAGS += -flto
AR = $(subst clang,llvm-ar,$(subst gcc,gcc-ar,$(CC)))
endif
endif # COMPILE_SIZE
2017-08-29 14:57:48 +00:00
ifneq ($(findstring clang,$(CC)),)
LTM_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
2017-08-29 14:57:48 +00:00
endif
ifneq ($(findstring mingw,$(CC)),)
LTM_CFLAGS += -Wno-shadow
endif
2017-08-29 14:57:48 +00:00
ifeq ($(PLATFORM), Darwin)
LTM_CFLAGS += -Wno-nullability-completeness
2017-08-29 14:57:48 +00:00
endif
2018-12-02 16:56:10 +00:00
ifeq ($(PLATFORM), CYGWIN)
LIBTOOLFLAGS += -no-undefined
endif
2017-08-29 14:57:48 +00:00
# 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
2019-02-28 10:28:07 +00:00
_ARCH := $(shell uname -m)
endif
# adjust coverage set
ifneq ($(filter $(_ARCH), i386 i686 x86_64 amd64 ia64),)
COVERAGE = test timing
2018-02-02 09:09:08 +00:00
COVERAGE_APP = ./test && ./timing
else
COVERAGE = test
COVERAGE_APP = ./test
endif
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.
#DATAPATH The directory to install the pdf docs.
DESTDIR ?=
PREFIX ?= /usr/local
LIBPATH ?= $(PREFIX)/lib
INCPATH ?= $(PREFIX)/include
DATAPATH ?= $(PREFIX)/share/doc/libtommath/pdf
# build & run test-suite
check: test
./test
2015-12-12 19:19:15 +00:00
#make the code coverage of the library
#
coverage: LTM_CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
coverage: LTM_LFLAGS += -lgcov
coverage: LTM_LDFLAGS += -lgcov
2015-12-12 19:19:15 +00:00
coverage: $(COVERAGE)
$(COVERAGE_APP)
2015-12-12 19:19:15 +00:00
lcov: coverage
rm -f coverage.info
lcov --capture --no-external --no-recursion $(LCOV_ARGS) --output-file coverage.info -q
genhtml coverage.info --output-directory coverage -q
# target that removes all coverage output
cleancov-clean:
rm -f `find . -type f -name "*.info" | xargs`
rm -rf coverage/
# cleans everything - coverage output and standard 'clean'
cleancov: cleancov-clean clean
clean:
2019-10-09 15:18:56 +00:00
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 tommath_amalgam.c pre_gen/tommath_amalgam.c *.da *.dyn *.dpi tommath.tex \
`find . -type f | grep [~] | xargs` *.lo *.la
2019-10-09 15:18:56 +00:00
rm -rf .libs/ demo/.libs
2017-05-10 09:37:48 +00:00
${MAKE} -C etc/ clean MAKE=${MAKE}
${MAKE} -C doc/ clean MAKE=${MAKE}