allow the user to override {C,L,LD}FLAGS
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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
diff --git a/etc/makefile b/etc/makefile
index ce9cf06..bad1741 100644
--- a/etc/makefile
+++ b/etc/makefile
@@ -1,4 +1,5 @@
-CFLAGS += -Wall -W -Wextra -Wshadow -O3 -I../
+LTM_CFLAGS += -Wall -W -Wextra -Wshadow -O3 -I../
+LTM_CFLAGS += $(CFLAGS)
# default lib name (requires install with root)
# LIBNAME=-ltommath
@@ -8,31 +9,31 @@ LIBNAME=../libtommath.a
#provable primes
pprime: pprime.o
- $(CC) $(CFLAGS) pprime.o $(LIBNAME) -o pprime
+ $(CC) $(LTM_CFLAGS) pprime.o $(LIBNAME) -o pprime
# portable [well requires clock()] tuning app
tune: tune.o
- $(CC) $(CFLAGS) tune.o $(LIBNAME) -o tune
+ $(CC) $(LTM_CFLAGS) tune.o $(LIBNAME) -o tune
./tune_it.sh
test_standalone: tune.o
# The benchmark program works as a testtool, too
- $(CC) $(CFLAGS) tune.o $(LIBNAME) -o test
+ $(CC) $(LTM_CFLAGS) tune.o $(LIBNAME) -o test
# spits out mersenne primes
mersenne: mersenne.o
- $(CC) $(CFLAGS) mersenne.o $(LIBNAME) -o mersenne
+ $(CC) $(LTM_CFLAGS) mersenne.o $(LIBNAME) -o mersenne
# finds DR safe primes for the given config
drprime: drprime.o
- $(CC) $(CFLAGS) drprime.o $(LIBNAME) -o drprime
+ $(CC) $(LTM_CFLAGS) drprime.o $(LIBNAME) -o drprime
# finds 2k safe primes for the given config
2kprime: 2kprime.o
- $(CC) $(CFLAGS) 2kprime.o $(LIBNAME) -o 2kprime
+ $(CC) $(LTM_CFLAGS) 2kprime.o $(LIBNAME) -o 2kprime
mont: mont.o
- $(CC) $(CFLAGS) mont.o $(LIBNAME) -o mont
+ $(CC) $(LTM_CFLAGS) mont.o $(LIBNAME) -o mont
clean:
diff --git a/makefile b/makefile
index 8de82d1..89d2b3b 100644
--- a/makefile
+++ b/makefile
@@ -21,7 +21,7 @@ include makefile_include.mk
ifneq ($V,1)
@echo " * ${CC} $@"
endif
- ${silent} ${CC} -c ${CFLAGS} $< -o $@
+ ${silent} ${CC} -c ${LTM_CFLAGS} $< -o $@
LCOV_ARGS=--directory .
@@ -77,11 +77,11 @@ profiled:
#make a single object profiled library
profiled_single:
perl gen.pl
- $(CC) $(CFLAGS) -fprofile-arcs -DTESTING -c mpi.c -o mpi.o
- $(CC) $(CFLAGS) -DTESTING -DTIMER demo/timing.c mpi.o -lgcov -o timing
+ $(CC) $(LTM_CFLAGS) -fprofile-arcs -DTESTING -c mpi.c -o mpi.o
+ $(CC) $(LTM_CFLAGS) -DTESTING -DTIMER demo/timing.c mpi.o -lgcov -o timing
./timing
rm -f *.o timing
- $(CC) $(CFLAGS) -fbranch-probabilities -DTESTING -c mpi.c -o mpi.o
+ $(CC) $(LTM_CFLAGS) -fbranch-probabilities -DTESTING -c mpi.c -o mpi.o
$(AR) $(ARFLAGS) $(LIBNAME) mpi.o
ranlib $(LIBNAME)
@@ -96,17 +96,17 @@ uninstall:
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
- $(CC) $(CFLAGS) $^ $(LFLAGS) -o test
+ $(CC) $(LTM_CFLAGS) $^ $(LTM_LFLAGS) -o test
.PHONY: mtest
mtest:
- cd mtest ; $(CC) $(CFLAGS) -O0 mtest.c $(LFLAGS) -o mtest
+ cd mtest ; $(CC) $(LTM_CFLAGS) -O0 mtest.c $(LTM_LFLAGS) -o mtest
timing: $(LIBNAME) demo/timing.c
- $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) $(LFLAGS) -o timing
+ $(CC) $(LTM_CFLAGS) -DTIMER demo/timing.c $(LIBNAME) $(LTM_LFLAGS) -o timing
tune: $(LIBNAME)
- $(MAKE) -C etc tune
+ $(MAKE) -C etc tune CFLAGS="$(LTM_CFLAGS)"
$(MAKE)
# You have to create a file .coveralls.yml with the content "repo_token: <the token>"
diff --git a/makefile.shared b/makefile.shared
index e6bb1ef..f77b5e5 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -58,12 +58,12 @@ bn_s_mp_sqr.o bn_s_mp_sqr_fast.o bn_s_mp_sub.o bn_s_mp_toom_mul.o bn_s_mp_toom_s
objs: $(OBJECTS)
.c.o: $(HEADERS)
- $(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
+ $(LTCOMPILE) $(LTM_CFLAGS) $(LTM_LDFLAGS) -o $@ -c $<
LOBJECTS = $(OBJECTS:.o=.lo)
$(LIBNAME): $(OBJECTS)
- $(LTLINK) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO) $(LIBTOOLFLAGS)
+ $(LTLINK) $(LTM_LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO) $(LTM_LIBTOOLFLAGS)
install: $(LIBNAME)
install -d $(DESTDIR)$(LIBPATH)
@@ -80,17 +80,17 @@ uninstall:
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
- $(LTLINK) $(LDFLAGS) $^ -o test
+ $(LTLINK) $(LTM_LDFLAGS) $^ -o test
.PHONY: mtest
mtest:
- cd mtest ; $(CC) $(CFLAGS) -O0 mtest.c $(LDFLAGS) -o mtest
+ cd mtest ; $(CC) $(LTM_CFLAGS) -O0 mtest.c $(LTM_LDFLAGS) -o mtest
timing: $(LIBNAME) demo/timing.c
- $(LTLINK) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o timing
+ $(LTLINK) $(LTM_CFLAGS) $(LTM_LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o timing
tune: $(LIBNAME)
- $(LTCOMPILE) $(CFLAGS) -c etc/tune.c -o etc/tune.o
- $(LTLINK) $(LDFLAGS) -o etc/tune etc/tune.o $(LIBNAME)
+ $(LTCOMPILE) $(LTM_CFLAGS) -c etc/tune.c -o etc/tune.o
+ $(LTLINK) $(LTM_LDFLAGS) -o etc/tune etc/tune.o $(LIBNAME)
cd etc/; /bin/sh tune_it.sh; cd ..
$(MAKE) -f makefile.shared
diff --git a/makefile_include.mk b/makefile_include.mk
index 9303ffc..a766343 100644
--- a/makefile_include.mk
+++ b/makefile_include.mk
@@ -47,60 +47,67 @@ else
endif
endif
-CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
+LTM_CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
ifdef SANITIZER
-CFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=float-divide-by-zero
+LTM_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
+LTM_CFLAGS += -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align
+LTM_CFLAGS += -Wstrict-prototypes -Wpointer-arith
endif
ifdef CONV_WARNINGS
-CFLAGS += -std=c89 -Wconversion -Wsign-conversion
+LTM_CFLAGS += -std=c89 -Wconversion -Wsign-conversion
ifeq ($(CONV_WARNINGS), strict)
-CFLAGS += -DMP_USE_ENUMS -Wc++-compat
+LTM_CFLAGS += -DMP_USE_ENUMS -Wc++-compat
endif
else
-CFLAGS += -Wsystem-headers
+LTM_CFLAGS += -Wsystem-headers
endif
ifdef COMPILE_DEBUG
#debug
-CFLAGS += -g3
+LTM_CFLAGS += -g3
endif
ifdef COMPILE_SIZE
#for size
-CFLAGS += -Os
+LTM_CFLAGS += -Os
else
ifndef IGNORE_SPEED
#for speed
-CFLAGS += -O3 -funroll-loops
+LTM_CFLAGS += -O3 -funroll-loops
#x86 optimizations [should be valid for any GCC install though]
-CFLAGS += -fomit-frame-pointer
+LTM_CFLAGS += -fomit-frame-pointer
endif
endif # COMPILE_SIZE
ifneq ($(findstring clang,$(CC)),)
-CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
+LTM_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
endif
ifneq ($(findstring mingw,$(CC)),)
-CFLAGS += -Wno-shadow
+LTM_CFLAGS += -Wno-shadow
endif
ifeq ($(PLATFORM), Darwin)
-CFLAGS += -Wno-nullability-completeness
+LTM_CFLAGS += -Wno-nullability-completeness
endif
ifeq ($(PLATFORM), CYGWIN)
LIBTOOLFLAGS += -no-undefined
endif
+# 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
@@ -119,7 +126,7 @@ endif
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
-test_standalone: CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0
+test_standalone: LTM_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.
@@ -132,9 +139,9 @@ DATAPATH ?= $(PREFIX)/share/doc/libtommath/pdf
#make the code coverage of the library
#
-coverage: CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
-coverage: LFLAGS += -lgcov
-coverage: LDFLAGS += -lgcov
+coverage: LTM_CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS
+coverage: LTM_LFLAGS += -lgcov
+coverage: LTM_LDFLAGS += -lgcov
coverage: $(COVERAGE)
$(COVERAGE_APP)