summaryrefslogtreecommitdiff
path: root/autoconfig.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2014-11-28 17:38:56 +0000
committerMike Buland <eichlan@xagasoft.com>2014-11-28 17:38:56 +0000
commit8bbf908ab1afd341e361dd5ad0c37f3c1b9a6635 (patch)
tree6dadb4930707e541a4ed86ac5ddb4d8af9f48dfc /autoconfig.cpp
parent2698c84576447535f397fafcb9f5f06290c3596a (diff)
downloadlibbu++-8bbf908ab1afd341e361dd5ad0c37f3c1b9a6635.tar.gz
libbu++-8bbf908ab1afd341e361dd5ad0c37f3c1b9a6635.tar.bz2
libbu++-8bbf908ab1afd341e361dd5ad0c37f3c1b9a6635.tar.xz
libbu++-8bbf908ab1afd341e361dd5ad0c37f3c1b9a6635.zip
Autoconfig now detects libraries that libbu++ can use and generates the
appropriate headers. bin2cpp now uses those headers to compile correctly despite having missing filters.
Diffstat (limited to 'autoconfig.cpp')
-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 }