Merge pull request #33 from ryancdotorg/ryancdotorg/non_str_funcs
[tomsfastmath.git] / makefile_include.mk
blob53d693c8f5738bcdfebce371f57fcda9fc8c90ea
2 # Include makefile used by makefile + makefile.shared
3 # (GNU make only)
4 # SPDX-License-Identifier: Unlicense
6 ifndef INSTALL_CMD
7 $(error your makefile must define INSTALL_CMD)
8 endif
9 ifndef UNINSTALL_CMD
10 $(error your makefile must define UNINSTALL_CMD)
11 endif
14 # The Version of the library
16 VERSION=0.13.1-next
17 VERSION_LIB=1:0:0
18 VERSION_PC=0.13.1
20 GIT_VERSION := $(shell [ -e .git ] && { printf git- ; git describe --tags --always --dirty ; } || echo $(VERSION))
21 ifneq ($(GIT_VERSION),)
22 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
23 endif
25 # Compiler and Linker Names
26 ifndef CROSS_COMPILE
27 CROSS_COMPILE:=
28 endif
30 ifeq ($(CC),cc)
31 CC := $(CROSS_COMPILE)gcc
32 endif
33 LD:=$(CROSS_COMPILE)ld
34 AR:=$(CROSS_COMPILE)ar
35 RANLIB=$(CROSS_COMPILE)ranlib
37 ifndef MAKE
38 MAKE=make
39 endif
42 # Compilation flags
44 # Note that we're extending the environments' CFLAGS.
45 # If you think that our CFLAGS are not nice you can easily override them
46 # by giving them as a parameter to make:
47 # make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
50 CFLAGS += -Wall -W -Wshadow -Isrc/headers
52 ifdef COMPILE_DEBUG
53 #debug
54 CFLAGS += -g3
55 else
56 ifndef IGNORE_SPEED
58 CFLAGS += -O3
60 PLATFORM := $(shell uname | sed -e 's/_.*//')
61 ifneq ($(PLATFORM), Darwin)
62 CFLAGS += -funroll-loops
63 endif
65 #profiling
66 #PROF=-pg -g
67 #CFLAGS += $(PROF)
69 #speed
70 CFLAGS += -fomit-frame-pointer
72 endif
73 endif
76 # (Un)Install related variables
78 DESTDIR ?=
79 PREFIX ?= /usr/local
80 LIBPATH ?= $(PREFIX)/lib
81 INCPATH ?= $(PREFIX)/include
85 # Build targets
88 default: $(LIBNAME)
91 demo/test.o: CFLAGS+=-Wno-unused-result
93 .PHONY: mtest
94 mtest: $(LIBNAME)
95 CC="$(CC)" CFLAGS="$(CFLAGS) -I../" MAKE=${MAKE} ${MAKE} -C mtest/ mtest
97 .common_install: $(LIBNAME)
98 install -d $(DESTDIR)$(LIBPATH)
99 $(INSTALL_CMD) $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
100 install -d $(DESTDIR)$(INCPATH)
101 install $(HEADERS_PUB) $(DESTDIR)$(INCPATH)/tomsfastmath
104 HEADER_FILES=$(notdir $(HEADERS_PUB))
105 .common_uninstall:
106 $(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
107 rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
110 #This rule cleans the source tree of all compiled code, not including the pdf
111 #documentation.
112 clean:
113 find . -type f -name "*.o" \
114 -o -name "*.lo" \
115 -o -name "*.a" \
116 -o -name "*.la" \
117 -o -name "*.obj" \
118 -o -name "*.lib" \
119 -o -name "*.exe" \
120 -o -name "*.dll" \
121 -o -name "*.so" \
122 -o -name "*.gcov"\
123 -o -name "*.gcda"\
124 -o -name "*.gcno"\
125 -o -name "*.il" \
126 -o -name "*.dyn" \
127 -o -name "*.dpi" | xargs rm -f
128 find . -type d -name "*.libs" | xargs rm -rf
129 rm -f tfm.aux tfm.dvi tfm.idx tfm.ilg tfm.ind tfm.lof tfm.log tfm.out tfm.toc test test.exe
130 cd mtest; MAKE=${MAKE} ${MAKE} clean
132 docs:
133 $(MAKE) -C doc/ $@ V=$(V)
135 doc/tfm.pdf:
136 $(MAKE) -C doc/ tfm.pdf V=$(V)
139 SOURCES = $(OBJECTS:.o=.c)
140 pre_gen/tfm_amalgam.c: $(SOURCES)
141 mkdir -p pre_gen
142 @printf "\
143 /* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */\n\
144 /* SPDX-License-Identifier: Unlicense */\n\
146 /*** AUTO-GENERATED FILE! DO NOT EDIT MANUALLY ***/\n\
148 #define TFM_PRE_GEN_MPI_C\n\
149 \n" > $@
150 cat $(SOURCES) >> $@
152 amalgam pre_gen: pre_gen/tfm_amalgam.c
154 zipup: doc/tfm.pdf
155 @# Update the index, so diff-index won't fail in case the pdf has been created.
156 @# As the pdf creation modifies tfm.tex, git sometimes detects the
157 @# modified file, but misses that it's put back to its original version.
158 @git update-index --refresh
159 @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 )
160 rm -rf tomsfastmath-$(VERSION) tfm-$(VERSION).*
161 @# files/dirs excluded from "git archive" are defined in .gitattributes
162 git archive --format=tar --prefix=tomsfastmath-$(VERSION)/ HEAD | tar x
163 mkdir -p tomsfastmath-$(VERSION)/doc
164 cp doc/tfm.pdf tomsfastmath-$(VERSION)/doc/tfm.pdf
165 $(MAKE) -C tomsfastmath-$(VERSION)/ pre_gen
166 tar -c tomsfastmath-$(VERSION)/ | xz -6e -c - > tfm-$(VERSION).tar.xz
167 zip -9rq tfm-$(VERSION).zip tomsfastmath-$(VERSION)
168 rm -rf tomsfastmath-$(VERSION)
169 gpg -b -a tfm-$(VERSION).tar.xz
170 gpg -b -a tfm-$(VERSION).zip
172 new_file:
173 bash updatemakes.sh
175 .PHONY: doc/tfm.pdf