Fix the snappy library check (#6479)
* Fix the snappy library check * Fix code style * Maintain compatibility with PKG_CHECK_MODULES
Vladimir Kobal committed
Jul 18, 2019 at 11:20 UTC
6daa4b72d516dd2a71f3bf1b3bb19dc7406a5e55
1 file changed
+46
-18
configure.ac
+46
-18
@@ -816,17 +816,17 @@ if test "${have_libaws_cpp_sdk_core}" = "yes" -a "${have_libcrypto}" = "yes" -a
816
CXXFLAGS="${CXXFLAGS} -std=c++11"
817
818
AC_TRY_LINK(
819
- [
820
- #include <aws/core/Aws.h>
821
- #include <aws/core/client/ClientConfiguration.h>
822
- #include <aws/core/auth/AWSCredentials.h>
823
- #include <aws/core/utils/Outcome.h>
824
- #include <aws/kinesis/KinesisClient.h>
825
- #include <aws/kinesis/model/PutRecordRequest.h>
826
- ],
827
- [Aws::Kinesis::Model::PutRecordRequest request;],
828
- [have_libaws_cpp_sdk_kinesis=yes],
829
- [have_libaws_cpp_sdk_kinesis=no]
819
+ [
820
+ #include <aws/core/Aws.h>
821
+ #include <aws/core/client/ClientConfiguration.h>
822
+ #include <aws/core/auth/AWSCredentials.h>
823
+ #include <aws/core/utils/Outcome.h>
824
+ #include <aws/kinesis/KinesisClient.h>
825
+ #include <aws/kinesis/model/PutRecordRequest.h>
826
+ ],
827
+ [Aws::Kinesis::Model::PutRecordRequest request;],
828
+ [have_libaws_cpp_sdk_kinesis=yes],
829
+ [have_libaws_cpp_sdk_kinesis=no]
830
)
831
832
LIBS="${save_LIBS}"
@@ -879,12 +879,40 @@ PKG_CHECK_MODULES(
879
[have_libprotobuf=no]
880
)
881
882
-PKG_CHECK_MODULES(
883
- [SNAPPY],
884
- [snappy],
885
- [have_libsnappy=yes],
886
- [have_libsnappy=no]
887
-)
882
+AC_MSG_CHECKING([for snappy::RawCompress in -lsnappy])
883
+
884
+ AC_LANG_SAVE
885
+ AC_LANG_CPLUSPLUS
886
+ save_LIBS="${LIBS}"
887
+ LIBS="-lsnappy"
888
+ save_CXXFLAGS="${CXXFLAGS}"
889
+ CXXFLAGS="${CXXFLAGS} -std=c++11"
890
+
891
+ AC_TRY_LINK(
892
+ [
893
+ #include <stdlib.h>
894
+ #include <snappy.h>
895
+ ],
896
+ [
897
+ const char *input = "test";
898
+ size_t compressed_length;
899
+ char *buffer = (char *)malloc(5 * sizeof(char));
900
+ snappy::RawCompress(input, 4, buffer, &compressed_length);
901
+ free(buffer);
902
+ ],
903
+ [
904
+ have_libsnappy=yes
905
+ SNAPPY_CFLAGS=""
906
+ SNAPPY_LIBS="-lsnappy"
907
+ ],
908
+ [have_libsnappy=no]
909
+ )
910
+
911
+ LIBS="${save_LIBS}"
912
+ CXXFLAGS="${save_CXXFLAGS}"
913
+ AC_LANG_RESTORE
914
+
915
+AC_MSG_RESULT([${have_libsnappy}])
916
917
AC_PATH_PROG([PROTOC], [protoc], [no])
918
AS_IF(
@@ -919,7 +947,7 @@ if test "${enable_backend_prometeus_remote_write}" != "no" -a "${have_libprotobu
947
AC_DEFINE([ENABLE_PROMETHEUS_REMOTE_WRITE], [1], [Prometheus remote write API usability])
948
OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS="${PROTOBUF_CFLAGS} ${SNAPPY_CFLAGS}"
949
CXX11FLAG="-std=c++11"
922
- OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS="${PROTOBUF_LIBS} ${SNAPPY_LIBS} "
950
+ OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS="${PROTOBUF_LIBS} ${SNAPPY_LIBS}"
951
else
952
enable_backend_prometheus_remote_write="no"
953
fi