]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
build: attempt to fix build issues on FreeBSD
authorDmitry Baryshkov <dbaryshkov@gmail.com>
Thu, 16 Apr 2020 15:49:22 +0000 (18:49 +0300)
committerDmitry Baryshkov <dbaryshkov@gmail.com>
Thu, 16 Apr 2020 18:28:35 +0000 (21:28 +0300)
BSD sed does not like \n and \0 in string substitution. Workaround this
by using sed magic.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
devel/import-ecc-from-nettle.sh

index 9ed40f077ad2ae49a5be9693c15a42207f88eff4..6bfb9d30d8461b1d03f8f5ef63aa83bfb33a2f87 100755 (executable)
@@ -121,9 +121,9 @@ for f in $IMPORTS; do
        sed -e 's/^#define \(.*\) nettle_\1/#define \1 gnutls_nettle_ecc_\1/' \
            -e 's/^#define \(.*\) _nettle_\1/#define \1 _gnutls_nettle_ecc_\1/' \
            -e 's/^#define _\(.*\) _nettle_\1/#define _\1 _gnutls_nettle_ecc_\1/' \
-           -e 's/^_nettle_\(.*\)(.*/#define _nettle_\1 _gnutls_nettle_ecc_\1\n\0/' \
-           -e 's/^extern const struct ecc_curve _nettle_\(.*\);/#define _nettle_\1 _gnutls_nettle_ecc_\1\n\0/' \
-           -e 's/^extern const struct ecc_eddsa _nettle_\(.*\);/#define _nettle_\1 _gnutls_nettle_ecc_\1\n\0/' \
+           -e '/^_nettle_/ { h ; s/^_nettle_\(.*\)(.*/#define _nettle_\1 _gnutls_nettle_ecc_\1/g ; p; x; }' \
+           -e '/^extern const struct ecc_curve _nettle_\(.*\);/ { h ; s/.*_nettle\(.*\);/#define _nettle_\1 _gnutls_nettle_ecc_\1/ ; p; x; }' \
+           -e '/^extern const struct ecc_eddsa _nettle_\(.*\);/ { h ; s/.*_nettle\(.*\);/#define _nettle_\1 _gnutls_nettle_ecc_\1/ ; p; x; }' \
            -e '/gostdsa_generate_keypair/d' \
            $dst > $dst-t && \
          mv $dst-t $dst
@@ -152,7 +152,7 @@ for f in $IMPORTS; do
       */ecc-gost-gc256b.c)
        # The generated file is arch dependent, conditionalize the
        # inclusion.
-       sed '/^#include "ecc-gost-gc256b\.h"/ { i\
+       sed -e '/^#include "ecc-gost-gc256b\.h"/ { i\
 #if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)\
 # pragma GCC diagnostic ignored "-Wunused-const-variable"\
 #endif\
@@ -164,12 +164,16 @@ for f in $IMPORTS; do
 #error unsupported configuration\
 #endif
 ; d
-}' $dst | sed -e 's/#include "ecc-internal.h"/\0\n#include "ecc-gost-curve.h"/' > $dst-t && mv $dst-t $dst
+}' \
+         -e '/#include "ecc-internal.h"/ { i\
+#include "ecc-gost-curve.h"
+; }' \
+         $dst > $dst-t && mv $dst-t $dst
        ;;
       */ecc-gost-gc512a.c)
        # The generated file is arch dependent, conditionalize the
        # inclusion.
-       sed '/^#include "ecc-gost-gc512a\.h"/ { i\
+       sed -e '/^#include "ecc-gost-gc512a\.h"/ { i\
 #if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)\
 # pragma GCC diagnostic ignored "-Wunused-const-variable"\
 #endif\
@@ -181,7 +185,11 @@ for f in $IMPORTS; do
 #error unsupported configuration\
 #endif
 ; d
-}' $dst | sed -e 's/#include "ecc-internal.h"/\0\n#include "ecc-gost-curve.h"/' > $dst-t && mv $dst-t $dst
+}' \
+         -e '/#include "ecc-internal.h"/ { i\
+#include "ecc-gost-curve.h"
+; }' \
+         $dst > $dst-t && mv $dst-t $dst
        ;;
       */eddsa-hash.c)
        # Known to be unnecessary.