Merge pull request #26 from aewag/develop
[tomsfastmath.git] / makefile_include.mk
blobeab54c87135c571876c54a1b72d5ae6e8c2c3871
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)
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)
138 pre_gen:
139 mkdir -p pre_gen
140 perl gen.pl
141 sed -e 's/[[:blank:]]*$$//' mpi.c > pre_gen/mpi.c
142 rm mpi.c
144 zipup: doc/tfm.pdf
145 @# Update the index, so diff-index won't fail in case the pdf has been created.
146 @# As the pdf creation modifies tfm.tex, git sometimes detects the
147 @# modified file, but misses that it's put back to its original version.
148 @git update-index --refresh
149 @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 )
150 rm -rf tomsfastmath-$(VERSION) tfm-$(VERSION).*
151 @# files/dirs excluded from "git archive" are defined in .gitattributes
152 git archive --format=tar --prefix=tomsfastmath-$(VERSION)/ HEAD | tar x
153 mkdir -p tomsfastmath-$(VERSION)/doc
154 cp doc/tfm.pdf tomsfastmath-$(VERSION)/doc/tfm.pdf
155 $(MAKE) -C tomsfastmath-$(VERSION)/ pre_gen
156 tar -c tomsfastmath-$(VERSION)/ | xz -6e -c - > tfm-$(VERSION).tar.xz
157 zip -9rq tfm-$(VERSION).zip tomsfastmath-$(VERSION)
158 rm -rf tomsfastmath-$(VERSION)
159 gpg -b -a tfm-$(VERSION).tar.xz
160 gpg -b -a tfm-$(VERSION).zip
162 new_file:
163 bash updatemakes.sh
165 .PHONY: pre_gen doc/tfm.pdf