Skip to content

Commit

Permalink
configure: Use $SED and $GREP to make sure we get correct tools
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse committed Nov 28, 2024
1 parent c64c105 commit 6f6dc7c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
29 changes: 16 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ AM_INIT_AUTOMAKE([foreign tar-ustar])
AM_SILENT_RULES([yes])

AM_MAINTAINER_MODE
AC_PROG_GREP
AC_PROG_SED

PKG_PREREQ([0.28])
PKG_PROG_PKG_CONFIG

Expand Down Expand Up @@ -265,7 +268,7 @@ AM_ICONV
CXXFLAGS="$CXXFLAGS -D__STDC_LIMIT_MACROS"

# Use the first x.y.z numbers of the version.
DOVECOT_CONFIG_VERSION=$(echo "$PACKAGE_VERSION" | sed 's/^\([[0-9]]*\.[[0-9]]*\.[[0-9]]*\).*$/\1/')
DOVECOT_CONFIG_VERSION=$(echo "$PACKAGE_VERSION" | $SED 's/^\([[0-9]]*\.[[0-9]]*\.[[0-9]]*\).*$/\1/')
if test "$is_pro_build" = "yes"; then
SET_PRO_DEFINES
AC_SUBST(DOVECOT_ASSET_URL, "doc.dovecotpro.com")
Expand Down Expand Up @@ -730,19 +733,19 @@ dnl **
dnl ** Settings
dnl **

libdovecot_dirs=`echo "$LIBDOVECOT_LA_LIBS" | sed -e "s:\\$(top_builddir):$srcdir:g" -e 's:/[[^/]]*\\.la::g'`
libdovecot_dirs=`echo "$LIBDOVECOT_LA_LIBS" | $SED -e "s:\\$(top_builddir):$srcdir:g" -e 's:/[[^/]]*\\.la::g'`

libdovecot_headers=
libdovecot_c_files=
non_libdovecot_headers=
non_libdovecot_c_files=
all_files=`find $srcdir/src -name '*.[[ch]]' | grep -v '/src/config/all-settings.c' | grep -v '/src/lib-settings/' | grep -v '/test-' | xargs grep -e 'struct setting_parser_info [[a-z]]' -e 'struct service_settings [[a-z]]' -e '<settings checks>' | sed 's/:.*//' | sort | uniq`
all_files=`find $srcdir/src -name '*.[[ch]]' | $GREP -v '/src/config/all-settings.c' | $GREP -v '/src/lib-settings/' | $GREP -v '/test-' | xargs $GREP -e 'struct setting_parser_info [[a-z]]' -e 'struct service_settings [[a-z]]' -e '<settings checks>' | $SED 's/:.*//' | sort | uniq`
for file in $all_files; do
dir=`echo "$file" | sed 's:/[[^/]]*$::'`
dir=`echo "$file" | $SED 's:/[[^/]]*$::'`
basefile=`basename $file`
if echo "$libdovecot_dirs" | grep "$dir" >/dev/null; then
if echo "$libdovecot_dirs" | $GREP "$dir" >/dev/null; then
dnl lib-dovecot
if echo "$file" | grep '\.h$' >/dev/null; then
if echo "$file" | $GREP '\.h$' >/dev/null; then
libdovecot_headers="$libdovecot_headers $file"
else
libdovecot_c_files="$libdovecot_c_files $file"
Expand All @@ -753,7 +756,7 @@ for file in $all_files; do

if test "$BUILD_IMAP_HIBERNATE" = 0 && test "$basefile" = "imap-hibernate-settings.c"; then
continue
elif echo "$file" | grep '\.h$' >/dev/null; then
elif echo "$file" | $GREP '\.h$' >/dev/null; then
non_libdovecot_headers="$non_libdovecot_headers $file"
else
non_libdovecot_c_files="$non_libdovecot_c_files $file"
Expand All @@ -766,8 +769,8 @@ dnl file contents. However, we still need to scan the .c files for any
dnl setting_parser_infos that aren't elsewhere.

# list headers first, C files last
SETTING_FILES=`echo $libdovecot_headers $non_libdovecot_headers $non_libdovecot_c_files | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
SETTING_LINKED_FILES=`echo $libdovecot_c_files | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
SETTING_FILES=`echo $libdovecot_headers $non_libdovecot_headers $non_libdovecot_c_files | $SED -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
SETTING_LINKED_FILES=`echo $libdovecot_c_files | $SED -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
AC_SUBST(SETTING_FILES)
AC_SUBST(SETTING_LINKED_FILES)

Expand Down Expand Up @@ -929,10 +932,10 @@ if test "$want_sql" = "plugin"; then
sql_drivers="$sql_drivers (plugins)"
fi

not_passdb=`echo "$not_passdb"|sed 's/ / -/g'`
not_userdb=`echo "$not_userdb"|sed 's/ / -/g'`
not_sql_drivers=`echo "$not_sql_drivers"|sed 's/ / -/g'`
not_fts=`echo "$not_fts"|sed 's/ / -/g'`
not_passdb=`echo "$not_passdb"| $SED 's/ / -/g'`
not_userdb=`echo "$not_userdb"| $SED 's/ / -/g'`
not_sql_drivers=`echo "$not_sql_drivers"| $SED 's/ / -/g'`
not_fts=`echo "$not_fts"| $SED 's/ / -/g'`

