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