Skip to content

Commit

Permalink
build: move more repetitive module work into our Autoconf macro
Browse files Browse the repository at this point in the history
Signed-off-by: Ferenc Wágner <[email protected]>
  • Loading branch information
wferi committed Dec 4, 2017
1 parent 4f34a68 commit c793738
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 57 deletions.
14 changes: 7 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,37 @@ if BUILDSCTP
else
sed -i -e "s#@sctp@#bcond_with#g" $@-t
endif
if BUILDCRYPTONSS
if BUILD_CRYPTO_NSS
sed -i -e "s#@nss@#bcond_without#g" $@-t
else
sed -i -e "s#@nss@#bcond_with#g" $@-t
endif
if BUILDCRYPTOOPENSSL
if BUILD_CRYPTO_OPENSSL
sed -i -e "s#@openssl@#bcond_without#g" $@-t
else
sed -i -e "s#@openssl@#bcond_with#g" $@-t
endif
if BUILDCOMPZLIB
if BUILD_COMPRESS_ZLIB
sed -i -e "s#@zlib@#bcond_without#g" $@-t
else
sed -i -e "s#@zlib@#bcond_with#g" $@-t
endif
if BUILDCOMPLZ4
if BUILD_COMPRESS_LZ4
sed -i -e "s#@lz4@#bcond_without#g" $@-t
else
sed -i -e "s#@lz4@#bcond_with#g" $@-t
endif
if BUILDCOMPLZO2
if BUILD_COMPRESS_LZO2
sed -i -e "s#@lzo2@#bcond_without#g" $@-t
else
sed -i -e "s#@lzo2@#bcond_with#g" $@-t
endif
if BUILDCOMPLZMA
if BUILD_COMPRESS_LZMA
sed -i -e "s#@lzma@#bcond_without#g" $@-t
else
sed -i -e "s#@lzma@#bcond_with#g" $@-t
endif
if BUILDCOMPBZIP2
if BUILD_COMPRESS_BZIP2
sed -i -e "s#@bzip2@#bcond_without#g" $@-t
else
sed -i -e "s#@bzip2@#bcond_with#g" $@-t
Expand Down
57 changes: 14 additions & 43 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -86,45 +86,10 @@ AC_ARG_ENABLE([crypto-all],
[ --disable-crypto-all : disable libknet all crypto modules support ],,
[ enable_crypto_all="yes" ])

AC_ARG_ENABLE([crypto-nss],
[ --disable-crypto-nss : disable libknet nss support ],,
[ enable_crypto_nss="$enable_crypto_all" ])
AM_CONDITIONAL([BUILDCRYPTONSS], [test x$enable_crypto_nss = xyes])

AC_ARG_ENABLE([crypto-openssl],
[ --disable-crypto-openssl : disable libknet openssl support ],,
[ enable_crypto_openssl="$enable_crypto_all" ])
AM_CONDITIONAL([BUILDCRYPTOOPENSSL], [test x$enable_crypto_openssl = xyes])

AC_ARG_ENABLE([compress-all],
[ --disable-compress-all : disable libknet all compress modules support ],,
[ enable_compress_all="yes" ])

AC_ARG_ENABLE([compress-zlib],
[ --disable-compress-zlib : disable libknet zlib support ],,
[ enable_compress_zlib="$enable_compress_all" ])
AM_CONDITIONAL([BUILDCOMPZLIB], [test x$enable_compress_zlib = xyes])

AC_ARG_ENABLE([compress-lz4],
[ --disable-compress-lz4 : disable libknet lz4 support ],,
[ enable_compress_lz4="$enable_compress_all" ])
AM_CONDITIONAL([BUILDCOMPLZ4], [test x$enable_compress_lz4 = xyes])

AC_ARG_ENABLE([compress-lzo2],
[ --disable-compress-lzo2 : disable libknet lzo2 support ],,
[ enable_compress_lzo2="$enable_compress_all" ])
AM_CONDITIONAL([BUILDCOMPLZO2], [test x$enable_compress_lzo2 = xyes])

AC_ARG_ENABLE([compress-lzma],
[ --disable-compress-lzma : disable libknet lzma support ],,
[ enable_compress_lzma="$enable_compress_all" ])
AM_CONDITIONAL([BUILDCOMPLZMA], [test x$enable_compress_lzma = xyes])

AC_ARG_ENABLE([compress-bzip2],
[ --disable-compress-bzip2 : disable libknet bzip2 support ],,
[ enable_compress_bzip2="$enable_compress_all" ])
AM_CONDITIONAL([BUILDCOMPBZIP2], [test x$enable_compress_bzip2 = xyes])

AC_ARG_ENABLE([poc],
[ --enable-poc : enable building poc code ],,
[ enable_poc="no" ])
Expand Down Expand Up @@ -201,34 +166,40 @@ case "$host_os" in
;;
esac

