libtommath/makefile_include.mk

161 lines
3.9 KiB
Makefile
Raw Normal View History

#
# Include makefile for libtommath
#
2015-12-12 19:19:15 +00:00
#version of library
2019-01-28 20:21:40 +00:00
VERSION=1.1.0-develop
2018-12-26 13:35:39 +00:00
VERSION_PC=1.1.0
2019-01-22 12:49:36 +00:00
VERSION_SO=2:0:1
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 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
2017-08-29 08:40:05 +00:00
LD=$(CROSS_COMPILE)ld
AR=$(CROSS_COMPILE)ar
RANLIB=$(CROSS_COMPILE)ranlib
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
CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
2019-05-10 22:19:28 +00:00
ifdef SANITIZER
CFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=float-divide-by-zero
endif
ifndef NO_ADDTL_WARNINGS
# additional warnings
CFLAGS += -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align
CFLAGS += -Wstrict-prototypes -Wpointer-arith
endif
ifdef CONV_WARNINGS
CFLAGS += -std=c89 -Wconversion -Wsign-conversion
ifeq ($(CONV_WARNINGS), strict)
CFLAGS += -DMP_USE_ENUMS -Wc++-compat
endif
else
CFLAGS += -Wsystem-headers
endif
ifdef COMPILE_DEBUG
#debug
CFLAGS += -g3
endif
ifdef COMPILE_SIZE
#for size
CFLAGS += -Os
else
ifndef IGNORE_SPEED
#for speed
CFLAGS += -O3 -funroll-loops
#x86 optimizations [should be valid for any GCC install though]
CFLAGS += -fomit-frame-pointer
endif
endif # COMPILE_SIZE
2017-08-29 14:57:48 +00:00
ifneq ($(findstring clang,$(CC)),)
CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
endif
ifneq ($(findstring mingw,$(CC)),)
CFLAGS += -Wno-shadow
endif
2017-08-29 14:57:48 +00:00
ifeq ($(PLATFORM), Darwin)
CFLAGS += -Wno-nullability-completeness
endif
2018-12-02 16:56:10 +00:00
ifeq ($(PLATFORM), CYGWIN)
LIBTOOLFLAGS += -no-undefined
endif
2017-08-29 14:57:48 +00:00
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_standalone timing
2018-02-02 09:09:08 +00:00
COVERAGE_APP = ./test && ./timing
else
COVERAGE = test_standalone
COVERAGE_APP = ./test
endif
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
2015-04-18 11:58:17 +00:00
test_standalone: CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0
#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
2015-12-12 19:19:15 +00:00
#make the code coverage of the library
#
coverage: CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
coverage: LFLAGS += -lgcov
coverage: LDFLAGS += -lgcov
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:
rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/test.o demo/main.o demo/opponent.o test timing mpitest mtest/mtest mtest/mtest.exe tuning_list\
2015-12-12 19:19:15 +00:00
*.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/
2017-05-10 09:37:48 +00:00
${MAKE} -C etc/ clean MAKE=${MAKE}
${MAKE} -C doc/ clean MAKE=${MAKE}