tools build: Add feature check for lzma library
authorJiri Olsa <jolsa@kernel.org>
Wed, 4 Mar 2015 10:35:47 +0000 (11:35 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 21 Mar 2015 17:53:39 +0000 (14:53 -0300)
Will be used to decompress 'xz' objects. The check detects
the liblzma.so devel library normally delivered by xz package.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
tools/build/Makefile.feature
tools/build/feature/Makefile
tools/build/feature/test-all.c
tools/build/feature/test-lzma.c [new file with mode: 0644]

index c6f44894d4a14987a26655c7d1c1f004256be4a6..3a0b0ca2a28c1b0bcc6a568d6c7d3ee6ced8c627 100644 (file)
@@ -50,7 +50,8 @@ FEATURE_TESTS =                       \
        stackprotector-all              \
        timerfd                         \
        libdw-dwarf-unwind              \
-       zlib
+       zlib                            \
+       lzma
 
 FEATURE_DISPLAY =                      \
        dwarf                           \
@@ -65,7 +66,8 @@ FEATURE_DISPLAY =                     \
        libslang                        \
        libunwind                       \
        libdw-dwarf-unwind              \
-       zlib
+       zlib                            \
+       lzma
 
 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
 # If in the future we need per-feature checks/flags for features not
index 0d694a94cda2613d25268927956bed7b1d010484..463ed8f2a267bd6ad58f0a96656ea342574d3865 100644 (file)
@@ -32,7 +32,8 @@ FILES=                                        \
        test-libbabeltrace.bin          \
        test-compile-32.bin             \
        test-compile-x32.bin            \
-       test-zlib.bin
+       test-zlib.bin                   \
+       test-lzma.bin
 
 CC := $(CROSS_COMPILE)gcc -MD
 PKG_CONFIG := $(CROSS_COMPILE)pkg-config
@@ -45,7 +46,7 @@ __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@)
 ###############################
 
 test-all.bin:
-       $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz
+       $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma
 
 test-hello.bin:
        $(BUILD)
@@ -152,6 +153,9 @@ test-compile-x32.bin:
 test-zlib.bin:
        $(BUILD) -lz
 
+test-lzma.bin:
+       $(BUILD) -llzma
+
 -include *.d
 
 ###############################
index a61c20456705bfd6e0109d089e1d6a72d8280b9b..84689a67814a9a622bd3f12b69fe5a8f5733a499 100644 (file)
 #undef main
 #endif
 
+#define main main_test_lzma
+# include "test-lzma.c"
+#undef main
+
 int main(int argc, char *argv[])
 {
        main_test_libpython();
@@ -138,6 +142,7 @@ int main(int argc, char *argv[])
        main_test_sync_compare_and_swap(argc, argv);
        main_test_zlib();
        main_test_pthread_attr_setaffinity_np();
+       main_test_lzma();
 
        return 0;
 }
diff --git a/tools/build/feature/test-lzma.c b/tools/build/feature/test-lzma.c
new file mode 100644 (file)
index 0000000..95adc8c
--- /dev/null
@@ -0,0 +1,10 @@
+#include <lzma.h>
+
+int main(void)
+{
+       lzma_stream strm = LZMA_STREAM_INIT;
+       int ret;
+
+       ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
+       return ret ? -1 : 0;
+}