aboutsummaryrefslogtreecommitdiff
path: root/autoconfig.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--autoconfig.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/autoconfig.cpp b/autoconfig.cpp
index 28362ec..9d09412 100644
--- a/autoconfig.cpp
+++ b/autoconfig.cpp
@@ -13,6 +13,35 @@ bool testCpp( const char *prog )
13 return pclose(pop) == 0; 13 return pclose(pop) == 0;
14} 14}
15 15
16bool testLib( const char *lib, const char *symname, const char *humname )
17{
18 printf("Detecting library %s (-l%s)...", humname, lib );
19 fflush( stdout );
20 static const char *prog = "int main () { return 0; }";
21 char *cmdline = (char *)malloc( 29+strlen(lib) );
22 strcpy( cmdline, "g++ -x c++ -l");
23 strcat( cmdline, lib );
24 strcat( cmdline, " - -o /dev/null");
25
26 FILE *pop = popen( cmdline, "w");
27 fwrite( prog, 1, strlen( prog ), pop );
28 free( cmdline );
29 if( pclose(pop) == 0 )
30 {
31 printf("found.\n");
32 fprintf( fOut, "#define BU_FEATURE_%s 1\n", symname );
33 fprintf( fOut, "#define BU_HAS_%s\n", symname );
34 return false;
35 }
36 else
37 {
38 printf("missing.\n");
39 fprintf( fOut, "#define BU_FEATURE_%s 0\n", symname );
40 fprintf( fOut, "#define BU_MISSING_%s\n", symname );
41 return true;
42 }
43}
44
16void detectEndianness() 45void detectEndianness()
17{ 46{
18 printf("Detecting endian support..."); 47 printf("Detecting endian support...");
@@ -59,6 +88,9 @@ int main( int argc, char *argv[] )
59 ); 88 );
60 89
61 detectEndianness(); 90 detectEndianness();
91 testLib("z", "DEFLATE", "Deflate");
92 testLib("bz2", "BZIP2", "BZip2");
93 testLib("lzma", "LZMA", "Lzma");
62 94
63 fprintf( fOut, "#endif\n"); 95 fprintf( fOut, "#endif\n");
64 } 96 }