Merge pull request #247 from libtom/pr/custom_compile_flags
introduce LTC_CFLAGS and LTC_LDFLAGS
This commit is contained in:
commit
89d0c64335
18
makefile
18
makefile
@ -39,19 +39,19 @@ include makefile_include.mk
|
|||||||
ifeq ($(COVERAGE),1)
|
ifeq ($(COVERAGE),1)
|
||||||
all_test: LIB_PRE = -Wl,--whole-archive
|
all_test: LIB_PRE = -Wl,--whole-archive
|
||||||
all_test: LIB_POST = -Wl,--no-whole-archive
|
all_test: LIB_POST = -Wl,--no-whole-archive
|
||||||
CFLAGS += -fprofile-arcs -ftest-coverage
|
LTC_CFLAGS += -fprofile-arcs -ftest-coverage
|
||||||
EXTRALIBS += -lgcov
|
EXTRALIBS += -lgcov
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#AES comes in two flavours... enc+dec and enc
|
#AES comes in two flavours... enc+dec and enc
|
||||||
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
|
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
|
||||||
${silent} ${CC} ${CFLAGS} -DENCRYPT_ONLY -c $< -o $@
|
${silent} ${CC} ${LTC_CFLAGS} -DENCRYPT_ONLY -c $< -o $@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
ifneq ($V,1)
|
ifneq ($V,1)
|
||||||
@echo " * ${CC} $@"
|
@echo " * ${CC} $@"
|
||||||
endif
|
endif
|
||||||
${silent} ${CC} ${CFLAGS} -c $< -o $@
|
${silent} ${CC} ${LTC_CFLAGS} -c $< -o $@
|
||||||
|
|
||||||
$(LIBNAME): $(OBJECTS)
|
$(LIBNAME): $(OBJECTS)
|
||||||
ifneq ($V,1)
|
ifneq ($V,1)
|
||||||
@ -67,13 +67,13 @@ timing: $(LIBNAME) $(TIMINGS)
|
|||||||
ifneq ($V,1)
|
ifneq ($V,1)
|
||||||
@echo " * ${CC} $@"
|
@echo " * ${CC} $@"
|
||||||
endif
|
endif
|
||||||
${silent} $(CC) $(LDFLAGS) $(TIMINGS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING)
|
${silent} $(CC) $(LTC_LDFLAGS) $(TIMINGS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING)
|
||||||
|
|
||||||
test: $(LIBNAME) $(TOBJECTS)
|
test: $(LIBNAME) $(TOBJECTS)
|
||||||
ifneq ($V,1)
|
ifneq ($V,1)
|
||||||
@echo " * ${CC} $@"
|
@echo " * ${CC} $@"
|
||||||
endif
|
endif
|
||||||
${silent} $(CC) $(LDFLAGS) $(TOBJECTS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST)
|
${silent} $(CC) $(LTC_LDFLAGS) $(TOBJECTS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST)
|
||||||
|
|
||||||
# build the demos from a template
|
# build the demos from a template
|
||||||
define DEMO_template
|
define DEMO_template
|
||||||
@ -81,7 +81,7 @@ $(1): demos/$(1).o $$(LIBNAME)
|
|||||||
ifneq ($V,1)
|
ifneq ($V,1)
|
||||||
@echo " * $${CC} $$@"
|
@echo " * $${CC} $$@"
|
||||||
endif
|
endif
|
||||||
$${silent} $$(CC) $$(CFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
|
$${silent} $$(CC) $$(LTC_CFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
|
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
|
||||||
@ -97,10 +97,10 @@ install_bins: .common_install_bins
|
|||||||
uninstall: .common_uninstall
|
uninstall: .common_uninstall
|
||||||
|
|
||||||
profile:
|
profile:
|
||||||
CFLAGS="$(CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
|
LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
|
||||||
./timing
|
./timing
|
||||||
rm -f timing `find . -type f | grep [.][ao] | xargs`
|
rm -f timing `find . -type f | grep [.][ao] | xargs`
|
||||||
CFLAGS="$(CFLAGS) -fprofile-use" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
|
LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-use" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
|
||||||
|
|
||||||
# target that pre-processes all coverage data
|
# target that pre-processes all coverage data
|
||||||
lcov-single-create:
|
lcov-single-create:
|
||||||
@ -128,7 +128,7 @@ lcov-single:
|
|||||||
|
|
||||||
|
|
||||||
#make the code coverage of the library
|
#make the code coverage of the library
|
||||||
coverage: CFLAGS += -fprofile-arcs -ftest-coverage
|
coverage: LTC_CFLAGS += -fprofile-arcs -ftest-coverage
|
||||||
coverage: EXTRALIBS += -lgcov
|
coverage: EXTRALIBS += -lgcov
|
||||||
coverage: LIB_PRE = -Wl,--whole-archive
|
coverage: LIB_PRE = -Wl,--whole-archive
|
||||||
coverage: LIB_POST = -Wl,--no-whole-archive
|
coverage: LIB_POST = -Wl,--no-whole-archive
|
||||||
|
@ -25,7 +25,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath
|
|||||||
EXTRALIBS = -L../libtommath -ltommath
|
EXTRALIBS = -L../libtommath -ltommath
|
||||||
|
|
||||||
#Compilation flags
|
#Compilation flags
|
||||||
LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itests -DLTC_SOURCE
|
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
|
||||||
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
|
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
|
||||||
VERSION=1.18.0-rc1
|
VERSION=1.18.0-rc1
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ CFLAGS = /Ox /DUSE_LTM /DLTM_DESC /I../libtommath
|
|||||||
EXTRALIBS = ../libtommath/tommath.lib
|
EXTRALIBS = ../libtommath/tommath.lib
|
||||||
|
|
||||||
#Compilation flags
|
#Compilation flags
|
||||||
LTC_CFLAGS = $(CFLAGS) /nologo /Isrc/headers/ /Itests/ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /DLTC_SOURCE /W3
|
LTC_CFLAGS = /nologo /Isrc/headers/ /Itests/ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /DLTC_SOURCE /W3 $(CFLAGS)
|
||||||
LTC_LDFLAGS = advapi32.lib $(EXTRALIBS)
|
LTC_LDFLAGS = advapi32.lib $(EXTRALIBS)
|
||||||
VERSION=1.18.0-rc1
|
VERSION=1.18.0-rc1
|
||||||
|
|
||||||
|
@ -38,15 +38,15 @@ include makefile_include.mk
|
|||||||
|
|
||||||
#ciphers come in two flavours... enc+dec and enc
|
#ciphers come in two flavours... enc+dec and enc
|
||||||
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
|
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
|
||||||
$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
|
$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $<
|
$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
LOBJECTS = $(OBJECTS:.o=.lo)
|
LOBJECTS = $(OBJECTS:.o=.lo)
|
||||||
|
|
||||||
$(LIBNAME): $(OBJECTS)
|
$(LIBNAME): $(OBJECTS)
|
||||||
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT)
|
$(LT) --mode=link --tag=CC $(CC) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT)
|
||||||
|
|
||||||
install: .common_install
|
install: .common_install
|
||||||
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtomcrypt.pc.in > libtomcrypt.pc
|
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtomcrypt.pc.in > libtomcrypt.pc
|
||||||
@ -59,10 +59,10 @@ uninstall: .common_uninstall
|
|||||||
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
|
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
|
||||||
|
|
||||||
test: $(LIBNAME) $(TOBJECTS)
|
test: $(LIBNAME) $(TOBJECTS)
|
||||||
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
|
$(LT) --mode=link --tag=CC $(CC) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
|
||||||
|
|
||||||
timing: $(TIMINGS) $(LIBNAME)
|
timing: $(TIMINGS) $(LIBNAME)
|
||||||
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $^ $(EXTRALIBS)
|
$(LT) --mode=link --tag=CC $(CC) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $(TIMING) $^ $(EXTRALIBS)
|
||||||
|
|
||||||
# build the demos from a template
|
# build the demos from a template
|
||||||
define DEMO_template
|
define DEMO_template
|
||||||
@ -70,7 +70,7 @@ $(1): demos/$(1).o $$(LIBNAME)
|
|||||||
ifneq ($V,1)
|
ifneq ($V,1)
|
||||||
@echo " * $${CC} $$@"
|
@echo " * $${CC} $$@"
|
||||||
endif
|
endif
|
||||||
$$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
|
$$(LT) --mode=link --tag=CC $$(CC) $$(LTC_CFLAGS) $$(CPPFLAGS) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
|
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
|
||||||
|
@ -37,7 +37,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath
|
|||||||
EXTRALIBS = ../libtommath/libtommath.a
|
EXTRALIBS = ../libtommath/libtommath.a
|
||||||
|
|
||||||
#Compilation flags
|
#Compilation flags
|
||||||
LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itests -DLTC_SOURCE
|
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
|
||||||
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
|
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
|
||||||
VERSION=1.18.0-rc1
|
VERSION=1.18.0-rc1
|
||||||
|
|
||||||
|
@ -52,44 +52,44 @@ endif
|
|||||||
# by giving them as a parameter to make:
|
# by giving them as a parameter to make:
|
||||||
# make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
|
# make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
|
||||||
#
|
#
|
||||||
CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE
|
LTC_CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE
|
||||||
|
|
||||||
ifdef OLD_GCC
|
ifdef OLD_GCC
|
||||||
CFLAGS += -W
|
LTC_CFLAGS += -W
|
||||||
# older GCCs can't handle the "rotate with immediate" ROLc/RORc/etc macros
|
# older GCCs can't handle the "rotate with immediate" ROLc/RORc/etc macros
|
||||||
# define this to help
|
# define this to help
|
||||||
CFLAGS += -DLTC_NO_ROLC
|
LTC_CFLAGS += -DLTC_NO_ROLC
|
||||||
else
|
else
|
||||||
CFLAGS += -Wextra
|
LTC_CFLAGS += -Wextra
|
||||||
# additional warnings
|
# additional warnings
|
||||||
CFLAGS += -Wsystem-headers -Wbad-function-cast -Wcast-align
|
LTC_CFLAGS += -Wsystem-headers -Wbad-function-cast -Wcast-align
|
||||||
CFLAGS += -Wstrict-prototypes -Wpointer-arith
|
LTC_CFLAGS += -Wstrict-prototypes -Wpointer-arith
|
||||||
CFLAGS += -Wdeclaration-after-statement
|
LTC_CFLAGS += -Wdeclaration-after-statement
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -Wno-type-limits
|
LTC_CFLAGS += -Wno-type-limits
|
||||||
|
|
||||||
ifdef LTC_DEBUG
|
ifdef LTC_DEBUG
|
||||||
# compile for DEBUGGING (required for ccmalloc checking!!!)
|
# compile for DEBUGGING (required for ccmalloc checking!!!)
|
||||||
CFLAGS += -g3 -DLTC_NO_ASM
|
LTC_CFLAGS += -g3 -DLTC_NO_ASM
|
||||||
ifneq (,$(strip $(LTC_DEBUG)))
|
ifneq (,$(strip $(LTC_DEBUG)))
|
||||||
CFLAGS += -DLTC_TEST_DBG=$(LTC_DEBUG)
|
LTC_CFLAGS += -DLTC_TEST_DBG=$(LTC_DEBUG)
|
||||||
else
|
else
|
||||||
CFLAGS += -DLTC_TEST_DBG
|
LTC_CFLAGS += -DLTC_TEST_DBG
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
|
|
||||||
ifdef LTC_SMALL
|
ifdef LTC_SMALL
|
||||||
# optimize for SIZE
|
# optimize for SIZE
|
||||||
CFLAGS += -Os -DLTC_SMALL_CODE
|
LTC_CFLAGS += -Os -DLTC_SMALL_CODE
|
||||||
else
|
else
|
||||||
|
|
||||||
ifndef IGNORE_SPEED
|
ifndef IGNORE_SPEED
|
||||||
# optimize for SPEED
|
# optimize for SPEED
|
||||||
CFLAGS += -O3 -funroll-loops
|
LTC_CFLAGS += -O3 -funroll-loops
|
||||||
|
|
||||||
# add -fomit-frame-pointer. hinders debugging!
|
# add -fomit-frame-pointer. hinders debugging!
|
||||||
CFLAGS += -fomit-frame-pointer
|
LTC_CFLAGS += -fomit-frame-pointer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif # COMPILE_SMALL
|
endif # COMPILE_SMALL
|
||||||
@ -97,23 +97,26 @@ endif # COMPILE_DEBUG
|
|||||||
|
|
||||||
|
|
||||||
ifneq ($(findstring clang,$(CC)),)
|
ifneq ($(findstring clang,$(CC)),)
|
||||||
CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
|
LTC_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM), Darwin)
|
ifeq ($(PLATFORM), Darwin)
|
||||||
CFLAGS += -Wno-nullability-completeness
|
LTC_CFLAGS += -Wno-nullability-completeness
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
GIT_VERSION := $(shell [ -e .git ] && { printf git- ; git describe --tags --always --dirty ; } || echo $(VERSION))
|
GIT_VERSION := $(shell [ -e .git ] && { printf git- ; git describe --tags --always --dirty ; } || echo $(VERSION))
|
||||||
ifneq ($(GIT_VERSION),)
|
ifneq ($(GIT_VERSION),)
|
||||||
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
|
LTC_CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
LTC_CFLAGS := $(LTC_CFLAGS) $(CFLAGS)
|
||||||
|
|
||||||
ifneq ($(findstring -DLTC_PTHREAD,$(CFLAGS)),)
|
ifneq ($(findstring -DLTC_PTHREAD,$(LTC_CFLAGS)),)
|
||||||
LDFLAGS += -pthread
|
LTC_LDFLAGS += -pthread
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
LTC_LDFLAGS := $(LTC_LDFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
#List of demo objects
|
#List of demo objects
|
||||||
DSOURCES = $(wildcard demos/*.c)
|
DSOURCES = $(wildcard demos/*.c)
|
||||||
DOBJECTS = $(DSOURCES:.c=.o)
|
DOBJECTS = $(DSOURCES:.c=.o)
|
||||||
@ -340,8 +343,8 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22
|
|||||||
src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
|
src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
|
||||||
src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
|
src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
|
||||||
|
|
||||||
$(DOBJECTS): CFLAGS += -Itests
|
$(DOBJECTS): LTC_CFLAGS := -Itests $(LTC_CFLAGS)
|
||||||
$(TOBJECTS): CFLAGS += -Itests
|
$(TOBJECTS): LTC_CFLAGS := -Itests $(LTC_CFLAGS)
|
||||||
|
|
||||||
#This rule makes the libtomcrypt library.
|
#This rule makes the libtomcrypt library.
|
||||||
library: $(LIBNAME)
|
library: $(LIBNAME)
|
||||||
|
Loading…
Reference in New Issue
Block a user