AC_DEFUN([KNET_COMP_DEFINES],[
# KNET_OPTION_DEFINES(stem,type,detect)
# type is compress or crypto
# -----------------------------------
AC_DEFUN([KNET_OPTION_DEFINES],[
AC_ARG_ENABLE([$2-$1],[AS_HELP_STRING([--disable-$2-$1],[disable libknet $1 support])],,
[enable_$2_$1="$enable_$2_all"])
AM_CONDITIONAL([BUILD_]m4_toupper([$2_$1]),[test "x$enable_$2_$1" = xyes])
if test "x$enable_$2_$1" = xyes; then
$3
fi
AC_DEFINE_UNQUOTED([WITH_]m4_toupper([$2_$1]), [`test "x$enable_$2_$1" != xyes; echo $?`], $1 $2 [built in])
])

# crypto libraries checks
KNET_COMP_DEFINES([nss],[crypto],[PKG_CHECK_MODULES([nss], [nss])])
KNET_COMP_DEFINES([openssl],[crypto],[
KNET_OPTION_DEFINES([nss],[crypto],[PKG_CHECK_MODULES([nss], [nss])])
KNET_OPTION_DEFINES([openssl],[crypto],[
PKG_CHECK_MODULES([openssl],[libcrypto < 1.1],
[AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL10], [1], [openssl 1.0 crypto])],
[PKG_CHECK_MODULES([openssl],[libcrypto >= 1.1],
[AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL11], [1], [openssl 1.1 crypto])])])
])

# compress libraries checks
KNET_COMP_DEFINES([zlib],[compress],[PKG_CHECK_MODULES([zlib], [zlib])])
KNET_COMP_DEFINES([lz4],[compress],[PKG_CHECK_MODULES([liblz4], [liblz4])])
KNET_COMP_DEFINES([lzo2],[compress],[
KNET_OPTION_DEFINES([zlib],[compress],[PKG_CHECK_MODULES([zlib], [zlib])])
KNET_OPTION_DEFINES([lz4],[compress],[PKG_CHECK_MODULES([liblz4], [liblz4])])
KNET_OPTION_DEFINES([lzo2],[compress],[
PKG_CHECK_MODULES([lzo2], [lzo2],,
[AC_CHECK_HEADERS([lzo/lzo1x.h],
[AC_CHECK_LIB([lzo2], [lzo1x_decompress_safe],
[AC_SUBST([lzo2_LIBS], [-llzo2])])],
[AC_MSG_ERROR(["missing required lzo/lzo1x.h header"])])])
])
KNET_COMP_DEFINES([lzma],[compress],[PKG_CHECK_MODULES([liblzma], [liblzma])])
KNET_COMP_DEFINES([bzip2],[compress],[
KNET_OPTION_DEFINES([lzma],[compress],[PKG_CHECK_MODULES([liblzma], [liblzma])])
KNET_OPTION_DEFINES([bzip2],[compress],[
PKG_CHECK_MODULES([bzip2], [bzip2],,
[AC_CHECK_HEADERS([bzlib.h],
[AC_CHECK_LIB([bz2], [BZ2_bzBuffToBuffCompress],
Expand Down
14 changes: 7 additions & 7 deletions libknet/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ libknet_la_LIBADD = $(PTHREAD_LIBS) $(dl_LIBS) $(rt_LIBS) $(m_LIBS)
# Prepare empty value for appending
pkglib_LTLIBRARIES =

if BUILDCOMPZLIB
if BUILD_COMPRESS_ZLIB
pkglib_LTLIBRARIES += compress_zlib.la
compress_zlib_la_LDFLAGS = -module -avoid-version
compress_zlib_la_CFLAGS = $(zlib_CFLAGS)
compress_zlib_la_LIBADD = $(zlib_LIBS)
endif

if BUILDCOMPLZ4
if BUILD_COMPRESS_LZ4
pkglib_LTLIBRARIES += compress_lz4.la compress_lz4hc.la
compress_lz4_la_LDFLAGS = -module -avoid-version
compress_lz4_la_CFLAGS = $(liblz4_CFLAGS)
Expand All @@ -110,35 +110,35 @@ compress_lz4hc_la_CFLAGS = $(liblz4_CFLAGS)
compress_lz4hc_la_LIBADD = $(liblz4_LIBS)
endif

if BUILDCOMPLZO2
if BUILD_COMPRESS_LZO2
pkglib_LTLIBRARIES += compress_lzo2.la
compress_lzo2_la_LDFLAGS = -module -avoid-version
compress_lzo2_la_CFLAGS = $(lzo2_CFLAGS)
compress_lzo2_la_LIBADD = $(lzo2_LIBS)
endif

if BUILDCOMPLZMA
if BUILD_COMPRESS_LZMA
pkglib_LTLIBRARIES += compress_lzma.la
compress_lzma_la_LDFLAGS = -module -avoid-version
compress_lzma_la_CFLAGS = $(liblzma_CFLAGS)
compress_lzma_la_LIBADD = $(liblzma_LIBS)
endif

if BUILDCOMPBZIP2
if BUILD_COMPRESS_BZIP2
pkglib_LTLIBRARIES += compress_bzip2.la
compress_bzip2_la_LDFLAGS = -module -avoid-version
compress_bzip2_la_CFLAGS = $(bzip2_CFLAGS)
compress_bzip2_la_LIBADD = $(bzip2_LIBS)
endif

if BUILDCRYPTONSS
if BUILD_CRYPTO_NSS
pkglib_LTLIBRARIES += crypto_nss.la
crypto_nss_la_LDFLAGS = -module -avoid-version
crypto_nss_la_CFLAGS = $(nss_CFLAGS)
crypto_nss_la_LIBADD = $(nss_LIBS)
endif

if BUILDCRYPTOOPENSSL
if BUILD_CRYPTO_OPENSSL
pkglib_LTLIBRARIES += crypto_openssl.la
crypto_openssl_la_LDFLAGS = -module -avoid-version
crypto_openssl_la_CFLAGS = $(openssl_CFLAGS)
Expand Down

0 comments on commit c793738

Please sign in to comment.