echo
echo "Install prefix . : $prefix"
Expand Down
14 changes: 7 additions & 7 deletions m4/ac_typeof.m4
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ AC_DEFUN([AC_TYPEOF], [
visible="unknown"
break
])
result="`echo $type|sed 's/-/ /g'`"
result="`echo $type | $SED 's/-/ /g'`"
visible="$result"
],[])
])
Expand All @@ -63,7 +63,7 @@ AC_DEFUN([AC_TYPEOF], [
AS_IF([test "$result" = ""], [
for type in $order; do
type="`echo $type|sed 's/-/ /g'`"
type="`echo $type | $SED 's/-/ /g'`"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
typedef $type $1;
Expand Down Expand Up @@ -97,10 +97,10 @@ AC_DEFUN([AC_TYPEOF], [
rm -f conftestval
for type in $order; do
actype="ac_cv_sizeof_`echo $type|sed 's/-/_/g'`"
actype="ac_cv_sizeof_`echo $type | $SED 's/-/_/g'`"
AS_IF([test "$size" = "`eval echo \\$$actype`"], [
result="`echo $type|sed 's/-/ /g'`"
visible="`expr $size \* 8`bit (using $result)"
result="`echo $type | $SED 's/-/ /g'`"
visible="`expr $size \* 8`bit ( using $result)"
break
])
done
Expand All @@ -114,8 +114,8 @@ AC_DEFUN([AC_TYPEOF], [
dnl * AC_CACHE_VAL
])
typeof_$1=`echo $i_cv_typeof_$1 | sed s,/.*$,,`
visible=`echo $i_cv_typeof_$1 | sed s,^.*/,,`
typeof_$1=`echo $i_cv_typeof_$1 | $SED s,/.*$,,`
visible=`echo $i_cv_typeof_$1 | $SED s,^.*/,,`
AC_MSG_RESULT($visible)
])

10 changes: 5 additions & 5 deletions m4/dovecot.m4
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ AC_DEFUN([DC_DOVECOT],[
ORIG_BINARY_CFLAGS="$BINARY_CFLAGS"
ORIG_BINARY_LDFLAGS="$BINARY_LDFLAGS"
eval `grep -i '^dovecot_[[a-z_]]*=' "$dovecotdir"/dovecot-config`
eval `grep '^LIBDOVECOT[[A-Z0-9_]]*=' "$dovecotdir"/dovecot-config`
eval `$GREP -i '^dovecot_[[a-z_]]*=' "$dovecotdir"/dovecot-config`
eval `$GREP '^LIBDOVECOT[[A-Z0-9_]]*=' "$dovecotdir"/dovecot-config`
CFLAGS="$ORIG_CFLAGS"
LDFLAGS="$ORIG_LDFLAGS"
Expand Down Expand Up @@ -411,15 +411,15 @@ AC_DEFUN([DC_DOVECOT],[
AC_DEFUN([DC_CC_WRAPPER],[
AS_IF([test "$want_shared_libs" != "yes"], [
dnl want_shared_libs=no is for internal use. the liblib.la check is for plugins
AS_IF([test "$want_shared_libs" = "no" || echo "$LIBDOVECOT" | grep "/liblib.la" > /dev/null], [
AS_IF([test "$want_shared_libs" = "no" || echo "$LIBDOVECOT" | $GREP "/liblib.la" > /dev/null], [
AS_IF([test "$with_gnu_ld" = yes], [
dnl libtool can't handle using whole-archive flags, so we need to do this
dnl with a CC wrapper.. shouldn't be much of a problem, since most people
dnl are building with shared libs.
cat > cc-wrapper.sh <<_DC_EOF
#!/bin/sh
if echo "\$[*]" | grep -- -export-dynamic > /dev/null; then
if echo "\$[*]" | $GREP -- -export-dynamic > /dev/null; then
# the binary uses plugins. make sure we include everything from .a libs
exec $CC -Wl,--whole-archive \$[*] -Wl,--no-whole-archive
else
Expand Down Expand Up @@ -515,7 +515,7 @@ m4_ifval([$2],
dnl * clang check
AC_DEFUN([CC_CLANG],[
AC_MSG_CHECKING([whether $CC is clang 3.3+])
AS_IF([$CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1], [
AS_IF([$CC -dM -E -x c /dev/null | $GREP __clang__ > /dev/null 2>&1], [
AS_VAR_SET([have_clang], [yes])
], [
AS_VAR_SET([have_clang], [no])
Expand Down
4 changes: 2 additions & 2 deletions m4/test_with.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dnl TEST_WITH(name, value, [plugin])
AC_DEFUN([TEST_WITH], [
want=want_`echo $1|sed s/-/_/g`
want=want_`echo $1| $SED s/-/_/g`
AS_IF([test "$2" = yes || test "$2" = no || test "$2" = auto], [
eval $want=$2
], [test "$2" = plugin], [
Expand All @@ -9,7 +9,7 @@ AC_DEFUN([TEST_WITH], [
], [
AC_MSG_ERROR(--with-$1=plugin not supported)
])
], [test "$(echo $2|grep -c '^/' 2>/dev/null)" -gt 0], [
], [test "$(echo $2 | $GREP -c '^/' 2>/dev/null)" -gt 0], [
AC_MSG_ERROR(--with-$1=path not supported. You may want to use instead:
CPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1)
], [
Expand Down

0 comments on commit 6f6dc7c

Please sign in to comment.