summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2022-11-10 17:39:27 +0800
committerMatt Johnston <matt@ucc.asn.au>2022-11-10 17:39:27 +0800
commit54a90ddac59ec1a1b453fb31c5aca1c96061035b (patch)
tree662217ca81ed358e693febb3afc6994e4172ec8f
parentcda8070898858b9000e6671a16b0da9d24888343 (diff)
downloaddropbear-54a90ddac59ec1a1b453fb31c5aca1c96061035b.tar.gz
Add LTM_CFLAGS configure argument
-rw-r--r--SMALL6
-rwxr-xr-xconfigure16
-rw-r--r--configure.ac10
-rw-r--r--libtommath/Makefile.in6
4 files changed, 38 insertions, 0 deletions
diff --git a/SMALL b/SMALL
index 0ddb89a..dbf80be 100644
--- a/SMALL
+++ b/SMALL
@@ -47,4 +47,10 @@ deciding.
Of course using small C libraries such as uClibc and dietlibc can also help.
+---
+
+Libtommath has its own default CFLAGS to improve speed. You can use
+./configure LTM_CFLAGS=-O2
+to reduce size at the expense of speed.
+
If you have any queries, mail me and I'll see if I can help.
diff --git a/configure b/configure
index 427c2da..e1986dd 100755
--- a/configure
+++ b/configure
@@ -672,6 +672,8 @@ build_vendor
build_cpu
build
STATIC
+DROPBEAR_LTM_CFLAGS
+LTM_CFLAGS
LD
OBJEXT
EXEEXT
@@ -754,6 +756,7 @@ CFLAGS
LDFLAGS
LIBS
CPPFLAGS
+LTM_CFLAGS
CXX
CXXFLAGS
CCC
@@ -1417,6 +1420,8 @@ Some influential environment variables:
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
+ LTM_CFLAGS CFLAGS for bundled libtommath. Default -O3 -funroll-loops
+ -fomit-frame-pointer
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CPP C preprocessor
@@ -3990,6 +3995,17 @@ printf "%s\n" "$as_me: No \$CFLAGS set... using \"-Os -W -Wall\" for GCC" >&6;}
CFLAGS="-Os -W -Wall"
fi
+# LTM_CFLAGS is given to ./configure by the user,
+# DROPBEAR_LTM_CFLAGS is substituted in the LTM Makefile.in
+DROPBEAR_LTM_CFLAGS="$LTM_CFLAGS"
+if test -z "$DROPBEAR_LTM_CFLAGS"; then
+ DROPBEAR_LTM_CFLAGS="-O3 -funroll-loops -fomit-frame-pointer"
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Setting LTM_CFLAGS to $DROPBEAR_LTM_CFLAGS" >&5
+printf "%s\n" "$as_me: Setting LTM_CFLAGS to $DROPBEAR_LTM_CFLAGS" >&6;}
+
+
+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking if compiler '$CC' supports -Wno-pointer-sign" >&5
printf "%s\n" "$as_me: Checking if compiler '$CC' supports -Wno-pointer-sign" >&6;}
diff --git a/configure.ac b/configure.ac
index 93916c5..a4f8f94 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,16 @@ if test -z "$ORIGCFLAGS" && test "$GCC" = "yes"; then
CFLAGS="-Os -W -Wall"
fi
+# LTM_CFLAGS is given to ./configure by the user,
+# DROPBEAR_LTM_CFLAGS is substituted in the LTM Makefile.in
+DROPBEAR_LTM_CFLAGS="$LTM_CFLAGS"
+if test -z "$DROPBEAR_LTM_CFLAGS"; then
+ DROPBEAR_LTM_CFLAGS="-O3 -funroll-loops -fomit-frame-pointer"
+fi
+AC_MSG_NOTICE(Setting LTM_CFLAGS to $DROPBEAR_LTM_CFLAGS)
+AC_ARG_VAR(LTM_CFLAGS, CFLAGS for bundled libtommath. Default -O3 -funroll-loops -fomit-frame-pointer)
+AC_SUBST(DROPBEAR_LTM_CFLAGS)
+
AC_MSG_NOTICE([Checking if compiler '$CC' supports -Wno-pointer-sign])
DB_TRYADDCFLAGS([-Wno-pointer-sign])
diff --git a/libtommath/Makefile.in b/libtommath/Makefile.in
index 18d26f6..f1cb59c 100644
--- a/libtommath/Makefile.in
+++ b/libtommath/Makefile.in
@@ -25,8 +25,14 @@ endif
coverage: LIBNAME:=-Wl,--whole-archive $(LIBNAME) -Wl,--no-whole-archive
+# Dropbear sets its own flags below
+IGNORE_SPEED=1
+
include $(srcdir)/makefile_include.mk
+# override makefile_include.mk flags
+LTM_CFLAGS += @DROPBEAR_LTM_CFLAGS@
+
%.o: %.c $(HEADERS)
ifneq ($V,1)
@echo " * ${CC} $@"