whitedb-0.7.3/0000755000175000001440000000000012426224010010135 500000000000000whitedb-0.7.3/unite.sh0000755000175000001440000000177512421471034011557 00000000000000#!/bin/sh amal() { sed 's/#include\ "../\/\//' $1 } [ -f config.h ] || cp config-gcc.h config.h if [ config-gcc.h -nt config.h ]; then echo "Warning: config.h is older than config-gcc.h, consider updating it" fi cat << EOT > whitedb.h #include $(amal config.h) $(amal json/yajl_api.h) $(amal json/yajl_all.h) $(amal Db/dballoc.h) $(amal Db/dbmem.h) $(amal Db/dbfeatures.h) $(amal Db/dbdata.h) $(amal Db/dblog.h) $(amal Db/dbdump.h) $(amal Db/dbhash.h) $(amal Db/dbindex.h) $(amal Db/dbcompare.h) $(amal Db/dbquery.h) $(amal Db/dbutil.h) $(amal Db/dbmpool.h) $(amal Db/dbjson.h) $(amal Db/dblock.h) $(amal Db/dbschema.h) EOT cat << EOT > whitedb.c #include $(amal Db/crc1.h) $(amal json/yajl_all.c) $(amal Db/dbmem.c) $(amal Db/dballoc.c) $(amal Db/dbdata.c) $(amal Db/dblog.c) $(amal Db/dbdump.c) $(amal Db/dbhash.c) $(amal Db/dbindex.c) $(amal Db/dbcompare.c) $(amal Db/dbquery.c) $(amal Db/dbutil.c) $(amal Db/dbmpool.c) $(amal Db/dbjson.c) $(amal Db/dbschema.c) $(amal Db/dblock.c) EOT whitedb-0.7.3/Examples/0000755000175000001440000000000012426224011011714 500000000000000whitedb-0.7.3/Examples/compile_query.bat0000755000175000001440000000041212421471034015205 00000000000000cl /Ox /W3 /I..\Db query.c ..\Db\dbmem.c ..\Db\dballoc.c ..\Db\dbdata.c ..\Db\dblock.c ..\DB\dbindex.c ..\Db\dblog.c ..\Db\dbhash.c ..\Db\dbcompare.c ..\Db\dbquery.c ..\Db\dbutil.c ..\Test\dbtest.c ..\Db\dbmpool.c ..\Db\dbjson.c ..\Db\dbschema.c ..\json\yajl_all.c whitedb-0.7.3/Examples/compile_demo.sh0000755000175000001440000000104312426116005014630 00000000000000#!/bin/sh [ -z "$CC" ] && CC="cc" if [ -z "$(which $CC 2>/dev/null)" ]; then echo "Error: No compiler found" exit 1 fi # run unite.sh if needed if [ ! -f ../whitedb.c ]; then cd ..; ./unite.sh; cd "$OLDPWD" fi # use output of unite.sh $CC -O2 -I.. -o demo demo.c ../whitedb.c -lm #$CC -O2 -o demo demo.c ../Db/dbmem.c ../Db/dballoc.c ../Db/dbdata.c ../Db/dblock.c ../Db/dbindex.c ../Db/dblog.c ../Db/dbhash.c ../Db/dbcompare.c ../Db/dbquery.c ../Db/dbutil.c ../Db/dbmpool.c ../Db/dbjson.c ../Db/dbschema.c ../json/yajl_all.c -lm whitedb-0.7.3/Examples/compile_demo.bat0000755000175000001440000000037012237372400014771 00000000000000cl /Ox /W3 /I..\Db demo.c ..\Db\dbmem.c ..\Db\dballoc.c ..\Db\dbdata.c ..\Db\dblock.c ..\DB\dbindex.c ..\Db\dblog.c ..\Db\dbhash.c ..\Db\dbcompare.c ..\Db\dbquery.c ..\Db\dbutil.c ..\Db\dbmpool.c ..\Db\dbjson.c ..\Db\dbschema.c ..\json\yajl_all.c whitedb-0.7.3/Examples/tut4.c0000644000175000001440000000254412257033123012711 00000000000000#include #include int main(int argc, char **argv) { void *db, *rec; wg_int enc; wg_query_arg arglist[2]; /* holds the arguments to the query */ wg_query *query; /* used to fetch the query results */ db = wg_attach_database("1000", 2000000); /* just in case, create some records for testing */ rec = wg_create_record(db, 10); enc = wg_encode_int(db, 443); /* will match */ wg_set_field(db, rec, 7, enc); rec = wg_create_record(db, 10); enc = wg_encode_int(db, 442); wg_set_field(db, rec, 7, enc); /* will not match */ /* now find the records that match the condition * "field 7 equals 443 and field 6 equals NULL". The * second part is a bit redundant but we're adding it * to show the use of the argument list. */ arglist[0].column = 7; arglist[0].cond = WG_COND_EQUAL; arglist[0].value = wg_encode_query_param_int(db, 443); arglist[1].column = 6; arglist[1].cond = WG_COND_EQUAL; arglist[1].value = wg_encode_query_param_null(db, NULL); query = wg_make_query(db, NULL, 0, arglist, 2); while((rec = wg_fetch(db, query))) { printf("Found a record where field 7 is 443 and field 6 is NULL\n"); } /* Free the memory allocated for the query */ wg_free_query(db, query); wg_free_query_param(db, arglist[0].value); wg_free_query_param(db, arglist[1].value); return 0; } whitedb-0.7.3/Examples/query.c0000644000175000001440000002361612257043255013170 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010,2011,2013 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file query.c * Demonstration of various queries to WhiteDB database. * This program also uses locking to show how to handle queries * in a parallel environment. */ /* ====== Includes =============== */ #include #include #include #include "../Db/dbapi.h" #include "../Db/indexapi.h" /* Extra protos for demo data (not in dbapi.h) */ int wg_genintdata_mix(void *db, int databasesize, int recordsize); /* ====== Private defs =========== */ /* ======= Private protos ================ */ void run_querydemo(void *db); void fetchall(void *db, wg_query *q); /* ====== Functions ============== */ /** Init database, run demo, drop database * Command line arguments are ignored. */ int main(int argc, char **argv) { char* shmptr; /* Create a database with custom key and size */ shmptr=wg_attach_database("9722", 2000000); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Database was created, run demo and clean up. */ run_querydemo(shmptr); wg_delete_database("9722"); exit(0); } /** Run demo queries. * */ void run_querydemo(void* db) { void *rec = NULL, *firstrec = NULL; wg_int lock_id; wg_query_arg arglist[5]; /* holds query parameters */ wg_query *query; /* query object */ wg_int matchrec[10]; /* match record query parameter */ int i; printf("********* Starting query demo ************\n"); /* Create indexes on the database */ if(wg_create_index(db, 0, WG_INDEX_TYPE_TTREE, NULL, 0)) { fprintf(stderr, "index creation failed, aborting.\n"); return; } if(wg_create_index(db, 2, WG_INDEX_TYPE_TTREE, NULL, 0)) { fprintf(stderr, "index creation failed, aborting.\n"); return; } if(wg_create_index(db, 3, WG_INDEX_TYPE_TTREE, NULL, 0)) { fprintf(stderr, "index creation failed, aborting.\n"); return; } /* Take a write lock until we're done writing to the database. */ lock_id = wg_start_write(db); if(!lock_id) { fprintf(stderr, "failed to get write lock, aborting.\n"); return; /* lock timed out */ } /* Generate test data */ wg_genintdata_mix(db, 20, 4); /* Add some non-unique values */ firstrec = rec = wg_get_first_record(db); i = 0; while(rec) { wg_set_field(db, rec, 0, wg_encode_int(db, i++ % 3)); if(i<=6) wg_set_field(db, rec, 3, wg_encode_int(db, 6)); rec = wg_get_next_record(db, rec); } printf("Database test data contents\n"); wg_print_db(db); /* Release the write lock. We could have released it before wg_print_db() * and acquired a separate read lock instead. That would have been correct, * but unnecessary for this demo. */ wg_end_write(db, lock_id); /* Encode query arguments. We will use the wg_encode_query_param*() * family of functions which do not write to the shared memory * area, therefore locking is not required at this point. * * Basic query 1: column 2 less than 30 */ arglist[0].column = 2; arglist[0].cond = WG_COND_LESSTHAN; arglist[0].value = wg_encode_query_param_int(db, 30); /* Take read lock. No alterations should be allowed * during the building of the query. */ lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } query = wg_make_query(db, NULL, 0, arglist, 1); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } /* We keep the lock before using the results for best possible * isolation. In some cases this is not necessary. */ printf("Printing results for query 1: column 2 less than 30\n"); fetchall(db, query); /* Release the read lock */ wg_end_read(db, lock_id); wg_free_query(db, query); /* free the memory */ /* Basic query 2: col 2 > 21 and col 2 <= 111 */ arglist[0].column = 2; arglist[0].cond = WG_COND_GREATER; arglist[0].value = wg_encode_query_param_int(db, 21); arglist[1].column = 2; arglist[1].cond = WG_COND_LTEQUAL; arglist[1].value = wg_encode_query_param_int(db, 111); lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } query = wg_make_query(db, NULL, 0, arglist, 2); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Printing results for query 2: col 2 > 21 and col 2 <= 111\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); /* Basic query 3: match all records [ 0, ...]. Fields that * are beyond the size of matchrec implicitly become wildcards. */ matchrec[0] = wg_encode_query_param_int(db, 0); lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } query = wg_make_query(db, matchrec, 1, NULL, 0); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Printing results for query 3: all records that match [ 0, ... ]\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); /* Combine the parameters of queries 2 and 3 (it is allowed to * mix both types of arguments). */ lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } query = wg_make_query(db, matchrec, 1, arglist, 2); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Printing results for combined queries 2 and 3\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); /* Add an extra condition */ arglist[2].column = 3; arglist[2].cond = WG_COND_EQUAL; arglist[2].value = wg_encode_query_param_int(db, 112); lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } query = wg_make_query(db, matchrec, 1, arglist, 3); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Adding extra condtion to previous queries: col 3 = 112\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); /* Non-indexed columns may be used too. This will produce * a "full scan" query with non-ordered results. */ arglist[0].column = 1; arglist[0].cond = WG_COND_GREATER; arglist[0].value = wg_encode_query_param_int(db, 20); arglist[1].column = 1; arglist[1].cond = WG_COND_LTEQUAL; arglist[1].value = wg_encode_query_param_int(db, 110); lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } query = wg_make_query(db, NULL, 0, arglist, 2); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Printing results for non-indexed column: col 1 > 20 and col 1 <= 110\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); /* More complete match record. Use variable field type * for wildcards. The identifier used for the variable is not * important currently. */ matchrec[0] = wg_encode_query_param_int(db, 1); matchrec[1] = wg_encode_query_param_var(db, 0); matchrec[2] = wg_encode_query_param_var(db, 0); matchrec[3] = wg_encode_query_param_int(db, 6); lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } query = wg_make_query(db, matchrec, 4, NULL, 0); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Printing results for match query: records like [ 1, *, *, 6 ]\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } /* Arguments may be omitted. This causes the query to return * all the rows in the database. */ query = wg_make_query(db, NULL, 0, NULL, 0); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Printing results for a query with no arguments\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); lock_id = wg_start_read(db); if(!lock_id) { fprintf(stderr, "failed to get read lock, aborting.\n"); return; /* lock timed out */ } /* Finally, try matching to a database record. Depending on the * test data, this sould return at least one record. Note that * reclen 0 indicates that the record should be taken from database. */ query = wg_make_query(db, firstrec, 0, NULL, 0); if(!query) { fprintf(stderr, "failed to build query, aborting.\n"); return; } printf("Printing records matching the first record in database\n"); fetchall(db, query); wg_end_read(db, lock_id); wg_free_query(db, query); printf("********* Demo ended ************\n"); } /** Fetch the results of a single query * */ void fetchall(void *db, wg_query *q) { void *rec = wg_fetch(db, q); while(rec) { wg_print_record(db, rec); printf("\n"); rec = wg_fetch(db, q); } printf("---- end of data ----\n"); } whitedb-0.7.3/Examples/tut3.c0000644000175000001440000000133312257033123012703 00000000000000#include #include int main(int argc, char **argv) { void *db, *rec; wg_int enc; db = wg_attach_database("1000", 2000000); /* create some records for testing */ rec = wg_create_record(db, 10); enc = wg_encode_int(db, 443); /* will match */ wg_set_field(db, rec, 7, enc); rec = wg_create_record(db, 10); enc = wg_encode_int(db, 442); wg_set_field(db, rec, 7, enc); /* will not match */ /* now find the records that match our condition * "field 7 equals 443" */ rec = wg_find_record_int(db, 7, WG_COND_EQUAL, 443, NULL); while(rec) { printf("Found a record where field 7 is 443\n"); rec = wg_find_record_int(db, 7, WG_COND_EQUAL, 443, rec); } return 0; } whitedb-0.7.3/Examples/tut5.c0000644000175000001440000000256012257033123012710 00000000000000#include #include #include int main(int argc, char **argv) { void *db, *rec, *lastrec; wg_int enc; int i; db = wg_attach_database("1000", 1000000); /* 1MB should fill up fast */ if(!db) { printf("ERR: Could not attach to database.\n"); exit(1); } lastrec = NULL; for(i=0;;i++) { char buf[20]; rec = wg_create_record(db, 1); if(!rec) { printf("ERR: Failed to create a record (made %d so far)\n", i); break; } lastrec = rec; sprintf(buf, "%d", i); /* better to use snprintf() in real applications */ enc = wg_encode_str(db, buf, NULL); if(enc == WG_ILLEGAL) { printf("ERR: Failed to encode a string (%d records currently)\n", i+1); break; } if(wg_set_field(db, rec, 0, enc)) { printf("ERR: This error is less likely, but wg_set_field() failed.\n"); break; } } /* For educational purposes, let's pretend we're interested in what's * stored in the last record. */ if(lastrec) { char *str = wg_decode_str(db, wg_get_field(db, lastrec, 0)); if(!str) { printf("ERR: Decoding the string field failed.\n"); if(wg_get_field_type(db, lastrec, 0) != WG_STRTYPE) { printf("ERR: The field type is not string - " "should have checked that first!\n"); } } } wg_detach_database(db); return 0; } whitedb-0.7.3/Examples/speed/0000755000175000001440000000000012426224010013013 500000000000000whitedb-0.7.3/Examples/speed/speed4.c0000644000175000001440000000120712232205232014263 00000000000000/* creating and immediately deleting 10 million records of 5 fields in a 1 GIG database real 0m1.160s user 0m1.149s sys 0m0.009s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="4"; int i; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<10000000;i++) { rec = wg_create_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } wg_delete_record(db, rec); } printf("i %d\n", i); wg_detach_database(db); wg_delete_database(name); return 0; } whitedb-0.7.3/Examples/speed/speed5.c0000644000175000001440000000175612232205232014275 00000000000000/* creating and immediately filling with data 10 million records of 5 fields in a 1 GIG database real 0m1.163s user 0m1.042s sys 0m0.120s adding code to read back the value and add it to a counter: real 0m1.768s user 0m1.643s sys 0m0.124s doing record filling with 1000 records of length 50 thousand: real 0m0.941s user 0m0.863s sys 0m0.077s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="51"; int i,j,count=0; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<10000000;i++) { rec = wg_create_raw_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } for (j=0;j<5;j++) { wg_set_new_field(db,rec,j,wg_encode_int(db,i+j)); //count+=wg_decode_int(db,wg_get_field(db, rec, j)); } } printf("i %d count %d\n", i,count); wg_detach_database(db); wg_delete_database(name); return 0; } whitedb-0.7.3/Examples/speed/README0000644000175000001440000000011012232205232013603 00000000000000Simple single-core speed tests covered in http://whitedb.org/speed.html whitedb-0.7.3/Examples/speed/speed3.c0000644000175000001440000000112312232205232014257 00000000000000/* creating 10 million raw records of 5 fields in a 1 GB database real 0m0.349s user 0m0.217s sys 0m0.131s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="3"; int i; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<10000000;i++) { rec = wg_create_raw_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } } printf("i %d\n", i); wg_detach_database(db); wg_delete_database(name); return 0; } whitedb-0.7.3/Examples/speed/speed8.c0000644000175000001440000000142112232205232014265 00000000000000/* creating and immediately filling with double data 1 million records of 5 fields in a 1 GIG database. The double value is encoded each time. real 0m0.190s user 0m0.144s sys 0m0.045s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="9"; int i,j; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<1000000;i++) { rec = wg_create_raw_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } for (j=0;j<5;j++) { wg_set_new_field(db,rec,j,wg_encode_double(db,(double)(i+j))); } } printf("i %d \n", i); wg_detach_database(db); wg_delete_database(name); return 0; } whitedb-0.7.3/Examples/speed/speed7.c0000644000175000001440000000162312232205232014270 00000000000000/* creating and immediately filling with string data 1 million records of 5 fields in a 1 GIG database: the string is 100 bytes long and is encoded each time. real 0m1.464s user 0m1.446s sys 0m0.017s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="7"; int i,j; char* content="0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<1000000;i++) { rec = wg_create_raw_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } for (j=0;j<5;j++) { wg_set_new_field(db,rec,j,wg_encode_str(db,content,NULL)); } } printf("i %d \n", i); wg_detach_database(db); wg_delete_database(name); return 0; } whitedb-0.7.3/Examples/speed/speed11.c0000644000175000001440000000203312232205232014337 00000000000000/* Scan through 10 million records in a pre-built database, counting all these records which have integer 123 as the value of the third field. Database was created earlier by speed10. Do not forget to delete database later, a la: wgdb 10 free real 0m0.201s user 0m0.157s sys 0m0.044s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="10"; int i=0; int count=0; wg_int encval; db = wg_attach_database(name, 1000000000); if (!db) { printf("db attaching failed \n"); exit(0); } encval=wg_encode_int(db,123); // encode for faster comparison in the loop rec=wg_get_first_record(db); do { //if (wg_decode_int(db,wg_get_field(db,rec,3))==123) count++; // a bit slower alternative if (wg_get_field(db,rec,3)==encval) count++; rec=wg_get_next_record(db,rec); i++; } while(rec!=NULL); wg_free_encoded(db,encval); // have to free encval since we did not store it to db printf("i %d, count %d\n", i,count); return 0; } whitedb-0.7.3/Examples/speed/speed15.c0000644000175000001440000000254212232205232014350 00000000000000/* creating a flat pointer list of 10 million records of 5 fields in a 1 GB database: store a pointer to the previous record to field 3 of each record, store a pointer to the last record to field 2 of first record. Observe that we use standard C int 0 for the NULL pointer, this is also what wg_encode_null(db,0) always gives. real 0m0.666s user 0m0.516s sys 0m0.150s */ #include #include #include int main(int argc, char **argv) { void *db, *rec, *firstrec, *lastrec; char *name="15"; int i; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } rec = wg_create_raw_record(db, 5); firstrec=rec; // store for use in the end lastrec=rec; for(i=1;i<10000000;i++) { rec = wg_create_raw_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } // store a pointer to the previously built record wg_set_new_field(db,rec,3,wg_encode_record(db,lastrec)); lastrec=rec; } // field 3 of the first record will be an encoded NULL pointer // which is always just (wg_int)0 wg_set_new_field(db,firstrec,3,wg_encode_null(db,0)); // field 2 of the first record will be a pointer to the last record wg_set_new_field(db,firstrec,2,wg_encode_record(db,lastrec)); printf("i %d\n", i); wg_detach_database(db); return 0; } whitedb-0.7.3/Examples/speed/speed6.c0000644000175000001440000000151312232205232014265 00000000000000/* creating and immediately filling with string data 1 million records of 5 fields in a 1 GIG database: the string is 30 bytes long and is encoded each time using up 32 bytes real 0m0.403s user 0m0.283s sys 0m0.119s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="69"; int i,j; char* content="01234567890"; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<1000000;i++) { rec = wg_create_raw_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } for (j=0;j<5;j++) { wg_set_new_field(db,rec,j,wg_encode_str(db,content,NULL)); } } printf("i %d \n", i); wg_detach_database(db); wg_delete_database(name); return 0; } whitedb-0.7.3/Examples/speed/speed13.c0000644000175000001440000000266412232205232014353 00000000000000/* Outer loop: run the inner loop million times to obtain sensible timings. Inner loop: prepare query and search from the index on 10 million records, counting all these which have integer 123 as the value of the third field, using query on the indexed field. There are 100 of such values. Database was created earlier by speed11 and indexed by speed 12. Do not forget to delete database later, a la: wgdb 10 free Outer loop time (i.e. 1 million identical query building / performing / deallocating operations) altogether: real 0m3.256s user 0m3.252s sys 0m0.001s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="10"; int i; int count=0; wg_query *query; wg_query_arg arglist[5]; db = wg_attach_database(name, 1000000000); if (!db) { printf("db attaching failed \n"); exit(0); } // outer loop is just for sensible timing: do the same thing 1000 times for(i=0;i<1000000;i++) { arglist[0].column = 3; arglist[0].cond = WG_COND_EQUAL; arglist[0].value = wg_encode_query_param_int(db,123); query = wg_make_query(db, NULL, 0, arglist, 1); if(!query) { printf("query creation failed \n"); exit(0); } while((rec = wg_fetch(db, query))) { count++; //wg_print_record(db, rec); printf("\n"); } wg_free_query(db,query); } printf("count altogether for i %d runs: %d\n", i, count); return 0; } whitedb-0.7.3/Examples/speed/speed1.c0000644000175000001440000000112012232205232014252 00000000000000/* creating and deleting a 1 GB database 1000 times: real 0m9.694s user 0m2.044s sys 0m7.642s creating and deleting a 10 MB database 100000 times: real 0m12.800s user 0m2.622s sys 0m10.137s */ #include #include #include int main(int argc, char **argv) { void *db; char *name="1"; int i; for(i=0;i<1000;i++) { // 100000 db = wg_attach_database(name,1000000000); // 10000000 if (!db) { printf("failed at try %d\n", i); exit(0); } wg_detach_database(db); wg_delete_database(name); } printf("i %d\n", i); return 0; } whitedb-0.7.3/Examples/speed/speed10.c0000644000175000001440000000153712232205232014346 00000000000000/* creating and immediately filling with integer data 10 million records of 5 fields in a 1 GIG database. Field values are computed as the last five digits of the record number, thus storing each number between 0...100000 to 100 different records. Database created will be later used by speed11 for scanning. real 0m0.483s user 0m0.381s sys 0m0.101s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="10"; int i,j; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<10000000;i++) { rec = wg_create_raw_record(db, 5); if (!rec) { printf("record creation failed \n"); exit(0); } wg_set_new_field(db,rec,3,wg_encode_int(db,i%100000)); } printf("i %d\n", i); return 0; } whitedb-0.7.3/Examples/speed/speed16.c0000644000175000001440000000227412232205232014353 00000000000000/* traversing a flat pre-built (in speed15.c) pointer list of 10 million records of 5 fields in a 1 GB database: a pointer to the previous record is stored in field 3 of each record, a pointer to the last record is stored in field 2 of first record. Observe that we use standard C int 0 for the NULL pointer, this is also what wg_encode_null(db,0) always gives. Database was created earlier by speed15. Do not forget to delete database later, a la: wgdb 15 free real 0m0.153s user 0m0.110s sys 0m0.043s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="15"; int i; wg_int encptr; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } rec=wg_get_first_record(db); // get a pointer to the last record rec=wg_decode_record(db,wg_get_field(db,rec,2)); i=1; while(1) { encptr=wg_get_field(db,rec,3); // encptr is not yet decoded if (encptr==(wg_int)0) break; // encoded null is always standard 0 rec=wg_decode_record(db,encptr); // get a pointer to the previous record i++; } printf("i %d\n", i); wg_detach_database(db); return 0; }whitedb-0.7.3/Examples/speed/speed12.c0000644000175000001440000000116112232205232014341 00000000000000/* create an index for the field 3 in the previously built database of 10 million records. real 0m6.540s user 0m6.436s sys 0m0.098s */ #include #include // must additionally include indexapi.h #include #include int main(int argc, char **argv) { void *db, *rec; char *name="10"; int tmp; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } tmp=wg_create_index(db,3,WG_INDEX_TYPE_TTREE,NULL,0); if (tmp) printf("Index creation failed\n"); else printf("Index creation succeeded\n"); return 0; } whitedb-0.7.3/Examples/speed/speed2.c0000644000175000001440000000126212232205232014262 00000000000000/* creating 10 million records of 5 fields in a 1 GB database real 0m0.586s user 0m0.473s sys 0m0.113s creating 10 million records of 9 fields in a 1 GB database real 0m0.812s user 0m0.645s sys 0m0.166s */ #include #include #include int main(int argc, char **argv) { void *db, *rec; char *name="2"; int i; db = wg_attach_database(name, 1000000000); if (!db) { printf("db creation failed \n"); exit(0); } for(i=0;i<10000000;i++) { rec = wg_create_record(db, 9); if (!rec) { printf("record creation failed \n"); exit(0); } } printf("i %d\n", i); wg_detach_database(db); wg_delete_database(name); return 0; } whitedb-0.7.3/Examples/tut2.c0000644000175000001440000000061112257033123012700 00000000000000#include int main(int argc, char **argv) { void *db, *rec, *rec2; wg_int enc, enc2; db = wg_attach_database("1000", 2000000); rec = wg_create_record(db, 10); rec2 = wg_create_record(db, 2); enc = wg_encode_int(db, 443); enc2 = wg_encode_str(db, "this is my string", NULL); wg_set_field(db, rec, 7, enc); wg_set_field(db, rec2, 0, enc2); return 0; } whitedb-0.7.3/Examples/Makefile.am0000644000175000001440000000127212421471034013676 00000000000000# $Id: $ # $Source: $ # # Compile test program(s) # ---- options ---- # ---- targets ---- noinst_PROGRAMS = demo query #if RAPTOR #noinst_PROGRAMS += raptortry #endif # ---- extra dependencies, flags, etc ----- LIBDEPS = -lm # dependency from libm round() should be removed if RAPTOR LIBDEPS += `$(RAPTOR_CONFIG) --libs` endif #if RAPTOR #raptortry_CFLAGS = $(AM_CFLAGS) `$(RAPTOR_CONFIG) --cflags` #endif AM_LDFLAGS = $(LIBDEPS) # ----- all sources for the created programs ----- #raptortry_SOURCES = raptortry.c #raptortry_LDADD = ../Main/libwgdb.la demo_SOURCES = demo.c demo_LDADD = ../Main/libwgdb.la query_SOURCES = query.c query_LDADD = ../Main/libwgdb.la ../Test/libTest.la whitedb-0.7.3/Examples/compile_query.sh0000755000175000001440000000111112426116005015045 00000000000000#!/bin/sh [ -z "$CC" ] && CC="cc" if [ -z "$(which $CC 2>/dev/null)" ]; then echo "Error: No compiler found" exit 1 fi # run unite.sh if needed if [ ! -f ../whitedb.c ]; then cd ..; ./unite.sh; cd "$OLDPWD" fi # use output of unite.sh $CC -O2 -I.. -o query query.c ../Test/dbtest.c ../whitedb.c -lm #$CC -O2 -o query query.c ../Db/dbmem.c ../Db/dballoc.c ../Db/dbdata.c ../Db/dblock.c ../Db/dbindex.c ../Db/dblog.c ../Db/dbhash.c ../Db/dbcompare.c ../Db/dbquery.c ../Db/dbutil.c ../Test/dbtest.c ../Db/dbmpool.c ../Db/dbjson.c ../Db/dbschema.c ../json/yajl_all.c -lm whitedb-0.7.3/Examples/Makefile.in0000644000175000001440000004417212426224004013713 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: $ # $Source: $ # # Compile test program(s) # ---- options ---- # ---- targets ---- VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ noinst_PROGRAMS = demo$(EXEEXT) query$(EXEEXT) @RAPTOR_TRUE@am__append_1 = `$(RAPTOR_CONFIG) --libs` subdir = Examples DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) am_demo_OBJECTS = demo.$(OBJEXT) demo_OBJECTS = $(am_demo_OBJECTS) demo_DEPENDENCIES = ../Main/libwgdb.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_query_OBJECTS = query.$(OBJEXT) query_OBJECTS = $(am_query_OBJECTS) query_DEPENDENCIES = ../Main/libwgdb.la ../Test/libTest.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(demo_SOURCES) $(query_SOURCES) DIST_SOURCES = $(demo_SOURCES) $(query_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PRTDIAG = @PRTDIAG@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_INCLUDES = @PYTHON_INCLUDES@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RAPTOR_CONFIG = @RAPTOR_CONFIG@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ #if RAPTOR #noinst_PROGRAMS += raptortry #endif # ---- extra dependencies, flags, etc ----- LIBDEPS = -lm $(am__append_1) #if RAPTOR #raptortry_CFLAGS = $(AM_CFLAGS) `$(RAPTOR_CONFIG) --cflags` #endif AM_LDFLAGS = $(LIBDEPS) # ----- all sources for the created programs ----- #raptortry_SOURCES = raptortry.c #raptortry_LDADD = ../Main/libwgdb.la demo_SOURCES = demo.c demo_LDADD = ../Main/libwgdb.la query_SOURCES = query.c query_LDADD = ../Main/libwgdb.la ../Test/libTest.la all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Examples/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Examples/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list demo$(EXEEXT): $(demo_OBJECTS) $(demo_DEPENDENCIES) $(EXTRA_demo_DEPENDENCIES) @rm -f demo$(EXEEXT) $(AM_V_CCLD)$(LINK) $(demo_OBJECTS) $(demo_LDADD) $(LIBS) query$(EXEEXT): $(query_OBJECTS) $(query_DEPENDENCIES) $(EXTRA_query_DEPENDENCIES) @rm -f query$(EXEEXT) $(AM_V_CCLD)$(LINK) $(query_OBJECTS) $(query_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: whitedb-0.7.3/Examples/tut1.c0000644000175000001440000000025412257033123012702 00000000000000#include /* or #include on Windows */ int main(int argc, char **argv) { void *db; db = wg_attach_database("1000", 2000000); return 0; } whitedb-0.7.3/Examples/tut6.c0000644000175000001440000000414212257033123012707 00000000000000#include #include #include #define NUM_INCREMENTS 100000 void die(void *db, int err) { wg_detach_database(db); exit(err); } int main(int argc, char **argv) { void *db, *rec; wg_int lock_id; int i, val; if(!(db = wg_attach_database("1000", 1000000))) { exit(1); /* failed to attach */ } /* First we need to make sure both counting programs start at the * same time (otherwise the example would be boring). */ lock_id = wg_start_read(db); rec = wg_get_first_record(db); /* our database only contains one record, * so we don't need to make a query. */ wg_end_read(db, lock_id); if(!rec) { /* There is no record yet, we're the first to run and have * to set up the counter. */ lock_id = wg_start_write(db); if(!lock_id) die(db, 2); rec = wg_create_record(db, 1); wg_end_write(db, lock_id); if(!rec) die(db, 3); printf("Press a key when all the counter programs have been started."); fgetc(stdin); /* Setting the counter to 0 lets each counting program know it can * start counting now. */ lock_id = wg_start_write(db); if(!lock_id) die(db, 2); wg_set_field(db, rec, 0, wg_encode_int(db, 0)); wg_end_write(db, lock_id); } else { /* Some other program has started first, we wait until the counter * is ready. */ int ready = 0; while(!ready) { lock_id = wg_start_read(db); if(!lock_id) die(db, 2); if(wg_get_field_type(db, rec, 0) == WG_INTTYPE) ready = 1; wg_end_read(db, lock_id); } } /* Now start the actual counting. */ for(i=0; i #include #include #include #include // for alarm and termination signal handling #include // #if _MSC_VER // no alarm on windows #else #include // for alarm #endif /* =============== configuration macros =================== */ #define DEFAULT_DATABASE "1000" #define TIMEOUT_SECONDS 2 #define JSON_CONTENT_TYPE "content-type: application/json\r\n\r\n" #define CSV_CONTENT_TYPE "content-type: text/csv\r\n\r\n" #define CONTENT_LENGTH "content-length: %d\r\n" #define MAXQUERYLEN 2000 // query string length limit #define MAXPARAMS 100 // max number of cgi params in query #define MAXCOUNT 10000 // max number of result records #define MAXIDS 1000 // max number of rec id-s in recids query #define INITIAL_MALLOC 1000 // initially malloced result size #define MAX_MALLOC 100000000 // max malloced result size #define MIN_STRLEN 100 // fixed-len obj strlen, add this to strlen for print-space need #define STRLEN_FACTOR 6 // might need 6*strlen for json encoding #define DOUBLE_FORMAT "%g" // snprintf format for printing double #define JS_NULL "[]" #define CSV_SEPARATOR ',' // must be a single char #define MAX_DEPTH_DEFAULT 100 // can be increased #define MAX_DEPTH_HARD 10000 // too deep rec nesting will cause stack overflow in the printer #define TIMEOUT_ERR "timeout" #define INTERNAL_ERR "internal error" #define NOQUERY_ERR "no query" #define LONGQUERY_ERR "too long query" #define MALFQUERY_ERR "malformed query" #define UNKNOWN_PARAM_ERR "unrecognized parameter: %s" #define UNKNOWN_PARAM_VALUE_ERR "unrecognized value %s for parameter %s" #define NO_OP_ERR "no op given: use op=opname for opname in search" #define UNKNOWN_OP_ERR "unrecognized op: use op=search or op=recids" #define NO_FIELD_ERR "no field given" #define NO_VALUE_ERR "no value given" #define DB_PARAM_ERR "use db=name with a numeric name for a concrete database" #define DB_ATTACH_ERR "no database found: use db=name with a numeric name for a concrete database" #define FIELD_ERR "unrecognized field: use an integer starting from 0" #define COND_ERR "unrecognized compare: use equal, not_equal, lessthan, greater, ltequal or gtequal" #define INTYPE_ERR "unrecognized type: use null, int, double, str, char or record " #define INVALUE_ERR "did not find a value to use for comparison" #define INVALUE_TYPE_ERR "value does not match type" #define LOCK_ERR "database locked" #define LOCK_RELEASE_ERR "releasing read lock failed: database may be in deadlock" #define MALLOC_ERR "cannot allocate enough memory for result string" #define QUERY_ERR "query creation failed" #define DECODE_ERR "field data decoding failed" #define JS_TYPE_ERR "\"\"" // currently this will be shown also for empty string #if _MSC_VER // microsoft compatibility #define snprintf _snprintf #endif /* =============== protos =================== */ void timeout_handler(int signal); void termination_handler(int signal); void print_final(char* str,int format); char* search(char* database, char* inparams[], char* invalues[], int count, int* hformat); char* recids(char* database, char* inparams[], char* invalues[], int incount, int* hformat); static wg_int encode_incomp(void* db, char* incomp); static wg_int encode_intype(void* db, char* intype); static wg_int encode_invalue(void* db, char* invalue, wg_int type); static int isint(char* s); static int isdbl(char* s); static int parse_query(char* query, int ql, char* params[], char* values[]); static char* urldecode(char *indst, char *src); int sprint_record(void *db, wg_int *rec, char **buf, int *bufsize, char **bptr, int format, int showid, int depth, int maxdepth, int strenc); char* sprint_value(void *db, wg_int enc, char **buf, int *bufsize, char **bptr, int format, int showid, int depth, int maxdepth, int strenc); int sprint_string(char* bptr, int limit, char* strdata, int strenc); int sprint_blob(char* bptr, int limit, char* strdata, int strenc); int sprint_append(char** buf, char* str, int l); static char* str_new(int len); static int str_guarantee_space(char** stradr, int* strlenadr, char** ptr, int needed); void err_clear_detach_halt(void* db, wg_int lock_id, char* errstr); void errhalt(char* str); /* =============== globals =================== */ // global vars are used only for enabling signal/error handlers // to free the lock and detach from the database: // set/cleared after taking/releasing lock, attaching/detaching database // global_format used in error handler to select content-type header void* global_db=NULL; // NULL iff not attached wg_int global_lock_id=0; // 0 iff not locked int global_format=1; // 1 json, 0 csv /* =============== main =================== */ int main(int argc, char **argv) { int i=0; char* inquery=NULL; char query[MAXQUERYLEN]; int pcount=0; int ql,found; char* res=NULL; char* database=DEFAULT_DATABASE; char* params[MAXPARAMS]; char* values[MAXPARAMS]; int hformat=1; // for header 0: csv, 1: json: reset later after reading params // Set up timeout signal and abnormal termination handlers: // the termination handler clears the read lock and detaches database. // This may fail, however, for some lock strategies and in case // nontrivial operations are taken in the handler. #if _MSC_VER // no signals on windows #else signal(SIGSEGV,termination_handler); signal(SIGINT,termination_handler); signal(SIGFPE,termination_handler); signal(SIGABRT,termination_handler); signal(SIGTERM,termination_handler); signal(SIGALRM,timeout_handler); alarm(TIMEOUT_SECONDS); #endif // for debugging print the plain content-type immediately // printf("content-type: text/plain\r\n"); // get the cgi query: passed by server or given on the command line inquery=getenv("QUERY_STRING"); if (inquery==NULL && argc>1) inquery=argv[1]; // or use your own query string for testing a la // inquery="db=1000&op=search&field=1&value=2&compare=equal&type=record&from=0&count=3"; // parse the query if (inquery==NULL || inquery[0]=='\0') errhalt(NOQUERY_ERR); ql=strlen(inquery); if (ql>MAXQUERYLEN) errhalt(LONGQUERY_ERR); strcpy((char*)query,inquery); //printf("query: %s\n",query); pcount=parse_query(query,ql,params,values); if (pcount<=0) errhalt(MALFQUERY_ERR); //for(i=0;iMAX_DEPTH_HARD) maxdepth=MAX_DEPTH_HARD; rec=wg_get_first_record(db); do { if (rcount>=from) { gcount++; if (gcount>count) break; str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); if (gcount>1 && format!=0) { // json and not first row snprintf(strbufferptr,MIN_STRLEN,",\n"); strbufferptr+=2; } sprint_record(db,rec,&strbuffer,&strbufferlen,&strbufferptr,format,showid,0,maxdepth,escape); if (format==0) { // csv str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); snprintf(strbufferptr,MIN_STRLEN,"\r\n"); strbufferptr+=2; } } rec=wg_get_next_record(db,rec); rcount++; } while(rec!=NULL); if (!wg_end_read(db, lock_id)) { // release read lock err_clear_detach_halt(db,lock_id,LOCK_RELEASE_ERR); } global_lock_id=0; // only for handling errors wg_detach_database(db); global_db=NULL; // only for handling errors str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); if (format!=0) { // json snprintf(strbufferptr,MIN_STRLEN,"\n]"); strbufferptr+=3; } return strbuffer; } // ------------ normal search case: --------- // create a query list datastructure for(i=0;iMAX_DEPTH_HARD) maxdepth=MAX_DEPTH_HARD; while((rec = wg_fetch(db, wgquery))) { if (rcount>=from) { gcount++; str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); if (gcount>1 && format!=0) { // json and not first row snprintf(strbufferptr,MIN_STRLEN,",\n"); strbufferptr+=2; } sprint_record(db,rec,&strbuffer,&strbufferlen,&strbufferptr,format,showid,0,maxdepth,escape); if (format==0) { // csv str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); snprintf(strbufferptr,MIN_STRLEN,"\r\n"); strbufferptr+=2; } } rcount++; if (gcount>=count) break; } // free query datastructure, release lock, detach for(i=0;i0) ids[x++]=atoi(cids+j); if (x>=MAXIDS) break; for(;jMAX_DEPTH_HARD) maxdepth=MAX_DEPTH_HARD; for(j=0; ids[j]!=0 && jcount) break; str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); if (gcount>1 && format!=0) { // json and not first row snprintf(strbufferptr,MIN_STRLEN,",\n"); strbufferptr+=2; } sprint_record(db,rec,&strbuffer,&strbufferlen,&strbufferptr,format,showid,0,maxdepth,escape); if (format==0) { // csv str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); snprintf(strbufferptr,MIN_STRLEN,"\r\n"); strbufferptr+=2; } rec=wg_get_next_record(db,rec); } if (!wg_end_read(db, lock_id)) { // release read lock err_clear_detach_halt(db,lock_id,LOCK_RELEASE_ERR); } global_lock_id=0; // only for handling errors wg_detach_database(db); global_db=NULL; // only for handling errors str_guarantee_space(&strbuffer,&strbufferlen,&strbufferptr,MIN_STRLEN); if (format!=0) { // json snprintf(strbufferptr,MIN_STRLEN,"\n]"); strbufferptr+=3; } return strbuffer; } /* *************** encode cgi params as query vals ******************** */ static wg_int encode_incomp(void* db, char* incomp) { if (incomp==NULL || incomp=='\0') return WG_COND_EQUAL; else if (!strcmp(incomp,"equal")) return WG_COND_EQUAL; else if (!strcmp(incomp,"not_equal")) return WG_COND_NOT_EQUAL; else if (!strcmp(incomp,"lessthan")) return WG_COND_LESSTHAN; else if (!strcmp(incomp,"greater")) return WG_COND_GREATER; else if (!strcmp(incomp,"ltequal")) return WG_COND_LTEQUAL; else if (!strcmp(incomp,"gtequal")) return WG_COND_GTEQUAL; else err_clear_detach_halt(db,0,COND_ERR); return WG_COND_EQUAL; // this return never happens } static wg_int encode_intype(void* db, char* intype) { if (intype==NULL || intype=='\0') return 0; else if (!strcmp(intype,"null")) return WG_NULLTYPE; else if (!strcmp(intype,"int")) return WG_INTTYPE; else if (!strcmp(intype,"record")) return WG_RECORDTYPE; else if (!strcmp(intype,"double")) return WG_DOUBLETYPE; else if (!strcmp(intype,"str")) return WG_STRTYPE; else if (!strcmp(intype,"char")) return WG_CHARTYPE; else err_clear_detach_halt(db,0,INTYPE_ERR); return 0; // this return never happens } static wg_int encode_invalue(void* db, char* invalue, wg_int type) { if (invalue==NULL) { err_clear_detach_halt(db,0,INVALUE_ERR); return 0; // this return never happens } if (type==WG_NULLTYPE) return wg_encode_query_param_null(db,NULL); else if (type==WG_INTTYPE) { if (!isint(invalue)) err_clear_detach_halt(db,0,INVALUE_TYPE_ERR); return wg_encode_query_param_int(db,atoi(invalue)); } else if (type==WG_RECORDTYPE) { if (!isint(invalue)) err_clear_detach_halt(db,0,INVALUE_TYPE_ERR); return (wg_int)atoi(invalue); } else if (type==WG_DOUBLETYPE) { if (!isdbl(invalue)) err_clear_detach_halt(db,0,INVALUE_TYPE_ERR); return wg_encode_query_param_double(db,strtod(invalue,NULL)); } else if (type==WG_STRTYPE) { return wg_encode_query_param_str(db,invalue,NULL); } else if (type==WG_CHARTYPE) { return wg_encode_query_param_char(db,invalue[0]); } else if (type==0 && isint(invalue)) { return wg_encode_query_param_int(db,atoi(invalue)); } else if (type==0 && isdbl(invalue)) { return wg_encode_query_param_double(db,strtod(invalue,NULL)); } else if (type==0) { return wg_encode_query_param_str(db,invalue,NULL); } else { err_clear_detach_halt(db,0,INVALUE_TYPE_ERR); return 0; // this return never happens } } /* ******************* cgi query parsing ******************** */ /* query parser: split by & and =, urldecode param and value return param count or -1 for error */ static int parse_query(char* query, int ql, char* params[], char* values[]) { int count=0; int i,pi,vi; for(i=0;i=ql) return -1; vi=i; for(;i=MAXPARAMS) return -1; params[count]=urldecode(query+pi,query+pi); values[count]=urldecode(query+vi,query+vi); count++; } return count; } /* urldecode used by query parser */ static char* urldecode(char *indst, char *src) { char a, b; char* endptr; char* dst; dst=indst; if (src==NULL || src[0]=='\0') return indst; endptr=src+strlen(src); while (*src) { if ((*src == '%') && (src+2= 'a') a -= 'A'-'a'; if (a >= 'A') a -= ('A' - 10); else a -= '0'; if (b >= 'a') b -= 'A'-'a'; if (b >= 'A') b -= ('A' - 10); else b -= '0'; *dst++ = 16*a+b; src+=3; } else { *dst++ = *src++; } } *dst++ = '\0'; return indst; } /* **************** guess string datatype ***************** */ /* return 1 iff s contains numerals only */ static int isint(char* s) { if (s==NULL) return 0; while(*s!='\0') { if (!isdigit(*s)) return 0; s++; } return 1; } /* return 1 iff s contains numerals plus single optional period only */ static int isdbl(char* s) { int c=0; if (s==NULL) return 0; while(*s!='\0') { if (!isdigit(*s)) { if (*s=='.') c++; else return 0; if (c>1) return 0; } s++; } return 1; } /* **************** json printing **************** */ /** Print a record, handling records recursively The value is written into a character buffer. db: database pointer rec: rec to be printed buf: address of the whole string buffer start (not the start itself) bufsize: address of the actual pointer to start printing at in buffer bptr: address of the whole string buffer format: 0 csv, 1 json showid: print record id for record: 0 no show, 1 first (extra) elem of record depth: current depth in a nested record tree (increases from initial 0) maxdepth: limit on printing records nested via record pointers (0: no nesting) strenc==0: nothing is escaped at all strenc==1: non-ascii chars and % and " urlencoded strenc==2: json utf-8 encoding, not ascii-safe */ int sprint_record(void *db, wg_int *rec, char **buf, int *bufsize, char **bptr, int format, int showid, int depth, int maxdepth, int strenc) { int i,limit; wg_int enc, len; #ifdef USE_CHILD_DB void *parent; #endif limit=MIN_STRLEN; str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); if (rec==NULL) { snprintf(*bptr, limit, JS_NULL); (*bptr)+=strlen(JS_NULL); return 1; } if (format!=0) { // json **bptr= '['; (*bptr)++; } #ifdef USE_CHILD_DB parent = wg_get_rec_owner(db, rec); #endif if (1) { len = wg_get_record_len(db, rec); if (showid) { // add record id (offset) as the first extra elem of record snprintf(*bptr, limit-1, "%d",wg_encode_record(db,rec)); *bptr=*bptr+strlen(*bptr); } for(i=0; i=maxdepth) { snprintf(*bptr, limit,"%d", (int)enc); // record offset (i.e. id) return *bptr+strlen(*bptr); } else { // recursive print ptrdata = wg_decode_record(db, enc); sprint_record(db,ptrdata,buf,bufsize,bptr,format,showid,depth+1,maxdepth,strenc); **bptr='\0'; return *bptr; } break; case WG_INTTYPE: intdata = wg_decode_int(db, enc); str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, "%d", intdata); return *bptr+strlen(*bptr); case WG_DOUBLETYPE: doubledata = wg_decode_double(db, enc); str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, DOUBLE_FORMAT, doubledata); return *bptr+strlen(*bptr); case WG_FIXPOINTTYPE: doubledata = wg_decode_fixpoint(db, enc); str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, DOUBLE_FORMAT, doubledata); return *bptr+strlen(*bptr); case WG_STRTYPE: strdata = wg_decode_str(db, enc); exdata = wg_decode_str_lang(db,enc); if (strdata!=NULL) strl1=strlen(strdata); else strl1=0; if (exdata!=NULL) strl2=strlen(exdata); else strl2=0; str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN+STRLEN_FACTOR*(strl1+strl2)); sprint_string(*bptr,(strl1+strl2),strdata,strenc); if (exdata!=NULL) { snprintf(*bptr+strl1+1,limit,"@%s\"", exdata); } return *bptr+strlen(*bptr); case WG_URITYPE: strdata = wg_decode_uri(db, enc); exdata = wg_decode_uri_prefix(db, enc); if (strdata!=NULL) strl1=strlen(strdata); else strl1=0; if (exdata!=NULL) strl2=strlen(exdata); else strl2=0; limit=MIN_STRLEN+STRLEN_FACTOR*(strl1+strl2); str_guarantee_space(buf, bufsize, bptr, limit); if (exdata==NULL) snprintf(*bptr, limit, "\"%s\"", strdata); else snprintf(*bptr, limit, "\"%s:%s\"", exdata, strdata); return *bptr+strlen(*bptr); case WG_XMLLITERALTYPE: strdata = wg_decode_xmlliteral(db, enc); exdata = wg_decode_xmlliteral_xsdtype(db, enc); if (strdata!=NULL) strl1=strlen(strdata); else strl1=0; if (exdata!=NULL) strl2=strlen(exdata); else strl2=0; limit=MIN_STRLEN+STRLEN_FACTOR*(strl1+strl2); str_guarantee_space(buf, bufsize, bptr, limit); snprintf(*bptr, limit, "\"%s:%s\"", exdata, strdata); return *bptr+strlen(*bptr); case WG_CHARTYPE: intdata = wg_decode_char(db, enc); str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, "\"%c\"", (char) intdata); return *bptr+strlen(*bptr); case WG_DATETYPE: intdata = wg_decode_date(db, enc); wg_strf_iso_datetime(db,intdata,0,strbuf); strbuf[10]=0; str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, "\"%s\"",strbuf); return *bptr+strlen(*bptr); case WG_TIMETYPE: intdata = wg_decode_time(db, enc); wg_strf_iso_datetime(db,1,intdata,strbuf); str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, "\"%s\"",strbuf+11); return *bptr+strlen(*bptr); case WG_VARTYPE: intdata = wg_decode_var(db, enc); str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, "\"?%d\"", intdata); return *bptr+strlen(*bptr); case WG_BLOBTYPE: strdata = wg_decode_blob(db, enc); strl=wg_decode_blob_len(db, enc); limit=MIN_STRLEN+STRLEN_FACTOR*strlen(strdata); str_guarantee_space(buf, bufsize, bptr, limit); sprint_blob(*bptr,strl,strdata,strenc); return *bptr+strlen(*bptr); default: str_guarantee_space(buf, bufsize, bptr, MIN_STRLEN); snprintf(*bptr, limit, JS_TYPE_ERR); return *bptr+strlen(*bptr); } } /* Print string with several encoding/escaping options. It must be guaranteed beforehand that there is enough room in the buffer. bptr: direct pointer to location in buffer where to start writing limit: max nr of chars traversed (NOT limiting output len) strdata: pointer to printed string strenc==0: nothing is escaped at all strenc==1: non-ascii chars and % and " urlencoded strenc==2: json utf-8 encoding, not ascii-safe strenc==3: csv encoding, only " replaced for "" For proper json tools see: json rfc http://www.ietf.org/rfc/rfc4627.txt ccan json tool http://git.ozlabs.org/?p=ccan;a=tree;f=ccan/json Jansson json tool https://jansson.readthedocs.org/en/latest/ Parser http://linuxprograms.wordpress.com/category/json-c/ */ int sprint_string(char* bptr, int limit, char* strdata, int strenc) { unsigned char c; char *sptr; char *hex_chars="0123456789abcdef"; int i; sptr=strdata; *bptr++='"'; if (sptr==NULL) { *bptr++='"'; *bptr='\0'; return 1; } if (!strenc) { // nothing is escaped at all for(i=0;i126) { *bptr++='%'; *bptr++=hex_chars[c >> 4]; *bptr++=hex_chars[c & 0xf]; } else { *bptr++=c; } } } else { // json encoding; chars before ' ' are are escaped with \u00 sptr=strdata; for(i=0;i> 4]; *bptr++=hex_chars[c & 0xf]; } else { *bptr++=c; } } } } *bptr++='"'; *bptr='\0'; return 1; } int sprint_blob(char* bptr, int limit, char* strdata, int strenc) { unsigned char c; char *sptr; char *hex_chars="0123456789abcdef"; int i; sptr=strdata; *bptr++='"'; if (sptr==NULL) { *bptr++='"'; *bptr='\0'; return 1; } // non-ascii chars and % and " urlencoded for(i=0;i126) { *bptr++='%'; *bptr++=hex_chars[c >> 4]; *bptr++=hex_chars[c & 0xf]; } else { *bptr++=c; } } *bptr++='"'; *bptr='\0'; return 1; } int sprint_append(char** bptr, char* str, int l) { int i; for(i=0;i(*strlenadr-(int)((*ptr)-(*stradr)))) { used=(int)((*ptr)-(*stradr)); newlen=(*strlenadr)*2; if (newlenMAX_MALLOC) { if (*stradr!=NULL) free(*stradr); err_clear_detach_halt(global_db,global_lock_id,MALLOC_ERR); return 0; // never returns } //printf("needed %d oldlen %d used %d newlen %d \n",needed,*strlenadr,used,newlen); tmp=realloc(*stradr,newlen); if (tmp==NULL) { if (*stradr!=NULL) free(*stradr); err_clear_detach_halt(global_db,global_lock_id,MALLOC_ERR); return 0; // never returns } tmp[newlen-1]=0; // set last byte to 0 //printf("oldstradr %d newstradr %d oldptr %d newptr %d \n",(int)*stradr,(int)tmp,(int)*ptr,(int)tmp+used); *stradr=tmp; *strlenadr=newlen; *ptr=tmp+used; return 1; } return 1; } /* ******************* errors ******************** */ /* called in case of internal errors by the signal catcher: it is crucial that the locks are released and db detached */ void termination_handler(int xsignal) { err_clear_detach_halt(global_db,global_lock_id,INTERNAL_ERR); } /* called in case of timeout by the signal catcher: it is crucial that the locks are released and db detached */ void timeout_handler(int signal) { err_clear_detach_halt(global_db,global_lock_id,TIMEOUT_ERR); } /* normal termination call: free locks, detach, call errprint and halt */ void err_clear_detach_halt(void* db, wg_int lock_id, char* errstr) { int r; if (lock_id) { r=wg_end_read(db, lock_id); global_lock_id=0; // only for handling errors } if (db!=NULL) wg_detach_database(db); global_db=NULL; // only for handling errors errhalt(errstr); } /* error output and immediate halt */ void errhalt(char* str) { char buf[1000]; snprintf(buf,1000,"[\"%s\"]",str); print_final(buf,global_format); exit(0); } whitedb-0.7.3/Examples/demo.c0000644000175000001440000002052012257043255012736 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010 * * Minor mods by Tanel Tammet * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file demo.c * Demonstration of WhiteDB low-level API usage */ /* ====== Includes =============== */ #include #include #include /* Include dbapi.h for WhiteDB API functions */ #include "../Db/dbapi.h" #ifdef __cplusplus extern "C" { #endif /* ====== Private defs =========== */ /* ======= Private protos ================ */ void run_demo(void *db); /* ====== Functions ============== */ /** Init database, run demo, drop database * Command line arguments are ignored. */ int main(int argc, char **argv) { void* shmptr; /* Create a database with custom key and 2M size */ shmptr=wg_attach_database("9273", 2000000); /* Using default key and size: shmptr=wg_attach_database(NULL, 0); */ if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* We have successfully attached, run the demo code */ run_demo(shmptr); /* Clean up. The shared memory area is released. This is * useful for the purposes of this demo, but might best be * avoided for more persistent databases. */ wg_delete_database("9273"); /* Database with default key: wg_delete_database(NULL); */ exit(0); } /** Run demo code. * Uses various database API functions. */ void run_demo(void* db) { void *rec = NULL, *firstrec = NULL, *nextrec = NULL; /* Pointers to a database record */ wg_int enc; /* Encoded data */ wg_int lock_id; /* Id of an acquired lock (for releasing it later) */ wg_int len; int i; int intdata, datedata, timedata; char strbuf[80]; printf("********* Starting demo ************\n"); /* Begin by creating a simple record of 3 fields and fill it * with integer data. */ printf("Creating first record.\n"); rec=wg_create_record(db, 3); if (rec==NULL) { printf("rec creation error.\n"); return; } /* Encode a field, checking for errors */ enc = wg_encode_int(db, 44); if(enc==WG_ILLEGAL) { printf("failed to encode an integer.\n"); return; } /* Negative return value shows that an error occurred */ if(wg_set_field(db, rec, 0, enc) < 0) { printf("failed to store a field.\n"); return; } /* Skip error checking for the sake of brevity for the rest of fields */ enc = wg_encode_int(db, -199999); wg_set_field(db, rec, 1, enc); wg_set_field(db, rec, 2, wg_encode_int(db, 0)); /* Now examine the record we have created. Get record length, * encoded value of each field, data type and decoded value. */ /* Negative return value shows an error. */ len = wg_get_record_len(db, rec); if(len < 0) { printf("failed to get record length.\n"); return; } printf("Size of created record at %p was: %d\n", rec, (int) len); for(i=0; i #include int main(int argc, char **argv) { void *db, *rec, *rec2, *rec3; wg_int enc; if(!(db = wg_attach_database("1000", 2000000))) exit(1); /* failed to attach */ rec = wg_create_record(db, 2); /* this is some record */ rec2 = wg_create_record(db, 3); /* this is another record */ rec3 = wg_create_record(db, 4); /* this is a third record */ if(!rec || !rec2 || !rec3) exit(2); /* Add some content */ wg_set_field(db, rec, 1, wg_encode_str(db, "hello", NULL)); wg_set_field(db, rec2, 0, wg_encode_str(db, "I'm pointing to other records", NULL)); wg_set_field(db, rec3, 0, wg_encode_str(db, "I'm linked from two records", NULL)); /* link the records to each other */ enc = wg_encode_record(db, rec); wg_set_field(db, rec2, 2, enc); /* rec2[2] points to rec */ enc = wg_encode_record(db, rec3); wg_set_field(db, rec2, 1, enc); /* rec2[1] points to rec3 */ wg_set_field(db, rec, 0, enc); /* rec[0] points to rec3 */ wg_detach_database(db); return 0; } whitedb-0.7.3/AUTHORS0000644000175000001440000000060012421471034011126 00000000000000Authors ======= Project lead T.Tammet Main programming T.Tammet and P.Järv (priit@whitedb.org) Additional programming: E.Reilent (t-tree) A.Puusepp (java bindings), A.Rebane (dump/log parts), M.Puju (prototype version) WhiteDB uses several packages developed by other people. Information can be found in README and AUTHORS files in corresponding folders. whitedb-0.7.3/test-driver0000755000175000001440000001027712371232461012272 00000000000000#! /bin/sh # test-driver - basic testsuite driver script. scriptversion=2013-07-13.22; # UTC # Copyright (C) 2011-2013 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # Make unconditional expansion of undefined variables an error. This # helps a lot in preventing typo-related bugs. set -u usage_error () { echo "$0: $*" >&2 print_usage >&2 exit 2 } print_usage () { cat <$log_file 2>&1 estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then estatus=1 fi case $estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; *:*) col=$red res=FAIL recheck=yes gcopy=yes;; esac # Report outcome to console. echo "${col}${res}${std}: $test_name" # Register the test result, and other relevant metadata. echo ":test-result: $res" > $trs_file echo ":global-test-result: $res" >> $trs_file echo ":recheck: $recheck" >> $trs_file echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: whitedb-0.7.3/config.h.in0000644000175000001440000000562012426224010012103 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Use additional validation checks */ #undef CHECK /* Journal file directory */ #undef DBLOG_DIR /* Encoded data is 64-bit */ #undef HAVE_64BIT_GINT /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Compile with raptor rdf library */ #undef HAVE_RAPTOR /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Select locking protocol: reader-preference spinlock */ #undef LOCK_PROTO /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* The size of `ptrdiff_t', as computed by sizeof. */ #undef SIZEOF_PTRDIFF_T /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* String hash size (% of db size) */ #undef STRHASH_SIZE /* Use chained T-tree index nodes */ #undef TTREE_CHAINED_NODES /* Use single-compare T-tree mode */ #undef TTREE_SINGLE_COMPARE /* Use record banklinks */ #undef USE_BACKLINKING /* Enable child database support */ #undef USE_CHILD_DB /* Use dblog module for transaction logging */ #undef USE_DBLOG /* Use match templates for indexes */ #undef USE_INDEX_TEMPLATE /* Version number of package */ #undef VERSION /* Package major version */ #undef VERSION_MAJOR /* Package minor version */ #undef VERSION_MINOR /* Package revision number */ #undef VERSION_REV /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #undef YYTEXT_POINTER whitedb-0.7.3/install-sh0000755000175000001440000003325512153415437012105 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: whitedb-0.7.3/NEWS0000644000175000001440000000011212232205232010546 00000000000000News ==== Nothing here: see https://github.com/priitj/whitedb for historywhitedb-0.7.3/Bootstrap0000755000175000001440000000141012257043255011770 00000000000000#!/bin/sh # $Id: $ # $Source: $ # Booting up the GNU automake, autoconf, etc system: # not needed after the configure executable script has been built # Need to use use autoconf >= 2.50 an automake >= 1.5. This allows user to # set these variables in their environment, or to just use the defaults below. # This is needed since some systems still use autoconf-2.13 and automake-1.4 as # the defaults (e.g. debian). : ${ACLOCAL=aclocal} : ${AUTOMAKE=automake} : ${AUTOCONF=autoconf} : ${AUTOHEADER=autoheader} : ${LIBTOOLIZE=libtoolize} command -v glibtoolize && LIBTOOLIZE=glibtoolize set -e set -x ( ${ACLOCAL} ${AUTOHEADER} ${AUTOCONF} ${LIBTOOLIZE} --no-warn [ -d config-aux ] || mkdir config-aux ${AUTOMAKE} -a -c ) rm -f config.cache whitedb-0.7.3/configure.ac0000644000175000001440000001701212426223736012362 00000000000000# Process this file with autoconf to produce a configure script. # $Id: $ # $Source: $ # ------- Initialisation ------- m4_define([WHITEDB_MAJOR], [0]) m4_define([WHITEDB_MINOR], [7]) m4_define([WHITEDB_REV], [3]) # standard release m4_define([WHITEDB_VERSION], m4_defn([WHITEDB_MAJOR]).m4_defn([WHITEDB_MINOR]).m4_defn([WHITEDB_REV])) release candidate; fill in manually #m4_define([WHITEDB_VERSION], [0.7-alpha])) AC_INIT(WhiteDB, [WHITEDB_VERSION]) AC_MSG_NOTICE([====== initialising ======]) # Add new configuration files AC_CONFIG_SRCDIR(Db/dballoc.c) AC_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE #Initialize libtool AC_PROG_LIBTOOL # ------- Checking ------- AC_MSG_NOTICE([====== checking ======]) AC_PROG_CC AM_PROG_CC_C_O # for per-target flags #Checks for libraries. ACX_PTHREAD() AC_CHECK_LIB([m],[cos]) #Check for programs AC_PROG_INSTALL #Check for Python (optional) AC_ARG_WITH([python], [AS_HELP_STRING([--with-python], [enable building Python bindings])], [], [with_python=no]) if test "x$with_python" != "xno" then if test "x$with_python" != "xyes" then PYTHON="$with_python" fi AM_PATH_PYTHON(,,[]) else PYTHON="" fi if test "x$PYTHON" != "x" then AM_CHECK_PYTHON_HEADERS(,[PYTHON=[]]) fi # If PYTHON is non-empty, contents of Python subdir will be # included in the build. This also implies that the check for # headers was successful and PYTHON_INCLUDES contains something useful. AM_CONDITIONAL(PYTHON, [test "x$PYTHON" != "x"]) #Check for Raptor (optional) AC_CHECK_PROGS(RAPTOR_CONFIG, raptor-config, []) AM_CONDITIONAL(RAPTOR, [test "x$RAPTOR_CONFIG" != "x"]) if test "x$RAPTOR_CONFIG" != "x" then AC_DEFINE([HAVE_RAPTOR], [1], [Compile with raptor rdf library]) fi # lex and bison (needed for reasoner) AC_PROG_LEX AC_CHECK_TOOL([BISON], [bison], [:]) # futex availability AC_CHECK_HEADER(linux/futex.h, [futex=yes], [AC_MSG_RESULT([Futexes not supported, tfqueue locks not available])] ) # Set the journal directory AC_ARG_WITH(logdir, [AC_HELP_STRING([--with-logdir=DIR], [Journal file directory @<:@default=/tmp@:>@])], with_logdir="$withval", with_logdir="/tmp") if test "x$with_logdir" = "xyes" -o "x$with_logdir" = "xno" then # define it anyway, even if the user picked --without LOGDIR="/tmp" else LOGDIR="$with_logdir" fi AC_DEFINE_UNQUOTED([DBLOG_DIR], "$LOGDIR", Journal file directory) AC_CHECK_SIZEOF([ptrdiff_t]) if test $ac_cv_sizeof_ptrdiff_t -eq 8 then AC_DEFINE([HAVE_64BIT_GINT], [1], [Encoded data is 64-bit]) fi # ----------- configuration options ---------- AC_MSG_NOTICE([====== setting configuration options ======]) AC_MSG_CHECKING(for logging) AC_ARG_ENABLE(logging, [AS_HELP_STRING([--enable-logging], [enable transaction logging])], [logging=$enable_logging],logging=no) if test "$logging" != no then AC_DEFINE([USE_DBLOG], [1], [Use dblog module for transaction logging]) AC_MSG_RESULT([enabled, journal directory is $LOGDIR]) else AC_MSG_RESULT(disabled) fi AC_MSG_CHECKING(for locking protocol) AC_ARG_ENABLE(locking, [AS_HELP_STRING([--enable-locking], [select locking protocol (rpspin,wpspin,tfqueue,no) @<:@default=tfqueue@:>@])], [locking=$enable_locking],locking=tfqueue) if test "$locking" == no then AC_MSG_RESULT(disabled) elif test "$locking" == wpspin then AC_DEFINE([LOCK_PROTO], [2], [Select locking protocol: writer-preference spinlock]) AC_MSG_RESULT([wpspin]) elif test "$locking" == tfqueue -a "$futex" == "yes" then AC_DEFINE([LOCK_PROTO], [3], [Select locking protocol: task-fair queued lock]) AC_MSG_RESULT([tfqueue]) else # unknown or unsupported value, revert to default AC_DEFINE([LOCK_PROTO], [1], [Select locking protocol: reader-preference spinlock]) AC_MSG_RESULT([rpspin]) fi AC_MSG_CHECKING(for additional validation checks) AC_ARG_ENABLE(checking, [AS_HELP_STRING([--disable-checking], [disable additional validation checks in API layer (small performance gain) ])], [checking=$enable_checking],checking=yes) if test "$checking" != no then AC_DEFINE([CHECK], [1], [Use additional validation checks]) AC_MSG_RESULT(enabled) else AC_MSG_RESULT(disabled) fi AC_MSG_CHECKING(for single-compare T-tree mode) AC_ARG_ENABLE(single_compare, [AS_HELP_STRING([--disable-single-compare], [disable experimental single compare algorithm in T-tree search])], [single_compare=$enable_single_compare],single_compare=yes) if test "$single_compare" != no then AC_DEFINE([TTREE_SINGLE_COMPARE], [1], [Use single-compare T-tree mode]) AC_MSG_RESULT(enabled) else AC_MSG_RESULT(disabled) fi AC_MSG_CHECKING(for chained T-tree nodes algorithm) AC_ARG_ENABLE(tstar, [AS_HELP_STRING([--disable-tstar], [disable experimental chained T-tree (similar to T* tree) index algorithm])], [tstar=$enable_tstar],tstar=yes) if test "$tstar" != no then AC_DEFINE([TTREE_CHAINED_NODES], [1], [Use chained T-tree index nodes]) AC_MSG_RESULT(enabled) else AC_MSG_RESULT(disabled) fi AC_MSG_CHECKING(for backlinking) AC_ARG_ENABLE(backlink, [AS_HELP_STRING([--disable-backlink], [disable record backlinking])], [backlink=$enable_backlink],backlink=yes) if test "$backlink" != no then AC_DEFINE([USE_BACKLINKING], [1], [Use record banklinks]) AC_MSG_RESULT(enabled) else AC_MSG_RESULT(disabled) fi AC_MSG_CHECKING(for child db support) AC_ARG_ENABLE(childdb, [AS_HELP_STRING([--enable-childdb], [enable child database support])], [childdb=$enable_childdb],childdb=no) if test "$childdb" != no then AC_DEFINE([USE_CHILD_DB], [1], [Enable child database support]) AC_MSG_RESULT(enabled) else AC_MSG_RESULT(disabled) fi AC_MSG_CHECKING(for index templates) AC_ARG_ENABLE(index_templates, [AS_HELP_STRING([--disable-index-templates], [disable support for index templates])], [index_templates=$enable_index_templates],index_templates=yes) if test "$index_templates" != no then AC_DEFINE([USE_INDEX_TEMPLATE], [1], [Use match templates for indexes]) AC_MSG_RESULT(enabled) else AC_MSG_RESULT(disabled) fi AC_MSG_CHECKING(for reasoner) AC_ARG_ENABLE(reasoner, [AS_HELP_STRING([--enable-reasoner], [enable reasoner])], [reasoner=$enable_reasoner],reasoner=no) if test "$reasoner" != no then AC_MSG_RESULT([disabled, reasoner not distributed with this release]) reasoner=no else AC_MSG_RESULT(disabled) fi AM_CONDITIONAL(REASONER, [test "$reasoner" != no]) AC_MSG_CHECKING(string hash size) AC_ARG_ENABLE(strhash_size, [AS_HELP_STRING([--enable-strhash-size], [set string hash size (% of db size) @<:@default=2@:>@])], [strhash_size=$enable_strhash_size],strhash_size=2) if test "x$strhash_size" = xyes -o "x$strhash_size" = xno -o "x$strhash_size" = x then AC_DEFINE([STRHASH_SIZE], [2], [Default string hash size (2% of db size)]) AC_MSG_RESULT([2]) else AC_DEFINE_UNQUOTED([STRHASH_SIZE], $strhash_size, [String hash size (% of db size)]) AC_MSG_RESULT($strhash_size) fi # ---------- Compiler flags -------- AC_MSG_NOTICE([====== setting compiler flags ======]) auto_cflags="-Wall" AX_GCC_ARCHFLAG([no]) AC_SUBST([AM_CFLAGS], ["$auto_cflags"]) # ---------- Final creation -------- AC_MSG_NOTICE([====== final steps ======]) AC_DEFINE([VERSION_MAJOR], [WHITEDB_MAJOR], [Package major version]) AC_DEFINE([VERSION_MINOR], [WHITEDB_MINOR], [Package minor version]) AC_DEFINE([VERSION_REV], [WHITEDB_REV], [Package revision number]) AC_OUTPUT([ Makefile Db/Makefile json/Makefile Test/Makefile Main/Makefile Examples/Makefile Python/Makefile ]) whitedb-0.7.3/ltmain.sh0000644000175000001440000105152212362065432011715 00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION=2.4.2 TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 whitedb-0.7.3/config-gcc.h0000644000175000001440000000425212426223736012246 00000000000000/* * XXX: put this file under license if needed * */ /** @file config-gcc.h * Build configuration for gcc platform. * * Based on auto-generated config.h. Should be manually synced whenever * additional configuration parameters are added. */ /* Use additional validation checks */ #define CHECK 1 /* Journal file directory */ #define DBLOG_DIR "/tmp" /* Select locking protocol (undef to disable locking) * 1 - reader preference spinlock * 2 - writer preference spinlock * 3 - task-fair queued lock */ #define LOCK_PROTO 1 /* Encoded data is 64-bit */ /* #undef HAVE_64BIT_GINT */ /* Define if you have POSIX threads libraries and header files. */ #define HAVE_PTHREAD 1 /* Compile with raptor rdf library */ /* #undef HAVE_RAPTOR */ /* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* #undef NO_MINUS_C_MINUS_O */ /* Name of package */ #define PACKAGE "whitedb" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define PACKAGE_NAME "WhiteDB" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "WhiteDB 0.7.3" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "whitedb" /* Define to the version of this package. */ #define PACKAGE_VERSION "0.7.3" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ /* #undef PTHREAD_CREATE_JOINABLE */ /* String hash size (% of db size) */ #define STRHASH_SIZE 2 /* Use chained T-tree index nodes */ #define TTREE_CHAINED_NODES 1 /* Use single-compare T-tree mode */ #define TTREE_SINGLE_COMPARE 1 /* Use record banklinks */ #define USE_BACKLINKING 1 /* Enable child database support */ /* #undef USE_CHILD_DB */ /* Use dblog module for transaction logging */ /* #undef USE_DBLOG */ /* Use match templates for indexes */ #define USE_INDEX_TEMPLATE 1 /* Enable reasoner */ /* #undef USE_REASONER */ /* Version number of package */ #define VERSION "0.7.3" /* Package major version */ #define VERSION_MAJOR 0 /* Package minor version */ #define VERSION_MINOR 7 /* Package revision number */ #define VERSION_REV 3 whitedb-0.7.3/acinclude.m40000644000175000001440000006645412146112207012270 00000000000000# =========================================================================== # http://autoconf-archive.cryp.to/acx_pthread.html # =========================================================================== # # SYNOPSIS # # ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) # # DESCRIPTION # # This macro figures out how to build C programs using POSIX threads. It # sets the PTHREAD_LIBS output variable to the threads library and linker # flags, and the PTHREAD_CFLAGS output variable to any special C compiler # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # # Also sets PTHREAD_CC to any special C compiler that is needed for # multi-threaded programs (defaults to the value of CC otherwise). (This # is necessary on AIX to use the special cc_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also link it with them as well. e.g. you should link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threads programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name # (e.g. PTHREAD_CREATE_UNDETACHED on AIX). # # ACTION-IF-FOUND is a list of shell commands to run if a threads library # is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it # is not found. If ACTION-IF-FOUND is not specified, the default action # will define HAVE_PTHREAD. # # Please let the authors know if this macro fails on any platform, or if # you have any other suggestions or comments. This macro was based on work # by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help # from M. Frigo), as well as ac_pthread and hb_pthread macros posted by # Alejandro Forero Cuervo to the autoconf macro repository. We are also # grateful for the helpful feedback of numerous users. # # LAST MODIFICATION # # 2008-04-12 # # COPYLEFT # # Copyright (c) 2008 Steven G. Johnson # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Macro Archive. When you make and # distribute a modified version of the Autoconf Macro, you may extend this # special exception to the GPL to apply to your modified version as well. AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_SAVE AC_LANG_C acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) AC_MSG_RESULT($acx_pthread_ok) if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [acx_pthread_ok=yes]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($acx_pthread_ok) if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_TRY_LINK([#include ], [int attr=$attr; return attr;], [attr_name=$attr; break]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else acx_pthread_ok=no $2 fi AC_LANG_RESTORE ])dnl ACX_PTHREAD dnl a macro to check for ability to create python extensions dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) dnl function also defines PYTHON_INCLUDES AC_DEFUN([AM_CHECK_PYTHON_HEADERS], [AC_REQUIRE([AM_PATH_PYTHON]) AC_MSG_CHECKING(for headers required to compile python extensions) dnl deduce PYTHON_INCLUDES py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"` py_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"` if test -x "$PYTHON-config"; then PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null` else PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" if test "$py_prefix" != "$py_exec_prefix"; then PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" fi if test "${IS_WINDOWS}" = "yes"; then PYTHON_INCLUDES=`echo $PYTHON_INCLUDES -I${py_prefix}/include | sed s%\\\\\\\\%/%g` PYTHON_VER=`echo ${PYTHON_VERSION} | sed s:\\\\.::` PYTHON_LIBS=`echo -L${py_prefix}/libs -lpython${PYTHON_VER} | sed s%\\\\\\\\%/%g` fi fi AC_SUBST(PYTHON_INCLUDES) AC_SUBST(PYTHON_LIBS) dnl check if the headers exist: save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" AC_TRY_CPP([#include ],dnl [AC_MSG_RESULT(found) $1],dnl [AC_MSG_RESULT(not found) $2]) CPPFLAGS="$save_CPPFLAGS" ]) # =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_check_compiler_flags.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE]) # # DESCRIPTION # # Check whether the given compiler FLAGS work with the current language's # compiler, or whether they give an error. (Warnings, however, are # ignored.) # # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on # success/failure. # # LICENSE # # Copyright (c) 2009 Steven G. Johnson # Copyright (c) 2009 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. AC_DEFUN([AX_CHECK_COMPILER_FLAGS], [AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1]) dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname: AS_LITERAL_IF([$1], [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]), [ ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$1" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes, AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no) _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])], [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$1" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes, eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no) _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS]) eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]) AC_MSG_RESULT($ax_check_compiler_flags) if test "x$ax_check_compiler_flags" = xyes; then m4_default([$2], :) else m4_default([$3], :) fi ])dnl AX_CHECK_COMPILER_FLAGS # =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html # =========================================================================== # # SYNOPSIS # # AX_GCC_X86_CPUID(OP) # # DESCRIPTION # # On Pentium and later x86 processors, with gcc or a compiler that has a # compatible syntax for inline assembly instructions, run a small program # that executes the cpuid instruction with input OP. This can be used to # detect the CPU type. # # On output, the values of the eax, ebx, ecx, and edx registers are stored # as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable # ax_cv_gcc_x86_cpuid_OP. # # If the cpuid instruction fails (because you are running a # cross-compiler, or because you are not using gcc, or because you are on # a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP # is set to the string "unknown". # # This macro mainly exists to be used in AX_GCC_ARCHFLAG. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2008 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. AC_DEFUN([AX_GCC_X86_CPUID], [AC_REQUIRE([AC_PROG_CC]) AC_LANG_PUSH([C]) AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ int op = $1, eax, ebx, ecx, edx; FILE *f; __asm__("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (op)); f = fopen("conftest_cpuid", "w"); if (!f) return 1; fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); fclose(f); return 0; ])], [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], [ax_cv_gcc_x86_cpuid_$1=unknown])]) AC_LANG_POP([C]) ]) # =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html # =========================================================================== # # SYNOPSIS # # AX_GCC_ARCHFLAG([PORTABLE?], [ACTION-SUCCESS], [ACTION-FAILURE]) # # DESCRIPTION # # This macro tries to guess the "native" arch corresponding to the target # architecture for use with gcc's -march=arch or -mtune=arch flags. If # found, the cache variable $ax_cv_gcc_archflag is set to this flag and # ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is is set to # "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is # to add $ax_cv_gcc_archflag to the end of $CFLAGS. # # PORTABLE? should be either [yes] (default) or [no]. In the former case, # the flag is set to -mtune (or equivalent) so that the architecture is # only used for tuning, but the instruction set used is still portable. In # the latter case, the flag is set to -march (or equivalent) so that # architecture-specific instructions are enabled. # # The user can specify --with-gcc-arch= in order to override the # macro's choice of architecture, or --without-gcc-arch to disable this. # # When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is # called unless the user specified --with-gcc-arch manually. # # Requires macros: AX_CHECK_COMPILER_FLAGS, AX_GCC_X86_CPUID # # (The main emphasis here is on recent CPUs, on the principle that doing # high-performance computing on old hardware is uncommon.) # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2008 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. AC_DEFUN([AX_GCC_ARCHFLAG], [AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=], [use architecture for gcc -march/-mtune, instead of guessing])], ax_gcc_arch=$withval, ax_gcc_arch=yes) AC_MSG_CHECKING([for gcc architecture flag]) AC_MSG_RESULT([]) AC_CACHE_VAL(ax_cv_gcc_archflag, [ ax_cv_gcc_archflag="unknown" if test "$GCC" = yes; then if test "x$ax_gcc_arch" = xyes; then ax_gcc_arch="" if test "$cross_compiling" = no; then case $host_cpu in i[[3456]]86*|x86_64*) # use cpuid codes, in part from x86info-1.7 by D. Jones AX_GCC_X86_CPUID(0) AX_GCC_X86_CPUID(1) case $ax_cv_gcc_x86_cpuid_0 in *:756e6547:*:*) # Intel case $ax_cv_gcc_x86_cpuid_1 in *5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; *5??:*:*:*) ax_gcc_arch=pentium ;; *6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; *6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; *6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; *6[[9d]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; *6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; *6??:*:*:*) ax_gcc_arch=pentiumpro ;; *f3[[347]]:*:*:*|*f4[1347]:*:*:*) case $host_cpu in x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;; *) ax_gcc_arch="prescott pentium4 pentiumpro" ;; esac ;; *f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";; esac ;; *:68747541:*:*) # AMD case $ax_cv_gcc_x86_cpuid_1 in *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;; *5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; *5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; *60?:*:*:*) ax_gcc_arch=k7 ;; *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;; *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;; *6[[68a]]?:*:*:*) AX_GCC_X86_CPUID(0x80000006) # L2 cache size case $ax_cv_gcc_x86_cpuid_0x80000006 in *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256 ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; *) ax_gcc_arch="athlon-4 athlon k7" ;; esac ;; *f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; *f5?:*:*:*) ax_gcc_arch="opteron k8" ;; *f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;; *f??:*:*:*) ax_gcc_arch="k8" ;; esac ;; *:746e6543:*:*) # IDT case $ax_cv_gcc_x86_cpuid_1 in *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; *58?:*:*:*) ax_gcc_arch=winchip2 ;; *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;; *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;; esac ;; esac if test x"$ax_gcc_arch" = x; then # fallback case $host_cpu in i586*) ax_gcc_arch=pentium ;; i686*) ax_gcc_arch=pentiumpro ;; esac fi ;; sparc*) AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/]) cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` cputype=`echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters` case $cputype in *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; *supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;; *hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;; *cypress*) ax_gcc_arch=cypress ;; esac ;; alphaev5) ax_gcc_arch=ev5 ;; alphaev56) ax_gcc_arch=ev56 ;; alphapca56) ax_gcc_arch="pca56 ev56" ;; alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; alphaev6) ax_gcc_arch=ev6 ;; alphaev67) ax_gcc_arch=ev67 ;; alphaev68) ax_gcc_arch="ev68 ev67" ;; alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; powerpc*) cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'` case $cputype in *750*) ax_gcc_arch="750 G3" ;; *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;; *74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;; *74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;; *970*) ax_gcc_arch="970 G5 power4";; *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; 603ev|8240) ax_gcc_arch="$cputype 603e 603";; *) ax_gcc_arch=$cputype ;; esac ax_gcc_arch="$ax_gcc_arch powerpc" ;; esac fi # not cross-compiling fi # guess arch if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then for arch in $ax_gcc_arch; do if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code flags="-mtune=$arch" # -mcpu=$arch and m$arch generate nonportable code on every arch except # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac else flags="-march=$arch -mcpu=$arch -m$arch" fi for flag in $flags; do AX_CHECK_COMPILER_FLAGS($flag, [ax_cv_gcc_archflag=$flag; break]) done test "x$ax_cv_gcc_archflag" = xunknown || break done fi fi # $GCC=yes ]) AC_MSG_CHECKING([for gcc architecture flag]) AC_MSG_RESULT($ax_cv_gcc_archflag) if test "x$ax_cv_gcc_archflag" = xunknown; then m4_default([$3],:) else m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"]) fi ]) whitedb-0.7.3/config.guess0000755000175000001440000012746312153415437012426 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013 Free Software Foundation, Inc. timestamp='2012-12-29' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: whitedb-0.7.3/Doxyfile0000644000175000001440000015305612146112207011600 00000000000000# Doxyfile 1.5.4 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file that # follow. The default is UTF-8 which is also the encoding used for all text before # the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into # libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of # possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = WhiteDB # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = Doc/ # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, # Italian, Japanese, Japanese-en (Japanese with English messages), Korean, # Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, # Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 2 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to # include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct (or union) is # documented as struct with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code where the coding convention is that all structs are # typedef'ed and only the typedef is referenced never the struct's name. TYPEDEF_HIDES_STRUCT = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be extracted # and appear in the documentation as a namespace called 'anonymous_namespace{file}', # where file will be replaced with the base name of the file that contains the anonymous # namespace. By default anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = Main Db # This tag can be used to specify the character encoding of the source files that # doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default # input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. # See http://www.gnu.org/software/libiconv for the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the output. # The symbol name can be a fully qualified name, a word, or if the wildcard * is used, # a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH # then you must also enable this option. If you don't then doxygen will produce # a warning and turn it on anyway SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentstion. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = NO #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to # produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to # specify the directory where the mscgen tool resides. If left empty the tool is assumed to # be found in the default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will # generate a caller dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable caller graphs for selected # functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the number # of direct children of the root node in a graph is already larger than # MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = YES # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO whitedb-0.7.3/aclocal.m40000644000175000001440000127613312426223763011750 00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS # Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) # ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------------------------- # Adds support for distributing Python modules and packages. To # install modules, copy them to $(pythondir), using the python_PYTHON # automake variable. To install a package with the same name as the # automake package, install to $(pkgpythondir), or use the # pkgpython_PYTHON automake variable. # # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as # locations to install python extension modules (shared libraries). # Another macro is required to find the appropriate flags to compile # extension modules. # # If your package is configured with a different prefix to python, # users will have to add the install directory to the PYTHONPATH # environment variable, or create a .pth file (see the python # documentation for details). # # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will # cause an error if the version of python installed on the system # doesn't meet the requirement. MINIMUM-VERSION should consist of # numbers and dots only. AC_DEFUN([AM_PATH_PYTHON], [ dnl Find a Python interpreter. Python versions prior to 2.0 are not dnl supported. (2.0 was released on October 16, 2000). m4_define_default([_AM_PYTHON_INTERPRETER_LIST], [python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 dnl python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0]) AC_ARG_VAR([PYTHON], [the Python interpreter]) m4_if([$1],[],[ dnl No version check is needed. # Find any Python interpreter. if test -z "$PYTHON"; then AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) fi am_display_PYTHON=python ], [ dnl A version check is needed. if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. AC_MSG_CHECKING([whether $PYTHON version is >= $1]) AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_MSG_ERROR([Python interpreter is too old])]) am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. AC_CACHE_CHECK([for a Python interpreter with version >= $1], [am_cv_pathless_PYTHON],[ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do test "$am_cv_pathless_PYTHON" = none && break AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) done]) # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then PYTHON=: else AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) fi am_display_PYTHON=$am_cv_pathless_PYTHON fi ]) if test "$PYTHON" = :; then dnl Run any user-specified action, or abort. m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) else dnl Query Python for its version number. Getting [:3] seems to be dnl the best way to do this; it's what "site.py" does in the standard dnl library. AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`]) AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) dnl Use the values of $prefix and $exec_prefix for the corresponding dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made dnl distinct variables so they can be overridden if need be. However, dnl general consensus is that you shouldn't need this ability. AC_SUBST([PYTHON_PREFIX], ['${prefix}']) AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) dnl At times (like when building shared libraries) you may want dnl to know which OS platform Python thinks this is. AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`]) AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) # Just factor out some code duplication. am_python_setup_sysconfig="\ import sys # Prefer sysconfig over distutils.sysconfig, for better compatibility # with python 3.x. See automake bug#10227. try: import sysconfig except ImportError: can_use_sysconfig = 0 else: can_use_sysconfig = 1 # Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs: # try: from platform import python_implementation if python_implementation() == 'CPython' and sys.version[[:3]] == '2.7': can_use_sysconfig = 0 except ImportError: pass" dnl Set up 4 directories: dnl pythondir -- where to install python scripts. This is the dnl site-packages directory, not the python standard library dnl directory like in previous automake betas. This behavior dnl is more consistent with lispdir.m4 for example. dnl Query distutils for this directory. AC_CACHE_CHECK([for $am_display_PYTHON script directory], [am_cv_python_pythondir], [if test "x$prefix" = xNONE then am_py_prefix=$ac_default_prefix else am_py_prefix=$prefix fi am_cv_python_pythondir=`$PYTHON -c " $am_python_setup_sysconfig if can_use_sysconfig: sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'}) else: from distutils import sysconfig sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix') sys.stdout.write(sitedir)"` case $am_cv_python_pythondir in $am_py_prefix*) am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"` ;; *) case $am_py_prefix in /usr|/System*) ;; *) am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac ]) AC_SUBST([pythondir], [$am_cv_python_pythondir]) dnl pkgpythondir -- $PACKAGE directory under pythondir. Was dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is dnl more consistent with the rest of automake. AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) dnl pyexecdir -- directory for installing python extension modules dnl (shared libraries) dnl Query distutils for this directory. AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], [am_cv_python_pyexecdir], [if test "x$exec_prefix" = xNONE then am_py_exec_prefix=$am_py_prefix else am_py_exec_prefix=$exec_prefix fi am_cv_python_pyexecdir=`$PYTHON -c " $am_python_setup_sysconfig if can_use_sysconfig: sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'}) else: from distutils import sysconfig sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix') sys.stdout.write(sitedir)"` case $am_cv_python_pyexecdir in $am_py_exec_prefix*) am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"` ;; *) case $am_py_exec_prefix in /usr|/System*) ;; *) am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac ]) AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) dnl Run any user-specified action. $2 fi ]) # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # --------------------------------------------------------------------------- # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. # Run ACTION-IF-FALSE otherwise. # This test uses sys.hexversion instead of the string equivalent (first # word of sys.version), in order to cope with versions such as 2.2c1. # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000). AC_DEFUN([AM_PYTHON_CHECK_VERSION], [prog="import sys # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. # map returns an iterator in Python 3.0 and a list in 2.x minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] minverhex = 0 # xrange is not present in Python 3.0 and range returns an iterator for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] sys.exit(sys.hexversion < minverhex)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) whitedb-0.7.3/missing0000755000175000001440000001533112153415437011473 00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2012-06-26.16; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'automa4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: whitedb-0.7.3/README0000644000175000001440000000343412232205232010741 00000000000000WhiteDB (wgdb) README ====================== WhiteDB is a lightweight database library operating fully in main memory. Disk is used only for dumping/restoring database and logging. Data is persistantly kept in the shared memory area: it is available simultaneously to all processes and is kept intact even if no processes are currently using the database. WhiteDB has no server process. Data is read and written directly from/to memory, no sockets are used between WhiteDB and the application using WhiteDB. WhiteDB keeps data as N-tuples: each database record is a tuple of N elements. Each element (record field) may have an arbitrary type amongst the types provided by WhiteDB. Each record field contains exactly one integer (4 bytes or 8 bytes). Datatypes which cannot be fit into one integer are allocated separately and the record field contains an (encoded) pointer to the real data. WhiteDB is written in pure C in a portable manner and should compile and function without additional porting at least under Linux (gcc) and Windows (native Windows C compiler cl). It has Python and experimental Java bindings. WhiteDB has several goals: - speed - portability - small footprint and low memory usage - usability as an rdf database - usability as an extended rdf database, xml database and outside these scopes - seamless integration with the Gandalf rule engine (work in progress) See http://whitedb.org for up-to-date documentation and other information. This distribution also includes various documentation: Doc/Install.txt - the installation instructions Doc/Tutorial.txt - getting started with the database Doc/Manual.txt - full C API documentation Doc/Utilities.txt - command line utilities and other programs Doc/python.txt - Python API documentation WhiteDB is licenced under GPL version 3. whitedb-0.7.3/GPLLICENCE0000644000175000001440000010451312146112207011414 00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . whitedb-0.7.3/py-compile0000755000175000001440000001107612153415440012074 00000000000000#!/bin/sh # py-compile - Compile a Python program scriptversion=2011-06-08.12; # UTC # Copyright (C) 2000-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . if [ -z "$PYTHON" ]; then PYTHON=python fi me=py-compile usage_error () { echo "$me: $*" >&2 echo "Try '$me --help' for more information." >&2 exit 1 } basedir= destdir= while test $# -ne 0; do case "$1" in --basedir) if test $# -lt 2; then usage_error "option '--basedir' requires an argument" else basedir=$2 fi shift ;; --destdir) if test $# -lt 2; then usage_error "option '--destdir' requires an argument" else destdir=$2 fi shift ;; -h|--help) cat <<\EOF Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..." Byte compile some python scripts FILES. Use --destdir to specify any leading directory path to the FILES that you don't want to include in the byte compiled file. Specify --basedir for any additional path information you do want to be shown in the byte compiled file. Example: py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py Report bugs to . EOF exit $? ;; -v|--version) echo "$me $scriptversion" exit $? ;; --) shift break ;; -*) usage_error "unrecognized option '$1'" ;; *) break ;; esac shift done files=$* if test -z "$files"; then usage_error "no files given" fi # if basedir was given, then it should be prepended to filenames before # byte compilation. if [ -z "$basedir" ]; then pathtrans="path = file" else pathtrans="path = os.path.join('$basedir', file)" fi # if destdir was given, then it needs to be prepended to the filename to # byte compile but not go into the compiled file. if [ -z "$destdir" ]; then filetrans="filepath = path" else filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" fi $PYTHON -c " import sys, os, py_compile, imp files = '''$files''' sys.stdout.write('Byte-compiling python modules...\n') for file in files.split(): $pathtrans $filetrans if not os.path.exists(filepath) or not (len(filepath) >= 3 and filepath[-3:] == '.py'): continue sys.stdout.write(file) sys.stdout.flush() if hasattr(imp, 'get_tag'): py_compile.compile(filepath, imp.cache_from_source(filepath), path) else: py_compile.compile(filepath, filepath + 'c', path) sys.stdout.write('\n')" || exit $? # this will fail for python < 1.5, but that doesn't matter ... $PYTHON -O -c " import sys, os, py_compile, imp # pypy does not use .pyo optimization if hasattr(sys, 'pypy_translation_info'): sys.exit(0) files = '''$files''' sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n') for file in files.split(): $pathtrans $filetrans if not os.path.exists(filepath) or not (len(filepath) >= 3 and filepath[-3:] == '.py'): continue sys.stdout.write(file) sys.stdout.flush() if hasattr(imp, 'get_tag'): py_compile.compile(filepath, imp.cache_from_source(filepath, False), path) else: py_compile.compile(filepath, filepath + 'o', path) sys.stdout.write('\n')" 2>/dev/null || : # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: whitedb-0.7.3/compile0000755000175000001440000001624512153415437011457 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: whitedb-0.7.3/compile.sh0000755000175000001440000000231612426116005012052 00000000000000#!/bin/sh # alternative to compilation with automake/make: just run # current version does not build reasoner: added later [ -z "$CC" ] && CC="cc" if [ -z "$(which $CC 2>/dev/null)" ]; then echo "Error: No compiler found" exit 1 fi [ -f config.h ] || cp config-gcc.h config.h if [ config-gcc.h -nt config.h ]; then echo "Warning: config.h is older than config-gcc.h, consider updating it" fi ${CC} -O2 -Wall -o Main/wgdb Main/wgdb.c Db/dbmem.c \ Db/dballoc.c Db/dbdata.c Db/dblock.c Db/dbindex.c Db/dbdump.c \ Db/dblog.c Db/dbhash.c Db/dbcompare.c Db/dbquery.c Db/dbutil.c Db/dbmpool.c \ Db/dbjson.c Db/dbschema.c json/yajl_all.c -lm # debug and testing programs: uncomment as needed #$CC -O2 -Wall -o Main/indextool Main/indextool.c Db/dbmem.c \ # Db/dballoc.c Db/dbdata.c Db/dblock.c Db/dbindex.c Db/dblog.c \ # Db/dbhash.c Db/dbcompare.c Db/dbquery.c Db/dbutil.c Db/dbmpool.c \ # Db/dbjson.c Db/dbschema.c json/yajl_all.c -lm #$CC -O2 -Wall -o Main/selftest Main/selftest.c Db/dbmem.c \ # Db/dballoc.c Db/dbdata.c Db/dblock.c Db/dbindex.c Test/dbtest.c Db/dbdump.c \ # Db/dblog.c Db/dbhash.c Db/dbcompare.c Db/dbquery.c Db/dbutil.c Db/dbmpool.c \ # Db/dbjson.c Db/dbschema.c json/yajl_all.c -lm whitedb-0.7.3/json/0000755000175000001440000000000012426224010011106 500000000000000whitedb-0.7.3/json/yajl_all.h0000644000175000001440000002044612237372400013003 00000000000000/* * Copyright (c) 2007-2011, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef YAJL_ALL_H #define YAJL_ALL_H #ifdef __cplusplus extern "C" { #endif /** * \file yajl_alloc.h * default memory allocation routines for yajl which use malloc/realloc and * free */ #include "yajl_api.h" #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz)) #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr)) #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz)) static void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf); /* * Implementation/performance notes. If this were moved to a header * only implementation using #define's where possible we might be * able to sqeeze a little performance out of the guy by killing function * call overhead. YMMV. */ /** * yajl_buf is a buffer with exponential growth. the buffer ensures that * you are always null padded. */ typedef struct yajl_buf_t * yajl_buf; /* allocate a new buffer */ static yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc); /* free the buffer */ static void yajl_buf_free(yajl_buf buf); /* append a number of bytes to the buffer */ static void yajl_buf_append(yajl_buf buf, const void * data, size_t len); /* empty the buffer */ static void yajl_buf_clear(yajl_buf buf); /* get a pointer to the beginning of the buffer */ static const unsigned char * yajl_buf_data(yajl_buf buf); /* get the length of the buffer */ static size_t yajl_buf_len(yajl_buf buf); /* * A header only implementation of a simple stack of bytes, used in YAJL * to maintain parse state. */ #define YAJL_BS_INC 128 typedef struct yajl_bytestack_t { unsigned char * stack; size_t size; size_t used; yajl_alloc_funcs * yaf; } yajl_bytestack; /* initialize a bytestack */ #define yajl_bs_init(obs, _yaf) { \ (obs).stack = NULL; \ (obs).size = 0; \ (obs).used = 0; \ (obs).yaf = (_yaf); \ } \ /* initialize a bytestack */ #define yajl_bs_free(obs) \ if ((obs).stack) (obs).yaf->free((obs).yaf->ctx, (obs).stack); #define yajl_bs_current(obs) \ (assert((obs).used > 0), (obs).stack[(obs).used - 1]) #define yajl_bs_push(obs, byte) { \ if (((obs).size - (obs).used) == 0) { \ (obs).size += YAJL_BS_INC; \ (obs).stack = (obs).yaf->realloc((obs).yaf->ctx,\ (void *) (obs).stack, (obs).size);\ } \ (obs).stack[((obs).used)++] = (byte); \ } /* removes the top item of the stack, returns nothing */ #define yajl_bs_pop(obs) { ((obs).used)--; } #define yajl_bs_set(obs, byte) \ (obs).stack[((obs).used) - 1] = (byte); static void yajl_string_encode(const yajl_print_t printer, void * ctx, const unsigned char * str, size_t length, int escape_solidus); static void yajl_string_decode(yajl_buf buf, const unsigned char * str, size_t length); static int yajl_string_validate_utf8(const unsigned char * s, size_t len); typedef enum { yajl_tok_bool, yajl_tok_colon, yajl_tok_comma, yajl_tok_eof, yajl_tok_error, yajl_tok_left_brace, yajl_tok_left_bracket, yajl_tok_null, yajl_tok_right_brace, yajl_tok_right_bracket, /* we differentiate between integers and doubles to allow the * parser to interpret the number without re-scanning */ yajl_tok_integer, yajl_tok_double, /* we differentiate between strings which require further processing, * and strings that do not */ yajl_tok_string, yajl_tok_string_with_escapes, /* comment tokens are not currently returned to the parser, ever */ yajl_tok_comment } yajl_tok; typedef struct yajl_lexer_t * yajl_lexer; static yajl_lexer yajl_lex_alloc(yajl_alloc_funcs * alloc, unsigned int allowComments, unsigned int validateUTF8); static void yajl_lex_free(yajl_lexer lexer); /** * run/continue a lex. "offset" is an input/output parameter. * It should be initialized to zero for a * new chunk of target text, and upon subsetquent calls with the same * target text should passed with the value of the previous invocation. * * the client may be interested in the value of offset when an error is * returned from the lexer. This allows the client to render useful n * error messages. * * When you pass the next chunk of data, context should be reinitialized * to zero. * * Finally, the output buffer is usually just a pointer into the jsonText, * however in cases where the entity being lexed spans multiple chunks, * the lexer will buffer the entity and the data returned will be * a pointer into that buffer. * * This behavior is abstracted from client code except for the performance * implications which require that the client choose a reasonable chunk * size to get adequate performance. */ static yajl_tok yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset, const unsigned char ** outBuf, size_t * outLen); typedef enum { yajl_lex_e_ok = 0, yajl_lex_string_invalid_utf8, yajl_lex_string_invalid_escaped_char, yajl_lex_string_invalid_json_char, yajl_lex_string_invalid_hex_char, yajl_lex_invalid_char, yajl_lex_invalid_string, yajl_lex_missing_integer_after_decimal, yajl_lex_missing_integer_after_exponent, yajl_lex_missing_integer_after_minus, yajl_lex_unallowed_comment } yajl_lex_error; static const char * yajl_lex_error_to_string(yajl_lex_error error); /** allows access to more specific information about the lexical * error when yajl_lex_lex returns yajl_tok_error. */ static yajl_lex_error yajl_lex_get_error(yajl_lexer lexer); typedef enum { yajl_state_start = 0, yajl_state_parse_complete, yajl_state_parse_error, yajl_state_lexical_error, yajl_state_map_start, yajl_state_map_sep, yajl_state_map_need_val, yajl_state_map_got_val, yajl_state_map_need_key, yajl_state_array_start, yajl_state_array_got_val, yajl_state_array_need_val, yajl_state_got_value, } yajl_state; struct yajl_handle_t { const yajl_callbacks * callbacks; void * ctx; yajl_lexer lexer; const char * parseError; /* the number of bytes consumed from the last client buffer, * in the case of an error this will be an error offset, in the * case of an error this can be used as the error offset */ size_t bytesConsumed; /* temporary storage for decoded strings */ yajl_buf decodeBuf; /* a stack of states. access with yajl_state_XXX routines */ yajl_bytestack stateStack; /* memory allocation routines */ yajl_alloc_funcs alloc; /* bitfield */ unsigned int flags; }; static yajl_status yajl_do_parse(yajl_handle handle, const unsigned char * jsonText, size_t jsonTextLen); static yajl_status yajl_do_finish(yajl_handle handle); static unsigned char * yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen, int verbose); /* A little built in integer parsing routine with the same semantics as strtol * that's unaffected by LOCALE. */ static long long yajl_parse_integer(const unsigned char *number, unsigned int length); #ifdef __cplusplus } #endif #endif /* YAJL_ALL_H */ whitedb-0.7.3/json/Makefile.am0000644000175000001440000000017612237372400013075 00000000000000# # - - - - json parser sources - - - noinst_LTLIBRARIES = libjson.la libjson_la_SOURCES = yajl_api.h yajl_all.h yajl_all.c whitedb-0.7.3/json/yajl_all.c0000644000175000001440000020563212421471034012776 00000000000000/* * Copyright (c) 2007-2011, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include "yajl_api.h" #include "yajl_all.h" #define YAJL_BUF_INIT_SIZE 2048 /* There seem to be some environments where long long is supported but * LLONG_MAX and LLONG_MIN are not defined. This is a safe workaround * (parsing large integers may break however). */ #ifndef LLONG_MAX #define LLONG_MAX LONG_MAX #define LLONG_MIN LONG_MIN #endif #ifdef _WIN32 #define snprintf(s, sz, f, ...) _snprintf_s(s, sz+1, sz, f, ## __VA_ARGS__) #endif struct yajl_buf_t { size_t len; size_t used; unsigned char * data; yajl_alloc_funcs * alloc; }; typedef enum { yajl_gen_start, yajl_gen_map_start, yajl_gen_map_key, yajl_gen_map_val, yajl_gen_array_start, yajl_gen_in_array, yajl_gen_complete, yajl_gen_error } yajl_gen_state; struct yajl_gen_t { unsigned int flags; unsigned int depth; const char * indentString; yajl_gen_state state[YAJL_MAX_DEPTH]; yajl_print_t print; void * ctx; /* yajl_buf */ /* memory allocation routines */ yajl_alloc_funcs alloc; }; struct yajl_lexer_t { /* the overal line and char offset into the data */ size_t lineOff; size_t charOff; /* error */ yajl_lex_error error; /* a input buffer to handle the case where a token is spread over * multiple chunks */ yajl_buf buf; /* in the case where we have data in the lexBuf, bufOff holds * the current offset into the lexBuf. */ size_t bufOff; /* are we using the lex buf? */ unsigned int bufInUse; /* shall we allow comments? */ unsigned int allowComments; /* shall we validate utf8 inside strings? */ unsigned int validateUTF8; yajl_alloc_funcs * alloc; }; static void * yajl_internal_malloc(void *ctx, size_t sz) { (void)ctx; return malloc(sz); } static void * yajl_internal_realloc(void *ctx, void * previous, size_t sz) { (void)ctx; return realloc(previous, sz); } static void yajl_internal_free(void *ctx, void * ptr) { (void)ctx; free(ptr); } static void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf) { yaf->malloc = yajl_internal_malloc; yaf->free = yajl_internal_free; yaf->realloc = yajl_internal_realloc; yaf->ctx = NULL; } static void yajl_buf_ensure_available(yajl_buf buf, size_t want) { size_t need; assert(buf != NULL); /* first call */ if (buf->data == NULL) { buf->len = YAJL_BUF_INIT_SIZE; buf->data = (unsigned char *) YA_MALLOC(buf->alloc, buf->len); buf->data[0] = 0; } need = buf->len; while (want >= (need - buf->used)) need <<= 1; if (need != buf->len) { buf->data = (unsigned char *) YA_REALLOC(buf->alloc, buf->data, need); buf->len = need; } } static yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc) { yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t)); memset((void *) b, 0, sizeof(struct yajl_buf_t)); b->alloc = alloc; return b; } static void yajl_buf_free(yajl_buf buf) { assert(buf != NULL); if (buf->data) YA_FREE(buf->alloc, buf->data); YA_FREE(buf->alloc, buf); } static void yajl_buf_append(yajl_buf buf, const void * data, size_t len) { yajl_buf_ensure_available(buf, len); if (len > 0) { assert(data != NULL); memcpy(buf->data + buf->used, data, len); buf->used += len; buf->data[buf->used] = 0; } } static void yajl_buf_clear(yajl_buf buf) { buf->used = 0; if (buf->data) buf->data[buf->used] = 0; } static const unsigned char * yajl_buf_data(yajl_buf buf) { return buf->data; } static size_t yajl_buf_len(yajl_buf buf) { return buf->used; } const char * yajl_status_to_string(yajl_status stat) { const char * statStr = "unknown"; switch (stat) { case yajl_status_ok: statStr = "ok, no error"; break; case yajl_status_client_canceled: statStr = "client canceled parse"; break; case yajl_status_error: statStr = "parse error"; break; } return statStr; } yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx) { yajl_handle hand = NULL; yajl_alloc_funcs afsBuffer; /* first order of business is to set up memory allocation routines */ if (afs != NULL) { if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL) { return NULL; } } else { yajl_set_default_alloc_funcs(&afsBuffer); afs = &afsBuffer; } hand = (yajl_handle) YA_MALLOC(afs, sizeof(struct yajl_handle_t)); /* copy in pointers to allocation routines */ memcpy((void *) &(hand->alloc), (void *) afs, sizeof(yajl_alloc_funcs)); hand->callbacks = callbacks; hand->ctx = ctx; hand->lexer = NULL; hand->bytesConsumed = 0; hand->decodeBuf = yajl_buf_alloc(&(hand->alloc)); hand->flags = 0; yajl_bs_init(hand->stateStack, &(hand->alloc)); yajl_bs_push(hand->stateStack, yajl_state_start); return hand; } int yajl_config(yajl_handle h, yajl_option opt, ...) { int rv = 1; va_list ap; va_start(ap, opt); switch(opt) { case yajl_allow_comments: case yajl_dont_validate_strings: case yajl_allow_trailing_garbage: case yajl_allow_multiple_values: case yajl_allow_partial_values: if (va_arg(ap, int)) h->flags |= opt; else h->flags &= ~opt; break; default: rv = 0; } va_end(ap); return rv; } void yajl_free(yajl_handle handle) { yajl_bs_free(handle->stateStack); yajl_buf_free(handle->decodeBuf); if (handle->lexer) { yajl_lex_free(handle->lexer); handle->lexer = NULL; } YA_FREE(&(handle->alloc), handle); } yajl_status yajl_parse(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen) { yajl_status status; /* lazy allocation of the lexer */ if (hand->lexer == NULL) { hand->lexer = yajl_lex_alloc(&(hand->alloc), hand->flags & yajl_allow_comments, !(hand->flags & yajl_dont_validate_strings)); } status = yajl_do_parse(hand, jsonText, jsonTextLen); return status; } yajl_status yajl_complete_parse(yajl_handle hand) { /* The lexer is lazy allocated in the first call to parse. if parse is * never called, then no data was provided to parse at all. This is a * "premature EOF" error unless yajl_allow_partial_values is specified. * allocating the lexer now is the simplest possible way to handle this * case while preserving all the other semantics of the parser * (multiple values, partial values, etc). */ if (hand->lexer == NULL) { hand->lexer = yajl_lex_alloc(&(hand->alloc), hand->flags & yajl_allow_comments, !(hand->flags & yajl_dont_validate_strings)); } return yajl_do_finish(hand); } unsigned char * yajl_get_error(yajl_handle hand, int verbose, const unsigned char * jsonText, size_t jsonTextLen) { return yajl_render_error_string(hand, jsonText, jsonTextLen, verbose); } size_t yajl_get_bytes_consumed(yajl_handle hand) { if (!hand) return 0; else return hand->bytesConsumed; } void yajl_free_error(yajl_handle hand, unsigned char * str) { /* use memory allocation functions if set */ YA_FREE(&(hand->alloc), str); } static void CharToHex(unsigned char c, char * hexBuf) { const char * hexchar = "0123456789ABCDEF"; hexBuf[0] = hexchar[c >> 4]; hexBuf[1] = hexchar[c & 0x0F]; } static void yajl_string_encode(const yajl_print_t print, void * ctx, const unsigned char * str, size_t len, int escape_solidus) { size_t beg = 0; size_t end = 0; char hexBuf[7]; hexBuf[0] = '\\'; hexBuf[1] = 'u'; hexBuf[2] = '0'; hexBuf[3] = '0'; hexBuf[6] = 0; while (end < len) { const char * escaped = NULL; switch (str[end]) { case '\r': escaped = "\\r"; break; case '\n': escaped = "\\n"; break; case '\\': escaped = "\\\\"; break; /* it is not required to escape a solidus in JSON: * read sec. 2.5: http://www.ietf.org/rfc/rfc4627.txt * specifically, this production from the grammar: * unescaped = %x20-21 / %x23-5B / %x5D-10FFFF */ case '/': if (escape_solidus) escaped = "\\/"; break; case '"': escaped = "\\\""; break; case '\f': escaped = "\\f"; break; case '\b': escaped = "\\b"; break; case '\t': escaped = "\\t"; break; default: if ((unsigned char) str[end] < 32) { CharToHex(str[end], hexBuf + 4); escaped = hexBuf; } break; } if (escaped != NULL) { print(ctx, (const char *) (str + beg), end - beg); print(ctx, escaped, (unsigned int)strlen(escaped)); beg = ++end; } else { ++end; } } print(ctx, (const char *) (str + beg), end - beg); } static void hexToDigit(unsigned int * val, const unsigned char * hex) { unsigned int i; for (i=0;i<4;i++) { unsigned char c = hex[i]; if (c >= 'A') c = (c & ~0x20) - 7; c -= '0'; assert(!(c & 0xF0)); *val = (*val << 4) | c; } } static void Utf32toUtf8(unsigned int codepoint, char * utf8Buf) { if (codepoint < 0x80) { utf8Buf[0] = (char) codepoint; utf8Buf[1] = 0; } else if (codepoint < 0x0800) { utf8Buf[0] = (char) ((codepoint >> 6) | 0xC0); utf8Buf[1] = (char) ((codepoint & 0x3F) | 0x80); utf8Buf[2] = 0; } else if (codepoint < 0x10000) { utf8Buf[0] = (char) ((codepoint >> 12) | 0xE0); utf8Buf[1] = (char) (((codepoint >> 6) & 0x3F) | 0x80); utf8Buf[2] = (char) ((codepoint & 0x3F) | 0x80); utf8Buf[3] = 0; } else if (codepoint < 0x200000) { utf8Buf[0] =(char)((codepoint >> 18) | 0xF0); utf8Buf[1] =(char)(((codepoint >> 12) & 0x3F) | 0x80); utf8Buf[2] =(char)(((codepoint >> 6) & 0x3F) | 0x80); utf8Buf[3] =(char)((codepoint & 0x3F) | 0x80); utf8Buf[4] = 0; } else { utf8Buf[0] = '?'; utf8Buf[1] = 0; } } static void yajl_string_decode(yajl_buf buf, const unsigned char * str, size_t len) { size_t beg = 0; size_t end = 0; while (end < len) { if (str[end] == '\\') { char utf8Buf[5]; const char * unescaped = "?"; yajl_buf_append(buf, str + beg, end - beg); switch (str[++end]) { case 'r': unescaped = "\r"; break; case 'n': unescaped = "\n"; break; case '\\': unescaped = "\\"; break; case '/': unescaped = "/"; break; case '"': unescaped = "\""; break; case 'f': unescaped = "\f"; break; case 'b': unescaped = "\b"; break; case 't': unescaped = "\t"; break; case 'u': { unsigned int codepoint = 0; hexToDigit(&codepoint, str + ++end); end+=3; /* check if this is a surrogate */ if ((codepoint & 0xFC00) == 0xD800) { end++; if (str[end] == '\\' && str[end + 1] == 'u') { unsigned int surrogate = 0; hexToDigit(&surrogate, str + end + 2); codepoint = (((codepoint & 0x3F) << 10) | ((((codepoint >> 6) & 0xF) + 1) << 16) | (surrogate & 0x3FF)); end += 5; } else { unescaped = "?"; break; } } Utf32toUtf8(codepoint, utf8Buf); unescaped = utf8Buf; if (codepoint == 0) { yajl_buf_append(buf, unescaped, 1); beg = ++end; continue; } break; } default: assert("this should never happen" == NULL); } yajl_buf_append(buf, unescaped, (unsigned int)strlen(unescaped)); beg = ++end; } else { end++; } } yajl_buf_append(buf, str + beg, end - beg); } #define ADV_PTR s++; if (!(len--)) return 0; static int yajl_string_validate_utf8(const unsigned char * s, size_t len) { if (!len) return 1; if (!s) return 0; while (len--) { /* single byte */ if (*s <= 0x7f) { /* noop */ } /* two byte */ else if ((*s >> 5) == 0x6) { ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; } /* three byte */ else if ((*s >> 4) == 0x0e) { ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; } /* four byte */ else if ((*s >> 3) == 0x1e) { ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; } else { return 0; } s++; } return 1; } int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...) { int rv = 1; va_list ap; va_start(ap, opt); switch(opt) { case yajl_gen_beautify: case yajl_gen_validate_utf8: case yajl_gen_escape_solidus: if (va_arg(ap, int)) g->flags |= opt; else g->flags &= ~opt; break; case yajl_gen_indent_string: { const char *indent = va_arg(ap, const char *); g->indentString = indent; for (; *indent; indent++) { if (*indent != '\n' && *indent != '\v' && *indent != '\f' && *indent != '\t' && *indent != '\r' && *indent != ' ') { g->indentString = NULL; rv = 0; } } break; } case yajl_gen_print_callback: yajl_buf_free(g->ctx); g->print = va_arg(ap, const yajl_print_t); g->ctx = va_arg(ap, void *); break; default: rv = 0; } va_end(ap); return rv; } yajl_gen yajl_gen_alloc(const yajl_alloc_funcs * afs) { yajl_gen g = NULL; yajl_alloc_funcs afsBuffer; /* first order of business is to set up memory allocation routines */ if (afs != NULL) { if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL) { return NULL; } } else { yajl_set_default_alloc_funcs(&afsBuffer); afs = &afsBuffer; } g = (yajl_gen) YA_MALLOC(afs, sizeof(struct yajl_gen_t)); if (!g) return NULL; memset((void *) g, 0, sizeof(struct yajl_gen_t)); /* copy in pointers to allocation routines */ memcpy((void *) &(g->alloc), (void *) afs, sizeof(yajl_alloc_funcs)); g->print = (yajl_print_t)&yajl_buf_append; g->ctx = yajl_buf_alloc(&(g->alloc)); g->indentString = " "; return g; } void yajl_gen_free(yajl_gen g) { if (g->print == (yajl_print_t)&yajl_buf_append) yajl_buf_free((yajl_buf)g->ctx); YA_FREE(&(g->alloc), g); } #define INSERT_SEP \ if (g->state[g->depth] == yajl_gen_map_key || \ g->state[g->depth] == yajl_gen_in_array) { \ g->print(g->ctx, ",", 1); \ if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); \ } else if (g->state[g->depth] == yajl_gen_map_val) { \ g->print(g->ctx, ":", 1); \ if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, " ", 1); \ } #define INSERT_WHITESPACE \ if ((g->flags & yajl_gen_beautify)) { \ if (g->state[g->depth] != yajl_gen_map_val) { \ unsigned int _i; \ for (_i=0;_idepth;_i++) \ g->print(g->ctx, \ g->indentString, \ (unsigned int)strlen(g->indentString)); \ } \ } #define ENSURE_NOT_KEY \ if (g->state[g->depth] == yajl_gen_map_key || \ g->state[g->depth] == yajl_gen_map_start) { \ return yajl_gen_keys_must_be_strings; \ } \ /* check that we're not complete, or in error state. in a valid state * to be generating */ #define ENSURE_VALID_STATE \ if (g->state[g->depth] == yajl_gen_error) { \ return yajl_gen_in_error_state;\ } else if (g->state[g->depth] == yajl_gen_complete) { \ return yajl_gen_generation_complete; \ } #define INCREMENT_DEPTH \ if (++(g->depth) >= YAJL_MAX_DEPTH) return yajl_max_depth_exceeded; /* XXX: this is hairy. Shouldn't it check for 0? */ #define DECREMENT_DEPTH \ if (--(g->depth) >= YAJL_MAX_DEPTH) return yajl_max_depth_exceeded; #define APPENDED_ATOM \ switch (g->state[g->depth]) { \ case yajl_gen_start: \ g->state[g->depth] = yajl_gen_complete; \ break; \ case yajl_gen_map_start: \ case yajl_gen_map_key: \ g->state[g->depth] = yajl_gen_map_val; \ break; \ case yajl_gen_array_start: \ g->state[g->depth] = yajl_gen_in_array; \ break; \ case yajl_gen_map_val: \ g->state[g->depth] = yajl_gen_map_key; \ break; \ default: \ break; \ } \ #define FINAL_NEWLINE \ if ((g->flags & yajl_gen_beautify) && g->state[g->depth] == yajl_gen_complete) \ g->print(g->ctx, "\n", 1); yajl_gen_status yajl_gen_integer(yajl_gen g, long long int number) { char i[32]; ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; snprintf(i, 31, "%lld", number); g->print(g->ctx, i, (unsigned int)strlen(i)); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } #if defined(_WIN32) || defined(WIN32) #include #define isnan _isnan #define isinf !_finite #endif yajl_gen_status yajl_gen_double(yajl_gen g, double number) { char i[32]; ENSURE_VALID_STATE; ENSURE_NOT_KEY; if (isnan(number) || isinf(number)) return yajl_gen_invalid_number; INSERT_SEP; INSERT_WHITESPACE; snprintf(i, 31, "%.20g", number); if (strspn(i, "0123456789-") == strlen(i)) { #ifdef _WIN32 strcat_s(i, 32, ".0"); #else strcat(i, ".0"); #endif } g->print(g->ctx, i, (unsigned int)strlen(i)); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_number(yajl_gen g, const char * s, size_t l) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, s, l); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_string(yajl_gen g, const unsigned char * str, size_t len) { // if validation is enabled, check that the string is valid utf8 // XXX: This checking could be done a little faster, in the same pass as // the string encoding if (g->flags & yajl_gen_validate_utf8) { if (!yajl_string_validate_utf8(str, len)) { return yajl_gen_invalid_string; } } ENSURE_VALID_STATE; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, "\"", 1); yajl_string_encode(g->print, g->ctx, str, len, g->flags & yajl_gen_escape_solidus); g->print(g->ctx, "\"", 1); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_null(yajl_gen g) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, "null", strlen("null")); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_bool(yajl_gen g, int boolean) { const char * val = boolean ? "true" : "false"; ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, val, (unsigned int)strlen(val)); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_map_open(yajl_gen g) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; INCREMENT_DEPTH; g->state[g->depth] = yajl_gen_map_start; g->print(g->ctx, "{", 1); if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_map_close(yajl_gen g) { ENSURE_VALID_STATE; DECREMENT_DEPTH; if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); APPENDED_ATOM; INSERT_WHITESPACE; g->print(g->ctx, "}", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_array_open(yajl_gen g) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; INCREMENT_DEPTH; g->state[g->depth] = yajl_gen_array_start; g->print(g->ctx, "[", 1); if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_array_close(yajl_gen g) { ENSURE_VALID_STATE; DECREMENT_DEPTH; if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); APPENDED_ATOM; INSERT_WHITESPACE; g->print(g->ctx, "]", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_get_buf(yajl_gen g, const unsigned char ** buf, size_t * len) { if (g->print != (yajl_print_t)&yajl_buf_append) return yajl_gen_no_buf; *buf = yajl_buf_data((yajl_buf)g->ctx); *len = yajl_buf_len((yajl_buf)g->ctx); return yajl_gen_status_ok; } void yajl_gen_clear(yajl_gen g) { if (g->print == (yajl_print_t)&yajl_buf_append) yajl_buf_clear((yajl_buf)g->ctx); } #ifdef YAJL_LEXER_DEBUG static const char * tokToStr(yajl_tok tok) { switch (tok) { case yajl_tok_bool: return "bool"; case yajl_tok_colon: return "colon"; case yajl_tok_comma: return "comma"; case yajl_tok_eof: return "eof"; case yajl_tok_error: return "error"; case yajl_tok_left_brace: return "brace"; case yajl_tok_left_bracket: return "bracket"; case yajl_tok_null: return "null"; case yajl_tok_integer: return "integer"; case yajl_tok_double: return "double"; case yajl_tok_right_brace: return "brace"; case yajl_tok_right_bracket: return "bracket"; case yajl_tok_string: return "string"; case yajl_tok_string_with_escapes: return "string_with_escapes"; } return "unknown"; } #endif /* Impact of the stream parsing feature on the lexer: * * YAJL support stream parsing. That is, the ability to parse the first * bits of a chunk of JSON before the last bits are available (still on * the network or disk). This makes the lexer more complex. The * responsibility of the lexer is to handle transparently the case where * a chunk boundary falls in the middle of a token. This is * accomplished is via a buffer and a character reading abstraction. * * Overview of implementation * * When we lex to end of input string before end of token is hit, we * copy all of the input text composing the token into our lexBuf. * * Every time we read a character, we do so through the readChar function. * readChar's responsibility is to handle pulling all chars from the buffer * before pulling chars from input text */ #define readChar(lxr, txt, off) \ (((lxr)->bufInUse && yajl_buf_len((lxr)->buf) && lxr->bufOff < yajl_buf_len((lxr)->buf)) ? \ (*((const unsigned char *) yajl_buf_data((lxr)->buf) + ((lxr)->bufOff)++)) : \ ((txt)[(*(off))++])) #define unreadChar(lxr, off) ((*(off) > 0) ? (*(off))-- : ((lxr)->bufOff--)) static yajl_lexer yajl_lex_alloc(yajl_alloc_funcs * alloc, unsigned int allowComments, unsigned int validateUTF8) { yajl_lexer lxr = (yajl_lexer) YA_MALLOC(alloc, sizeof(struct yajl_lexer_t)); memset((void *) lxr, 0, sizeof(struct yajl_lexer_t)); lxr->buf = yajl_buf_alloc(alloc); lxr->allowComments = allowComments; lxr->validateUTF8 = validateUTF8; lxr->alloc = alloc; return lxr; } static void yajl_lex_free(yajl_lexer lxr) { yajl_buf_free(lxr->buf); YA_FREE(lxr->alloc, lxr); return; } /* a lookup table which lets us quickly determine three things: * VEC - valid escaped control char * note. the solidus '/' may be escaped or not. * IJC - invalid json char * VHC - valid hex char * NFP - needs further processing (from a string scanning perspective) * NUC - needs utf8 checking when enabled (from a string scanning perspective) */ #define VEC 0x01 #define IJC 0x02 #define VHC 0x04 #define NFP 0x08 #define NUC 0x10 static const char charLookupTable[256] = { /*00*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*08*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*10*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*18*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*20*/ 0 , 0 , NFP|VEC|IJC, 0 , 0 , 0 , 0 , 0 , /*28*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , VEC , /*30*/ VHC , VHC , VHC , VHC , VHC , VHC , VHC , VHC , /*38*/ VHC , VHC , 0 , 0 , 0 , 0 , 0 , 0 , /*40*/ 0 , VHC , VHC , VHC , VHC , VHC , VHC , 0 , /*48*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /*50*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /*58*/ 0 , 0 , 0 , 0 , NFP|VEC|IJC, 0 , 0 , 0 , /*60*/ 0 , VHC , VEC|VHC, VHC , VHC , VHC , VEC|VHC, 0 , /*68*/ 0 , 0 , 0 , 0 , 0 , 0 , VEC , 0 , /*70*/ 0 , 0 , VEC , 0 , VEC , 0 , 0 , 0 , /*78*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC }; /** process a variable length utf8 encoded codepoint. * * returns: * yajl_tok_string - if valid utf8 char was parsed and offset was * advanced * yajl_tok_eof - if end of input was hit before validation could * complete * yajl_tok_error - if invalid utf8 was encountered * * NOTE: on error the offset will point to the first char of the * invalid utf8 */ #define UTF8_CHECK_EOF if (*offset >= jsonTextLen) { return yajl_tok_eof; } static yajl_tok yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset, unsigned char curChar) { if (curChar <= 0x7f) { /* single byte */ return yajl_tok_string; } else if ((curChar >> 5) == 0x6) { /* two byte */ UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) return yajl_tok_string; } else if ((curChar >> 4) == 0x0e) { /* three byte */ UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) { UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) return yajl_tok_string; } } else if ((curChar >> 3) == 0x1e) { /* four byte */ UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) { UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) { UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) return yajl_tok_string; } } } return yajl_tok_error; } /* lex a string. input is the lexer, pointer to beginning of * json text, and start of string (offset). * a token is returned which has the following meanings: * yajl_tok_string: lex of string was successful. offset points to * terminating '"'. * yajl_tok_eof: end of text was encountered before we could complete * the lex. * yajl_tok_error: embedded in the string were unallowable chars. offset * points to the offending char */ #define STR_CHECK_EOF \ if (*offset >= jsonTextLen) { \ tok = yajl_tok_eof; \ goto finish_string_lex; \ } /** scan a string for interesting characters that might need further * review. return the number of chars that are uninteresting and can * be skipped. * (lth) hi world, any thoughts on how to make this routine faster? */ static size_t yajl_string_scan(const unsigned char * buf, size_t len, int utf8check) { unsigned char mask = IJC|NFP|(utf8check ? NUC : 0); size_t skip = 0; while (skip < len && !(charLookupTable[*buf] & mask)) { skip++; buf++; } return skip; } static yajl_tok yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset) { yajl_tok tok = yajl_tok_error; int hasEscapes = 0; for (;;) { unsigned char curChar; /* now jump into a faster scanning routine to skip as much * of the buffers as possible */ { const unsigned char * p; size_t len; if ((lexer->bufInUse && yajl_buf_len(lexer->buf) && lexer->bufOff < yajl_buf_len(lexer->buf))) { p = ((const unsigned char *) yajl_buf_data(lexer->buf) + (lexer->bufOff)); len = yajl_buf_len(lexer->buf) - lexer->bufOff; lexer->bufOff += yajl_string_scan(p, len, lexer->validateUTF8); } else if (*offset < jsonTextLen) { p = jsonText + *offset; len = jsonTextLen - *offset; *offset += yajl_string_scan(p, len, lexer->validateUTF8); } } STR_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); /* quote terminates */ if (curChar == '"') { tok = yajl_tok_string; break; } /* backslash escapes a set of control chars, */ else if (curChar == '\\') { hasEscapes = 1; STR_CHECK_EOF; /* special case \u */ curChar = readChar(lexer, jsonText, offset); if (curChar == 'u') { unsigned int i = 0; for (i=0;i<4;i++) { STR_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if (!(charLookupTable[curChar] & VHC)) { /* back up to offending char */ unreadChar(lexer, offset); lexer->error = yajl_lex_string_invalid_hex_char; goto finish_string_lex; } } } else if (!(charLookupTable[curChar] & VEC)) { /* back up to offending char */ unreadChar(lexer, offset); lexer->error = yajl_lex_string_invalid_escaped_char; goto finish_string_lex; } } /* when not validating UTF8 it's a simple table lookup to determine * if the present character is invalid */ else if(charLookupTable[curChar] & IJC) { /* back up to offending char */ unreadChar(lexer, offset); lexer->error = yajl_lex_string_invalid_json_char; goto finish_string_lex; } /* when in validate UTF8 mode we need to do some extra work */ else if (lexer->validateUTF8) { yajl_tok t = yajl_lex_utf8_char(lexer, jsonText, jsonTextLen, offset, curChar); if (t == yajl_tok_eof) { tok = yajl_tok_eof; goto finish_string_lex; } else if (t == yajl_tok_error) { lexer->error = yajl_lex_string_invalid_utf8; goto finish_string_lex; } } /* accept it, and move on */ } finish_string_lex: /* tell our buddy, the parser, wether he needs to process this string * again */ if (hasEscapes && tok == yajl_tok_string) { tok = yajl_tok_string_with_escapes; } return tok; } #define RETURN_IF_EOF if (*offset >= jsonTextLen) return yajl_tok_eof; static yajl_tok yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset) { /** XXX: numbers are the only entities in json that we must lex * _beyond_ in order to know that they are complete. There * is an ambiguous case for integers at EOF. */ unsigned char c; yajl_tok tok = yajl_tok_integer; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); /* optional leading minus */ if (c == '-') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } /* a single zero, or a series of integers */ if (c == '0') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } else if (c >= '1' && c <= '9') { do { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } while (c >= '0' && c <= '9'); } else { unreadChar(lexer, offset); lexer->error = yajl_lex_missing_integer_after_minus; return yajl_tok_error; } /* optional fraction (indicates this is floating point) */ if (c == '.') { int numRd = 0; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); while (c >= '0' && c <= '9') { numRd++; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } if (!numRd) { unreadChar(lexer, offset); lexer->error = yajl_lex_missing_integer_after_decimal; return yajl_tok_error; } tok = yajl_tok_double; } /* optional exponent (indicates this is floating point) */ if (c == 'e' || c == 'E') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); /* optional sign */ if (c == '+' || c == '-') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } if (c >= '0' && c <= '9') { do { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } while (c >= '0' && c <= '9'); } else { unreadChar(lexer, offset); lexer->error = yajl_lex_missing_integer_after_exponent; return yajl_tok_error; } tok = yajl_tok_double; } /* we always go "one too far" */ unreadChar(lexer, offset); return tok; } static yajl_tok yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset) { unsigned char c; yajl_tok tok = yajl_tok_comment; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); /* either slash or star expected */ if (c == '/') { /* now we throw away until end of line */ do { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } while (c != '\n'); } else if (c == '*') { /* now we throw away until end of comment */ for (;;) { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); if (c == '*') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); if (c == '/') { break; } else { unreadChar(lexer, offset); } } } } else { lexer->error = yajl_lex_invalid_char; tok = yajl_tok_error; } return tok; } static yajl_tok yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset, const unsigned char ** outBuf, size_t * outLen) { yajl_tok tok = yajl_tok_error; unsigned char c; size_t startOffset = *offset; *outBuf = NULL; *outLen = 0; for (;;) { assert(*offset <= jsonTextLen); if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); switch (c) { case '{': tok = yajl_tok_left_bracket; goto lexed; case '}': tok = yajl_tok_right_bracket; goto lexed; case '[': tok = yajl_tok_left_brace; goto lexed; case ']': tok = yajl_tok_right_brace; goto lexed; case ',': tok = yajl_tok_comma; goto lexed; case ':': tok = yajl_tok_colon; goto lexed; case '\t': case '\n': case '\v': case '\f': case '\r': case ' ': startOffset++; break; case 't': { const char * want = "rue"; do { if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); if (c != *want) { unreadChar(lexer, offset); lexer->error = yajl_lex_invalid_string; tok = yajl_tok_error; goto lexed; } } while (*(++want)); tok = yajl_tok_bool; goto lexed; } case 'f': { const char * want = "alse"; do { if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); if (c != *want) { unreadChar(lexer, offset); lexer->error = yajl_lex_invalid_string; tok = yajl_tok_error; goto lexed; } } while (*(++want)); tok = yajl_tok_bool; goto lexed; } case 'n': { const char * want = "ull"; do { if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); if (c != *want) { unreadChar(lexer, offset); lexer->error = yajl_lex_invalid_string; tok = yajl_tok_error; goto lexed; } } while (*(++want)); tok = yajl_tok_null; goto lexed; } case '"': { tok = yajl_lex_string(lexer, (const unsigned char *) jsonText, jsonTextLen, offset); goto lexed; } case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { /* integer parsing wants to start from the beginning */ unreadChar(lexer, offset); tok = yajl_lex_number(lexer, (const unsigned char *) jsonText, jsonTextLen, offset); goto lexed; } case '/': /* hey, look, a probable comment! If comments are disabled * it's an error. */ if (!lexer->allowComments) { unreadChar(lexer, offset); lexer->error = yajl_lex_unallowed_comment; tok = yajl_tok_error; goto lexed; } /* if comments are enabled, then we should try to lex * the thing. possible outcomes are * - successful lex (tok_comment, which means continue), * - malformed comment opening (slash not followed by * '*' or '/') (tok_error) * - eof hit. (tok_eof) */ tok = yajl_lex_comment(lexer, (const unsigned char *) jsonText, jsonTextLen, offset); if (tok == yajl_tok_comment) { /* "error" is silly, but that's the initial * state of tok. guilty until proven innocent. */ tok = yajl_tok_error; yajl_buf_clear(lexer->buf); lexer->bufInUse = 0; startOffset = *offset; break; } /* hit error or eof, bail */ goto lexed; default: lexer->error = yajl_lex_invalid_char; tok = yajl_tok_error; goto lexed; } } lexed: /* need to append to buffer if the buffer is in use or * if it's an EOF token */ if (tok == yajl_tok_eof || lexer->bufInUse) { if (!lexer->bufInUse) yajl_buf_clear(lexer->buf); lexer->bufInUse = 1; yajl_buf_append(lexer->buf, jsonText + startOffset, *offset - startOffset); lexer->bufOff = 0; if (tok != yajl_tok_eof) { *outBuf = yajl_buf_data(lexer->buf); *outLen = yajl_buf_len(lexer->buf); lexer->bufInUse = 0; } } else if (tok != yajl_tok_error) { *outBuf = jsonText + startOffset; *outLen = *offset - startOffset; } /* special case for strings. skip the quotes. */ if (tok == yajl_tok_string || tok == yajl_tok_string_with_escapes) { assert(*outLen >= 2); (*outBuf)++; *outLen -= 2; } #ifdef YAJL_LEXER_DEBUG if (tok == yajl_tok_error) { printf("lexical error: %s\n", yajl_lex_error_to_string(yajl_lex_get_error(lexer))); } else if (tok == yajl_tok_eof) { printf("EOF hit\n"); } else { printf("lexed %s: '", tokToStr(tok)); fwrite(*outBuf, 1, *outLen, stdout); printf("'\n"); } #endif return tok; } static const char * yajl_lex_error_to_string(yajl_lex_error error) { switch (error) { case yajl_lex_e_ok: return "ok, no error"; case yajl_lex_string_invalid_utf8: return "invalid bytes in UTF8 string."; case yajl_lex_string_invalid_escaped_char: return "inside a string, '\\' occurs before a character " "which it may not."; case yajl_lex_string_invalid_json_char: return "invalid character inside string."; case yajl_lex_string_invalid_hex_char: return "invalid (non-hex) character occurs after '\\u' inside " "string."; case yajl_lex_invalid_char: return "invalid char in json text."; case yajl_lex_invalid_string: return "invalid string in json text."; case yajl_lex_missing_integer_after_exponent: return "malformed number, a digit is required after the exponent."; case yajl_lex_missing_integer_after_decimal: return "malformed number, a digit is required after the " "decimal point."; case yajl_lex_missing_integer_after_minus: return "malformed number, a digit is required after the " "minus sign."; case yajl_lex_unallowed_comment: return "probable comment found in input text, comments are " "not enabled."; } return "unknown error code"; } /** allows access to more specific information about the lexical * error when yajl_lex_lex returns yajl_tok_error. */ static yajl_lex_error yajl_lex_get_error(yajl_lexer lexer) { if (lexer == NULL) return (yajl_lex_error) -1; return lexer->error; } #define MAX_VALUE_TO_MULTIPLY ((LLONG_MAX / 10) + (LLONG_MAX % 10)) /* same semantics as strtol */ static long long yajl_parse_integer(const unsigned char *number, unsigned int length) { long long ret = 0; long sign = 1; const unsigned char *pos = number; if (*pos == '-') { pos++; sign = -1; } if (*pos == '+') { pos++; } while (pos < number + length) { if ( ret > MAX_VALUE_TO_MULTIPLY ) { errno = ERANGE; return sign == 1 ? LLONG_MAX : LLONG_MIN; } ret *= 10; if (LLONG_MAX - ret < (*pos - '0')) { errno = ERANGE; return sign == 1 ? LLONG_MAX : LLONG_MIN; } if (*pos < '0' || *pos > '9') { errno = ERANGE; return sign == 1 ? LLONG_MAX : LLONG_MIN; } ret += (*pos++ - '0'); } return sign * ret; } static unsigned char * yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen, int verbose) { size_t offset = hand->bytesConsumed; unsigned char * str; const char * errorType = NULL; const char * errorText = NULL; char text[72]; const char * arrow = " (right here) ------^\n"; if (yajl_bs_current(hand->stateStack) == yajl_state_parse_error) { errorType = "parse"; errorText = hand->parseError; } else if (yajl_bs_current(hand->stateStack) == yajl_state_lexical_error) { errorType = "lexical"; errorText = yajl_lex_error_to_string(yajl_lex_get_error(hand->lexer)); } else { errorType = "unknown"; } { size_t memneeded = 0; memneeded += strlen(errorType); memneeded += strlen(" error"); if (errorText != NULL) { memneeded += strlen(": "); memneeded += strlen(errorText); } str = (unsigned char *) YA_MALLOC(&(hand->alloc), memneeded + 2); if (!str) return NULL; str[0] = 0; #ifdef _WIN32 strcat_s((char *) str, memneeded+2, errorType); strcat_s((char *) str, memneeded+2, " error"); #else strcat((char *) str, errorType); strcat((char *) str, " error"); #endif if (errorText != NULL) { #ifdef _WIN32 strcat_s((char *) str, memneeded+2, ": "); strcat_s((char *) str, memneeded+2, errorText); #else strcat((char *) str, ": "); strcat((char *) str, errorText); #endif } #ifdef _WIN32 strcat_s((char *) str, memneeded+2, "\n"); #else strcat((char *) str, "\n"); #endif } /* now we append as many spaces as needed to make sure the error * falls at char 41, if verbose was specified */ if (verbose) { size_t start, end, i; size_t spacesNeeded; spacesNeeded = (offset < 30 ? 40 - offset : 10); start = (offset >= 30 ? offset - 30 : 0); end = (offset + 30 > jsonTextLen ? jsonTextLen : offset + 30); for (i=0;ialloc), memneeded); if (newStr) { newStr[0] = 0; #ifdef _WIN32 strcat_s((char *) newStr, memneeded, (char *) str); strcat_s((char *) newStr, memneeded, text); strcat_s((char *) newStr, memneeded, arrow); #else strcat((char *) newStr, (char *) str); strcat((char *) newStr, text); strcat((char *) newStr, arrow); #endif } YA_FREE(&(hand->alloc), str); str = (unsigned char *) newStr; } } return str; } /* check for client cancelation */ #define _CC_CHK(x) \ if (!(x)) { \ yajl_bs_set(hand->stateStack, yajl_state_parse_error); \ hand->parseError = \ "client cancelled parse via callback return value"; \ return yajl_status_client_canceled; \ } static yajl_status yajl_do_finish(yajl_handle hand) { yajl_status stat; stat = yajl_do_parse(hand,(const unsigned char *) " ",1); if (stat != yajl_status_ok) return stat; switch(yajl_bs_current(hand->stateStack)) { case yajl_state_parse_error: case yajl_state_lexical_error: return yajl_status_error; case yajl_state_got_value: case yajl_state_parse_complete: return yajl_status_ok; default: if (!(hand->flags & yajl_allow_partial_values)) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "premature EOF"; return yajl_status_error; } return yajl_status_ok; } } static yajl_status yajl_do_parse(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen) { yajl_tok tok; const unsigned char * buf; size_t bufLen; size_t * offset = &(hand->bytesConsumed); *offset = 0; around_again: switch (yajl_bs_current(hand->stateStack)) { case yajl_state_parse_complete: if (hand->flags & yajl_allow_multiple_values) { yajl_bs_set(hand->stateStack, yajl_state_got_value); goto around_again; } if (!(hand->flags & yajl_allow_trailing_garbage)) { if (*offset != jsonTextLen) { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); if (tok != yajl_tok_eof) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "trailing garbage"; } goto around_again; } } return yajl_status_ok; case yajl_state_lexical_error: case yajl_state_parse_error: return yajl_status_error; case yajl_state_start: case yajl_state_got_value: case yajl_state_map_need_val: case yajl_state_array_need_val: case yajl_state_array_start: { /* for arrays and maps, we advance the state for this * depth, then push the state of the next depth. * If an error occurs during the parsing of the nesting * enitity, the state at this level will not matter. * a state that needs pushing will be anything other * than state_start */ yajl_state stateToPush = yajl_state_start; tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; case yajl_tok_string: if (hand->callbacks && hand->callbacks->yajl_string) { _CC_CHK(hand->callbacks->yajl_string(hand->ctx, buf, bufLen)); } break; case yajl_tok_string_with_escapes: if (hand->callbacks && hand->callbacks->yajl_string) { yajl_buf_clear(hand->decodeBuf); yajl_string_decode(hand->decodeBuf, buf, bufLen); _CC_CHK(hand->callbacks->yajl_string( hand->ctx, yajl_buf_data(hand->decodeBuf), yajl_buf_len(hand->decodeBuf))); } break; case yajl_tok_bool: if (hand->callbacks && hand->callbacks->yajl_boolean) { _CC_CHK(hand->callbacks->yajl_boolean(hand->ctx, *buf == 't')); } break; case yajl_tok_null: if (hand->callbacks && hand->callbacks->yajl_null) { _CC_CHK(hand->callbacks->yajl_null(hand->ctx)); } break; case yajl_tok_left_bracket: if (hand->callbacks && hand->callbacks->yajl_start_map) { _CC_CHK(hand->callbacks->yajl_start_map(hand->ctx)); } stateToPush = yajl_state_map_start; break; case yajl_tok_left_brace: if (hand->callbacks && hand->callbacks->yajl_start_array) { _CC_CHK(hand->callbacks->yajl_start_array(hand->ctx)); } stateToPush = yajl_state_array_start; break; case yajl_tok_integer: if (hand->callbacks) { if (hand->callbacks->yajl_number) { _CC_CHK(hand->callbacks->yajl_number( hand->ctx,(const char *) buf, bufLen)); } else if (hand->callbacks->yajl_integer) { long long int i = 0; errno = 0; i = yajl_parse_integer(buf, bufLen); if ((i == LLONG_MIN || i == LLONG_MAX) && errno == ERANGE) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "integer overflow" ; /* try to restore error offset */ if (*offset >= bufLen) *offset -= bufLen; else *offset = 0; goto around_again; } _CC_CHK(hand->callbacks->yajl_integer(hand->ctx, i)); } } break; case yajl_tok_double: if (hand->callbacks) { if (hand->callbacks->yajl_number) { _CC_CHK(hand->callbacks->yajl_number( hand->ctx, (const char *) buf, bufLen)); } else if (hand->callbacks->yajl_double) { double d = 0.0; yajl_buf_clear(hand->decodeBuf); yajl_buf_append(hand->decodeBuf, buf, bufLen); buf = yajl_buf_data(hand->decodeBuf); errno = 0; d = strtod((char *) buf, NULL); if ((d == HUGE_VAL || d == -HUGE_VAL) && errno == ERANGE) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "numeric (floating point) " "overflow"; /* try to restore error offset */ if (*offset >= bufLen) *offset -= bufLen; else *offset = 0; goto around_again; } _CC_CHK(hand->callbacks->yajl_double(hand->ctx, d)); } } break; case yajl_tok_right_brace: { if (yajl_bs_current(hand->stateStack) == yajl_state_array_start) { if (hand->callbacks && hand->callbacks->yajl_end_array) { _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; } /* intentional fall-through */ } case yajl_tok_colon: case yajl_tok_comma: case yajl_tok_right_bracket: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "unallowed token at this point in JSON text"; goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "invalid token, internal error"; goto around_again; } /* got a value. transition depends on the state we're in. */ { yajl_state s = yajl_bs_current(hand->stateStack); if (s == yajl_state_start || s == yajl_state_got_value) { yajl_bs_set(hand->stateStack, yajl_state_parse_complete); } else if (s == yajl_state_map_need_val) { yajl_bs_set(hand->stateStack, yajl_state_map_got_val); } else { yajl_bs_set(hand->stateStack, yajl_state_array_got_val); } } if (stateToPush != yajl_state_start) { yajl_bs_push(hand->stateStack, stateToPush); } goto around_again; } case yajl_state_map_start: case yajl_state_map_need_key: { /* only difference between these two states is that in * start '}' is valid, whereas in need_key, we've parsed * a comma, and a string key _must_ follow */ tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; case yajl_tok_string_with_escapes: if (hand->callbacks && hand->callbacks->yajl_map_key) { yajl_buf_clear(hand->decodeBuf); yajl_string_decode(hand->decodeBuf, buf, bufLen); buf = yajl_buf_data(hand->decodeBuf); bufLen = yajl_buf_len(hand->decodeBuf); } /* intentional fall-through */ case yajl_tok_string: if (hand->callbacks && hand->callbacks->yajl_map_key) { _CC_CHK(hand->callbacks->yajl_map_key(hand->ctx, buf, bufLen)); } yajl_bs_set(hand->stateStack, yajl_state_map_sep); goto around_again; case yajl_tok_right_bracket: if (yajl_bs_current(hand->stateStack) == yajl_state_map_start) { if (hand->callbacks && hand->callbacks->yajl_end_map) { _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; } default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "invalid object key (must be a string)"; goto around_again; } } case yajl_state_map_sep: { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_colon: yajl_bs_set(hand->stateStack, yajl_state_map_need_val); goto around_again; case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "object key and value must " "be separated by a colon (':')"; goto around_again; } } case yajl_state_map_got_val: { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_right_bracket: if (hand->callbacks && hand->callbacks->yajl_end_map) { _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; case yajl_tok_comma: yajl_bs_set(hand->stateStack, yajl_state_map_need_key); goto around_again; case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "after key and value, inside map, " "I expect ',' or '}'"; /* try to restore error offset */ if (*offset >= bufLen) *offset -= bufLen; else *offset = 0; goto around_again; } } case yajl_state_array_got_val: { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_right_brace: if (hand->callbacks && hand->callbacks->yajl_end_array) { _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; case yajl_tok_comma: yajl_bs_set(hand->stateStack, yajl_state_array_need_val); goto around_again; case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "after array element, I expect ',' or ']'"; goto around_again; } } } abort(); return yajl_status_error; } whitedb-0.7.3/json/yajl_api.h0000644000175000001440000003606412237372400013007 00000000000000/* * Copyright (c) 2007-2011, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef YAJL_API_H #define YAJL_API_H #include #ifdef __cplusplus extern "C" { #endif #define YAJL_MAX_DEPTH 128 #define YAJL_API /** pointer to a malloc function, supporting client overriding memory * allocation routines */ typedef void * (*yajl_malloc_func)(void *ctx, size_t sz); /** pointer to a free function, supporting client overriding memory * allocation routines */ typedef void (*yajl_free_func)(void *ctx, void * ptr); /** pointer to a realloc function which can resize an allocation. */ typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, size_t sz); /** A structure which can be passed to yajl_*_alloc routines to allow the * client to specify memory allocation functions to be used. */ typedef struct { /** pointer to a function that can allocate uninitialized memory */ yajl_malloc_func malloc; /** pointer to a function that can resize memory allocations */ yajl_realloc_func realloc; /** pointer to a function that can free memory allocated using * reallocFunction or mallocFunction */ yajl_free_func free; /** a context pointer that will be passed to above allocation routines */ void * ctx; } yajl_alloc_funcs; /** * \file yajl_parse.h * Interface to YAJL's JSON stream parsing facilities. */ /** error codes returned from this interface */ typedef enum { /** no error was encountered */ yajl_status_ok, /** a client callback returned zero, stopping the parse */ yajl_status_client_canceled, /** An error occured during the parse. Call yajl_get_error for * more information about the encountered error */ yajl_status_error } yajl_status; /** attain a human readable, english, string for an error */ YAJL_API const char * yajl_status_to_string(yajl_status code); /** an opaque handle to a parser */ typedef struct yajl_handle_t * yajl_handle; /** yajl is an event driven parser. this means as json elements are * parsed, you are called back to do something with the data. The * functions in this table indicate the various events for which * you will be called back. Each callback accepts a "context" * pointer, this is a void * that is passed into the yajl_parse * function which the client code may use to pass around context. * * All callbacks return an integer. If non-zero, the parse will * continue. If zero, the parse will be canceled and * yajl_status_client_canceled will be returned from the parse. * * \attention { * A note about the handling of numbers: * * yajl will only convert numbers that can be represented in a * double or a 64 bit (long long) int. All other numbers will * be passed to the client in string form using the yajl_number * callback. Furthermore, if yajl_number is not NULL, it will * always be used to return numbers, that is yajl_integer and * yajl_double will be ignored. If yajl_number is NULL but one * of yajl_integer or yajl_double are defined, parsing of a * number larger than is representable in a double or 64 bit * integer will result in a parse error. * } */ typedef struct { int (* yajl_null)(void * ctx); int (* yajl_boolean)(void * ctx, int boolVal); int (* yajl_integer)(void * ctx, long long integerVal); int (* yajl_double)(void * ctx, double doubleVal); /** A callback which passes the string representation of the number * back to the client. Will be used for all numbers when present */ int (* yajl_number)(void * ctx, const char * numberVal, size_t numberLen); /** strings are returned as pointers into the JSON text when, * possible, as a result, they are _not_ null padded */ int (* yajl_string)(void * ctx, const unsigned char * stringVal, size_t stringLen); int (* yajl_start_map)(void * ctx); int (* yajl_map_key)(void * ctx, const unsigned char * key, size_t stringLen); int (* yajl_end_map)(void * ctx); int (* yajl_start_array)(void * ctx); int (* yajl_end_array)(void * ctx); } yajl_callbacks; /** allocate a parser handle * \param callbacks a yajl callbacks structure specifying the * functions to call when different JSON entities * are encountered in the input text. May be NULL, * which is only useful for validation. * \param afs memory allocation functions, may be NULL for to use * C runtime library routines (malloc and friends) * \param ctx a context pointer that will be passed to callbacks. */ YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx); /** configuration parameters for the parser, these may be passed to * yajl_config() along with option specific argument(s). In general, * all configuration parameters default to *off*. */ typedef enum { /** Ignore javascript style comments present in * JSON input. Non-standard, but rather fun * arguments: toggled off with integer zero, on otherwise. * * example: * yajl_config(h, yajl_allow_comments, 1); // turn comment support on */ yajl_allow_comments = 0x01, /** * When set the parser will verify that all strings in JSON input are * valid UTF8 and will emit a parse error if this is not so. When set, * this option makes parsing slightly more expensive (~7% depending * on processor and compiler in use) * * example: * yajl_config(h, yajl_dont_validate_strings, 1); // disable utf8 checking */ yajl_dont_validate_strings = 0x02, /** * By default, upon calls to yajl_complete_parse(), yajl will * ensure the entire input text was consumed and will raise an error * otherwise. Enabling this flag will cause yajl to disable this * check. This can be useful when parsing json out of a that contains more * than a single JSON document. */ yajl_allow_trailing_garbage = 0x04, /** * Allow multiple values to be parsed by a single handle. The * entire text must be valid JSON, and values can be seperated * by any kind of whitespace. This flag will change the * behavior of the parser, and cause it continue parsing after * a value is parsed, rather than transitioning into a * complete state. This option can be useful when parsing multiple * values from an input stream. */ yajl_allow_multiple_values = 0x08, /** * When yajl_complete_parse() is called the parser will * check that the top level value was completely consumed. I.E., * if called whilst in the middle of parsing a value * yajl will enter an error state (premature EOF). Setting this * flag suppresses that check and the corresponding error. */ yajl_allow_partial_values = 0x10 } yajl_option; /** allow the modification of parser options subsequent to handle * allocation (via yajl_alloc) * \returns zero in case of errors, non-zero otherwise */ YAJL_API int yajl_config(yajl_handle h, yajl_option opt, ...); /** free a parser handle */ YAJL_API void yajl_free(yajl_handle handle); /** Parse some json! * \param hand - a handle to the json parser allocated with yajl_alloc * \param jsonText - a pointer to the UTF8 json text to be parsed * \param jsonTextLength - the length, in bytes, of input text */ YAJL_API yajl_status yajl_parse(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLength); /** Parse any remaining buffered json. * Since yajl is a stream-based parser, without an explicit end of * input, yajl sometimes can't decide if content at the end of the * stream is valid or not. For example, if "1" has been fed in, * yajl can't know whether another digit is next or some character * that would terminate the integer token. * * \param hand - a handle to the json parser allocated with yajl_alloc */ YAJL_API yajl_status yajl_complete_parse(yajl_handle hand); /** get an error string describing the state of the * parse. * * If verbose is non-zero, the message will include the JSON * text where the error occured, along with an arrow pointing to * the specific char. * * \returns A dynamically allocated string will be returned which should * be freed with yajl_free_error */ YAJL_API unsigned char * yajl_get_error(yajl_handle hand, int verbose, const unsigned char * jsonText, size_t jsonTextLength); /** * get the amount of data consumed from the last chunk passed to YAJL. * * In the case of a successful parse this can help you understand if * the entire buffer was consumed (which will allow you to handle * "junk at end of input"). * * In the event an error is encountered during parsing, this function * affords the client a way to get the offset into the most recent * chunk where the error occured. 0 will be returned if no error * was encountered. */ YAJL_API size_t yajl_get_bytes_consumed(yajl_handle hand); /** free an error returned from yajl_get_error */ YAJL_API void yajl_free_error(yajl_handle hand, unsigned char * str); /** * \file yajl_gen.h * Interface to YAJL's JSON generation facilities. */ /** generator status codes */ typedef enum { /** no error */ yajl_gen_status_ok = 0, /** at a point where a map key is generated, a function other than * yajl_gen_string was called */ yajl_gen_keys_must_be_strings, /** YAJL's maximum generation depth was exceeded. see * YAJL_MAX_DEPTH */ yajl_max_depth_exceeded, /** A generator function (yajl_gen_XXX) was called while in an error * state */ yajl_gen_in_error_state, /** A complete JSON document has been generated */ yajl_gen_generation_complete, /** yajl_gen_double was passed an invalid floating point value * (infinity or NaN). */ yajl_gen_invalid_number, /** A print callback was passed in, so there is no internal * buffer to get from */ yajl_gen_no_buf, /** returned from yajl_gen_string() when the yajl_gen_validate_utf8 * option is enabled and an invalid was passed by client code. */ yajl_gen_invalid_string } yajl_gen_status; /** an opaque handle to a generator */ typedef struct yajl_gen_t * yajl_gen; /** a callback used for "printing" the results. */ typedef void (*yajl_print_t)(void * ctx, const char * str, size_t len); /** configuration parameters for the parser, these may be passed to * yajl_gen_config() along with option specific argument(s). In general, * all configuration parameters default to *off*. */ typedef enum { /** generate indented (beautiful) output */ yajl_gen_beautify = 0x01, /** * Set an indent string which is used when yajl_gen_beautify * is enabled. Maybe something like \\t or some number of * spaces. The default is four spaces ' '. */ yajl_gen_indent_string = 0x02, /** * Set a function and context argument that should be used to * output generated json. the function should conform to the * yajl_print_t prototype while the context argument is a * void * of your choosing. * * example: * yajl_gen_config(g, yajl_gen_print_callback, myFunc, myVoidPtr); */ yajl_gen_print_callback = 0x04, /** * Normally the generator does not validate that strings you * pass to it via yajl_gen_string() are valid UTF8. Enabling * this option will cause it to do so. */ yajl_gen_validate_utf8 = 0x08, /** * the forward solidus (slash or '/' in human) is not required to be * escaped in json text. By default, YAJL will not escape it in the * iterest of saving bytes. Setting this flag will cause YAJL to * always escape '/' in generated JSON strings. */ yajl_gen_escape_solidus = 0x10 } yajl_gen_option; /** allow the modification of generator options subsequent to handle * allocation (via yajl_alloc) * \returns zero in case of errors, non-zero otherwise */ YAJL_API int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...); /** allocate a generator handle * \param allocFuncs an optional pointer to a structure which allows * the client to overide the memory allocation * used by yajl. May be NULL, in which case * malloc/free/realloc will be used. * * \returns an allocated handle on success, NULL on failure (bad params) */ YAJL_API yajl_gen yajl_gen_alloc(const yajl_alloc_funcs * allocFuncs); /** free a generator handle */ YAJL_API void yajl_gen_free(yajl_gen handle); YAJL_API yajl_gen_status yajl_gen_integer(yajl_gen hand, long long int number); /** generate a floating point number. number may not be infinity or * NaN, as these have no representation in JSON. In these cases the * generator will return 'yajl_gen_invalid_number' */ YAJL_API yajl_gen_status yajl_gen_double(yajl_gen hand, double number); YAJL_API yajl_gen_status yajl_gen_number(yajl_gen hand, const char * num, size_t len); YAJL_API yajl_gen_status yajl_gen_string(yajl_gen hand, const unsigned char * str, size_t len); YAJL_API yajl_gen_status yajl_gen_null(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_bool(yajl_gen hand, int boolean); YAJL_API yajl_gen_status yajl_gen_map_open(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_map_close(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_array_open(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_array_close(yajl_gen hand); /** access the null terminated generator buffer. If incrementally * outputing JSON, one should call yajl_gen_clear to clear the * buffer. This allows stream generation. */ YAJL_API yajl_gen_status yajl_gen_get_buf(yajl_gen hand, const unsigned char ** buf, size_t * len); /** clear yajl's output buffer, but maintain all internal generation * state. This function will not "reset" the generator state, and is * intended to enable incremental JSON outputing. */ YAJL_API void yajl_gen_clear(yajl_gen hand); #ifdef __cplusplus } #endif #endif /* YAJL_API_H */ whitedb-0.7.3/json/Makefile.in0000644000175000001440000004241112426224004013100 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # - - - - json parser sources - - - VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = json DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libjson_la_LIBADD = am_libjson_la_OBJECTS = yajl_all.lo libjson_la_OBJECTS = $(am_libjson_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libjson_la_SOURCES) DIST_SOURCES = $(libjson_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PRTDIAG = @PRTDIAG@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_INCLUDES = @PYTHON_INCLUDES@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RAPTOR_CONFIG = @RAPTOR_CONFIG@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libjson.la libjson_la_SOURCES = yajl_api.h yajl_all.h yajl_all.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu json/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu json/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libjson.la: $(libjson_la_OBJECTS) $(libjson_la_DEPENDENCIES) $(EXTRA_libjson_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libjson_la_OBJECTS) $(libjson_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yajl_all.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: whitedb-0.7.3/config.sub0000755000175000001440000010546712153415437012071 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013 Free Software Foundation, Inc. timestamp='2012-12-29' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: whitedb-0.7.3/wgdb.def0000644000175000001440000000723512421471034011474 00000000000000; ; Contains all functions exported by wgdb.dll ; this file should list everything declared in Db/dbapi.h ; LIBRARY WGDB EXPORTS wg_attach_database wg_attach_existing_database wg_attach_logged_database wg_attach_database_mode wg_attach_logged_database_mode wg_detach_database wg_delete_database wg_create_record wg_create_raw_record wg_delete_record wg_get_first_record wg_get_next_record wg_get_first_parent wg_get_next_parent wg_get_record_len wg_get_record_dataarray wg_set_field wg_set_new_field wg_set_int_field wg_set_double_field wg_set_str_field wg_update_atomic_field wg_set_atomic_field wg_add_int_atomic_field wg_get_field wg_get_field_type wg_get_encoded_type wg_free_encoded wg_encode_null wg_decode_null wg_encode_int wg_decode_int wg_encode_double wg_decode_double wg_encode_fixpoint wg_decode_fixpoint wg_encode_date wg_decode_date wg_encode_time wg_decode_time wg_current_utcdate wg_current_localdate wg_current_utctime wg_current_localtime wg_strf_iso_datetime wg_strp_iso_date wg_strp_iso_time wg_ymd_to_date wg_hms_to_time wg_date_to_ymd wg_time_to_hms wg_encode_str wg_decode_str wg_decode_str_lang wg_decode_str_len wg_decode_str_lang_len wg_decode_str_copy wg_decode_str_lang_copy wg_encode_xmlliteral wg_decode_xmlliteral_copy wg_decode_xmlliteral_xsdtype_copy wg_decode_xmlliteral_len wg_decode_xmlliteral_xsdtype_len wg_decode_xmlliteral wg_decode_xmlliteral_xsdtype wg_encode_uri wg_decode_uri_copy wg_decode_uri_prefix_copy wg_decode_uri_len wg_decode_uri_prefix_len wg_decode_uri wg_decode_uri_prefix wg_encode_blob wg_decode_blob_len wg_decode_blob wg_decode_blob_copy wg_decode_blob_type wg_decode_blob_type_copy wg_decode_blob_type_len wg_encode_record wg_decode_record wg_encode_char wg_decode_char wg_encode_var wg_decode_var wg_start_write wg_end_write wg_start_read wg_end_read wg_dump wg_dump_internal wg_import_dump wg_attach_local_database wg_delete_local_database wg_print_db wg_print_record wg_snprint_value wg_make_query wg_make_query_rc wg_fetch wg_free_query wg_encode_query_param_null wg_encode_query_param_record wg_encode_query_param_char wg_encode_query_param_fixpoint wg_encode_query_param_date wg_encode_query_param_time wg_encode_query_param_var wg_encode_query_param_int wg_encode_query_param_double wg_encode_query_param_str wg_encode_query_param_xmlliteral wg_encode_query_param_uri wg_free_query_param wg_export_db_csv wg_import_db_csv wg_register_external_db wg_encode_external_data wg_create_index wg_create_multi_index wg_drop_index wg_column_to_index_id wg_multi_column_to_index_id wg_get_index_type wg_get_index_template wg_get_all_indexes wg_parse_json_file wg_check_json wg_parse_json_document wg_parse_json_fragment wg_replay_log wg_start_logging wg_stop_logging wg_database_size wg_database_freesize ; this is a temporary hack to search a hash index under Windows wg_search_hash ; non-API functions (not in dbapi.h) needed to link wgdb.exe wg_parse_and_encode wg_get_rec_owner wg_attach_memsegment wg_check_header_compat wg_print_code_version wg_print_header_version wg_check_dump wg_parse_and_encode_param wg_delete_document wg_parse_json_param wg_make_json_query wg_print_json_document wg_pretty_print_memsize wg_memmode wg_memowner wg_memgroup wg_journal_filename ; end of wgdb.exe related exports whitedb-0.7.3/Makefile.am0000644000175000001440000000310312426223736012124 00000000000000# $Id: $ # $Source: $ # # Top level Makefile.am of WhiteDB: calling makes in subdirs # #AUTOMAKE_OPTIONS = foreign AUTOMAKE_OPTIONS = subdir-objects SUBDIRS = Db json SUBDIRS += Test Main Examples if PYTHON SUBDIRS += Python endif # --- man --- man_MANS = Doc/whitedb.7 # --- optional components ---- # -------- Tests ------------------- TESTS = Test/common.test Test/log.test Test/log.log: Test/common.log # -------- Extras ------------------- EXTRA_DIST = Bootstrap README INSTALL MANIFEST GPLLICENCE NEWS AUTHORS \ Doc/whitedb.7 Doc/python.txt Doc/Manual.txt \ Doc/Install.txt Doc/Utilities.txt Doc/Tutorial.txt \ wgdb.def config-w32.h config-gcc.h Doxyfile compile.sh compile.bat \ unite.sh \ Db/dbapi.h Db/rdfapi.h Db/indexapi.h \ Examples/compile_demo.sh Examples/compile_demo.bat \ Examples/compile_query.sh Examples/compile_query.bat \ Examples/dserve.c Examples/tut1.c Examples/tut2.c Examples/tut3.c \ Examples/tut4.c Examples/tut5.c Examples/tut6.c Examples/tut7.c \ Examples/speed/README Examples/speed/speed1.c Examples/speed/speed2.c \ Examples/speed/speed3.c Examples/speed/speed4.c Examples/speed/speed5.c \ Examples/speed/speed6.c Examples/speed/speed7.c Examples/speed/speed8.c \ Examples/speed/speed10.c Examples/speed/speed11.c Examples/speed/speed12.c \ Examples/speed/speed13.c Examples/speed/speed15.c Examples/speed/speed16.c \ Python/compile.bat Python/compile.sh Python/tests.py \ Test/common.test Test/log.test # this conflicts with the distcheck target, so disabled for now. #dist-hook: # cp $(top_distdir)/config-gcc.h $(top_distdir)/config.h whitedb-0.7.3/Main/0000755000175000001440000000000012426224011011022 500000000000000whitedb-0.7.3/Main/Makefile.am0000644000175000001440000000247412421471034013011 00000000000000# $Id: $ # $Source: $ # # Creating the WhiteDB binaries # ---- options ---- # ---- path variables ---- dbdir=../Db printerdir=../Printer parserdir=../Parser reasonerdir=../Reasoner jsondir=../json testdir=../Test # ---- targets ---- lib_LTLIBRARIES = libwgdb.la bin_PROGRAMS = wgdb noinst_PROGRAMS = stresstest selftest gendata indextool pkginclude_HEADERS = $(dbdir)/dbapi.h $(dbdir)/rdfapi.h $(dbdir)/indexapi.h # ---- extra dependencies, flags, etc ----- LIBDEPS = if RAPTOR LIBDEPS += `$(RAPTOR_CONFIG) --libs` endif AM_LDFLAGS = $(LIBDEPS) stresstest_LIBS=$(PTHREAD_LIBS) stresstest_CFLAGS=$(AM_CFLAGS) $(PTHREAD_CFLAGS) stresstest_LDFLAGS= -static $(PTHREAD_CFLAGS) $(LIBDEPS) stresstest_CC=$(PTHREAD_CC) libwgdb_la_LDFLAGS = # ----- all sources for the created programs ----- libwgdb_la_SOURCES = libwgdb_la_LIBADD = $(dbdir)/libDb.la ${jsondir}/libjson.la if REASONER libwgdb_la_LIBADD += $(parserdir)/libParser.la \ $(printerdir)/libPrinter.la $(reasonerdir)/libReasoner.la endif wgdb_SOURCES = wgdb.c wgdb_LDADD = libwgdb.la stresstest_SOURCES = stresstest.c stresstest_LDADD = libwgdb.la indextool_SOURCES = indextool.c indextool_LDADD = libwgdb.la selftest_SOURCES = selftest.c selftest_LDADD = $(testdir)/libTest.la libwgdb.la gendata_SOURCES = gendata.c gendata_LDADD = $(testdir)/libTest.la libwgdb.la whitedb-0.7.3/Main/indextool.c0000644000175000001440000002002012421471034013111 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Enar Reilent 2009 * Copyright (c) Priit Järv 2013,2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file indextool.c * Command line utility for index manipulation */ /* ====== Includes =============== */ #include #include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "../Db/dballoc.h" #include "../Db/dbmem.h" #include "../Db/dbindex.h" #include "../Db/dbhash.h" #include "../Db/dbutil.h" /* ====== Private headers and defs ======== */ #ifdef _WIN32 #define sscanf sscanf_s /* XXX: This will break for string parameters */ #endif /* ======= Private protos ================ */ void print_tree(void *db, FILE *file, struct wg_tnode *node, int col); int log_tree(void *db, char *file, struct wg_tnode *node, int col); void dump_hash(void *db, FILE *file, db_hash_area_header *ha); wg_index_header *get_index_by_id(void *db, gint index_id); /* ====== Functions ============== */ static int printhelp(){ printf("\nindextool user commands:\n" \ "indextool [shmname] logtree [filename] - log tree\n" \ "indextool [shmname] dumphash - print hash table\n\n"); return 0; } int main(int argc, char **argv) { char* shmname = NULL; void *db; int i, scan_to, shmsize; if(argc < 3) scan_to = argc; else scan_to = 3; shmsize = 0; /* 0 size causes default size to be used */ /* Similar command parser as in wgdb.c */ for(i=1; i (i+2)) a = argv[i+2]; hdr = get_index_by_id(db, index_id); if(hdr) { if(hdr->type != WG_INDEX_TYPE_TTREE && \ hdr->type != WG_INDEX_TYPE_TTREE_JSON) { fprintf(stderr, "Index type not supported.\n"); return 0; } log_tree(db, a, (struct wg_tnode *) offsettoptr(db, TTREE_ROOT_NODE(hdr)), hdr->rec_field_index[0]); } else { fprintf(stderr, "Invalid index id.\n"); return 0; } return 0; } else if(!strcmp(argv[i], "dumphash")) { int index_id; wg_index_header *hdr; if(argc < (i+1)) { printhelp(); return 0; } db = (void *) wg_attach_database(shmname, shmsize); if(!db) { fprintf(stderr, "Failed to attach to database.\n"); return 0; } sscanf(argv[i+1], "%d", &index_id); hdr = get_index_by_id(db, index_id); if(hdr) { if(hdr->type != WG_INDEX_TYPE_HASH && \ hdr->type != WG_INDEX_TYPE_HASH_JSON) { fprintf(stderr, "Index type not supported.\n"); return 0; } dump_hash(db, stdout, HASHIDX_ARRAYP(hdr)); } else { fprintf(stderr, "Invalid index id.\n"); return 0; } return 0; } shmname = argv[1]; /* assuming two loops max */ i++; } printhelp(); return 0; } void print_tree(void *db, FILE *file, struct wg_tnode *node, int col){ int i; char strbuf[256]; fprintf(file,"\n", (int) ptrtooffset(db, node)); fprintf(file,"%d",node->number_of_elements); fprintf(file,"\n"); fprintf(file,"%d",node->left_subtree_height); fprintf(file,"\n"); fprintf(file,"%d",node->right_subtree_height); fprintf(file,"\n"); #ifdef TTREE_CHAINED_NODES fprintf(file,"%d\n", (int) node->succ_offset); fprintf(file,"%d\n", (int) node->pred_offset); #endif wg_snprint_value(db, node->current_min, strbuf, 255); fprintf(file,"%s ",strbuf); wg_snprint_value(db, node->current_max, strbuf, 255); fprintf(file,"%s\n",strbuf); fprintf(file,""); for(i=0;inumber_of_elements;i++){ wg_int encoded = wg_get_field(db, (struct wg_tnode *) offsettoptr(db,node->array_of_values[i]), col); wg_snprint_value(db, encoded, strbuf, 255); fprintf(file, "%s ", strbuf); } fprintf(file,"\n"); fprintf(file,"\n"); if(node->left_child_offset == 0)fprintf(file,"null"); else{ print_tree(db,file, (struct wg_tnode *) offsettoptr(db,node->left_child_offset),col); } fprintf(file,"\n"); fprintf(file,"\n"); if(node->right_child_offset == 0)fprintf(file,"null"); else{ print_tree(db,file, (struct wg_tnode *) offsettoptr(db,node->right_child_offset),col); } fprintf(file,"\n"); fprintf(file,"\n"); } int log_tree(void *db, char *file, struct wg_tnode *node, int col){ #ifdef _WIN32 FILE *filee; fopen_s(&filee, file, "w"); #else FILE *filee = fopen(file,"w"); #endif print_tree(db,filee,node,col); fflush(filee); fclose(filee); return 0; } void dump_hash(void *db, FILE *file, db_hash_area_header *ha) { gint i; for(i=0; iarraylength; i++) { gint bucket = dbfetch(db, (ha->arraystart)+(sizeof(gint) * i)); if(bucket) { #ifdef _WIN32 fprintf(file, "hash: %Id\n", i); #else fprintf(file, "hash: %td\n", i); #endif while(bucket) { gint j, rec_offset; gint length = dbfetch(db, bucket + HASHIDX_META_POS*sizeof(gint)); unsigned char *dptr = offsettoptr(db, bucket + \ HASHIDX_HEADER_SIZE*sizeof(gint)); /* Hash string dump */ #ifdef _WIN32 fprintf(file, " offset: %Id ", bucket); #else fprintf(file, " offset: %td ", bucket); #endif for(j=0; j 126) fputc('.', file); else fputc(dptr[j], file); } fprintf(file, ")\n"); /* Offset dump */ fprintf(file, " records:"); rec_offset = dbfetch(db, bucket + HASHIDX_RECLIST_POS*sizeof(gint)); while(rec_offset) { gcell *rec_cell = (gcell *) offsettoptr(db, rec_offset); #ifdef _WIN32 fprintf(file, " %Id", rec_cell->car); #else fprintf(file, " %td", rec_cell->car); #endif rec_offset = rec_cell->cdr; } fprintf(file, "\n"); bucket = dbfetch(db, bucket + HASHIDX_HASHCHAIN_POS*sizeof(gint)); } } } } /* Find index by id * * helper function to validate index id-s. Checks if the * index is present in master list before converting the offset * into pointer. */ wg_index_header *get_index_by_id(void *db, gint index_id) { wg_index_header *hdr = NULL; db_memsegment_header* dbh = dbmemsegh(db); gint *ilist = &dbh->index_control_area_header.index_list; /* Locate the header */ while(*ilist) { gcell *ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car == index_id) { hdr = (wg_index_header *) offsettoptr(db, index_id); break; } ilist = &ilistelem->cdr; } return hdr; } #ifdef __cplusplus } #endif whitedb-0.7.3/Main/Makefile.in0000644000175000001440000007143212426224004013020 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: $ # $Source: $ # # Creating the WhiteDB binaries # ---- options ---- # ---- path variables ---- VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = wgdb$(EXEEXT) noinst_PROGRAMS = stresstest$(EXEEXT) selftest$(EXEEXT) \ gendata$(EXEEXT) indextool$(EXEEXT) @RAPTOR_TRUE@am__append_1 = `$(RAPTOR_CONFIG) --libs` @REASONER_TRUE@am__append_2 = $(parserdir)/libParser.la \ @REASONER_TRUE@ $(printerdir)/libPrinter.la $(reasonerdir)/libReasoner.la subdir = Main DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(pkginclude_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(pkgincludedir)" LTLIBRARIES = $(lib_LTLIBRARIES) libwgdb_la_DEPENDENCIES = $(dbdir)/libDb.la ${jsondir}/libjson.la \ $(am__append_2) am_libwgdb_la_OBJECTS = libwgdb_la_OBJECTS = $(am_libwgdb_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libwgdb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libwgdb_la_LDFLAGS) $(LDFLAGS) -o $@ PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am_gendata_OBJECTS = gendata.$(OBJEXT) gendata_OBJECTS = $(am_gendata_OBJECTS) gendata_DEPENDENCIES = $(testdir)/libTest.la libwgdb.la am_indextool_OBJECTS = indextool.$(OBJEXT) indextool_OBJECTS = $(am_indextool_OBJECTS) indextool_DEPENDENCIES = libwgdb.la am_selftest_OBJECTS = selftest.$(OBJEXT) selftest_OBJECTS = $(am_selftest_OBJECTS) selftest_DEPENDENCIES = $(testdir)/libTest.la libwgdb.la am_stresstest_OBJECTS = stresstest-stresstest.$(OBJEXT) stresstest_OBJECTS = $(am_stresstest_OBJECTS) stresstest_DEPENDENCIES = libwgdb.la stresstest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(stresstest_CFLAGS) \ $(CFLAGS) $(stresstest_LDFLAGS) $(LDFLAGS) -o $@ am_wgdb_OBJECTS = wgdb.$(OBJEXT) wgdb_OBJECTS = $(am_wgdb_OBJECTS) wgdb_DEPENDENCIES = libwgdb.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libwgdb_la_SOURCES) $(gendata_SOURCES) \ $(indextool_SOURCES) $(selftest_SOURCES) $(stresstest_SOURCES) \ $(wgdb_SOURCES) DIST_SOURCES = $(libwgdb_la_SOURCES) $(gendata_SOURCES) \ $(indextool_SOURCES) $(selftest_SOURCES) $(stresstest_SOURCES) \ $(wgdb_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(pkginclude_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PRTDIAG = @PRTDIAG@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_INCLUDES = @PYTHON_INCLUDES@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RAPTOR_CONFIG = @RAPTOR_CONFIG@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ dbdir = ../Db printerdir = ../Printer parserdir = ../Parser reasonerdir = ../Reasoner jsondir = ../json testdir = ../Test # ---- targets ---- lib_LTLIBRARIES = libwgdb.la pkginclude_HEADERS = $(dbdir)/dbapi.h $(dbdir)/rdfapi.h $(dbdir)/indexapi.h # ---- extra dependencies, flags, etc ----- LIBDEPS = $(am__append_1) AM_LDFLAGS = $(LIBDEPS) stresstest_LIBS = $(PTHREAD_LIBS) stresstest_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) stresstest_LDFLAGS = -static $(PTHREAD_CFLAGS) $(LIBDEPS) stresstest_CC = $(PTHREAD_CC) libwgdb_la_LDFLAGS = # ----- all sources for the created programs ----- libwgdb_la_SOURCES = libwgdb_la_LIBADD = $(dbdir)/libDb.la ${jsondir}/libjson.la \ $(am__append_2) wgdb_SOURCES = wgdb.c wgdb_LDADD = libwgdb.la stresstest_SOURCES = stresstest.c stresstest_LDADD = libwgdb.la indextool_SOURCES = indextool.c indextool_LDADD = libwgdb.la selftest_SOURCES = selftest.c selftest_LDADD = $(testdir)/libTest.la libwgdb.la gendata_SOURCES = gendata.c gendata_LDADD = $(testdir)/libTest.la libwgdb.la all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Main/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Main/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libwgdb.la: $(libwgdb_la_OBJECTS) $(libwgdb_la_DEPENDENCIES) $(EXTRA_libwgdb_la_DEPENDENCIES) $(AM_V_CCLD)$(libwgdb_la_LINK) -rpath $(libdir) $(libwgdb_la_OBJECTS) $(libwgdb_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list gendata$(EXEEXT): $(gendata_OBJECTS) $(gendata_DEPENDENCIES) $(EXTRA_gendata_DEPENDENCIES) @rm -f gendata$(EXEEXT) $(AM_V_CCLD)$(LINK) $(gendata_OBJECTS) $(gendata_LDADD) $(LIBS) indextool$(EXEEXT): $(indextool_OBJECTS) $(indextool_DEPENDENCIES) $(EXTRA_indextool_DEPENDENCIES) @rm -f indextool$(EXEEXT) $(AM_V_CCLD)$(LINK) $(indextool_OBJECTS) $(indextool_LDADD) $(LIBS) selftest$(EXEEXT): $(selftest_OBJECTS) $(selftest_DEPENDENCIES) $(EXTRA_selftest_DEPENDENCIES) @rm -f selftest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(selftest_OBJECTS) $(selftest_LDADD) $(LIBS) stresstest$(EXEEXT): $(stresstest_OBJECTS) $(stresstest_DEPENDENCIES) $(EXTRA_stresstest_DEPENDENCIES) @rm -f stresstest$(EXEEXT) $(AM_V_CCLD)$(stresstest_LINK) $(stresstest_OBJECTS) $(stresstest_LDADD) $(LIBS) wgdb$(EXEEXT): $(wgdb_OBJECTS) $(wgdb_DEPENDENCIES) $(EXTRA_wgdb_DEPENDENCIES) @rm -f wgdb$(EXEEXT) $(AM_V_CCLD)$(LINK) $(wgdb_OBJECTS) $(wgdb_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gendata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indextool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/selftest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stresstest-stresstest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wgdb.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< stresstest-stresstest.o: stresstest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stresstest_CFLAGS) $(CFLAGS) -MT stresstest-stresstest.o -MD -MP -MF $(DEPDIR)/stresstest-stresstest.Tpo -c -o stresstest-stresstest.o `test -f 'stresstest.c' || echo '$(srcdir)/'`stresstest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stresstest-stresstest.Tpo $(DEPDIR)/stresstest-stresstest.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stresstest.c' object='stresstest-stresstest.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stresstest_CFLAGS) $(CFLAGS) -c -o stresstest-stresstest.o `test -f 'stresstest.c' || echo '$(srcdir)/'`stresstest.c stresstest-stresstest.obj: stresstest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stresstest_CFLAGS) $(CFLAGS) -MT stresstest-stresstest.obj -MD -MP -MF $(DEPDIR)/stresstest-stresstest.Tpo -c -o stresstest-stresstest.obj `if test -f 'stresstest.c'; then $(CYGPATH_W) 'stresstest.c'; else $(CYGPATH_W) '$(srcdir)/stresstest.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stresstest-stresstest.Tpo $(DEPDIR)/stresstest-stresstest.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stresstest.c' object='stresstest-stresstest.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stresstest_CFLAGS) $(CFLAGS) -c -o stresstest-stresstest.obj `if test -f 'stresstest.c'; then $(CYGPATH_W) 'stresstest.c'; else $(CYGPATH_W) '$(srcdir)/stresstest.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \ uninstall-pkgincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-libLTLIBRARIES \ install-man install-pdf install-pdf-am \ install-pkgincludeHEADERS install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-libLTLIBRARIES \ uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: whitedb-0.7.3/Main/wgdb.c0000644000175000001440000007403612421471034012047 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Enar Reilent 2009 * Copyright (c) Priit Järv 2010,2011,2012,2013,2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file wgdb.c * WhiteDB database tool: command line utility */ /* ====== Includes =============== */ #include #include #include #include #include #ifndef _WIN32 #include #include #include #endif #ifdef _WIN32 #include // for _getch #endif #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "../Db/dballoc.h" #include "../Db/dbmem.h" #include "../Db/dbdata.h" #include "../Db/dbdump.h" #include "../Db/dblog.h" #include "../Db/dbquery.h" #include "../Db/dbutil.h" #include "../Db/dblock.h" #include "../Db/dbjson.h" #include "../Db/dbschema.h" #ifdef USE_REASONER #include "../Parser/dbparse.h" #endif /* ====== Private defs =========== */ #ifdef _WIN32 #define sscanf sscanf_s /* XXX: This will break for string parameters */ #endif #define FLAGS_FORCE 0x1 #define FLAGS_LOGGING 0x2 /* Helper macros for database lock management */ #define RLOCK(d,i) i = wg_start_read(d); \ if(!i) { \ fprintf(stderr, "Failed to get database lock\n"); \ break; \ } #define WLOCK(d,i) i = wg_start_write(d); \ if(!i) { \ fprintf(stderr, "Failed to get database lock\n"); \ break; \ } #define RULOCK(d,i) if(i) { \ wg_end_read(d,i); \ i = 0; \ } #define WULOCK(d,i) if(i) { \ wg_end_write(d,i); \ i = 0; \ } /* ======= Private protos ================ */ gint parse_shmsize(char *arg); gint parse_flag(char *arg); int parse_memmode(char *arg); wg_query_arg *make_arglist(void *db, char **argv, int argc, int *sz); void free_arglist(void *db, wg_query_arg *arglist, int sz); void query(void *db, char **argv, int argc); void del(void *db, char **argv, int argc); void selectdata(void *db, int howmany, int startingat); int add_row(void *db, char **argv, int argc); wg_json_query_arg *make_json_arglist(void *db, char *json, int *sz, void **doc); void findjson(void *db, char *json); void segment_stats(void *db); void print_indexes(void *db, FILE *f); /* ====== Functions ============== */ /* how to set 500 meg of shared memory: su echo 500000000 > /proc/sys/kernel/shmmax */ /** usage: display command line help. * */ void usage(char *prog) { printf("usage: %s [shmname] [command arguments]\n"\ "Where:\n"\ " shmname - (numeric) shared memory name for database. May be omitted.\n"\ " command - required, one of:\n\n"\ " help (or \"-h\") - display this text.\n"\ " version (or \"-v\") - display libwgdb version.\n"\ " free - free shared memory.\n"\ " export [-f] - write memory dump to disk (-f: force dump "\ "even if unable to get lock)\n"\ " import [-l] - read memory dump from disk. Overwrites "\ " existing memory contents (-l: enable logging after import).\n"\ " exportcsv - export data to a CSV file.\n"\ " importcsv - import data from a CSV file.\n", prog); #ifdef USE_REASONER printf(" importotter - import facts/rules from "\ "otter syntax file.\n"\ " importprolog - import facts/rules from "\ "prolog syntax file.\n"\ " runreasoner - run the reasoner on facts/rules in the database.\n"); #endif #ifdef HAVE_RAPTOR printf(" exportrdf - export data to a RDF/XML file.\n"\ " importrdf - import data from a RDF file.\n"); #endif #ifdef USE_DBLOG printf(" replay - replay a journal file.\n"); #endif printf(" info - print information about the memory database.\n"\ " add .. - store data row (only int or str recognized)\n"\ " select [start from] - print db contents.\n"\ " query \"\" .. - basic query.\n"\ " del \"\" .. - like query. Matching rows "\ "are deleted from database.\n"\ " addjson [filename] - store a json document.\n"\ " findjson - find documents with matching keys/values.\n"\ " createindex - create ttree index\n" \ " createhash - create hash index (JSON support)\n" \ " dropindex - delete an index\n" \ " listindex - list all indexes in database\n"); #ifdef _WIN32 printf(" server [-l] [size] - provide persistent shared memory for "\ "other processes (-l: enable logging in the database). Will allocate "\ "requested amount of memory and sleep; "\ "Ctrl+C aborts and releases the memory.\n"); #else printf(" create [-l] [size [mode]] - create empty db of given size "\ "(-l: enable logging in the database, mode: segment permissions "\ "(octal)).\n"); #endif printf("\nCommands may have variable number of arguments. "\ "Commands that take values as arguments have limited support "\ "for parsing various data types (see manual for details). Size "\ "may be given as bytes or in larger units by appending k, M or G "\ "to the size argument.\n"); } /** Handle the user-supplied database size (or pick a reasonable * substitute). Parses up to 32-bit values, but the user may * append up to 'G' for larger bases on 64-bit systems. */ gint parse_shmsize(char *arg) { char *trailing = NULL; long maxv = LONG_MAX, mult = 1, val = strtol(arg, &trailing, 10); if((val == LONG_MAX || val == LONG_MIN) && errno==ERANGE) { fprintf(stderr, "Numeric value out of range (try k, M, G?)\n"); } else if(trailing) { switch(trailing[0]) { case 'k': case 'K': mult = 1000; break; case 'm': case 'M': mult = 1000000; break; case 'g': case 'G': mult = 1000000000; break; default: break; } } #ifndef HAVE_64BIT_GINT maxv /= mult; #endif if(val > maxv) { fprintf(stderr, "Requested segment size not supported (using %ld)\n", mult * maxv); val = maxv; } return (gint) val * (gint) mult; } /** Handle a command-line flag * */ gint parse_flag(char *arg) { while(arg[0] == '-') arg++; switch(arg[0]) { case 'f': return FLAGS_FORCE; case 'l': return FLAGS_LOGGING; default: fprintf(stderr, "Unrecognized option: `%c'\n", arg[0]); break; } return 0; } /** Parse the mode bits given in octal (textual representation) * */ int parse_memmode(char *arg) { char *trailing = NULL; long parsed = strtol(arg, &trailing, 8); if(errno == 0 && (!trailing || strlen(trailing) == 0) && parsed <= 0777 && parsed > 0) { return (int) parsed; } return 0; } /** top level for the database command line tool * * */ int main(int argc, char **argv) { char *shmname = NULL; void *shmptr = NULL; int i, scan_to; gint shmsize; wg_int rlock = 0; wg_int wlock = 0; /* look for commands in argv[1] or argv[2] */ if(argc < 3) scan_to = argc; else scan_to = 3; shmsize = 0; /* 0 size causes default size to be used */ /* 1st loop through, shmname is NULL for default. If * the first argument is not a recognizable command, it * is assumed to be the shmname and the next argument * is checked against known commands. */ for(i=1; i(i+1) && !strcmp(argv[i],"import")){ wg_int err, minsize, maxsize; int flags = 0; if(argv[i+1][0] == '-') { flags = parse_flag(argv[++i]); if(argc<=(i+1)) { /* Filename argument missing */ usage(argv[0]); exit(1); } } err = wg_check_dump(NULL, argv[i+1], &minsize, &maxsize); if(err) { fprintf(stderr, "Import failed.\n"); break; } shmptr=wg_attach_memsegment(shmname, minsize, maxsize, 1, (flags & FLAGS_LOGGING), 0); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Locking is handled internally by the dbdump.c functions */ err = wg_import_dump(shmptr,argv[i+1]); if(!err) printf("Database imported.\n"); else if(err<-1) fprintf(stderr, "Fatal error in wg_import_dump, db may have"\ " become corrupt\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>(i+1) && !strcmp(argv[i],"export")){ wg_int err; int flags = 0; if(argv[i+1][0] == '-') { flags = parse_flag(argv[++i]); if(argc<=(i+1)) { /* Filename argument missing */ usage(argv[0]); exit(1); } } shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Locking is handled internally by the dbdump.c functions */ if(flags & FLAGS_FORCE) err = wg_dump_internal(shmptr,argv[i+1], 0); else err = wg_dump(shmptr,argv[i+1]); if(err<-1) fprintf(stderr, "Fatal error in wg_dump, db may have"\ " become corrupt\n"); else if(err) fprintf(stderr, "Export failed.\n"); break; } #ifdef USE_DBLOG else if(argc>(i+1) && !strcmp(argv[i],"replay")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); err = wg_replay_log(shmptr,argv[i+1]); WULOCK(shmptr, wlock); if(!err) printf("Log suggessfully imported from file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, database may have "\ "become corrupt\n"); else fprintf(stderr, "Failed to import log (database unmodified).\n"); break; } #endif else if(argc>(i+1) && !strcmp(argv[i],"exportcsv")){ shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } RLOCK(shmptr, rlock); wg_export_db_csv(shmptr,argv[i+1]); RULOCK(shmptr, rlock); break; } else if(argc>(i+1) && !strcmp(argv[i],"importcsv")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); err = wg_import_db_csv(shmptr,argv[i+1]); WULOCK(shmptr, wlock); if(!err) printf("Data imported from file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } #ifdef USE_REASONER else if(argc>(i+1) && !strcmp(argv[i],"importprolog")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } err = wg_import_prolog_file(shmptr,argv[i+1]); if(!err) printf("Data imported from prolog file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>(i+1) && !strcmp(argv[i],"importotter")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } err = wg_import_otter_file(shmptr,argv[i+1]); if(!err) printf("Data imported from otter file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing otter file, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>i && !strcmp(argv[i],"runreasoner")){ wg_int err; shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } //printf("about to call wg_run_reasoner\n"); err = wg_run_reasoner(shmptr,argc,argv); //if(!err); //printf("wg_run_reasoner finished ok.\n"); //else //fprintf(stderr, "wg_run_reasoner finished with an error %d.\n",err); //break; break; } #endif #ifdef HAVE_RAPTOR else if(argc>(i+2) && !strcmp(argv[i],"exportrdf")){ wg_int err; int pref_fields = atol(argv[i+1]); shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } printf("Exporting with %d prefix fields.\n", pref_fields); RLOCK(shmptr, rlock); err = wg_export_raptor_rdfxml_file(shmptr, pref_fields, argv[i+2]); RULOCK(shmptr, rlock); if(err) fprintf(stderr, "Export failed.\n"); break; } else if(argc>(i+3) && !strcmp(argv[i],"importrdf")){ wg_int err; int pref_fields = atol(argv[i+1]); int suff_fields = atol(argv[i+2]); shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } printf("Importing with %d prefix fields, %d suffix fields.\n,", pref_fields, suff_fields); WLOCK(shmptr, wlock); err = wg_import_raptor_file(shmptr, pref_fields, suff_fields, wg_rdfparse_default_callback, argv[i+3]); WULOCK(shmptr, wlock); if(!err) printf("Data imported from file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } #endif else if(!strcmp(argv[i], "info")) { shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } RLOCK(shmptr, rlock); segment_stats(shmptr); RULOCK(shmptr, rlock); break; } #ifdef _WIN32 else if(!strcmp(argv[i],"server")) { int flags = 0; if(argc>(i+1) && argv[i+1][0] == '-') { flags = parse_flag(argv[++i]); } if(argc>(i+1)) { shmsize = parse_shmsize(argv[i+1]); if(!shmsize) fprintf(stderr, "Failed to parse memory size, using default.\n"); } shmptr=wg_attach_memsegment(shmname, shmsize, shmsize, 1, (flags & FLAGS_LOGGING), 0); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } printf("Press Ctrl-C to end and release the memory.\n"); while(_getch() != 3); break; } #else else if(!strcmp(argv[i],"create")) { int flags = 0, mode = 0; if(argc>(i+1) && argv[i+1][0] == '-') { flags = parse_flag(argv[++i]); } if(argc>(i+1)) { shmsize = parse_shmsize(argv[i+1]); if(!shmsize) fprintf(stderr, "Failed to parse memory size, using default.\n"); } if(argc>(i+2)) { mode = parse_memmode(argv[i+2]); if(mode == 0) fprintf(stderr, "Invalid permission mode, using default.\n"); } shmptr=wg_attach_memsegment(shmname, shmsize, shmsize, 1, (flags & FLAGS_LOGGING), mode); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } break; } #endif else if(argc>(i+1) && !strcmp(argv[i],"select")) { int rows = atol(argv[i+1]); int from = 0; if(!rows) { fprintf(stderr, "Invalid number of rows.\n"); exit(1); } if(argc > (i+2)) from = atol(argv[i+2]); shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } RLOCK(shmptr, rlock); selectdata(shmptr, rows, from); RULOCK(shmptr, rlock); break; } else if(argc>(i+1) && !strcmp(argv[i],"add")) { int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); err = add_row(shmptr, argv+i+1, argc-i-1); WULOCK(shmptr, wlock); if(!err) printf("Row added.\n"); break; } else if(argc>(i+2) && !strcmp(argv[i],"del")) { shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Delete works like query(), except deletes the matching rows */ del(shmptr, argv+i+1, argc-i-1); break; break; } else if(argc>(i+3) && !strcmp(argv[i],"query")) { shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Query handles it's own locking */ query(shmptr, argv+i+1, argc-i-1); break; } else if(argc>i && !strcmp(argv[i],"addjson")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); /* the filename parameter is optional */ err = wg_parse_json_file(shmptr, (argc>(i+1) ? argv[i+1] : NULL)); WULOCK(shmptr, wlock); if(!err) printf("JSON document imported.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>(i+1) && !strcmp(argv[i],"findjson")) { shmptr=wg_attach_existing_database(shmname); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); findjson(shmptr, argv[i+1]); WULOCK(shmptr, wlock); break; } else if(argc>(i+1) && !strcmp(argv[i], "createindex")) { int col; shmptr = (void *) wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } sscanf(argv[i+1], "%d", &col); WLOCK(shmptr, wlock); wg_create_index(shmptr, col, WG_INDEX_TYPE_TTREE, NULL, 0); WULOCK(shmptr, wlock); break; } else if(argc>(i+1) && !strcmp(argv[i], "createhash")) { gint cols[MAX_INDEX_FIELDS], col_count, j; shmptr = (void *) wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } col_count = 0; for(j = i+1; j(i+1) && !strcmp(argv[i], "dropindex")) { int index_id; shmptr = (void *) wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } sscanf(argv[i+1], "%d", &index_id); WLOCK(shmptr, wlock); if(wg_drop_index(shmptr, index_id)) fprintf(stderr, "Failed to drop index.\n"); else printf("Index dropped.\n"); WULOCK(shmptr, wlock); break; } else if(!strcmp(argv[i], "listindex")) { shmptr = (void *) wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } RLOCK(shmptr, rlock); print_indexes(shmptr, stdout); RULOCK(shmptr, rlock); break; } shmname = argv[1]; /* no match, assume shmname was given */ } if(i==scan_to) { /* loop completed normally ==> no commands found */ usage(argv[0]); } if(shmptr) { RULOCK(shmptr, rlock); WULOCK(shmptr, wlock); wg_detach_database(shmptr); } exit(0); } /** Parse row matching parameters from the command line * * argv should point to the part in argument list where the * parameters start. * * If the parsing is successful, *sz holds the size of the argument list. * Otherwise that value should be ignored; the return value of the * function should be used to check for success. */ wg_query_arg *make_arglist(void *db, char **argv, int argc, int *sz) { int c, i, j, qargc; char cond[80]; wg_query_arg *arglist; gint encoded; qargc = argc / 3; *sz = qargc; arglist = (wg_query_arg *) malloc(qargc * sizeof(wg_query_arg)); if(!arglist) return NULL; for(i=0,j=0; i=", 2)) arglist[i].cond = WG_COND_GTEQUAL; else if(!strncmp(cond, "<", 1)) arglist[i].cond = WG_COND_LESSTHAN; else if(!strncmp(cond, ">", 1)) arglist[i].cond = WG_COND_GREATER; else { fprintf(stderr, "invalid condition %s\n", cond); free_arglist(db, arglist, qargc); return NULL; } } return arglist; } /** Free the argument list created by make_arglist() * */ void free_arglist(void *db, wg_query_arg *arglist, int sz) { if(arglist) { int i; for(i=0; icolumn, q->qtype); */ rec = wg_fetch(db, q); while(rec) { wg_print_record(db, (gint *) rec); printf("\n"); rec = wg_fetch(db, q); } wg_free_query(db, q); abrt2: wg_end_read(db, lock_id); abrt1: free_arglist(db, arglist, qargc); } /** Delete rows * Like query(), except the selected rows are deleted. */ void del(void *db, char **argv, int argc) { int qargc; void *rec = NULL; wg_query *q; wg_query_arg *arglist; gint lock_id; arglist = make_arglist(db, argv, argc, &qargc); if(!arglist) return; /* Use maximum isolation */ if(!(lock_id = wg_start_write(db))) { fprintf(stderr, "failed to get lock on database\n"); goto abrt1; } q = wg_make_query(db, NULL, 0, arglist, qargc); if(!q) goto abrt2; if(q->res_count > 0) { printf("Deleting %d rows...", (int) q->res_count); rec = wg_fetch(db, q); while(rec) { wg_delete_record(db, (gint *) rec); rec = wg_fetch(db, q); } printf(" done\n"); } wg_free_query(db, q); abrt2: wg_end_write(db, lock_id); abrt1: free_arglist(db, arglist, qargc); } /** Print rows from database * */ void selectdata(void *db, int howmany, int startingat) { void *rec = wg_get_first_record(db); int i, count; for(i=0;ikey); printf("database version: "); wg_print_header_version(dbh, 0); wg_pretty_print_memsize(dbh->size, buf1, 40); wg_pretty_print_memsize(dbh->size - dbh->free, buf2, 40); printf("free space: %s (of %s)\n", buf2, buf1); #ifndef _WIN32 pwd = getpwuid(wg_memowner(db)); if(pwd) { printf("owner: %s\n", pwd->pw_name); } grp = getgrgid(wg_memgroup(db)); if(grp) { printf("group: %s\n", grp->gr_name); } printf("permissions: %o\n", wg_memmode(db)); #endif #ifdef USE_DBLOG if(dbh->logging.active) { wg_journal_filename(db, buf1, 200); printf("logging is active, journal file: %s\n", buf1); } else { printf("logging is not active\n"); } #endif printf("database has "); switch(dbh->index_control_area_header.number_of_indexes) { case 0: printf("no indexes\n"); break; case 1: printf("1 index\n"); break; default: printf("%d indexes\n", (int) dbh->index_control_area_header.number_of_indexes); break; } } void print_indexes(void *db, FILE *f) { int column; db_memsegment_header* dbh = dbmemsegh(db); gint *ilist; if(!dbh->index_control_area_header.number_of_indexes) { fprintf(f, "No indexes in the database.\n"); return; } else { fprintf(f, "col\ttype\tmulti\tid\tmask\n"); } for(column=0; column<=MAX_INDEXED_FIELDNR; column++) { ilist = &dbh->index_control_area_header.index_table[column]; while(*ilist) { gcell *ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { char typestr[3]; wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); typestr[2] = '\0'; switch(hdr->type) { case WG_INDEX_TYPE_TTREE: typestr[0] = 'T'; typestr[1] = '\0'; break; case WG_INDEX_TYPE_TTREE_JSON: typestr[0] = 'T'; typestr[1] = 'J'; break; case WG_INDEX_TYPE_HASH: typestr[0] = '#'; typestr[1] = '\0'; break; case WG_INDEX_TYPE_HASH_JSON: typestr[0] = '#'; typestr[1] = 'J'; break; default: break; } fprintf(f, "%d\t%s\t%d\t%d\t%s\n", column, typestr, (int) hdr->fields, (int) ilistelem->car, #ifndef USE_INDEX_TEMPLATE "-"); #else (hdr->template_offset ? "Y" : "N")); #endif } ilist = &ilistelem->cdr; } } } #ifdef __cplusplus } #endif whitedb-0.7.3/Main/gendata.c0000644000175000001440000000661012421732140012516 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file gendata.c * WhiteDB test tool: generate integer data */ /* ====== Includes =============== */ #include #include #include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "../Db/dballoc.h" #include "../Db/dbmem.h" #include "../Db/dblock.h" #include "../Test/dbtest.h" /* ====== Private defs =========== */ #define TESTREC_SIZE 3 /* Helper macros for database lock management */ #define WLOCK(d,i) i = wg_start_write(d); \ if(!i) { \ fprintf(stderr, "Failed to get database lock\n"); \ break; \ } #define WULOCK(d,i) if(i) { \ wg_end_write(d,i); \ i = 0; \ } /* ======= Private protos ================ */ /* ====== Functions ============== */ /** usage: display command line help. * */ void usage(char *prog) { printf("usage: %s [shmname] [command arguments]\n"\ "Where:\n"\ " shmname - (numeric) shared memory name for database. May be omitted.\n"\ " command - required, one of:\n\n"\ " help (or \"-h\") - display this text.\n"\ " fill [asc | desc | mix] - fill db with integer data.\n", prog); } /** Command line parser. * * */ int main(int argc, char **argv) { char *shmname = NULL; void *shmptr = NULL; int i, scan_to; gint shmsize; gint wlock = 0; /* look for commands in argv[1] or argv[2] */ if(argc < 3) scan_to = argc; else scan_to = 3; shmsize = 0; /* loop passes are handled like in wgdb.c: * if the first loop doesn't find a command, the * argument is assumed to be the shared memory key. */ for(i=1; i(i+1) && !strcmp(argv[i], "fill")) { int rows = atol(argv[i+1]); if(!rows) { fprintf(stderr, "Invalid number of rows.\n"); exit(1); } shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); if(argc > (i+2) && !strcmp(argv[i+2], "mix")) wg_genintdata_mix(shmptr, rows, TESTREC_SIZE); else if(argc > (i+2) && !strcmp(argv[i+2], "desc")) wg_genintdata_desc(shmptr, rows, TESTREC_SIZE); else wg_genintdata_asc(shmptr, rows, TESTREC_SIZE); WULOCK(shmptr, wlock); printf("Data inserted\n"); break; } shmname = argv[1]; } if(i==scan_to) { usage(argv[0]); } if(shmptr) { WULOCK(shmptr, wlock); wg_detach_database(shmptr); } exit(0); } #ifdef __cplusplus } #endif whitedb-0.7.3/Main/selftest.c0000644000175000001440000000652212421732140012746 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file selftest.c * WhiteDB regression test utility */ /* ====== Includes =============== */ #include #include #include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "../Db/dballoc.h" #include "../Test/dbtest.h" #ifdef USE_REASONER #include "../Test/rtest.h" #include "../Parser/dbparse.h" #endif /* ====== Private defs =========== */ #define FLAGS_QUIET 0x1 /* ======= Private protos ================ */ gint parse_flag(char *arg); /* ====== Functions ============== */ /** usage: display command line help. * */ void usage(char *prog) { printf("usage: %s [-q] \n"\ "Where:\n"\ " command is one of:\n\n"\ " help (or \"-h\") - display this text.\n"\ " common - run quick tests of common functionality.\n"\ " query - run in-depth query tests.\n"\ " index - run in-depth index tests.\n"\ " log - run journal logging tests.\n", prog); #ifdef USE_REASONER printf(" reasoner - test the reasoner.\n"); #endif printf("\nThe flag `-q' will disable most of the output from the tests.\n"); } /** Handle a command-line flag * */ gint parse_flag(char *arg) { while(arg[0] == '-') arg++; switch(arg[0]) { case 'q': return FLAGS_QUIET; default: fprintf(stderr, "Unrecognized option: `%c'\n", arg[0]); break; } return 0; } /** Parse the command line and execute at most one command. * * */ int main(int argc, char **argv) { int i, flags = 0; int rc = 0; for(i=1; i no commands found */ usage(argv[0]); } exit(rc); } #ifdef __cplusplus } #endif whitedb-0.7.3/Main/stresstest.c0000644000175000001440000003225612421471034013345 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2009 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file stresstest.c * generate load with writer and reader threads * Currently supports two thread API-s: libpthread and Win32 */ /* ====== Includes =============== */ #include #include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include #else #include #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #ifdef HAVE_PTHREAD #include #endif #ifdef __cplusplus extern "C" { #endif #include "../Db/dballoc.h" #include "../Db/dbmem.h" #include "../Db/dbdata.h" #include "../Db/dblock.h" /* ====== Private defs =========== */ #define DBSIZE 10000000 #define WORKLOAD 100000 #define REC_SIZE 5 #define CHATTY_THREADS 1 #define SYNC_THREADS 1 /* Use libpthread rwlock to create a reference * benchmark for measuring the performance of * dblock.c spinlocks against. */ /* #define BENCHMARK 1 */ typedef struct { int threadid; void *db; #ifdef HAVE_PTHREAD pthread_t pth; #elif defined(_WIN32) HANDLE hThread; #endif } pt_data; #if defined(_WIN32) typedef DWORD worker_t; #else /* compatible with libpthread */ typedef void * worker_t; #endif /* ======= Private protos ================ */ int prepare_data(void *db); void check_data(void *db, int wcnt); void run_workers(void *db, int rcnt, int wcnt); worker_t writer_thread(void * threadarg); worker_t reader_thread(void * threadarg); /* ====== Global vars ======== */ #ifdef SYNC_THREADS #if defined(HAVE_PTHREAD) pthread_mutex_t twait_mutex; pthread_cond_t twait_cv; #elif defined(_WIN32) HANDLE twait_ev; #endif volatile int twait_cnt; /* count of workers in wait state */ #endif #if defined(BENCHMARK) && defined(HAVE_PTHREAD) pthread_rwlock_t rwlock; #endif /* ====== Functions ============== */ int main(int argc, char **argv) { char* shmname = NULL; void* shmptr; int rcnt = -1, wcnt = -1; #ifndef _WIN32 struct timeval tv; #endif unsigned long long start_ms, end_ms; if(argc==4) { shmname = argv[1]; rcnt = atol(argv[2]); wcnt = atol(argv[3]); } if(rcnt<0 || wcnt<0) { fprintf(stderr, "usage: %s \n", argv[0]); exit(1); } shmptr=wg_attach_database(shmname,DBSIZE); if (shmptr==NULL) exit(2); if(prepare_data(shmptr)) { wg_delete_database(shmname); exit(3); } #ifdef _WIN32 start_ms = (unsigned long long) GetTickCount(); #else gettimeofday(&tv, NULL); start_ms = tv.tv_sec * 1000 + tv.tv_usec / 1000; #endif run_workers(shmptr, rcnt, wcnt); #ifdef _WIN32 end_ms = (unsigned long long) GetTickCount(); #else gettimeofday(&tv, NULL); end_ms = tv.tv_sec * 1000 + tv.tv_usec / 1000; #endif check_data(shmptr, wcnt); fprintf(stdout, "elapsed: %d ms\n", (int) (end_ms - start_ms)); wg_delete_database(shmname); exit(0); } /** * Precreate data for workers */ int prepare_data(void *db) { int i; for (i=0; i= tcnt) break; #ifdef HAVE_PTHREAD pthread_mutex_unlock(&twait_mutex); #endif } /* Now wake up all threads */ #if defined(HAVE_PTHREAD) pthread_cond_broadcast(&twait_cv); pthread_mutex_unlock(&twait_mutex); #elif defined(_WIN32) SetEvent(twait_ev); #endif #endif /* SYNC_THREADS */ /* Join the workers (wait for them to complete) */ for(i=0; idb; threadid = ((pt_data *) threadarg)->threadid; #ifdef CHATTY_THREADS fprintf(stdout, "Writer thread %d started.\n", threadid); #endif #ifdef SYNC_THREADS /* Increment the thread counter to inform the caller * that we are entering wait state. */ #ifdef HAVE_PTHREAD pthread_mutex_lock(&twait_mutex); #endif twait_cnt++; #if defined(HAVE_PTHREAD) pthread_cond_wait(&twait_cv, &twait_mutex); pthread_mutex_unlock(&twait_mutex); #elif defined(_WIN32) WaitForSingleObject(twait_ev, INFINITE); #endif #endif /* SYNC_THREADS */ frec = wg_get_first_record(db); for(i=0; idb; threadid = ((pt_data *) threadarg)->threadid; #ifdef CHATTY_THREADS fprintf(stdout, "Reader thread %d started.\n", threadid); #endif #ifdef SYNC_THREADS /* Enter wait state */ #ifdef HAVE_PTHREAD pthread_mutex_lock(&twait_mutex); #endif twait_cnt++; #if defined(HAVE_PTHREAD) pthread_cond_wait(&twait_cv, &twait_mutex); pthread_mutex_unlock(&twait_mutex); #elif defined(_WIN32) WaitForSingleObject(twait_ev, INFINITE); #endif #endif /* SYNC_THREADS */ for(i=0; i. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . get_dirname () { case $1 in */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';; # Otherwise, we want the empty string (not "."). esac } # guard FILE # ---------- # The CPP macro used to guard inclusion of FILE. guard() { printf '%s\n' "$1" \ | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \ -e 's/__*/_/g' } # quote_for_sed [STRING] # ---------------------- # Return STRING (or stdin) quoted to be used as a sed pattern. quote_for_sed () { case $# in 0) cat;; 1) printf '%s\n' "$1";; esac \ | sed -e 's|[][\\.*]|\\&|g' } case "$1" in '') echo "$0: No files given. Try '$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input="$1" shift # We'll later need for a correct munging of "#line" directives. input_sub_rx=`get_dirname "$input" | quote_for_sed` case "$input" in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input="`pwd`/$input" ;; esac input_rx=`get_dirname "$input" | quote_for_sed` # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot=false if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot=true fi # The parser itself, the first file, is the destination of the .y.c # rule in the Makefile. parser=$1 # A sed program to s/FROM/TO/g for all the FROM/TO so that, for # instance, we rename #include "y.tab.h" into #include "parse.h" # during the conversion from y.tab.c to parse.c. sed_fix_filenames= # Also rename header guards, as Bison 2.7 for instance uses its header # guard in its implementation file. sed_fix_header_guards= while test "$#" -ne 0; do if test "$1" = "--"; then shift break fi from=$1 # Handle y_tab.c and y_tab.h output by DOS if $y_tab_nodot; then case $from in "y.tab.c") from=y_tab.c;; "y.tab.h") from=y_tab.h;; esac fi shift to=$1 shift sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;" sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;" done # The program to run. prog="$1" shift # Make any relative path in $prog absolute. case "$prog" in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog="`pwd`/$prog" ;; esac # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then for from in * do to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"` if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend '../'. case $to in [\\/]* | ?:[\\/]*) target=$to;; *) target="../$to";; esac # Do not overwrite unchanged header files to avoid useless # recompilations. Always update the parser itself: it is the # destination of the .y.c rule in the Makefile. Divert the # output of all other files to a temporary file so we can # compare them to existing versions. if test $from != $parser; then realtarget="$target" target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'` fi # Munge "#line" or "#" directives. Don't let the resulting # debug information point at an absolute srcdir. Use the real # output file name, not yy.lex.c for instance. Adjust the # include guards too. sed -e "/^#/!b" \ -e "s|$input_rx|$input_sub_rx|" \ -e "$sed_fix_filenames" \ -e "$sed_fix_header_guards" \ "$from" >"$target" || ret=$? # Check whether files must be updated. if test "$from" != "$parser"; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$to is unchanged" rm -f "$target" else echo "updating $to" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the parser. This is a # blatant hack to let us support using "yacc -d". If -d is not # specified, don't fail when the header file is "missing". if test "$from" = "$parser"; then ret=1 fi fi done fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: whitedb-0.7.3/Makefile.in0000644000175000001440000012254312426224004012134 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: $ # $Source: $ # # Top level Makefile.am of WhiteDB: calling makes in subdirs # VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @PYTHON_TRUE@am__append_1 = Python subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in test-driver COPYING compile config.guess \ config.sub depcomp install-sh missing py-compile ylwrap \ ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man7dir = $(mandir)/man7 am__installdirs = "$(DESTDIR)$(man7dir)" NROFF = nroff MANS = $(man_MANS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope check recheck distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac DIST_SUBDIRS = Db json Test Main Examples Python DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PRTDIAG = @PRTDIAG@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_INCLUDES = @PYTHON_INCLUDES@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RAPTOR_CONFIG = @RAPTOR_CONFIG@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ #AUTOMAKE_OPTIONS = foreign AUTOMAKE_OPTIONS = subdir-objects SUBDIRS = Db json Test Main Examples $(am__append_1) # --- man --- man_MANS = Doc/whitedb.7 # --- optional components ---- # -------- Tests ------------------- TESTS = Test/common.test Test/log.test # -------- Extras ------------------- EXTRA_DIST = Bootstrap README INSTALL MANIFEST GPLLICENCE NEWS AUTHORS \ Doc/whitedb.7 Doc/python.txt Doc/Manual.txt \ Doc/Install.txt Doc/Utilities.txt Doc/Tutorial.txt \ wgdb.def config-w32.h config-gcc.h Doxyfile compile.sh compile.bat \ unite.sh \ Db/dbapi.h Db/rdfapi.h Db/indexapi.h \ Examples/compile_demo.sh Examples/compile_demo.bat \ Examples/compile_query.sh Examples/compile_query.bat \ Examples/dserve.c Examples/tut1.c Examples/tut2.c Examples/tut3.c \ Examples/tut4.c Examples/tut5.c Examples/tut6.c Examples/tut7.c \ Examples/speed/README Examples/speed/speed1.c Examples/speed/speed2.c \ Examples/speed/speed3.c Examples/speed/speed4.c Examples/speed/speed5.c \ Examples/speed/speed6.c Examples/speed/speed7.c Examples/speed/speed8.c \ Examples/speed/speed10.c Examples/speed/speed11.c Examples/speed/speed12.c \ Examples/speed/speed13.c Examples/speed/speed15.c Examples/speed/speed16.c \ Python/compile.bat Python/compile.sh Python/tests.py \ Test/common.test Test/log.test all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .log .test .test$(EXEEXT) .trs am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-man7: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man7dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man7dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man7dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.7[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man7dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man7dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man7dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man7dir)" || exit $$?; }; \ done; } uninstall-man7: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man7dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.7[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man7dir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ else \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile $(MANS) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(man7dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-man install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-man7 install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man7 .MAKE: $(am__recursive_targets) all check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-TESTS check-am clean clean-cscope \ clean-generic clean-libtool cscope cscopelist-am ctags \ ctags-am dist dist-all dist-bzip2 dist-gzip dist-lzip \ dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \ distclean-generic distclean-hdr distclean-libtool \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-man7 \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am recheck tags tags-am uninstall uninstall-am \ uninstall-man uninstall-man7 Test/log.log: Test/common.log # this conflicts with the distcheck target, so disabled for now. #dist-hook: # cp $(top_distdir)/config-gcc.h $(top_distdir)/config.h # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: whitedb-0.7.3/configure0000755000175000001440000167747112426223765012033 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for WhiteDB 0.7.3. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='WhiteDB' PACKAGE_TARNAME='whitedb' PACKAGE_VERSION='0.7.3' PACKAGE_STRING='WhiteDB 0.7.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="Db/dballoc.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS AM_CFLAGS PRTDIAG REASONER_FALSE REASONER_TRUE BISON LEXLIB LEX_OUTPUT_ROOT LEX RAPTOR_FALSE RAPTOR_TRUE RAPTOR_CONFIG PYTHON_FALSE PYTHON_TRUE PYTHON_LIBS PYTHON_INCLUDES pkgpyexecdir pyexecdir pkgpythondir pythondir PYTHON_PLATFORM PYTHON_EXEC_PREFIX PYTHON_PREFIX PYTHON_VERSION PYTHON PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CC acx_pthread_config CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_shared enable_static with_pic enable_fast_install enable_dependency_tracking with_gnu_ld with_sysroot enable_libtool_lock with_python with_logdir enable_logging enable_locking enable_checking enable_single_compare enable_tstar enable_backlink enable_childdb enable_index_templates enable_reasoner enable_strhash_size with_gcc_arch ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PYTHON' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures WhiteDB 0.7.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/whitedb] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of WhiteDB 0.7.3:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --disable-libtool-lock avoid locking (might break parallel builds) --enable-logging enable transaction logging --enable-locking select locking protocol (rpspin,wpspin,tfqueue,no) [default=tfqueue] --disable-checking disable additional validation checks in API layer (small performance gain) --disable-single-compare disable experimental single compare algorithm in T-tree search --disable-tstar disable experimental chained T-tree (similar to T* tree) index algorithm --disable-backlink disable record backlinking --enable-childdb enable child database support --disable-index-templates disable support for index templates --enable-reasoner enable reasoner --enable-strhash-size set string hash size (% of db size) [default=2] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-python enable building Python bindings --with-logdir=DIR Journal file directory [default=/tmp] --with-gcc-arch= use architecture for gcc -march/-mtune, instead of guessing Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PYTHON the Python interpreter Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF WhiteDB configure 0.7.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by WhiteDB $as_me 0.7.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: ====== initialising ======" >&5 $as_echo "$as_me: ====== initialising ======" >&6;} # Add new configuration files ac_config_headers="$ac_config_headers config.h" am__api_version='1.14' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='whitedb' VERSION='0.7.3' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi #Initialize libtool case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: # ------- Checking ------- { $as_echo "$as_me:${as_lineno-$LINENO}: ====== checking ======" >&5 $as_echo "$as_me: ====== checking ======" >&6;} ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi # for per-target flags #Checks for libraries. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_join (); int main () { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 $as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_acx_pthread_config+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$acx_pthread_config"; then ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_acx_pthread_config="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no" fi fi acx_pthread_config=$ac_cv_prog_acx_pthread_config if test -n "$acx_pthread_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5 $as_echo "$acx_pthread_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 $as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int attr=$attr; return attr; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : attr_name=$attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 $as_echo "$attr_name" >&6; } if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then cat >>confdefs.h <<_ACEOF #define PTHREAD_CREATE_JOINABLE $attr_name _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 $as_echo "${flag}" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then for ac_prog in xlc_r cc_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PTHREAD_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_PTHREAD_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}" else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h : else acx_pthread_ok=no fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } if ${ac_cv_lib_m_cos+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char cos (); int main () { return cos (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_cos=yes else ac_cv_lib_m_cos=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } if test "x$ac_cv_lib_m_cos" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF LIBS="-lm $LIBS" fi #Check for programs #Check for Python (optional) # Check whether --with-python was given. if test "${with_python+set}" = set; then : withval=$with_python; else with_python=no fi if test "x$with_python" != "xno" then if test "x$with_python" != "xyes" then PYTHON="$with_python" fi # Find any Python interpreter. if test -z "$PYTHON"; then for ac_prog in python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PYTHON+:} false; then : $as_echo_n "(cached) " >&6 else case $PYTHON in [\\/]* | ?:[\\/]*) ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PYTHON=$ac_cv_path_PYTHON if test -n "$PYTHON"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 $as_echo "$PYTHON" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PYTHON" && break done test -n "$PYTHON" || PYTHON=":" fi am_display_PYTHON=python if test "$PYTHON" = :; then as_fn_error $? "no suitable Python interpreter found" "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON version" >&5 $as_echo_n "checking for $am_display_PYTHON version... " >&6; } if ${am_cv_python_version+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5 $as_echo "$am_cv_python_version" >&6; } PYTHON_VERSION=$am_cv_python_version PYTHON_PREFIX='${prefix}' PYTHON_EXEC_PREFIX='${exec_prefix}' { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON platform" >&5 $as_echo_n "checking for $am_display_PYTHON platform... " >&6; } if ${am_cv_python_platform+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5 $as_echo "$am_cv_python_platform" >&6; } PYTHON_PLATFORM=$am_cv_python_platform # Just factor out some code duplication. am_python_setup_sysconfig="\ import sys # Prefer sysconfig over distutils.sysconfig, for better compatibility # with python 3.x. See automake bug#10227. try: import sysconfig except ImportError: can_use_sysconfig = 0 else: can_use_sysconfig = 1 # Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs: # try: from platform import python_implementation if python_implementation() == 'CPython' and sys.version[:3] == '2.7': can_use_sysconfig = 0 except ImportError: pass" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5 $as_echo_n "checking for $am_display_PYTHON script directory... " >&6; } if ${am_cv_python_pythondir+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$prefix" = xNONE then am_py_prefix=$ac_default_prefix else am_py_prefix=$prefix fi am_cv_python_pythondir=`$PYTHON -c " $am_python_setup_sysconfig if can_use_sysconfig: sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'}) else: from distutils import sysconfig sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix') sys.stdout.write(sitedir)"` case $am_cv_python_pythondir in $am_py_prefix*) am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"` ;; *) case $am_py_prefix in /usr|/System*) ;; *) am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5 $as_echo "$am_cv_python_pythondir" >&6; } pythondir=$am_cv_python_pythondir pkgpythondir=\${pythondir}/$PACKAGE { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON extension module directory" >&5 $as_echo_n "checking for $am_display_PYTHON extension module directory... " >&6; } if ${am_cv_python_pyexecdir+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$exec_prefix" = xNONE then am_py_exec_prefix=$am_py_prefix else am_py_exec_prefix=$exec_prefix fi am_cv_python_pyexecdir=`$PYTHON -c " $am_python_setup_sysconfig if can_use_sysconfig: sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'}) else: from distutils import sysconfig sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix') sys.stdout.write(sitedir)"` case $am_cv_python_pyexecdir in $am_py_exec_prefix*) am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"` ;; *) case $am_py_exec_prefix in /usr|/System*) ;; *) am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5 $as_echo "$am_cv_python_pyexecdir" >&6; } pyexecdir=$am_cv_python_pyexecdir pkgpyexecdir=\${pyexecdir}/$PACKAGE fi else PYTHON="" fi if test "x$PYTHON" != "x" then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for headers required to compile python extensions" >&5 $as_echo_n "checking for headers required to compile python extensions... " >&6; } py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"` py_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"` if test -x "$PYTHON-config"; then PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null` else PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" if test "$py_prefix" != "$py_exec_prefix"; then PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" fi if test "${IS_WINDOWS}" = "yes"; then PYTHON_INCLUDES=`echo $PYTHON_INCLUDES -I${py_prefix}/include | sed s%\\\\\\\\%/%g` PYTHON_VER=`echo ${PYTHON_VERSION} | sed s:\\\\.::` PYTHON_LIBS=`echo -L${py_prefix}/libs -lpython${PYTHON_VER} | sed s%\\\\\\\\%/%g` fi fi save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 $as_echo "found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } PYTHON= fi rm -f conftest.err conftest.i conftest.$ac_ext CPPFLAGS="$save_CPPFLAGS" fi # If PYTHON is non-empty, contents of Python subdir will be # included in the build. This also implies that the check for # headers was successful and PYTHON_INCLUDES contains something useful. if test "x$PYTHON" != "x"; then PYTHON_TRUE= PYTHON_FALSE='#' else PYTHON_TRUE='#' PYTHON_FALSE= fi #Check for Raptor (optional) for ac_prog in raptor-config do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RAPTOR_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RAPTOR_CONFIG"; then ac_cv_prog_RAPTOR_CONFIG="$RAPTOR_CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RAPTOR_CONFIG="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RAPTOR_CONFIG=$ac_cv_prog_RAPTOR_CONFIG if test -n "$RAPTOR_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RAPTOR_CONFIG" >&5 $as_echo "$RAPTOR_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$RAPTOR_CONFIG" && break done if test "x$RAPTOR_CONFIG" != "x"; then RAPTOR_TRUE= RAPTOR_FALSE='#' else RAPTOR_TRUE='#' RAPTOR_FALSE= fi if test "x$RAPTOR_CONFIG" != "x" then $as_echo "#define HAVE_RAPTOR 1" >>confdefs.h fi # lex and bison (needed for reasoner) for ac_prog in flex lex do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LEX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LEX"; then ac_cv_prog_LEX="$LEX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LEX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LEX=$ac_cv_prog_LEX if test -n "$LEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5 $as_echo "$LEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LEX" && break done test -n "$LEX" || LEX=":" if test "x$LEX" != "x:"; then cat >conftest.l <<_ACEOF %% a { ECHO; } b { REJECT; } c { yymore (); } d { yyless (1); } e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */ yyless ((input () != 0)); } f { unput (yytext[0]); } . { BEGIN INITIAL; } %% #ifdef YYTEXT_POINTER extern char *yytext; #endif int main (void) { return ! yylex () + ! yywrap (); } _ACEOF { { ac_try="$LEX conftest.l" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$LEX conftest.l") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5 $as_echo_n "checking lex output file root... " >&6; } if ${ac_cv_prog_lex_root+:} false; then : $as_echo_n "(cached) " >&6 else if test -f lex.yy.c; then ac_cv_prog_lex_root=lex.yy elif test -f lexyy.c; then ac_cv_prog_lex_root=lexyy else as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5 $as_echo "$ac_cv_prog_lex_root" >&6; } LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root if test -z "${LEXLIB+set}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5 $as_echo_n "checking lex library... " >&6; } if ${ac_cv_lib_lex+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_LIBS=$LIBS ac_cv_lib_lex='none needed' for ac_lib in '' -lfl -ll; do LIBS="$ac_lib $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lex=$ac_lib fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext test "$ac_cv_lib_lex" != 'none needed' && break done LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5 $as_echo "$ac_cv_lib_lex" >&6; } test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5 $as_echo_n "checking whether yytext is a pointer... " >&6; } if ${ac_cv_prog_lex_yytext_pointer+:} false; then : $as_echo_n "(cached) " >&6 else # POSIX says lex can declare yytext either as a pointer or an array; the # default is implementation-dependent. Figure out which it is, since # not all implementations provide the %pointer and %array declarations. ac_cv_prog_lex_yytext_pointer=no ac_save_LIBS=$LIBS LIBS="$LEXLIB $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define YYTEXT_POINTER 1 `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_prog_lex_yytext_pointer=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5 $as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; } if test $ac_cv_prog_lex_yytext_pointer = yes; then $as_echo "#define YYTEXT_POINTER 1" >>confdefs.h fi rm -f conftest.l $LEX_OUTPUT_ROOT.c fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}bison", so it can be a program name with args. set dummy ${ac_tool_prefix}bison; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_BISON+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$BISON"; then ac_cv_prog_BISON="$BISON" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_BISON="${ac_tool_prefix}bison" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi BISON=$ac_cv_prog_BISON if test -n "$BISON"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5 $as_echo "$BISON" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_BISON"; then ac_ct_BISON=$BISON # Extract the first word of "bison", so it can be a program name with args. set dummy bison; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_BISON+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_BISON"; then ac_cv_prog_ac_ct_BISON="$ac_ct_BISON" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_BISON="bison" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_BISON=$ac_cv_prog_ac_ct_BISON if test -n "$ac_ct_BISON"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_BISON" >&5 $as_echo "$ac_ct_BISON" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_BISON" = x; then BISON=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac BISON=$ac_ct_BISON fi else BISON="$ac_cv_prog_BISON" fi # futex availability ac_fn_c_check_header_mongrel "$LINENO" "linux/futex.h" "ac_cv_header_linux_futex_h" "$ac_includes_default" if test "x$ac_cv_header_linux_futex_h" = xyes; then : futex=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: Futexes not supported, tfqueue locks not available" >&5 $as_echo "Futexes not supported, tfqueue locks not available" >&6; } fi # Set the journal directory # Check whether --with-logdir was given. if test "${with_logdir+set}" = set; then : withval=$with_logdir; with_logdir="$withval" else with_logdir="/tmp" fi if test "x$with_logdir" = "xyes" -o "x$with_logdir" = "xno" then # define it anyway, even if the user picked --without LOGDIR="/tmp" else LOGDIR="$with_logdir" fi cat >>confdefs.h <<_ACEOF #define DBLOG_DIR "$LOGDIR" _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ptrdiff_t" >&5 $as_echo_n "checking size of ptrdiff_t... " >&6; } if ${ac_cv_sizeof_ptrdiff_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (ptrdiff_t))" "ac_cv_sizeof_ptrdiff_t" "$ac_includes_default"; then : else if test "$ac_cv_type_ptrdiff_t" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (ptrdiff_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_ptrdiff_t=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_ptrdiff_t" >&5 $as_echo "$ac_cv_sizeof_ptrdiff_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_PTRDIFF_T $ac_cv_sizeof_ptrdiff_t _ACEOF if test $ac_cv_sizeof_ptrdiff_t -eq 8 then $as_echo "#define HAVE_64BIT_GINT 1" >>confdefs.h fi # ----------- configuration options ---------- { $as_echo "$as_me:${as_lineno-$LINENO}: ====== setting configuration options ======" >&5 $as_echo "$as_me: ====== setting configuration options ======" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for logging" >&5 $as_echo_n "checking for logging... " >&6; } # Check whether --enable-logging was given. if test "${enable_logging+set}" = set; then : enableval=$enable_logging; logging=$enable_logging else logging=no fi if test "$logging" != no then $as_echo "#define USE_DBLOG 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled, journal directory is $LOGDIR" >&5 $as_echo "enabled, journal directory is $LOGDIR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for locking protocol" >&5 $as_echo_n "checking for locking protocol... " >&6; } # Check whether --enable-locking was given. if test "${enable_locking+set}" = set; then : enableval=$enable_locking; locking=$enable_locking else locking=tfqueue fi if test "$locking" == no then { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } elif test "$locking" == wpspin then $as_echo "#define LOCK_PROTO 2" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: wpspin" >&5 $as_echo "wpspin" >&6; } elif test "$locking" == tfqueue -a "$futex" == "yes" then $as_echo "#define LOCK_PROTO 3" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: tfqueue" >&5 $as_echo "tfqueue" >&6; } else # unknown or unsupported value, revert to default $as_echo "#define LOCK_PROTO 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: rpspin" >&5 $as_echo "rpspin" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for additional validation checks" >&5 $as_echo_n "checking for additional validation checks... " >&6; } # Check whether --enable-checking was given. if test "${enable_checking+set}" = set; then : enableval=$enable_checking; checking=$enable_checking else checking=yes fi if test "$checking" != no then $as_echo "#define CHECK 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 $as_echo "enabled" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for single-compare T-tree mode" >&5 $as_echo_n "checking for single-compare T-tree mode... " >&6; } # Check whether --enable-single_compare was given. if test "${enable_single_compare+set}" = set; then : enableval=$enable_single_compare; single_compare=$enable_single_compare else single_compare=yes fi if test "$single_compare" != no then $as_echo "#define TTREE_SINGLE_COMPARE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 $as_echo "enabled" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for chained T-tree nodes algorithm" >&5 $as_echo_n "checking for chained T-tree nodes algorithm... " >&6; } # Check whether --enable-tstar was given. if test "${enable_tstar+set}" = set; then : enableval=$enable_tstar; tstar=$enable_tstar else tstar=yes fi if test "$tstar" != no then $as_echo "#define TTREE_CHAINED_NODES 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 $as_echo "enabled" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for backlinking" >&5 $as_echo_n "checking for backlinking... " >&6; } # Check whether --enable-backlink was given. if test "${enable_backlink+set}" = set; then : enableval=$enable_backlink; backlink=$enable_backlink else backlink=yes fi if test "$backlink" != no then $as_echo "#define USE_BACKLINKING 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 $as_echo "enabled" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for child db support" >&5 $as_echo_n "checking for child db support... " >&6; } # Check whether --enable-childdb was given. if test "${enable_childdb+set}" = set; then : enableval=$enable_childdb; childdb=$enable_childdb else childdb=no fi if test "$childdb" != no then $as_echo "#define USE_CHILD_DB 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 $as_echo "enabled" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for index templates" >&5 $as_echo_n "checking for index templates... " >&6; } # Check whether --enable-index_templates was given. if test "${enable_index_templates+set}" = set; then : enableval=$enable_index_templates; index_templates=$enable_index_templates else index_templates=yes fi if test "$index_templates" != no then $as_echo "#define USE_INDEX_TEMPLATE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 $as_echo "enabled" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for reasoner" >&5 $as_echo_n "checking for reasoner... " >&6; } # Check whether --enable-reasoner was given. if test "${enable_reasoner+set}" = set; then : enableval=$enable_reasoner; reasoner=$enable_reasoner else reasoner=no fi if test "$reasoner" != no then { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled, reasoner not distributed with this release" >&5 $as_echo "disabled, reasoner not distributed with this release" >&6; } reasoner=no else { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi if test "$reasoner" != no; then REASONER_TRUE= REASONER_FALSE='#' else REASONER_TRUE='#' REASONER_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking string hash size" >&5 $as_echo_n "checking string hash size... " >&6; } # Check whether --enable-strhash_size was given. if test "${enable_strhash_size+set}" = set; then : enableval=$enable_strhash_size; strhash_size=$enable_strhash_size else strhash_size=2 fi if test "x$strhash_size" = xyes -o "x$strhash_size" = xno -o "x$strhash_size" = x then $as_echo "#define STRHASH_SIZE 2" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: 2" >&5 $as_echo "2" >&6; } else cat >>confdefs.h <<_ACEOF #define STRHASH_SIZE $strhash_size _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: $strhash_size" >&5 $as_echo "$strhash_size" >&6; } fi # ---------- Compiler flags -------- { $as_echo "$as_me:${as_lineno-$LINENO}: ====== setting compiler flags ======" >&5 $as_echo "$as_me: ====== setting compiler flags ======" >&6;} auto_cflags="-Wall" # Check whether --with-gcc-arch was given. if test "${with_gcc_arch+set}" = set; then : withval=$with_gcc_arch; ax_gcc_arch=$withval else ax_gcc_arch=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc architecture flag" >&5 $as_echo_n "checking for gcc architecture flag... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5 $as_echo "" >&6; } if ${ax_cv_gcc_archflag+:} false; then : $as_echo_n "(cached) " >&6 else ax_cv_gcc_archflag="unknown" if test "$GCC" = yes; then if test "x$ax_gcc_arch" = xyes; then ax_gcc_arch="" if test "$cross_compiling" = no; then case $host_cpu in i[3456]86*|x86_64*) # use cpuid codes, in part from x86info-1.7 by D. Jones ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0 output" >&5 $as_echo_n "checking for x86 cpuid 0 output... " >&6; } if ${ax_cv_gcc_x86_cpuid_0+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ax_cv_gcc_x86_cpuid_0=unknown else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int op = 0, eax, ebx, ecx, edx; FILE *f; __asm__("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (op)); f = fopen("conftest_cpuid", "w"); if (!f) return 1; fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); fclose(f); return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ax_cv_gcc_x86_cpuid_0=`cat conftest_cpuid`; rm -f conftest_cpuid else ax_cv_gcc_x86_cpuid_0=unknown; rm -f conftest_cpuid fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0" >&5 $as_echo "$ax_cv_gcc_x86_cpuid_0" >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 1 output" >&5 $as_echo_n "checking for x86 cpuid 1 output... " >&6; } if ${ax_cv_gcc_x86_cpuid_1+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ax_cv_gcc_x86_cpuid_1=unknown else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int op = 1, eax, ebx, ecx, edx; FILE *f; __asm__("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (op)); f = fopen("conftest_cpuid", "w"); if (!f) return 1; fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); fclose(f); return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ax_cv_gcc_x86_cpuid_1=`cat conftest_cpuid`; rm -f conftest_cpuid else ax_cv_gcc_x86_cpuid_1=unknown; rm -f conftest_cpuid fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_1" >&5 $as_echo "$ax_cv_gcc_x86_cpuid_1" >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu case $ax_cv_gcc_x86_cpuid_0 in *:756e6547:*:*) # Intel case $ax_cv_gcc_x86_cpuid_1 in *5[48]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; *5??:*:*:*) ax_gcc_arch=pentium ;; *6[3456]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; *6a?:*[01]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; *6a?:*[234]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; *6[9d]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; *6[78b]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; *6??:*:*:*) ax_gcc_arch=pentiumpro ;; *f3[347]:*:*:*|*f41347:*:*:*) case $host_cpu in x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;; *) ax_gcc_arch="prescott pentium4 pentiumpro" ;; esac ;; *f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";; esac ;; *:68747541:*:*) # AMD case $ax_cv_gcc_x86_cpuid_1 in *5[67]?:*:*:*) ax_gcc_arch=k6 ;; *5[8d]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; *5[9]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; *60?:*:*:*) ax_gcc_arch=k7 ;; *6[12]?:*:*:*) ax_gcc_arch="athlon k7" ;; *6[34]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;; *6[68a]?:*:*:*) ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0x80000006 output" >&5 $as_echo_n "checking for x86 cpuid 0x80000006 output... " >&6; } if ${ax_cv_gcc_x86_cpuid_0x80000006+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ax_cv_gcc_x86_cpuid_0x80000006=unknown else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int op = 0x80000006, eax, ebx, ecx, edx; FILE *f; __asm__("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (op)); f = fopen("conftest_cpuid", "w"); if (!f) return 1; fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); fclose(f); return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ax_cv_gcc_x86_cpuid_0x80000006=`cat conftest_cpuid`; rm -f conftest_cpuid else ax_cv_gcc_x86_cpuid_0x80000006=unknown; rm -f conftest_cpuid fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0x80000006" >&5 $as_echo "$ax_cv_gcc_x86_cpuid_0x80000006" >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # L2 cache size case $ax_cv_gcc_x86_cpuid_0x80000006 in *:*:*[1-9a-f]??????:*) # (L2 = ecx >> 16) >= 256 ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; *) ax_gcc_arch="athlon-4 athlon k7" ;; esac ;; *f[4cef8b]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; *f5?:*:*:*) ax_gcc_arch="opteron k8" ;; *f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;; *f??:*:*:*) ax_gcc_arch="k8" ;; esac ;; *:746e6543:*:*) # IDT case $ax_cv_gcc_x86_cpuid_1 in *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; *58?:*:*:*) ax_gcc_arch=winchip2 ;; *6[78]?:*:*:*) ax_gcc_arch=c3 ;; *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;; esac ;; esac if test x"$ax_gcc_arch" = x; then # fallback case $host_cpu in i586*) ax_gcc_arch=pentium ;; i686*) ax_gcc_arch=pentiumpro ;; esac fi ;; sparc*) # Extract the first word of "prtdiag", so it can be a program name with args. set dummy prtdiag; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PRTDIAG+:} false; then : $as_echo_n "(cached) " >&6 else case $PRTDIAG in [\\/]* | ?:[\\/]*) ac_cv_path_PRTDIAG="$PRTDIAG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PRTDIAG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PRTDIAG" && ac_cv_path_PRTDIAG="prtdiag" ;; esac fi PRTDIAG=$ac_cv_path_PRTDIAG if test -n "$PRTDIAG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PRTDIAG" >&5 $as_echo "$PRTDIAG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` cputype=`echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters` case $cputype in *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; *supersparc*|*tms390z5[05]*) ax_gcc_arch="supersparc v8" ;; *hypersparc*|*rt62[056]*) ax_gcc_arch="hypersparc v8" ;; *cypress*) ax_gcc_arch=cypress ;; esac ;; alphaev5) ax_gcc_arch=ev5 ;; alphaev56) ax_gcc_arch=ev56 ;; alphapca56) ax_gcc_arch="pca56 ev56" ;; alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; alphaev6) ax_gcc_arch=ev6 ;; alphaev67) ax_gcc_arch=ev67 ;; alphaev68) ax_gcc_arch="ev68 ev67" ;; alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; powerpc*) cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'` case $cputype in *750*) ax_gcc_arch="750 G3" ;; *740[0-9]*) ax_gcc_arch="$cputype 7400 G4" ;; *74[4-5][0-9]*) ax_gcc_arch="$cputype 7450 G4" ;; *74[0-9][0-9]*) ax_gcc_arch="$cputype G4" ;; *970*) ax_gcc_arch="970 G5 power4";; *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; 603ev|8240) ax_gcc_arch="$cputype 603e 603";; *) ax_gcc_arch=$cputype ;; esac ax_gcc_arch="$ax_gcc_arch powerpc" ;; esac fi # not cross-compiling fi # guess arch if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then for arch in $ax_gcc_arch; do if test "xno" = xyes; then # if we require portable code flags="-mtune=$arch" # -mcpu=$arch and m$arch generate nonportable code on every arch except # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac else flags="-march=$arch -mcpu=$arch -m$arch" fi for flag in $flags; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 $as_echo_n "checking whether C compiler accepts $flag... " >&6; } ax_save_FLAGS=$CFLAGS CFLAGS="$flag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval `$as_echo "ax_cv_c_flags_$flag" | $as_tr_sh`=yes else eval `$as_echo "ax_cv_c_flags_$flag" | $as_tr_sh`=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=$ax_save_FLAGS eval ax_check_compiler_flags=$`$as_echo "ax_cv_c_flags_$flag" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_check_compiler_flags" >&5 $as_echo "$ax_check_compiler_flags" >&6; } if test "x$ax_check_compiler_flags" = xyes; then ax_cv_gcc_archflag=$flag; break else : fi done test "x$ax_cv_gcc_archflag" = xunknown || break done fi fi # $GCC=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc architecture flag" >&5 $as_echo_n "checking for gcc architecture flag... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_archflag" >&5 $as_echo "$ax_cv_gcc_archflag" >&6; } if test "x$ax_cv_gcc_archflag" = xunknown; then : else CFLAGS="$CFLAGS $ax_cv_gcc_archflag" fi AM_CFLAGS="$auto_cflags" # ---------- Final creation -------- { $as_echo "$as_me:${as_lineno-$LINENO}: ====== final steps ======" >&5 $as_echo "$as_me: ====== final steps ======" >&6;} $as_echo "#define VERSION_MAJOR 0" >>confdefs.h $as_echo "#define VERSION_MINOR 7" >>confdefs.h $as_echo "#define VERSION_REV 3" >>confdefs.h ac_config_files="$ac_config_files Makefile Db/Makefile json/Makefile Test/Makefile Main/Makefile Examples/Makefile Python/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${PYTHON_TRUE}" && test -z "${PYTHON_FALSE}"; then as_fn_error $? "conditional \"PYTHON\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${RAPTOR_TRUE}" && test -z "${RAPTOR_FALSE}"; then as_fn_error $? "conditional \"RAPTOR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${REASONER_TRUE}" && test -z "${REASONER_FALSE}"; then as_fn_error $? "conditional \"REASONER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by WhiteDB $as_me 0.7.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ WhiteDB config.status 0.7.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "Db/Makefile") CONFIG_FILES="$CONFIG_FILES Db/Makefile" ;; "json/Makefile") CONFIG_FILES="$CONFIG_FILES json/Makefile" ;; "Test/Makefile") CONFIG_FILES="$CONFIG_FILES Test/Makefile" ;; "Main/Makefile") CONFIG_FILES="$CONFIG_FILES Main/Makefile" ;; "Examples/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/Makefile" ;; "Python/Makefile") CONFIG_FILES="$CONFIG_FILES Python/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi whitedb-0.7.3/Test/0000755000175000001440000000000012426224010011054 500000000000000whitedb-0.7.3/Test/dbtest.c0000644000175000001440000047363012421471034012447 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2010, 2011, 2012, 2013, 2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbtest.c * Database testing, checking and report procedures * */ /* ====== Includes =============== */ #include #include #include #include #include #include #include #ifndef _WIN32 #include #else #include #include #include #include #endif #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "../Db/dballoc.h" #include "../Db/dbdata.h" #include "../Db/dbhash.h" #include "../Db/dbindex.h" #include "../Db/dbmem.h" #include "../Db/dbutil.h" #include "../Db/dbquery.h" #include "../Db/dbcompare.h" #include "../Db/dblog.h" #include "../Db/dbschema.h" #include "../Db/dbjson.h" #include "dbtest.h" /* ====== Private headers and defs ======== */ #ifdef _WIN32 #define snprintf sprintf_s #endif #define OK_TO_CONTINUE(x) ((x)==0 || (x)==77) /* 77 - skipped test in * autotools framework */ /* ======= Private protos ================ */ static int do_check_parse_encode(void *db, gint enc, gint exptype, void *expval, int printlevel); static gint wg_check_db(void* db); static gint wg_check_datatype_writeread(void* db, int printlevel); static gint wg_check_backlinking(void* db, int printlevel); static gint wg_check_parse_encode(void* db, int printlevel); static gint wg_check_compare(void* db, int printlevel); static gint wg_check_query_param(void* db, int printlevel); static gint wg_check_strhash(void* db, int printlevel); static gint wg_test_index1(void *db, int magnitude, int printlevel); static gint wg_test_index2(void *db, int printlevel); static gint wg_test_index3(void *db, int magnitude, int printlevel); static gint wg_check_childdb(void* db, int printlevel); static gint wg_check_schema(void* db, int printlevel); static gint wg_check_json_parsing(void* db, int printlevel); static gint wg_check_idxhash(void* db, int printlevel); static gint wg_test_query(void *db, int magnitude, int printlevel); static gint wg_check_log(void* db, int printlevel); static void wg_show_db_area_header(void* db, void* area_header); static void wg_show_bucket_freeobjects(void* db, gint freelist); static void wg_show_strhash(void* db); static gint wg_count_freelist(void* db, gint freelist); static gint check_varlen_area(void* db, void* area_header); static gint check_varlen_area_freelist(void* db, void* area_header); static gint check_bucket_freeobjects(void* db, void* area_header, gint bucketindex); static gint check_varlen_area_markers(void* db, void* area_header); static gint check_varlen_area_dv(void* db, void* area_header); static gint check_object_in_areabounds(void*db,void* area_header,gint offset,gint size); static gint check_varlen_area_scan(void* db, void* area_header); static gint check_varlen_object_infreelist(void* db, void* area_header, gint offset, gint isfree); static int guarded_strlen(char* str); static int guarded_strcmp(char* a, char* b); static int bufguarded_strcmp(char* a, char* b); static int validate_index(void *db, void *rec, int rows, int column, int printlevel); static int validate_mc_index(void *db, void *rec, size_t rows, gint index_id, gint *columns, size_t col_count, int printlevel); #ifdef USE_CHILD_DB static int childdb_mkindex(void *db, int cnt); static int childdb_ckindex(void *db, int cnt, int printlevel); static int childdb_dropindex(void *db, int cnt); #endif static gint longstr_in_hash(void* db, char* data, char* extrastr, gint type, gint length); static int is_offset_in_list(void *db, gint reclist_offset, gint offset); static int check_matching_rows(void *db, int col, int cond, void *val, gint type, int expected, int printlevel); static int check_db_rows(void *db, int expected, int printlevel); static int check_sanity(void *db); /* ====== Functions ============== */ /** Run database tests. * Allows each test to be run in separate locally allocated databases, * if necessary. * * returns 0 if no errors. * returns 77 if a test was skipped. NOTE: this onlt makes sense * if the function is called with a single test. * * otherwise returns error code. */ int wg_run_tests(int tests, int printlevel) { int tmp = 0; void *db = NULL; if(tests & WG_TEST_COMMON) { db = wg_attach_local_database(800000); wg_show_db_memsegment_header(db); tmp=check_sanity(db); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_db(db); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_datatype_writeread(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_parse_encode(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_backlinking(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_compare(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_query_param(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_db(db); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_strhash(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_test_index2(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_childdb(db,printlevel); wg_delete_local_database(db); if (OK_TO_CONTINUE(tmp)) { /* separate database for the schema */ db = wg_attach_local_database(800000); tmp=wg_check_schema(db,printlevel); /* run this first */ if (OK_TO_CONTINUE(tmp)) tmp=wg_check_json_parsing(db,printlevel); if (OK_TO_CONTINUE(tmp)) tmp=wg_check_idxhash(db,printlevel); wg_delete_local_database(db); } if (OK_TO_CONTINUE(tmp)) { printf("\n***** Quick tests passed ******\n"); } else { printf("\n***** Quick test failed ******\n"); return tmp; } } if(tests & WG_TEST_INDEX) { db = wg_attach_local_database(20000000); tmp = wg_test_index1(db, 50, printlevel); wg_delete_local_database(db); if(OK_TO_CONTINUE(tmp)) { db = wg_attach_local_database(20000000); tmp = wg_test_index3(db, 50, printlevel); wg_delete_local_database(db); } if (!OK_TO_CONTINUE(tmp)) { printf("\n***** Index test failed ******\n"); return tmp; } else { printf("\n***** Index test succeeded ******\n"); } } if(tests & WG_TEST_QUERY) { db = wg_attach_local_database(120000000); tmp = wg_test_query(db, 4, printlevel); wg_delete_local_database(db); if (!OK_TO_CONTINUE(tmp)) { printf("\n***** Query test failed ******\n"); return tmp; } else { printf("\n***** Query test succeeded ******\n"); } } if(tests & WG_TEST_LOG) { db = wg_attach_local_database(800000); tmp = wg_check_log(db, printlevel); wg_delete_local_database(db); if (!OK_TO_CONTINUE(tmp)) { printf("\n***** Log test failed ******\n"); return tmp; } else { printf("\n***** Log test succeeded ******\n"); } } /* Add other tests here */ return tmp; } /* ---------------- overviews, statistics ---------------------- */ /** print an overview of full memsegment memory usage and addresses * * */ void wg_show_db_memsegment_header(void* db) { db_memsegment_header* dbh = dbmemsegh(db); printf("\nShowing db segment information\n"); printf("==============================\n"); printf("mark %d\n", (int) dbh->mark); #ifdef _WIN32 printf("size %Id\n", dbh->size); printf("free %Id\n", dbh->free); #else printf("size %td\n", dbh->size); printf("free %td\n", dbh->free); #endif printf("initialadr %p\n", (void *) dbh->initialadr); printf("key %d\n", (int) dbh->key); printf("segment header size %d\n", (int) sizeof(db_memsegment_header)); printf("subarea array size %d\n",SUBAREA_ARRAY_SIZE); printf("\ndatarec_area\n"); printf("-------------\n"); wg_show_db_area_header(db,&(dbh->datarec_area_header)); printf("\nlongstr_area\n"); printf("-------------\n"); wg_show_db_area_header(db,&(dbh->longstr_area_header)); printf("\nlistcell_area\n"); printf("-------------\n"); wg_show_db_area_header(db,&(dbh->listcell_area_header)); printf("\nshortstr_area\n"); printf("-------------\n"); wg_show_db_area_header(db,&(dbh->shortstr_area_header)); printf("\nword_area\n"); printf("-------------\n"); wg_show_db_area_header(db,&(dbh->word_area_header)); printf("\ndoubleword_area\n"); printf("-------------\n"); wg_show_db_area_header(db,&(dbh->doubleword_area_header)); printf("\ntnode_area\n"); printf("-------------\n"); wg_show_db_area_header(db,&(dbh->tnode_area_header)); } /** print an overview of a single area memory usage and addresses * * */ static void wg_show_db_area_header(void* db, void* area_header) { db_area_header* areah; gint i; areah=(db_area_header*)area_header; if (areah->fixedlength) { printf("fixedlength with objlength %d bytes\n", (int) areah->objlength); printf("freelist %d\n", (int) areah->freelist); printf("freelist len %d\n", (int) wg_count_freelist(db,areah->freelist)); } else { printf("varlength\n"); } printf("last_subarea_index %d\n", (int) areah->last_subarea_index); for (i=0;i<=(areah->last_subarea_index);i++) { printf("subarea nr %d \n", (int) i); printf(" size %d\n", (int) ((areah->subarea_array)[i]).size); printf(" offset %d\n", (int) ((areah->subarea_array)[i]).offset); printf(" alignedsize %d\n", (int) ((areah->subarea_array)[i]).alignedsize); printf(" alignedoffset %d\n", (int) ((areah->subarea_array)[i]).alignedoffset); } for (i=0;ifreebuckets)[i]!=0) { printf("bucket nr %d \n", (int) i); if (ifreebuckets)[i])); wg_show_bucket_freeobjects(db,(areah->freebuckets)[i]); } else { printf(" is varbucket at offset %d \n", (int) dbaddr(db,&(areah->freebuckets)[i])); wg_show_bucket_freeobjects(db,(areah->freebuckets)[i]); } } } if ((areah->freebuckets)[DVBUCKET]!=0) { printf("bucket nr %d at offset %d \n contains dv at offset %d with size %d(%d) and end %d \n", DVBUCKET, (int) dbaddr(db,&(areah->freebuckets)[DVBUCKET]), (int) (areah->freebuckets)[DVBUCKET], (int) ((areah->freebuckets)[DVSIZEBUCKET]>0 ? dbfetch(db,(areah->freebuckets)[DVBUCKET]) : -1), (int) (areah->freebuckets)[DVSIZEBUCKET], (int) ((areah->freebuckets)[DVBUCKET]+(areah->freebuckets)[DVSIZEBUCKET])); } } /** show a list of free objects in a bucket * */ static void wg_show_bucket_freeobjects(void* db, gint freelist) { gint size; gint freebits; gint nextptr; gint prevptr; while(freelist!=0) { size=getfreeobjectsize(dbfetch(db,freelist)); freebits=dbfetch(db,freelist) & 3; nextptr=dbfetch(db,freelist+sizeof(gint)); prevptr=dbfetch(db,freelist+2*sizeof(gint)); printf(" object offset %d end %d freebits %d size %d nextptr %d prevptr %d \n", (int) freelist, (int) (freelist+size), (int) freebits, (int) size, (int) nextptr, (int) prevptr); freelist=nextptr; } } /** count elements in a freelist * */ static gint wg_count_freelist(void* db, gint freelist) { gint i; //printf("freelist %d dbfetch(db,freelist) %d\n",freelist,dbfetch(db,freelist)); for(i=0;freelist; freelist=dbfetch(db,freelist)) { //printf("i %d freelist %u\n",i,(uint)freelist); i++; } return i; } /* --------------- datatype conversion/writing/reading testing ------------------------------*/ /** printlevel: 0 no print, 1 err print, 2 full print */ static gint wg_check_datatype_writeread(void* db, int printlevel) { int p; int i; int j; int k,r,m; int tries; // encoded and decoded data gint enc; gint* rec; char* nulldec; int intdec; char chardec; double doubledec; char* strdec; int len; int tmplen; int tmp; int decbuflen=1000; char decbuf[1000]; char encbuf[1000]; // amount of tested data int nulldata_nr=1; int chardata_nr=2; int vardata_nr=2; int intdata_nr=4; int doubledata_nr=4; int fixpointdata_nr=5; int datedata_nr=4; int timedata_nr=4; int datevecdata_nr=4; int datevecbad_nr=2; int timevecdata_nr=4; int timevecbad_nr=4; int strdata_nr=5; int xmlliteraldata_nr=2; int uridata_nr=2; int blobdata_nr=3; int recdata_nr=10; // tested data buffers char* nulldata[10]; char chardata[10]; int vardata[10]; int intdata[10]; double doubledata[10]; double fixpointdata[10]; int timedata[10]; int datedata[10]; char* strdata[10]; char* strextradata[10]; char* xmlliteraldata[10]; char* xmlliteralextradata[10]; char* uridata[10]; char* uriextradata[10]; char* blobdata[10]; char* blobextradata[10]; int bloblendata[10]; int recdata[10]; int tmpvec[4]; int datevecdata[][3] = { {1, 1, 1}, {2010, 1, 1}, {2010, 4, 30}, {5997, 1, 6} }; int datevecbad[][3] = { {1, -1, 2}, {1990, 7, 32}, {2010, 2, 29}, {2010, 4, 31} }; int timevecdata[][4] = { {0, 0, 0, 0}, {0, 10, 20, 3}, {24, 0, 0, 0}, {13, 32, 0, 3} }; int timevecbad[][4] = { {1, -1, 2, 99}, {1, 1, 1, 101}, {25, 2, 1, 0}, {23, 12, 73, 0} }; p=printlevel; tries=1; if (p>1) printf("********* check_datatype_writeread starts ************\n"); // initialise tested data nulldata[0]=NULL; chardata[0]='p'; chardata[1]=' '; intdata[0]=0; intdata[1]=100; intdata[2]=-50; intdata[3]=100200; doubledata[0]=0; doubledata[1]=1000; doubledata[2]=0.45678; doubledata[3]=-45.991; datedata[1]=733773; // 2010 m 1 d 1 datedata[2]=733892; // 2010 m 4 d 30 datedata[0]=1; datedata[3]=6000*365; timedata[0]=0; timedata[1]=10*(60*100)+20*100+3; timedata[2]=24*60*60*100; timedata[3]=14*60*58*100+3; fixpointdata[0]=0; fixpointdata[1]=1.23; fixpointdata[2]=790.3456; fixpointdata[3]=-799.7891; fixpointdata[4]=0.002345678; strdata[0]="abc"; strdata[1]="abcdefghijklmnop"; strdata[2]="1234567890123456789012345678901234567890"; strdata[3]=""; strdata[4]=""; strextradata[0]=NULL; strextradata[1]=NULL; strextradata[2]="op12345"; strextradata[3]="asdasdasdsd"; strextradata[4]=NULL; xmlliteraldata[0]="ffoo"; xmlliteraldata[1]="ffooASASASasaasweerrtttyyuuu"; xmlliteralextradata[0]="bar:we"; xmlliteralextradata[1]="bar:weasdasdasdasdasdasdasdasdasdasdasdasdasddas"; uridata[0]="dasdasdasd"; uridata[1]="dasdasdasd12345678901234567890"; uriextradata[0]=""; uriextradata[1]="fofofofof"; blobdata[0]=(char*)malloc(10); for(i=0;i<10;i++) *(blobdata[0]+i)=i+65; blobextradata[0]="type1"; bloblendata[0]=10; blobdata[1]=(char*)malloc(1000); for(i=0;i<1000;i++) *(blobdata[1]+i)=(i%10)+65; //i%256; blobextradata[1]="type2"; bloblendata[1]=200; blobdata[2]=(char*)malloc(10); for(i=0;i<10;i++) *(blobdata[2]+i)=i%256; blobextradata[2]=NULL; bloblendata[2]=10; recdata[0]=0; recdata[1]=1; recdata[2]=2; recdata[3]=3; recdata[4]=4; recdata[5]=5; recdata[6]=100; recdata[7]=101; recdata[8]=10000; recdata[9]=10001; vardata[0]=0; vardata[1]=999882; for (i=0;i1) printf("checking null enc/dec\n"); enc=wg_encode_null(db,nulldata[j]); if (wg_get_encoded_type(db,enc)!=WG_NULLTYPE) { if (p) printf("check_datatype_writeread gave error: null enc not right type \n"); return 1; } nulldec=wg_decode_null(db,enc); if (nulldata[j]!=nulldec) { if (p) printf("check_datatype_writeread gave error: null enc/dec \n"); return 1; } } // char test for (j=0;j1) printf("checking char enc/dec for j %d, value '%c'\n",j,chardata[j]); enc=wg_encode_char(db,chardata[j]); if (wg_get_encoded_type(db,enc)!=WG_CHARTYPE) { if (p) printf("check_datatype_writeread gave error: char enc not right type for j %d value '%c'\n", j,chardata[j]); return 1; } chardec=wg_decode_char(db,enc); if (chardata[j]!=chardec) { if (p) printf("check_datatype_writeread gave error: char enc/dec for j %d enc value '%c' dec value '%c'\n", j,chardata[j],chardec); return 1; } } // int test for (j=0;j1) printf("checking int enc/dec for j %d, value %d\n",j,intdata[j]); enc=wg_encode_int(db,intdata[j]); if (wg_get_encoded_type(db,enc)!=WG_INTTYPE) { if (p) printf("check_datatype_writeread gave error: int enc not right type for j %d value %d\n", j,intdata[j]); return 1; } intdec=wg_decode_int(db,enc); if (intdata[j]!=intdec) { if (p) printf("check_datatype_writeread gave error: int enc/dec for j %d enc value %d dec value %d\n", j,intdata[j],intdec); return 1; } } // double test for (j=0;j1) printf("checking double enc/dec for j %d, value %e\n",j,doubledata[j]); enc=wg_encode_double(db,doubledata[j]); if (wg_get_encoded_type(db,enc)!=WG_DOUBLETYPE) { if (p) printf("check_datatype_writeread gave error: double enc not right type for j %d value %e\n", j,doubledata[j]); return 1; } doubledec=wg_decode_double(db,enc); if (doubledata[j]!=doubledec) { if (p) printf("check_datatype_writeread gave error: double enc/dec for j %d enc value %e dec value %e\n", j,doubledata[j],doubledec); return 1; } } // date test for (j=0;j1) printf("checking date enc/dec for j %d, value %d\n",j,datedata[j]); enc=wg_encode_date(db,datedata[j]); if (wg_get_encoded_type(db,enc)!=WG_DATETYPE) { if (p) printf("check_datatype_writeread gave error: date enc not right type for j %d value %d\n", j,intdata[j]); return 1; } intdec=wg_decode_date(db,enc); if (datedata[j]!=intdec) { if (p) printf("check_datatype_writeread gave error: date enc/dec for j %d enc value %d dec value %d\n", j,datedata[j],intdec); return 1; } } for (j=0;j1) printf("checking building dates from vectors for j %d, expected value %d\n",j,datedata[j]); tmp=wg_ymd_to_date(db, datevecdata[j][0], datevecdata[j][1], datevecdata[j][2]); if(tmp != datedata[j]) { if (p) printf("check_datatype_writeread gave error: scalar date returned was %d\n",tmp); return 1; } wg_date_to_ymd(db, tmp, &tmpvec[0], &tmpvec[1], &tmpvec[2]); if(tmpvec[0]!=datevecdata[j][0] || tmpvec[1]!=datevecdata[j][1] ||\ tmpvec[2]!=datevecdata[j][2]) { if (p) printf("check_datatype_writeread gave error: scalar date reverse conversion failed for j %d\n",j); return 1; } } for (j=0;j1) printf("checking invalid date input for j %d\n",j); tmp=wg_ymd_to_date(db, datevecbad[j][0], datevecbad[j][1], datevecbad[j][2]); if(tmp != -1) { if (p) printf("check_datatype_writeread gave error: invalid date j %d did not cause an error\n", j); return 1; } } // time test for (j=0;j1) printf("checking time enc/dec for j %d, value %d\n",j,timedata[j]); enc=wg_encode_time(db,timedata[j]); if (wg_get_encoded_type(db,enc)!=WG_TIMETYPE) { if (p) printf("check_datatype_writeread gave error: time enc not right type for j %d value %d\n", j,timedata[j]); return 1; } intdec=wg_decode_time(db,enc); if (timedata[j]!=intdec) { if (p) printf("check_datatype_writeread gave error: time enc/dec for j %d enc value %d dec value %d\n", j,timedata[j],intdec); return 1; } } for (j=0;j1) printf("checking building times from vectors for j %d, expected value %d\n",j,timedata[j]); tmp=wg_hms_to_time(db, timevecdata[j][0], timevecdata[j][1], timevecdata[j][2], timevecdata[j][3]); if(tmp != timedata[j]) { if (p) printf("check_datatype_writeread gave error: scalar time returned was %d\n",tmp); return 1; } wg_time_to_hms(db, tmp, &tmpvec[0], &tmpvec[1], &tmpvec[2], &tmpvec[3]); if(tmpvec[0]!=timevecdata[j][0] || tmpvec[1]!=timevecdata[j][1] ||\ tmpvec[2]!=timevecdata[j][2] || tmpvec[3]!=timevecdata[j][3]) { if (p) printf("check_datatype_writeread gave error: scalar time reverse conversion failed for j %d\n",j); return 1; } } for (j=0;j1) printf("checking invalid time input for j %d\n",j); tmp=wg_hms_to_time(db, timevecbad[j][0], timevecbad[j][1], timevecbad[j][2], timevecbad[j][3]); if(tmp != -1) { if (p) printf("check_datatype_writeread gave error: invalid time j %d did not cause an error\n", j); return 1; } } // datetime test for (j=0;j1) printf("checking strf iso datetime conv for j %d, date %d time %d\n",j,datedata[j],timedata[j]); for(k=0;k<1000;k++) decbuf[k]=0; for(k=0;k<1000;k++) encbuf[k]=0; wg_strf_iso_datetime(db,datedata[j],timedata[j],decbuf); if (p>1) printf("wg_strf_iso_datetime gives %s ",decbuf); k=wg_strp_iso_date(db,decbuf); r=wg_strp_iso_time(db,decbuf+11); //printf("k is %d r is %d\n",k,r); if (1) { if (k>=0 && r>=0) { wg_strf_iso_datetime(db,k,r,encbuf); if (strcmp(decbuf,encbuf)) { if(p) printf("check_datatype_writeread gave error: wg_strf_iso_datetime gives %s and rev op gives %s\n", decbuf,encbuf); return 1; } if (p>1) printf("rev gives %s\n",decbuf); } else { if(p) printf("check_datatype_writeread gave error: wg_strp_iso_date gives %d and wg_strp_iso_time gives %d on %s\n", k,r,decbuf); return 1; } } } // current date and time test for(k=0;k<1000;k++) encbuf[k]=0; m=wg_current_utcdate(db); k=wg_current_localdate(db); r=wg_current_utctime(db); j=wg_current_localtime(db); if (p>1) { wg_strf_iso_datetime(db,m,r,encbuf); printf("checking wg_current_utcdate/utctime: %s\n",encbuf); wg_strf_iso_datetime(db,k,j,encbuf); printf("checking wg_current_localdate/localtime: %s\n",encbuf); } // fixpoint test for (j=0;j1) printf("checking fixpoint enc/dec for j %d, value %f\n",j,fixpointdata[j]); enc=wg_encode_fixpoint(db,fixpointdata[j]); if (wg_get_encoded_type(db,enc)!=WG_FIXPOINTTYPE) { if (p) printf("check_datatype_writeread gave error: fixpoint enc not right type for j %d value %e\n", j,doubledata[j]); return 1; } doubledec=wg_decode_fixpoint(db,enc); if (round(FIXPOINTDIVISOR*fixpointdata[j])!=round(FIXPOINTDIVISOR*doubledec)) { //(fixpointdata[j]!=doubledec) { if (p) printf("check_datatype_writeread gave error: fixpoint enc/dec for j %d enc value %f dec value %f\n", j,fixpointdata[j],doubledec); return 1; } } // str test for (j=0;j1) printf("checking str enc/dec for j %d, value \"%s\", extra \"%s\"\n", j,strdata[j],strextradata[j]); enc=wg_encode_str(db,strdata[j],strextradata[j]); if (wg_get_encoded_type(db,enc)!=WG_STRTYPE) { if (p) printf("check_datatype_writeread gave error: str enc not right type for j %d value \"%s\", extra \"%s\"\n", j,strdata[j],strextradata[j]); return 1; } len=wg_decode_str_len(db,enc); if (len!=guarded_strlen(strdata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_str_len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n", j,strdata[j],strextradata[j],guarded_strlen(strdata[j]),len); return 1; } strdec=wg_decode_str(db,enc); if (guarded_strcmp(strdata[j],strdec)) { if (p) printf("check_datatype_writeread gave error: wg_decode_str for j %d value \"%s\" extra \"%s\"\n", j,strdata[j],strextradata[j]); return 1; } tmplen=wg_decode_str_copy(db,enc,decbuf,decbuflen); if (tmplen!=guarded_strlen(strdata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_str_copy len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n\n", j,strdata[j],strextradata[j],guarded_strlen(strdata[j]),tmplen); return 1; } if (bufguarded_strcmp(decbuf,strdata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_str_copy for j %d value \"%s\" extra \"%s\" dec main \"%s\"\n", j,strdata[j],strextradata[j],decbuf); return 1; } len=wg_decode_str_lang_len(db,enc); if (len!=guarded_strlen(strextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_str_lang_len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n", j,strdata[j],strextradata[j],guarded_strlen(strextradata[j]),len); return 1; } strdec=wg_decode_str_lang(db,enc); if (guarded_strcmp(strextradata[j],strdec)) { if (p) printf("check_datatype_writeread gave error: wg_decode_str_lang for j %d value \"%s\" extra \"%s\"\n", j,strdata[j],strextradata[j]); return 1; } tmplen=wg_decode_str_lang_copy(db,enc,decbuf,decbuflen); if (tmplen!=guarded_strlen(strextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_str_lang_copy len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n\n", j,strdata[j],strextradata[j],guarded_strlen(strextradata[j]),tmplen); return 1; } if (bufguarded_strcmp(decbuf,strextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_str_lang_copy for j %d value \"%s\" extra \"%s\" dec extra \"%s\"\n", j,strdata[j],strextradata[j],decbuf); return 1; } } // xmllit test for (j=0;j1) printf("checking xmlliteral enc/dec for j %d, value \"%s\", extra \"%s\"\n", j,xmlliteraldata[j],xmlliteralextradata[j]); enc=wg_encode_xmlliteral(db,xmlliteraldata[j],xmlliteralextradata[j]); if (wg_get_encoded_type(db,enc)!=WG_XMLLITERALTYPE) { if (p) printf("check_datatype_writeread gave error: xmlliteral enc not right type for j %d value \"%s\", extra \"%s\"\n", j,xmlliteraldata[j],xmlliteralextradata[j]); return 1; } len=wg_decode_xmlliteral_len(db,enc); if (len!=guarded_strlen(xmlliteraldata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral_len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n", j,xmlliteraldata[j],xmlliteralextradata[j],guarded_strlen(xmlliteraldata[j]),len); return 1; } strdec=wg_decode_xmlliteral(db,enc); if (guarded_strcmp(xmlliteraldata[j],strdec)) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral for j %d value \"%s\" extra \"%s\"\n", j,xmlliteraldata[j],xmlliteralextradata[j]); return 1; } tmplen=wg_decode_xmlliteral_copy(db,enc,decbuf,decbuflen); if (tmplen!=guarded_strlen(xmlliteraldata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral_copy len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n\n", j,xmlliteraldata[j],xmlliteralextradata[j],guarded_strlen(xmlliteraldata[j]),tmplen); return 1; } if (bufguarded_strcmp(decbuf,xmlliteraldata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral_copy for j %d value \"%s\" extra \"%s\" dec main \"%s\"\n", j,xmlliteraldata[j],xmlliteralextradata[j],decbuf); return 1; } len=wg_decode_xmlliteral_xsdtype_len(db,enc); if (len!=guarded_strlen(xmlliteralextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral_xsdtype_len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n", j,xmlliteraldata[j],xmlliteralextradata[j],guarded_strlen(xmlliteralextradata[j]),len); return 1; } strdec=wg_decode_xmlliteral_xsdtype(db,enc); if (guarded_strcmp(xmlliteralextradata[j],strdec)) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral_xsdtype for j %d value \"%s\" extra \"%s\"\n", j,xmlliteraldata[j],xmlliteralextradata[j]); return 1; } tmplen=wg_decode_xmlliteral_xsdtype_copy(db,enc,decbuf,decbuflen); if (tmplen!=guarded_strlen(xmlliteralextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral_xsdtype_copy len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n\n", j,xmlliteraldata[j],xmlliteralextradata[j],guarded_strlen(xmlliteralextradata[j]),tmplen); return 1; } if (bufguarded_strcmp(decbuf,xmlliteralextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_xmlliteral_xsdtype_copy for j %d value \"%s\" extra \"%s\" dec extra \"%s\"\n", j,xmlliteraldata[j],xmlliteralextradata[j],decbuf); return 1; } } // uri test for (j=0;j1) printf("checking uri enc/dec for j %d, value \"%s\", extra \"%s\"\n", j,uridata[j],uriextradata[j]); enc=wg_encode_uri(db,uridata[j],uriextradata[j]); if (wg_get_encoded_type(db,enc)!=WG_URITYPE) { if (p) printf("check_datatype_writeread gave error: uri enc not right type for j %d value \"%s\", extra \"%s\"\n", j,uridata[j],uriextradata[j]); return 1; } len=wg_decode_uri_len(db,enc); if (len!=guarded_strlen(uridata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri_len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n", j,uridata[j],uriextradata[j],guarded_strlen(uridata[j]),len); return 1; } strdec=wg_decode_uri(db,enc); if (guarded_strcmp(uridata[j],strdec)) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri for j %d value \"%s\" extra \"%s\"\n", j,uridata[j],uriextradata[j]); return 1; } tmplen=wg_decode_uri_copy(db,enc,decbuf,decbuflen); if (tmplen!=guarded_strlen(uridata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri_copy len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n\n", j,uridata[j],uriextradata[j],guarded_strlen(uridata[j]),tmplen); return 1; } if (bufguarded_strcmp(decbuf,uridata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri_copy for j %d value \"%s\" extra \"%s\" dec main \"%s\"\n", j,uridata[j],uriextradata[j],decbuf); return 1; } len=wg_decode_uri_prefix_len(db,enc); if (len!=guarded_strlen(uriextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri_prefix_len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n", j,uridata[j],uriextradata[j],guarded_strlen(uriextradata[j]),len); return 1; } strdec=wg_decode_uri_prefix(db,enc); if (guarded_strcmp(uriextradata[j],strdec)) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri_prefix for j %d value \"%s\" extra \"%s\"\n", j,uridata[j],uriextradata[j]); return 1; } tmplen=wg_decode_uri_prefix_copy(db,enc,decbuf,decbuflen); if (tmplen!=guarded_strlen(uriextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri_prefix_copy len for j %d value \"%s\" extra \"%s\" enc len %d dec len %d\n\n", j,uridata[j],uriextradata[j],guarded_strlen(uriextradata[j]),tmplen); return 1; } if (bufguarded_strcmp(decbuf,uriextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_uri_prefix_copy for j %d value \"%s\" extra \"%s\" dec extra \"%s\"\n", j,uridata[j],uriextradata[j],decbuf); return 1; } } // blob test for (j=0;j1) printf("checking blob enc/dec for j %d, len %d extra \"%s\"\n", j,bloblendata[j],blobextradata[j]); enc=wg_encode_blob(db,blobdata[j],blobextradata[j],bloblendata[j]); if (!enc) { if (p) printf("check_datatype_writeread gave error: cannot create a blob\n"); return 1; } if (wg_get_encoded_type(db,enc)!=WG_BLOBTYPE) { if (p) printf("check_datatype_writeread gave error: blob enc not right type for j %d len %d, extra \"%s\"\n", j,bloblendata[j],blobextradata[j]); return 1; } len=wg_decode_blob_len(db,enc); if (len!=bloblendata[j]) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob_len for j %d len %d extra \"%s\" enc len %d dec len %d\n", j,bloblendata[j],blobextradata[j],bloblendata[j],len); return 1; } strdec=wg_decode_blob(db,enc); if (memcmp(blobdata[j],strdec,bloblendata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob for j %d len %d extra \"%s\"\n", j,bloblendata[j],blobextradata[j]); return 1; } tmplen=wg_decode_blob_copy(db,enc,decbuf,decbuflen); if (tmplen!=bloblendata[j]) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob_copy len for j %d len %d extra \"%s\" enc len %d dec len %d\n\n", j,bloblendata[j],blobextradata[j],bloblendata[j],tmplen); return 1; } if (memcmp(decbuf,blobdata[j],bloblendata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob_copy for j %d len %d extra \"%s\" dec len %d\n", j,bloblendata[j],blobextradata[j],tmplen); return 1; } len=wg_decode_blob_type_len(db,enc); if (len!=guarded_strlen(blobextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob_type_len for j %d len %d extra \"%s\" enc len %d dec len %d\n", j,bloblendata[j],blobextradata[j],guarded_strlen(blobextradata[j]),len); return 1; } strdec=wg_decode_blob_type(db,enc); if (guarded_strcmp(blobextradata[j],strdec)) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob_type for j %d len %d extra \"%s\"\n", j,bloblendata[j],blobextradata[j]); return 1; } tmplen=wg_decode_blob_type_copy(db,enc,decbuf,decbuflen); if (tmplen!=guarded_strlen(blobextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob_type_copy len for j %d len %d extra \"%s\" enc len %d dec len %d\n\n", j,bloblendata[j],blobextradata[j],guarded_strlen(blobextradata[j]),tmplen); return 1; } if (bufguarded_strcmp(decbuf,blobextradata[j])) { if (p) printf("check_datatype_writeread gave error: wg_decode_blob_type_copy for j %d len %d extra \"%s\" dec extra \"%s\"\n", j,bloblendata[j],blobextradata[j],decbuf); return 1; } } // rec test for (j=0;j1) printf("checking rec creation, content read/write for j %d, length %d\n",j,recdata[j]); rec=(gint *)wg_create_record(db,recdata[j]); if (rec==NULL) { if (p) printf("check_datatype_writeread gave error: creating record for j %d len %d failed\n", j,recdata[j]); return 1; } /* the following code can't be correct - rec is a pointer, not encoded value if (wg_get_encoded_type(db,(gint)rec)!=WG_RECORDTYPE) { if (p) printf("check_datatype_writeread gave error: created record not right type for j %d len %d\n", j,recdata[j]); return 1; } */ tmplen=wg_get_record_len(db,rec); if (tmplen!=recdata[j]) { if (p) printf("check_datatype_writeread gave error: wg_get_record_len gave %d for rec of len %d\n", tmplen,recdata[j]); return 1; } for(k=0;k1) printf("checking var enc/dec for j %d, value %d\n",j,vardata[j]); enc=wg_encode_var(db,vardata[j]); if (wg_get_encoded_type(db,enc)!=WG_VARTYPE) { if (p) printf("check_datatype_writeread gave error: var enc not right type for j %d value %d\n", j,vardata[j]); return 1; } intdec=wg_decode_var(db,enc); if (vardata[j]!=intdec) { if (p) printf("check_datatype_writeread gave error: var enc/dec for j %d enc value %d dec value %d\n", j,vardata[j],intdec); return 1; } } /* Test string decode with insufficient buffer size */ if (p>1) printf("checking decoding data that doesn't fit the decode buffer "\ "(expecting some errors)\n"); enc=wg_encode_str(db, "00000000001111111111", NULL); /* shortstr, len=20 */ memset(decbuf, 0, decbuflen); if(wg_decode_str_copy(db, enc, decbuf, 10) > 0) { /* we expect this to fail, but if it succeeds, let's check if the * buffer size was honored */ if(strlen(decbuf) != 10) { if(p) printf("check_datatype_writeread gave error: "\ "buffer overflow when decoding a shortstr\n"); return 1; } } enc=wg_encode_str(db, "0000000000111111111", "et"); /* longstr, len=19 */ memset(decbuf, 0, decbuflen); if(wg_decode_str_copy(db, enc, decbuf, 11) > 0) { if(strlen(decbuf) != 11) { if(p) printf("check_datatype_writeread gave error: "\ "buffer overflow when decoding a longstr\n"); return 1; } } enc=wg_encode_blob(db, "000000000011111111", "blobtype", 18); /* blob */ memset(decbuf, 0, decbuflen); if(wg_decode_blob_copy(db, enc, decbuf, 12) > 0) { if(strlen(decbuf) != 12) { if(p) printf("check_datatype_writeread gave error: "\ "buffer overflow when decoding a blob\n"); return 1; } } } if (p>1) printf("********* check_datatype_writeread ended without errors ************\n"); return 0; } static int guarded_strlen(char* str) { if (str==NULL) return 0; else return strlen(str); } static int guarded_strcmp(char* a, char* b) { if (a==NULL && b!=NULL) return 1; if (a!=NULL && b==NULL) return -1; if (a==NULL && b==NULL) return 0; else return strcmp(a,b); } static int bufguarded_strcmp(char* a, char* b) { if (a==NULL && b==NULL) return 0; if (a==NULL && strlen(b)==0) return 0; if (b==NULL && strlen(a)==0) return 0; if (a==NULL && b!=NULL) return 1; if (a!=NULL && b==NULL) return -1; else return strcmp(a,b); } /* ------------------------ test record linking ------------------------------*/ static gint wg_check_backlinking(void* db, int printlevel) { #ifdef USE_BACKLINKING int p; int tmp; gint *rec, *rec2, *rec3, *parent; p = printlevel; if (p>1) printf("********* checking record linking and deleting ************\n"); rec=(gint *) wg_create_record(db,2); rec2=(gint *) wg_create_record(db,2); rec3=(gint *) wg_create_record(db,2); if (rec==NULL || rec2==NULL || rec3==NULL) { if (p) printf("unexpected error: rec creation failed\n"); return 1; } wg_set_field(db, rec, 0, wg_encode_int(db, 10)); wg_set_field(db, rec, 1, wg_encode_str(db, "hello", NULL)); wg_set_field(db, rec2, 1, wg_encode_str(db, "hi", NULL)); wg_set_field(db, rec3, 0, wg_encode_record(db, rec2)); wg_set_field(db, rec3, 1, wg_encode_record(db, rec)); wg_set_field(db, rec2, 0, wg_encode_record(db, rec)); /* rec3 does not have parents */ if(wg_get_first_parent(db, rec3) != NULL) { if (p) printf("check_backlinking: non-referenced record had a parent"); return 1; } /* rec2 has one parent */ parent = wg_get_first_parent(db, rec2); if(parent != rec3) { if (p) printf("check_backlinking: record had an invalid parent"); return 1; } if(wg_get_next_parent(db, rec2, parent) != NULL) { if (p) printf("check_backlinking: record had too many parents"); return 1; } /* rec has two parents */ parent = wg_get_first_parent(db, rec); if(parent != rec3) { if (p) printf("check_backlinking: record had an invalid parent"); return 1; } if((parent = wg_get_next_parent(db, rec, parent)) != rec2) { if (p) printf("check_backlinking: record had an invalid parent"); return 1; } if(wg_get_next_parent(db, rec, parent) != NULL) { if (p) printf("check_backlinking: record had too many parents"); return 1; } /* this should fail */ tmp = wg_delete_record(db, rec); if(tmp != -1) { if (p) printf("check_backlinking: deleting referenced record, expected %d, received %d\n", -1, (int) tmp); return 1; } /* this should also fail */ tmp = wg_delete_record(db, rec2); if(tmp != -1) { if (p) printf("check_backlinking: deleting referenced record, expected %d, received %d\n", -1, (int) tmp); return 1; } wg_set_field(db, rec3, 0, 0); /* rec2 no longer has parents */ if(wg_get_first_parent(db, rec2) != NULL) { if (p) printf("check_backlinking: non-referenced record had a parent"); return 1; } wg_set_field(db, rec3, 1, 0); /* rec now has one parent */ parent = wg_get_first_parent(db, rec); if(parent != rec2) { if (p) printf("check_backlinking: record had an invalid parent"); return 1; } if(wg_get_next_parent(db, rec, parent) != NULL) { if (p) printf("check_backlinking: record had too many parents"); return 1; } /* this should now succeed */ tmp = wg_delete_record(db, rec2); if(tmp != 0) { if (p) printf("check_backlinking: deleting no longer referenced record, expected %d, received %d\n", 0, (int) tmp); return 1; } /* this should also succeed */ tmp = wg_delete_record(db, rec); if(tmp != 0) { if (p) printf("check_backlinking: deleting child of deleted record, expected %d, received %d\n", 0, (int) tmp); return 1; } /* and this should succeed */ tmp = wg_delete_record(db, rec3); if(tmp != 0) { if (p) printf("check_backlinking: deleting record, expected %d, received %d\n", 0, (int) tmp); return 1; } if (p>1) printf("********* check_backlinking: no errors ************\n"); #else printf("check_backlinking: disabled, skipping checks\n"); #endif return 0; } /* ------------------------ test string parsing ------------------------------*/ static int do_check_parse_encode(void *db, gint enc, gint exptype, void *expval, int printlevel) { int i, p=printlevel, tmp; gint intdec; double doubledec, diff; char* strdec; int vecdec[4]; gint enctype; enctype = wg_get_encoded_type(db, enc); if(enctype != exptype) { if(p) printf("check_parse_encode: expected type %s, got type %s\n", wg_get_type_name(db, exptype), wg_get_type_name(db, enctype)); return 1; } switch(enctype) { case WG_NULLTYPE: if(wg_decode_null(db, enc) != NULL) { if(p) printf("check_parse_encode: expected value NULL, got %d (encoded)\n", (int) enc); return 1; } break; case WG_INTTYPE: intdec = wg_decode_int(db, enc); if(intdec != *((gint *) expval)) { if(p) printf("check_parse_encode: expected value %d, got %d\n", (int) *((gint *) expval), (int) intdec); return 1; } break; case WG_DOUBLETYPE: doubledec = wg_decode_double(db, enc); diff = doubledec - *((double *) expval); if(diff < -0.000001 || diff > 0.000001) { if(p) printf("check_parse_encode: expected value %f, got %f\n", *((double *) expval), doubledec); return 1; } break; case WG_STRTYPE: strdec = wg_decode_str(db, enc); if(bufguarded_strcmp(strdec, (char *) expval)) { if(p) printf("check_parse_encode: expected value \"%s\", got \"%s\"\n", (char *) expval, strdec); return 1; } break; case WG_DATETYPE: tmp = wg_decode_date(db, enc); wg_date_to_ymd(db, tmp, &vecdec[0], &vecdec[1], &vecdec[2]); for(i=0; i<3; i++) { if(vecdec[i] != ((int *) expval)[i]) { if(p) printf("check_parse_encode: "\ "date vector pos %d expected value %d, got %d\n", i, ((int *) expval)[i], vecdec[i]); return 1; } } break; case WG_TIMETYPE: tmp = wg_decode_time(db, enc); wg_time_to_hms(db, tmp, &vecdec[0], &vecdec[1], &vecdec[2], &vecdec[3]); for(i=0; i<4; i++) { if(vecdec[i] != ((int *) expval)[i]) { if(p) printf("check_parse_encode: "\ "time vector pos %d expected value %d, got %d\n", i, ((int *) expval)[i], vecdec[i]); return 1; } } break; default: printf("check_parse_encode: unexpected type %s\n", wg_get_type_name(db, enctype)); return 1; } return 0; } static gint wg_check_parse_encode(void* db, int printlevel) { int p, i; const char *testinput[] = { "", /* empty string - NULL */ " ", /* space - string */ "\r\t \n\r\t \b\xff", /* various whitespace and other junk */ "üöäõõõü ÄÖÜÕ", /* ISO-8859-1 encoded string */ "\xc3\xb5\xc3\xa4\xc3\xb6\xc3\xbc \xc3\x95\xc3\x84\xc3\x96\xc3\x9c", /* UTF-8 */ "0", /* integer */ "5435354534", /* a large integer, parsed as string if strtol() is 32-bit */ "54312313214385290438390523442348932048234324348930243242342342389"\ "4380148902432428904283323892374282394832423", /* a very large integer */ "7.432432", /* floating point (CSV_DECIMAL_SEPARATOR in dbutil.c) */ "-7899", /* negative integer */ "-14324.432432", /* negative floating point number */ "-tere", /* something that is not a negative number */ "0.88872d", /* a number with garbage appended */ " 995", /* a number that is parsed as a string */ "1996-01-01", /* iso8601 date */ "2038-12-12", /* same, in the future */ "12:01:17", /* iso8601 time */ "23:01:17.87", /* iso8601 time, with fractions */ "09:01", /* time, no seconds */ NULL /* terminator */ }; /* verification data */ gint intval[] = { 0, (sizeof(long) > 4 ? (gint) 5435354534L : 0), -7899 }; double doubleval[] = { 7.432432, -14324.432432 }; int datevec[][3] = { {1996, 1, 1}, {2038, 12, 12} }; int timevec[][4] = { {12, 1, 17, 0}, {23, 1, 17, 87} }; /* should match testinput */ gint testtype[] = { WG_NULLTYPE, WG_STRTYPE, WG_STRTYPE, WG_STRTYPE, WG_STRTYPE, WG_INTTYPE, (sizeof(long) > 4 ? WG_INTTYPE : WG_STRTYPE), WG_STRTYPE, WG_DOUBLETYPE, WG_INTTYPE, WG_DOUBLETYPE, WG_STRTYPE, WG_STRTYPE, WG_STRTYPE, WG_DATETYPE, WG_DATETYPE, WG_TIMETYPE, WG_TIMETYPE, WG_STRTYPE, -1, /* unused */ }; /* map to verification data, recast to correct type when used */ void *testval[] = { NULL, /* unused */ (void *) testinput[1], (void *) testinput[2], (void *) testinput[3], (void *) testinput[4], (void *) &intval[0], (sizeof(long) > 4 ? (void *) &intval[1] : (void *) testinput[6]), (void *) testinput[7], (void *) &doubleval[0], (void *) &intval[2], (void *) &doubleval[1], (void *) testinput[11], (void *) testinput[12], (void *) testinput[13], (void *) datevec[0], (void *) datevec[1], (void *) timevec[0], (void *) timevec[1], (void *) testinput[18], NULL /* unused */ }; p=printlevel; if (p>1) printf("********* testing string parsing ************\n"); i=0; while(testinput[i]) { gint encv, encp; /* Announce */ if(p>1) { printf("parsing string: \"%s\"\n", testinput[i]); } /* Parse and encode */ encv = wg_parse_and_encode(db, (char *) testinput[i]); encp = wg_parse_and_encode_param(db, (char *) testinput[i]); /* Check */ if(encv == WG_ILLEGAL) { if(p) printf("check_parse_encode: encode value failed, got WG_ILLEGAL\n"); return 1; } else if(do_check_parse_encode(db, encv, testtype[i], testval[i], p)) { return 1; } if(encp == WG_ILLEGAL) { if(p) printf("check_parse_encode: encode param failed, got WG_ILLEGAL\n"); return 1; } else if(do_check_parse_encode(db, encp, testtype[i], testval[i], p)) { return 1; } /* Free */ wg_free_encoded(db, encv); wg_free_query_param(db, encp); i++; } if (p>1) printf("********* check_parse_encode: no errors ************\n"); return 0; } /* ------------------------ test comparison ------------------------------*/ static gint wg_check_compare(void* db, int printlevel) { int i, j; gint testdata[28]; void *rec1, *rec2, *rec3; testdata[0] = wg_encode_null(db, 0); testdata[4] = wg_encode_int(db, -321784); testdata[5] = wg_encode_int(db, 34531); testdata[6] = wg_encode_double(db, 0.000000001); testdata[7] = wg_encode_double(db, 0.00000001); testdata[8] = wg_encode_str(db, "", NULL); testdata[9] = wg_encode_str(db, "XX", NULL); testdata[10] = wg_encode_str(db, "this is a string", NULL); testdata[11] = wg_encode_str(db, "this is a string ", NULL); testdata[12] = wg_encode_xmlliteral(db, "this is a string ", "foo:bar"); testdata[13] = wg_encode_xmlliteral(db, "this is a string ", "foo:bart"); testdata[14] = wg_encode_uri(db, "www.amazon.com", "http://"); testdata[15] = wg_encode_uri(db, "www.yahoo.com", "http://"); testdata[16] = wg_encode_blob(db, "\0\0\045\120\104\106\055\061\0\056\065\012\045\045", "blob", 14); testdata[17] = wg_encode_blob(db, "\0\0\045\120\104\106\055\061\001\056\065\012\044", "blob", 13); testdata[18] = wg_encode_char(db, 'C'); testdata[19] = wg_encode_char(db, 'c'); testdata[20] = wg_encode_fixpoint(db, -7.25); testdata[21] = wg_encode_fixpoint(db, -7.2); testdata[22] = wg_encode_date(db, wg_ymd_to_date(db, 2010, 4, 1)); testdata[23] = wg_encode_date(db, wg_ymd_to_date(db, 2010, 4, 30)); testdata[24] = wg_encode_time(db, wg_hms_to_time(db, 13, 32, 0, 3)); testdata[25] = wg_encode_time(db, wg_hms_to_time(db, 24, 0, 0, 0)); testdata[26] = wg_encode_var(db, 7); testdata[27] = wg_encode_var(db, 10); /* create records in reverse order to catch offset comparison */ rec3 = wg_create_raw_record(db, 3); wg_set_new_field(db, rec3, 0, testdata[4]); wg_set_new_field(db, rec3, 1, testdata[23]); wg_set_new_field(db, rec3, 2, testdata[9]); rec2 = wg_create_raw_record(db, 3); wg_set_new_field(db, rec2, 0, testdata[4]); wg_set_new_field(db, rec2, 1, testdata[14]); wg_set_new_field(db, rec2, 2, testdata[9]); rec1 = wg_create_raw_record(db, 2); testdata[1] = wg_encode_record(db, rec1); testdata[2] = wg_encode_record(db, rec2); testdata[3] = wg_encode_record(db, rec3); if(printlevel>1) printf("********* testing data comparison ************\n"); for(i=0; i<26; i++) { for(j=i; j<26; j++) { if(i==j) { if(WG_COMPARE(db, testdata[i], testdata[j]) != WG_EQUAL) { if(printlevel) { printf("value1: "); wg_debug_print_value(db, testdata[i]); printf(" value2: "); wg_debug_print_value(db, testdata[j]); printf("\nvalue1 and value2 should have been equal\n"); } return 1; } } else #if WG_COMPARE_REC_DEPTH < 2 if(wg_get_encoded_type(db, testdata[i]) != \ wg_get_encoded_type(db, testdata[j]) || \ wg_get_encoded_type(db, testdata[i]) != WG_RECORDTYPE) #endif { if(WG_COMPARE(db, testdata[i], testdata[j]) != WG_LESSTHAN) { if(printlevel) { printf("value1: "); wg_debug_print_value(db, testdata[i]); printf(" value2: "); wg_debug_print_value(db, testdata[j]); printf("\nvalue1 should have been less than value2\n"); } return 1; } if(WG_COMPARE(db, testdata[j], testdata[i]) != WG_GREATER) { if(printlevel) { printf("value1: "); wg_debug_print_value(db, testdata[i]); printf(" value2: "); wg_debug_print_value(db, testdata[j]); printf("\nvalue1 should have been greater than value2\n"); } return 1; } } } } if(printlevel>1) printf("********* check_compare: no errors ************\n"); return 0; } /* -------------------- test query parameter encoding --------------------*/ static gint wg_check_query_param(void* db, int printlevel) { gint encv, encp, tmp; int i; char *strdata[] = { "RjlTKUoxfhdqLiIz", "llWsdbuVGhoGqjs", "HRmUHyBkMKiqsu", "NcDoCfVjFPgWh", "ESGgFsyEcGLI", "PxPGipbFQgq", "UdDVsnFVKA", "JnhQcGTnC", "KxKPyzju", NULL }; if(printlevel>1) printf("********* testing query parameter encoding ************\n"); /* Data that does not require storage allocation */ encv = wg_encode_null(db, 0); encp = wg_encode_query_param_null(db, 0); if(encv != encp) { if(printlevel) { printf("check_query_param: encoded NULL parameter (%d)"\ "was not equal to encoded NULL value (%d)\n", (int) encp, (int) encv); } return 1; } encv = wg_encode_char(db, 'X'); encp = wg_encode_query_param_char(db, 'X'); if(encv != encp) { if(printlevel) { printf("check_query_param: encoded char parameter (%d) "\ "was not equal to encoded char value (%d)\n", (int) encp, (int) encv); } return 1; } encv = wg_encode_fixpoint(db, 37.596); encp = wg_encode_query_param_fixpoint(db, 37.596); if(encv != encp) { if(printlevel) { printf("check_query_param: encoded fixpoint parameter (%d) "\ "was not equal to encoded fixpoint value (%d)\n", (int) encp, (int) encv); } return 1; } tmp = wg_ymd_to_date(db, 1859, 7, 13); encv = wg_encode_date(db, tmp); encp = wg_encode_query_param_date(db, tmp); if(encv != encp) { if(printlevel) { printf("check_query_param: encoded date parameter (%d) "\ "was not equal to encoded date value (%d)\n", (int) encp, (int) encv); } return 1; } tmp = wg_hms_to_time(db, 17, 15, 0, 0); encv = wg_encode_time(db, tmp); encp = wg_encode_query_param_time(db, tmp); if(encv != encp) { if(printlevel) { printf("check_query_param: encoded time parameter (%d) "\ "was not equal to encoded time value (%d)\n", (int) encp, (int) encv); } return 1; } encv = wg_encode_var(db, 2); encp = wg_encode_query_param_var(db, 2); if(encv != encp) { if(printlevel) { printf("check_query_param: encoded var parameter (%d) "\ "was not equal to encoded var value (%d)\n", (int) encp, (int) encv); } return 1; } /* Smallint */ encv = wg_encode_int(db, 77); encp = wg_encode_query_param_int(db, 77); if(encv != encp) { if(printlevel) { printf("check_query_param: encoded int parameter (%d) "\ "was not equal to encoded int value (%d)\n", (int) encp, (int) encv); } return 1; } /* Data that requires storage */ if(sizeof(gint) > 4) { tmp = (gint) 3152921502073741877L; } else { tmp = 2073741877; } encp = wg_encode_query_param_int(db, tmp); if(!isfullint(encp)) { if(printlevel) { printf("check_query_param: encoded int parameter (%d) "\ "had bad encoding (does not look like a full int)\n", (int) encp); } wg_free_query_param(db, encp); return 1; } if((gint) (dbfetch(db, decode_fullint_offset(encp))) != tmp) { if(printlevel) { printf("check_query_param: encoded int parameter (%d) "\ "contained an invalid value\n", (int) encp); } wg_free_query_param(db, encp); return 1; } tmp = decode_fullint_offset(encp); if(tmp > 0 && tmp < dbmemsegh(db)->free) { if(printlevel) { printf("check_query_param: encoded int parameter (%d) "\ "had an invalid offset\n", (int) encp); } wg_free_query_param(db, encp); return 1; } wg_free_query_param(db, encp); encp = wg_encode_query_param_double(db, 0.00000000000324445); if(!isfulldouble(encp)) { if(printlevel) { printf("check_query_param: encoded double parameter (%d) "\ "had bad encoding (does not look like a double)\n", (int) encp); } wg_free_query_param(db, encp); return 1; } else { double val = wg_decode_double(db, encp); double diff = val - 0.00000000000324445; if(diff > 0.00000000000000001 || diff < -0.00000000000000001) { if(printlevel) { printf("check_query_param: encoded double parameter (%d) "\ "contained an invalid value (delta: %f)\n", (int) encp, diff); } wg_free_query_param(db, encp); return 1; } tmp = decode_fulldouble_offset(encp); if(tmp > 0 && tmp < dbmemsegh(db)->free) { if(printlevel) { printf("check_query_param: encoded double parameter (%d) "\ "had an invalid offset\n", (int) encp); } wg_free_query_param(db, encp); return 1; } } wg_free_query_param(db, encp); encp = wg_encode_query_param_str(db, "lalalalalalalalalalalalalalalalalalalala", NULL); if(!isshortstr(encp)) { if(printlevel) { printf("check_query_param: encoded longstr parameter (%d) "\ "had bad encoding (should be encoded as shortstr)\n", (int) encp); } wg_free_query_param(db, encp); return 1; } else { char *val = wg_decode_str(db, encp); if(strcmp(val, "lalalalalalalalalalalalalalalalalalalala")) { if(printlevel) { printf("check_query_param: encoded longstr parameter (%d) "\ "decoded to an invalid value \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if(wg_decode_str_len(db, encp) != 40) { if(printlevel) { printf("check_query_param: encoded longstr parameter (%d) "\ "had invalid length\n", (int) encp); } wg_free_query_param(db, encp); return 1; } tmp = decode_shortstr_offset(encp); if(tmp > 0 && tmp < dbmemsegh(db)->free) { if(printlevel) { printf("check_query_param: encoded longstr parameter (%d) "\ "had an invalid offset\n", (int) encp); } wg_free_query_param(db, encp); return 1; } } wg_free_query_param(db, encp); encp = wg_encode_query_param_str(db, "", NULL); if(wg_get_encoded_type(db, encp) != WG_STRTYPE) { if(printlevel) { printf("check_query_param: encoded empty string parameter (%d) "\ "had bad type (should be WG_STRTYPE)\n", (int) encp); } wg_free_query_param(db, encp); return 1; } else { char *val = wg_decode_str(db, encp); if(strcmp(val, "")) { if(printlevel) { printf("check_query_param: encoded empty string parameter (%d) "\ "decoded to an invalid value \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if(wg_decode_str_len(db, encp) != 0) { if(printlevel) { printf("check_query_param: encoded empty string parameter (%d) "\ "had invalid length\n", (int) encp); } wg_free_query_param(db, encp); return 1; } tmp = decode_shortstr_offset(encp); if(tmp > 0 && tmp < dbmemsegh(db)->free) { if(printlevel) { printf("check_query_param: encoded empty string parameter (%d) "\ "had an invalid offset\n", (int) encp); } wg_free_query_param(db, encp); return 1; } } wg_free_query_param(db, encp); i=0; while(strdata[i]) { encp = wg_encode_query_param_str(db, strdata[i], "et"); if(!islongstr(encp)) { if(printlevel) { printf("check_query_param: encoded string parameter (%d) "\ "had bad encoding (should be encoded as longstr)\n", (int) encp); } wg_free_query_param(db, encp); return 1; } else { char *val = wg_decode_str(db, encp); char cbuf[17]; int strl = strlen(strdata[i]), encl; if(strcmp(val, strdata[i])) { if(printlevel) { printf("check_query_param: encoded string parameter (%d) "\ "decoded to an invalid value \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if((encl = wg_decode_str_len(db, encp)) != strl) { if(printlevel) { printf("check_query_param: encoded string parameter \"%s\" "\ "had invalid length (%d != %d)\n", strdata[i], encl, strl); } wg_free_query_param(db, encp); return 1; } if(wg_decode_str_copy(db, encp, cbuf, 17) != strl) { if(printlevel) { printf("check_query_param: wg_decode_str_copy(): invalid length\n"); } wg_free_query_param(db, encp); return 1; } if(strcmp(cbuf, strdata[i])) { if(printlevel) { printf("check_query_param: copy of encoded string parameter (%d) "\ "is an invalid value \"%s\"\n", (int) encp, cbuf); } wg_free_query_param(db, encp); return 1; } val = wg_decode_str_lang(db, encp); if(strcmp(val, "et")) { if(printlevel) { printf("check_query_param: encoded string parameter (%d) "\ "had invalid language \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if(wg_decode_str_lang_len(db, encp) != 2) { if(printlevel) { printf("check_query_param: encoded string parameter (%d) language "\ "had invalid length\n", (int) encp); } wg_free_query_param(db, encp); return 1; } if(wg_decode_str_lang_copy(db, encp, cbuf, 17) != 2) { if(printlevel) { printf("check_query_param: wg_decode_str_lang_copy(): "\ "invalid length\n"); } wg_free_query_param(db, encp); return 1; } if(strcmp(cbuf, "et")) { if(printlevel) { printf("check_query_param: copy of encoded string parameter's (%d) "\ "language is an invalid value \"%s\"\n", (int) encp, cbuf); } wg_free_query_param(db, encp); return 1; } tmp = decode_longstr_offset(encp); if(tmp > 0 && tmp < dbmemsegh(db)->free) { if(printlevel) { printf("check_query_param: encoded string parameter (%d) "\ "had an invalid offset\n", (int) encp); } wg_free_query_param(db, encp); return 1; } } wg_free_query_param(db, encp); i++; } encp = wg_encode_query_param_xmlliteral(db, "VwwEtCiQQLvcIoB", "ACWzCMGGFVcZBjk"); if(!islongstr(encp)) { if(printlevel) { printf("check_query_param: encoded string parameter (%d) "\ "had bad encoding (should be encoded as longstr)\n", (int) encp); } wg_free_query_param(db, encp); return 1; } else { char *val = wg_decode_xmlliteral(db, encp); char cbuf[16]; int encl; if(strcmp(val, "VwwEtCiQQLvcIoB")) { if(printlevel) { printf("check_query_param: encoded XML literal param (%d) "\ "decoded to an invalid value \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if((encl = wg_decode_xmlliteral_len(db, encp)) != 15) { if(printlevel) { printf("check_query_param: encoded XML literal param \"%s\" "\ "had invalid length (%d != 15)\n", strdata[i], encl); } wg_free_query_param(db, encp); return 1; } if(wg_decode_xmlliteral_copy(db, encp, cbuf, 16) != 15) { if(printlevel) { printf("check_query_param: wg_decode_xmlliteral_copy(): "\ "invalid length\n"); } wg_free_query_param(db, encp); return 1; } if(strcmp(cbuf, "VwwEtCiQQLvcIoB")) { if(printlevel) { printf("check_query_param: copy of encoded XML literal param (%d) "\ "is an invalid value \"%s\"\n", (int) encp, cbuf); } wg_free_query_param(db, encp); return 1; } val = wg_decode_xmlliteral_xsdtype(db, encp); if(strcmp(val, "ACWzCMGGFVcZBjk")) { if(printlevel) { printf("check_query_param: encoded XML literal param (%d) "\ "had invalid language \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if(wg_decode_xmlliteral_xsdtype_len(db, encp) != 15) { if(printlevel) { printf("check_query_param: encoded XML literal param (%d) type "\ "had invalid length\n", (int) encp); } wg_free_query_param(db, encp); return 1; } if(wg_decode_xmlliteral_xsdtype_copy(db, encp, cbuf, 16) != 15) { if(printlevel) { printf("check_query_param: wg_decode_xmlliteral_xsdtype_copy(): "\ "invalid length\n"); } wg_free_query_param(db, encp); return 1; } if(strcmp(cbuf, "ACWzCMGGFVcZBjk")) { if(printlevel) { printf("check_query_param: copy of encoded XML literal param's "\ "(%d) type is an invalid value \"%s\"\n", (int) encp, cbuf); } wg_free_query_param(db, encp); return 1; } tmp = decode_longstr_offset(encp); if(tmp > 0 && tmp < dbmemsegh(db)->free) { if(printlevel) { printf("check_query_param: encoded XML literal param (%d) "\ "had an invalid offset\n", (int) encp); } wg_free_query_param(db, encp); return 1; } } wg_free_query_param(db, encp); encp = wg_encode_query_param_uri(db, "GCwepgqnKqcxnTj", "WdszkaEjrhEjgNS"); if(!islongstr(encp)) { if(printlevel) { printf("check_query_param: encoded string parameter (%d) "\ "had bad encoding (should be encoded as longstr)\n", (int) encp); } wg_free_query_param(db, encp); return 1; } else { char *val = wg_decode_uri(db, encp); char cbuf[16]; int encl; if(strcmp(val, "GCwepgqnKqcxnTj")) { if(printlevel) { printf("check_query_param: encoded URI parameter (%d) "\ "decoded to an invalid value \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if((encl = wg_decode_uri_len(db, encp)) != 15) { if(printlevel) { printf("check_query_param: encoded URI parameter \"%s\" "\ "had invalid length (%d != 15)\n", strdata[i], encl); } wg_free_query_param(db, encp); return 1; } if(wg_decode_uri_copy(db, encp, cbuf, 16) != 15) { if(printlevel) { printf("check_query_param: wg_decode_uri_copy(): "\ "invalid length\n"); } wg_free_query_param(db, encp); return 1; } if(strcmp(cbuf, "GCwepgqnKqcxnTj")) { if(printlevel) { printf("check_query_param: copy of encoded URI parameter (%d) "\ "is an invalid value \"%s\"\n", (int) encp, cbuf); } wg_free_query_param(db, encp); return 1; } val = wg_decode_uri_prefix(db, encp); if(strcmp(val, "WdszkaEjrhEjgNS")) { if(printlevel) { printf("check_query_param: encoded URI parameter (%d) "\ "had invalid language \"%s\"\n", (int) encp, val); } wg_free_query_param(db, encp); return 1; } if(wg_decode_uri_prefix_len(db, encp) != 15) { if(printlevel) { printf("check_query_param: encoded URI parameter (%d) type "\ "had invalid length\n", (int) encp); } wg_free_query_param(db, encp); return 1; } if(wg_decode_uri_prefix_copy(db, encp, cbuf, 16) != 15) { if(printlevel) { printf("check_query_param: wg_decode_uri_prefix_copy(): "\ "invalid length\n"); } wg_free_query_param(db, encp); return 1; } if(strcmp(cbuf, "WdszkaEjrhEjgNS")) { if(printlevel) { printf("check_query_param: copy of encoded URI parameter's "\ "(%d) type is an invalid value \"%s\"\n", (int) encp, cbuf); } wg_free_query_param(db, encp); return 1; } tmp = decode_longstr_offset(encp); if(tmp > 0 && tmp < dbmemsegh(db)->free) { if(printlevel) { printf("check_query_param: encoded URI parameter (%d) "\ "had an invalid offset\n", (int) encp); } wg_free_query_param(db, encp); return 1; } } wg_free_query_param(db, encp); if(printlevel>1) printf("********* check_query_param: no errors ************\n"); return 0; } /* --------------- allocation, storage, updafe and deallocation tests ---------- */ /* gint wg_check_allocation_deallocation(void* db, int printlevel) { rec* records[1000]; gint strs[1000]; int count; int n; int i; int j; char tmpstr[1000]; char str; count=2; n=3; for(i=0;i1) printf("********* testing strhash ********** \n"); /*for(i=0;i<100;i++) strs[i]=0;*/ if (p>1) printf("---------- initial hashtable -----------\n"); if (p>1) wg_show_strhash(db); if (p>1) printf("---------- testing str creation --------- \n"); for (i=0;i1) printf("wg_set_field rec %d fld %d str '%s' lang '%s' encoded %d\n", (int)i,(int)j,instrbuf,lang,(int)enc); wg_set_field(db,rec,j,enc); if (!longstr_in_hash(db,instrbuf,lang,WG_STRTYPE,strlen(instrbuf)+1)) { if (p) printf("wg_check_strhash gave error: stored str not present in strhash: \"%s\" lang \"%s\" \n",instrbuf,lang); return 1; } } } if (p>1) printf("---------- hashtable after str adding -----------\n"); if (p>1) wg_show_strhash(db); if (p>1) printf("---------- testing str removals by overwriting data --------- \n"); for (i=0;i=0;i--) { if (strs[i]!=0) { if (p>1) printf("removing str nr %d enc %d\n",i,strs[i]); j=wg_remove_from_strhash(db,strs[i]); if (p>1) printf("removal result %d\n",j); wg_show_strhash(db); } } */ if (p>1) printf("---------- ending str removals, testing if strs removed from hash ----------\n"); for (i=0;i1) printf("---------- hashtable after str removals -----------\n"); if (p>1) wg_show_strhash(db); if (p>1)printf("********* strhash testing ended without errors ********** \n"); return 0; } static gint longstr_in_hash(void* db, char* data, char* extrastr, gint type, gint length) { db_memsegment_header* dbh = dbmemsegh(db); gint old=0; int hash; gint hasharrel; if (0) { } else { // find hash, check if exists hash=wg_hash_typedstr(db,data,extrastr,type,length); //hasharrel=((gint*)(offsettoptr(db,((db->strhash_area_header).arraystart))))[hash]; hasharrel=dbfetch(db,((dbh->strhash_area_header).arraystart)+(sizeof(gint)*hash)); //printf("hash %d ((dbh->strhash_area_header).arraystart)+(sizeof(gint)*hash) %d hasharrel %d\n", // hash,((dbh->strhash_area_header).arraystart)+(sizeof(gint)*hash), hasharrel); if (hasharrel) old=wg_find_strhash_bucket(db,data,extrastr,type,length,hasharrel); //printf("old %d \n",old); if (old) { //printf("str found in hash\n"); return 1; } //printf("str not found in hash\n"); return 0; } } static void wg_show_strhash(void* db) { db_memsegment_header* dbh = dbmemsegh(db); gint i; gint hashchain; /*gint lasthashchain;*/ gint type; //gint offset; //gint refc; //int encoffset; printf("\nshowing strhash table and buckets\n"); printf("-----------------------------------\n"); printf("configured strhash size %d (%% of db size)\n",STRHASH_SIZE); printf("size %d\n", (int) (dbh->strhash_area_header).size); printf("offset %d\n", (int) (dbh->strhash_area_header).offset); printf("arraystart %d\n", (int) (dbh->strhash_area_header).arraystart); printf("arraylength %d\n", (int) (dbh->strhash_area_header).arraylength); printf("nonempty hash buckets:\n"); for(i=0;i<(dbh->strhash_area_header).arraylength;i++) { hashchain=dbfetch(db,(dbh->strhash_area_header).arraystart+(sizeof(gint)*i)); /*lasthashchain=hashchain; */ if (hashchain!=0) { printf("%d: contains %d encoded offset to chain\n", (int) i, (int) hashchain); for(;hashchain!=0; hashchain=dbfetch(db,decode_longstr_offset(hashchain)+LONGSTR_HASHCHAIN_POS*sizeof(gint))) { //printf("hashchain %d decode_longstr_offset(hashchain) %d fulladr %d contents %d\n", // hashchain, // decode_longstr_offset(hashchain), // (decode_longstr_offset(hashchain)+LONGSTR_HASHCHAIN_POS*sizeof(gint)), // dbfetch(db,decode_longstr_offset(hashchain)+LONGSTR_HASHCHAIN_POS*sizeof(gint))); type=wg_get_encoded_type(db,hashchain); printf(" "); wg_debug_print_value(db,hashchain); printf("\n"); //printf(" type %s",wg_get_type_name(db,type)); if (type==WG_BLOBTYPE) { //printf(" len %d\n",wg_decode_str_len(db,hashchain)); } else if (type==WG_STRTYPE || type==WG_XMLLITERALTYPE || type==WG_URITYPE || type== WG_ANONCONSTTYPE) { } else { printf("ERROR: wrong type in strhash bucket\n"); exit(0); } /*lasthashchain=hashchain;*/ } } } } /* --------------- allocation/memory checking and testing ------------------------------*/ /** check if varlen freelist is ok * * return 0 if ok, error nr if wrong * in case of error an errmsg is printed and function returns immediately * */ static gint wg_check_db(void* db) { gint res; db_memsegment_header* dbh = dbmemsegh(db); printf("\nchecking datarec area\n"); printf("-----------------------\n"); res=check_varlen_area(db,&(dbh->datarec_area_header)); if (res) return res; printf("\narea test passed ok\n"); printf("\nchecking longstr area\n"); printf("-----------------------\n"); res=check_varlen_area(db,&(dbh->longstr_area_header)); if (res) return res; printf("\narea test passed ok\n"); printf("\nwhole test passed ok\n"); return 0; } static gint check_varlen_area(void* db, void* area_header) { gint res; res=check_varlen_area_markers(db,area_header); if (res) return res; res=check_varlen_area_dv(db,area_header); if (res) return res; res=check_varlen_area_freelist(db,area_header); if (res) return res; res=check_varlen_area_scan(db,area_header); if (res) return res; return 0; } static gint check_varlen_area_freelist(void* db, void* area_header) { db_area_header* areah; gint i; gint res; areah=(db_area_header*)area_header; for (i=0;ifreebuckets)[i]!=0) { //printf("checking bucket nr %d \n",i); if (ifreebuckets)[i])); res=check_bucket_freeobjects(db,areah,i); if (res) return res; } else { //printf(" is varbucket at offset %d \n",dbaddr(db,&(areah->freebuckets)[i])); res=check_bucket_freeobjects(db,areah,i); if (res) return res; } } } return 0; } static gint check_bucket_freeobjects(void* db, void* area_header, gint bucketindex) { db_area_header* areah; gint freelist; gint size; gint nextptr; gint prevptr; gint prevfreelist; gint tmp; areah=(db_area_header*)area_header; freelist=(areah->freebuckets)[bucketindex]; prevfreelist=ptrtooffset(db,&((areah->freebuckets)[bucketindex])); while(freelist!=0) { if (!isfreeobject(dbfetch(db,freelist))) { printf("varlen freelist object error:\n"); printf("object at offset %d has size gint %d which is not marked free\n", (int) freelist, (int) dbfetch(db,freelist)); return 1; } size=getfreeobjectsize(dbfetch(db,freelist)); if (bucketindex!=wg_freebuckets_index(db,size)) { printf("varlen freelist object error:\n"); printf("object at offset %d with size %d is in wrong bucket %d instead of right %d\n", (int) freelist, (int) size, (int) bucketindex, (int) wg_freebuckets_index(db,size)); return 2; } if (getfreeobjectsize(dbfetch(db,freelist+size-sizeof(gint)))!=size) { printf("varlen freelist object error:\n"); printf("object at offset %d has wrong end size %d which is not same as start size %d\n", (int) freelist, (int) dbfetch(db,freelist+size-sizeof(gint)), (int) size); return 3; } nextptr=dbfetch(db,freelist+sizeof(gint)); prevptr=dbfetch(db,freelist+2*sizeof(gint)); if (prevptr!=prevfreelist) { printf("varlen freelist object error:\n"); printf("object at offset %d has a wrong prevptr: %d instead of %d\n", (int) freelist, (int) prevptr, (int) prevfreelist); return 4; } tmp=check_object_in_areabounds(db,area_header,freelist,size); if (tmp) { printf("varlen freelist object error:\n"); if (tmp==1) { printf("object at offset %d does not start in the area bounds\n", (int) freelist); return 5; } else { printf("object at offset %d does not end (%d) in the same area it starts\n", (int) freelist, (int) (freelist+size)); return 6; } } //printf(" ok freeobject offset %d end %d size %d nextptr %d prevptr %d \n", // freelist,freelist+size,size,nextptr,prevptr); prevfreelist=freelist; freelist=nextptr; } return 0; } static gint check_varlen_area_markers(void* db, void* area_header) { /*db_subarea_header* arrayadr;*/ db_area_header* areah; gint last_subarea_index; gint i; gint size; gint subareastart; /*gint subareaend;*/ gint offset; gint head; areah=(db_area_header*)area_header; /*arrayadr=(areah->subarea_array);*/ last_subarea_index=areah->last_subarea_index; for(i=0;(i<=last_subarea_index)&&(isubarea_array)[i]).alignedsize; subareastart=((areah->subarea_array)[i]).alignedoffset; /*subareaend=(((areah->subarea_array)[i]).alignedoffset)+size;*/ // start marker offset=subareastart; head=dbfetch(db,offset); if (!isspecialusedobject(head)) { printf("start marker at offset %d has head %d which is not specialusedobject\n", (int) offset, (int) head); return 21; } if (getspecialusedobjectsize(head)!=MIN_VARLENOBJ_SIZE) { printf("start marker at offset %d has size %d which is not MIN_VARLENOBJ_SIZE %d\n", (int) offset, (int) getspecialusedobjectsize(head), (int) MIN_VARLENOBJ_SIZE); return 22; } if (dbfetch(db,offset+sizeof(gint))!=SPECIALGINT1START) { printf("start marker at offset %d has second gint %d which is not SPECIALGINT1START %d\n", (int) offset, (int) dbfetch(db,offset+sizeof(gint)), SPECIALGINT1START ); return 23; } //end marker offset=offset+size-MIN_VARLENOBJ_SIZE; head=dbfetch(db,offset); if (!isspecialusedobject(head)) { printf("end marker at offset %d has head %d which is not specialusedobject\n", (int) offset, (int) head); return 21; } if (getspecialusedobjectsize(head)!=MIN_VARLENOBJ_SIZE) { printf("end marker at offset %d has size %d which is not MIN_VARLENOBJ_SIZE %d\n", (int) offset, (int) getspecialusedobjectsize(head), (int) MIN_VARLENOBJ_SIZE); return 22; } if (dbfetch(db,offset+sizeof(gint))!=SPECIALGINT1END) { printf("end marker at offset %d has second gint %d which is not SPECIALGINT1END %d\n", (int) offset, (int) dbfetch(db,offset+sizeof(gint)), SPECIALGINT1END ); return 23; } } return 0; } static gint check_varlen_area_dv(void* db, void* area_header) { db_area_header* areah; gint dv; gint tmp; areah=(db_area_header*)area_header; dv=(areah->freebuckets)[DVBUCKET]; if (dv!=0) { printf("checking dv: bucket nr %d at offset %d \ncontains dv at offset %d with size %d(%d) and end %d \n", DVBUCKET, (int) dbaddr(db,&(areah->freebuckets)[DVBUCKET]), (int) dv, (int) ((areah->freebuckets)[DVSIZEBUCKET]>0 ? dbfetch(db,(areah->freebuckets)[DVBUCKET]) : -1), (int) (areah->freebuckets)[DVSIZEBUCKET], (int) ((areah->freebuckets)[DVBUCKET]+(areah->freebuckets)[DVSIZEBUCKET])); if (!isspecialusedobject(dbfetch(db,dv))) { printf("dv at offset %d has head %d which is not marked specialusedobject\n", (int) dv, (int) dbfetch(db,dv)); return 10; } if ((areah->freebuckets)[DVSIZEBUCKET]!=getspecialusedobjectsize(dbfetch(db,dv))) { printf("dv at offset %d has head %d with size %d which is different from freebuckets[DVSIZE] %d\n", (int) dv, (int) dbfetch(db,dv), (int) getspecialusedobjectsize(dbfetch(db,dv)), (int) (areah->freebuckets)[DVSIZEBUCKET]); return 11; } if (getspecialusedobjectsize(dbfetch(db,dv))subarea_array); last_subarea_index=areah->last_subarea_index; found=0; for(i=0;(i<=last_subarea_index)&&(i=subareastart && offsetsubareaend) { return 1; } found=1; break; } } if (!found) { return 2; } else { return 0; } } static gint check_varlen_area_scan(void* db, void* area_header) { db_area_header* areah; gint dv; gint tmp; /*db_subarea_header* arrayadr;*/ gint firstoffset; gint curoffset; gint head; gint last_subarea_index; gint i; gint subareastart; gint subareaend; gint freemarker; gint dvmarker; gint usedcount=0; gint usedbytesrealcount=0; gint usedbyteswantedcount=0; gint freecount=0; gint freebytescount=0; gint dvcount=0; gint dvbytescount=0; gint size; /*gint offset;*/ areah=(db_area_header*)area_header; /*arrayadr=(areah->subarea_array);*/ last_subarea_index=areah->last_subarea_index; dv=(areah->freebuckets)[DVBUCKET]; for(i=0;(i<=last_subarea_index)&&(isubarea_array)[i]).alignedsize; subareastart=((areah->subarea_array)[i]).alignedoffset; subareaend=(((areah->subarea_array)[i]).alignedoffset)+size; // start marker /*offset=subareastart; */ firstoffset=subareastart; // do not skip initial "used" marker curoffset=firstoffset; //printf("curroffset %d record %x\n",curoffset,(uint)record); freemarker=0; //assume first object is a special in-use marker dvmarker=0; // assume first object is not dv head=dbfetch(db,curoffset); while(1) { // increase offset to next memory block curoffset=curoffset+(freemarker ? getfreeobjectsize(head) : getusedobjectsize(head)); if (curoffset>=(subareastart+size)) { printf("object areanr %d offset %d size %d starts at or after area end %d\n", (int) i, (int) curoffset, (int) getusedobjectsize(head), (int) (subareastart+size)); return 32; } head=dbfetch(db,curoffset); //printf("new curoffset %d head %d isnormaluseobject %d isfreeobject %d \n", // curoffset,head,isnormalusedobject(head),isfreeobject(head)); // check if found a normal used object if (isnormalusedobject(head)) { if (freemarker && !isnormalusedobjectprevfree(head)) { printf("inuse normal object areanr %d offset %d size %d follows free but is not marked to follow free\n", (int) i, (int) curoffset, (int) getusedobjectsize(head)); return 31; } else if (!freemarker && !isnormalusedobjectprevused(head)) { printf("inuse normal object areanr %d offset %d size %d follows used but is not marked to follow used\n", (int) i, (int) curoffset, (int) getusedobjectsize(head)); return 32; } tmp=check_varlen_object_infreelist(db,area_header,curoffset,0); if (tmp!=0) return tmp; freemarker=0; dvmarker=0; usedcount++; usedbytesrealcount+=getusedobjectsize(head); usedbyteswantedcount+=getfreeobjectsize(head); // just remove two lowest bits } else if (isfreeobject(head)) { if (freemarker) { printf("free object areanr %d offset %d size %d follows free\n", (int) i, (int) curoffset, (int) getfreeobjectsize(head)); return 33; } if (dvmarker) { printf("free object areanr %d offset %d size %d follows dv\n", (int) i, (int) curoffset, (int) getfreeobjectsize(head)); return 34; } tmp=check_varlen_object_infreelist(db,area_header,curoffset,1); if (tmp!=1) { printf("free object areanr %d offset %d size %d not found in freelist\n", (int) i, (int) curoffset, (int) getfreeobjectsize(head)); return 55; } freemarker=1; dvmarker=0; freecount++; freebytescount+=getfreeobjectsize(head); // loop start leads us to next object } else { // found a special object (dv or end marker) if (dbfetch(db,curoffset+sizeof(gint))==SPECIALGINT1DV) { // we have reached a dv object if (curoffset!=dv) { printf("dv object found areanr %d offset %d size %d not marked as in[DVBUCKET] %d\n", (int) i, (int) curoffset, (int) getspecialusedobjectsize(head), (int) dv); return 35; } if (dvcount!=0) { printf("second dv object found areanr %d offset %d size %d\n", (int) i, (int) curoffset, (int) getspecialusedobjectsize(head)); return 36; } if (getspecialusedobjectsize(head)freebuckets)[bucketindex]; /*prevfreelist=0;*/ while(freelist!=0) { objsize=getfreeobjectsize(dbfetch(db,freelist)); if (isfree) { if (offset==freelist) return 1; } else { if (offset==freelist) { printf("used object at offset %d in freelist for bucket %d\n", (int) offset, (int) bucketindex); return 51; } if (offset>freelist && freelist+objsize>offset) { printf("used object at offset %d inside freelist object at %d size %d for bucket %d\n", (int) offset, (int) freelist, (int) objsize, (int) bucketindex); return 52; } } freelist=dbfetch(db,freelist+sizeof(gint)); } return 0; } /* --------------------- index testing ------------------------ */ /** Test data inserting with indexed column * */ static gint wg_test_index1(void *db, int magnitude, int printlevel) { const int dbsize = 50*magnitude, rand_updates = magnitude; int i, j; void *start = NULL, *rec = NULL; gint oldv, newv; db_memsegment_header* dbh = dbmemsegh(db); #ifdef _WIN32 srand(102435356); #else srandom(102435356); /* fixed seed for repeatable sequences */ #endif if(wg_column_to_index_id(db, 0, WG_INDEX_TYPE_TTREE, NULL, 0) == -1) { if(printlevel > 1) printf("no index found on column 0, creating.\n"); if(wg_create_index(db, 0, WG_INDEX_TYPE_TTREE, NULL, 0)) { if(printlevel) fprintf(stderr, "index creation failed, aborting.\n"); return -3; } } if(printlevel > 1) { printf("------- tnode_area stats before insert --------\n"); wg_show_db_area_header(db,&(dbh->tnode_area_header)); } /* 1st loop: insert data in set 1 */ for(i=0; i>4; #else newv = random()>>4; #endif if(wg_set_field(db, rec, 0, wg_encode_int(db, newv))) { if(printlevel) fprintf(stderr, "insert error, aborting.\n"); return -1; } } if(validate_index(db, start, dbsize, 0, printlevel)) { if(printlevel) fprintf(stderr, "index validation failed after insert.\n"); return -2; } if(printlevel > 1) { printf("------- tnode_area stats after insert --------\n"); wg_show_db_area_header(db,&(dbh->tnode_area_header)); } /* 2nd loop: keep updating with random data */ for(j=0; j>4; #else newv = random()>>4; #endif if(wg_set_field(db, rec, 0, wg_encode_int(db, newv))) { if(printlevel) { printf("loop: %d row: %d old: %d new: %d\n", j, i, (int) oldv, (int) newv); fprintf(stderr, "insert error, aborting.\n"); } return -2; } if(validate_index(db, start, dbsize, 0, printlevel)) { if(printlevel) { printf("loop: %d row: %d old: %d new: %d\n", j, i, (int) oldv, (int) newv); fprintf(stderr, "index validation failed after update.\n"); } return -2; } } } if(printlevel > 1) { printf("------- tnode_area stats after update --------\n"); wg_show_db_area_header(db,&(dbh->tnode_area_header)); } return 0; } /** Quick index test to check basic behaviour * indexes existing data in database and validates the resulting index */ static gint wg_test_index2(void *db, int printlevel) { int i, dbsize; void *rec, *start; if (printlevel>1) printf("********* testing T-tree index ********** \n"); for(i=0; i<10; i++) { if(wg_column_to_index_id(db, i, WG_INDEX_TYPE_TTREE, NULL, 0) == -1) { if(wg_create_index(db, i, WG_INDEX_TYPE_TTREE, NULL, 0)) { if (printlevel) printf("index creation failed, aborting.\n"); return -3; } } } start = rec = wg_get_first_record(db); dbsize = 0; /* Get the number of records in database */ while(rec) { dbsize++; rec = wg_get_next_record(db, rec); } if(!dbsize) return 0; /* no data, so nothing more to do */ for(i=0; i<10; i++) { if(validate_index(db, start, dbsize, i, printlevel)) { if (printlevel) printf("index validation failed.\n"); return -2; } } if (printlevel>1) printf("********* index test successful ********** \n"); return 0; } /** Test data inserting with multi-column hash indexes * */ static gint wg_test_index3(void *db, int magnitude, int printlevel) { const int dbsize = 10*magnitude, rand_updates = magnitude; int i, j, k; void *start = NULL, *rec = NULL; long int newv, rnddata; gint index1, index2; gint columns[2]; #ifdef _WIN32 srand(102435356); #else srandom(102435356); /* fixed seed for repeatable sequences */ #endif /* index the typical key/value columns */ columns[0] = 1; columns[1] = 2; if(printlevel > 1) { printf("------- hash index test: inserting data --------\n"); } /* 1st loop: insert data */ for(i=0; i>4; if(rnddata & 1) { enc = wg_encode_int(db, newv); } else { char buf[30]; snprintf(buf, 29, "%ld", newv); buf[29] = '\0'; enc = wg_encode_str(db, buf, NULL); } if(wg_set_field(db, rec, columns[j], enc)) { if(printlevel) fprintf(stderr, "insert error, aborting.\n"); return -1; } } } if(printlevel > 1) { printf("------- hash index test: creating indexes --------\n"); } /* Create indexes with data in db */ if(wg_create_multi_index(db, columns, 2, WG_INDEX_TYPE_HASH, NULL, 0)) { if(printlevel) fprintf(stderr, "index creation failed, aborting.\n"); return -3; } if((index1 = wg_multi_column_to_index_id(db, columns, 2, WG_INDEX_TYPE_HASH, NULL, 0)) == -1) { if(printlevel) fprintf(stderr, "index not found after creation.\n"); return -3; } /* Create indexes with data in db */ if(wg_create_multi_index(db, columns, 2, WG_INDEX_TYPE_HASH_JSON, NULL, 0)) { if(printlevel) fprintf(stderr, "index creation failed, aborting.\n"); return -3; } if((index2 = wg_multi_column_to_index_id(db, columns, 2, WG_INDEX_TYPE_HASH_JSON, NULL, 0)) == -1) { if(printlevel) fprintf(stderr, "index not found after creation.\n"); return -3; } if(printlevel > 1) { printf("------- hash index test: validating indexes --------\n"); } if(validate_mc_index(db, start, dbsize, index1, columns, 2, printlevel)) { if(printlevel) fprintf(stderr, "index1 validation failed after insert.\n"); return -2; } if(validate_mc_index(db, start, dbsize, index2, columns, 2, printlevel)) { if(printlevel) fprintf(stderr, "index2 validation failed after insert.\n"); return -2; } if(printlevel > 1) { printf("------- hash index test: updating data --------\n"); } /* 2nd loop: keep updating with random data */ for(k=0; k>4; if(rnddata & 1) { enc = wg_encode_int(db, newv); } else { char buf[30]; snprintf(buf, 29, "%ld", newv); buf[29] = '\0'; enc = wg_encode_str(db, buf, NULL); } oldenc = wg_get_field(db, rec, columns[j]); if(wg_set_field(db, rec, columns[j], enc)) { if(printlevel) { printf("loop: %d row: %d old (encoded): %d new (encoded): %d\n", k, i, (int) oldenc, (int) enc); fprintf(stderr, "insert error, aborting.\n"); } return -1; } } if(validate_mc_index(db, start, dbsize, index1, columns, 2, printlevel)) { if(printlevel) { printf("loop: %d row: %d\n", k, i); fprintf(stderr, "index1 validation failed after update.\n"); } return -2; } if(validate_mc_index(db, start, dbsize, index2, columns, 2, printlevel)) { if(printlevel) { printf("loop: %d row: %d\n", k, i); fprintf(stderr, "index2 validation failed after update.\n"); } return -2; } } } if(printlevel > 1) { printf("------- hash index test: no errors found --------\n"); } return 0; } /** Validate a T-tree index * 1. validates a set of rows starting from *rec. * 2. checks tree balance * 3. checks tree min/max values * returns 0 if no errors found * returns -1 if value was not indexed * returns -2 if there was another error */ static int validate_index(void *db, void *rec, int rows, int column, int printlevel) { gint index_id = wg_column_to_index_id(db, column, WG_INDEX_TYPE_TTREE, NULL, 0); gint tnode_offset; wg_index_header *hdr; if(index_id == -1) return -2; /* Check if all values are indexed */ while(rec && rows) { if(wg_get_record_len(db, rec) > column) { gint val = wg_get_field(db, rec, column); if(wg_search_ttree_index(db, index_id, val) < 1) { if(printlevel) { printf("missing: %d\n", (int) val); } return -1; } } rec = wg_get_next_record(db, rec); rows--; } hdr = (wg_index_header *) offsettoptr(db, index_id); if(((struct wg_tnode *)(offsettoptr(db, TTREE_ROOT_NODE(hdr))))->parent_offset != 0) { if(printlevel) printf("root node parent offset is not 0\n"); return -2; } #ifdef TTREE_CHAINED_NODES if(TTREE_MIN_NODE(hdr) == 0) { if(printlevel) printf("min node offset is 0\n"); return -2; } if(TTREE_MAX_NODE(hdr) == 0) { if(printlevel) printf("max node offset is 0\n"); return -2; } #endif #ifdef TTREE_CHAINED_NODES tnode_offset = TTREE_MIN_NODE(hdr); #else tnode_offset = wg_ttree_find_lub_node(db, TTREE_ROOT_NODE(hdr)); #endif while(tnode_offset) { int diff; gint minval, maxval; struct wg_tnode *node = (struct wg_tnode *) offsettoptr(db, tnode_offset); /* Check index tree balance */ diff = node->left_subtree_height - node->right_subtree_height; if(diff < -1 || diff > 1) return -2; /* Check min/max values */ minval = wg_get_field(db, offsettoptr(db, node->array_of_values[0]), column); maxval = wg_get_field(db, offsettoptr(db, node->array_of_values[node->number_of_elements - 1]), column); if(minval != node->current_min) { if(printlevel) { printf("current_min invalid: %d is: %d should be: %d\n", (int) tnode_offset, (int) node->current_min, (int) minval); } return -2; } if(maxval != node->current_max) { if(printlevel) { printf("current_max invalid: %d is: %d should be: %d\n", (int) tnode_offset, (int) node->current_max, (int) maxval); } return -2; } tnode_offset = TNODE_SUCCESSOR(db, node); } return 0; } /** Validate a multi-column index * validates a set of rows starting from *rec. * uses the index_id provided (to facilitate separate testing of * multiple indexes on the same column set). * * returns 0 if no errors found * returns -1 if value was not indexed or was indexed and shouldn't have been * returns -2 if there was another error */ static int validate_mc_index(void *db, void *rec, size_t rows, gint index_id, gint *columns, size_t col_count, int printlevel) { wg_index_header *hdr = (wg_index_header *) offsettoptr(db, index_id); gint max_col = -1; size_t i; for(i=0; i max_col) { max_col = columns[i]; } } if(hdr->type != WG_INDEX_TYPE_HASH_JSON && hdr->type != WG_INDEX_TYPE_HASH) { } /* Check if all values are indexed */ while(rec && rows) { if(wg_get_record_len(db, rec) > max_col) { gint values[MAX_INDEX_FIELDS]; gint reclist_offset; int found = 0; for(i=0; i 0) { gint *nextoffset = &reclist_offset; while(*nextoffset) { gcell *rec_cell = (gcell *) offsettoptr(db, *nextoffset); void *match = offsettoptr(db, rec_cell->car); if(match == rec) { found = 1; } else { for(i=0; itype == WG_INDEX_TYPE_HASH_JSON && \ !is_plain_record(match)) { if(printlevel) { printf("record %p shouldn't be indexed\n", rec); } return -1; } nextoffset = &(rec_cell->cdr); } } /* check if the record was supposed to have been indexed */ if(hdr->type == WG_INDEX_TYPE_HASH || is_plain_record(rec)) { if(!found) { if(printlevel) { printf("missing: record %p\n", rec); } return -1; } } } rec = wg_get_next_record(db, rec); rows--; } return 0; } /* -------------------- child db testing ------------------------ */ #ifdef USE_CHILD_DB static int childdb_mkindex(void *db, int cnt) { int i; for(i=0; i 1) printf("checking (%p %d).\n", dbmemseg(db), i); if(validate_index(db, start, dbsize, i, printlevel)) { if(printlevel) printf("index validation failed (%p %d).\n", dbmemseg(db), i); return 0; } } return 1; } static int childdb_dropindex(void *db, int cnt) { int i; for(i=0; i1) { printf("********* testing child database ********** \n"); } foo = wg_attach_local_database(500000); if(foo) { if(printlevel>1) { #ifndef _WIN32 printf("Parent: %p free %td.\nChild: %p free %td extdbs %td size %td\n", #else printf("Parent: %p free %Id.\nChild: %p free %Id extdbs %Id size %Id\n", #endif dbmemseg(db), dbmemsegh(db)->free, dbmemseg(foo), dbmemsegh(foo)->free, dbmemsegh(foo)->extdbs.count, dbmemsegh(foo)->size); } } else { printf("Failed to attach to local database.\n"); return 1; } if(dbmemsegh(db)->key != 0) { /* Test invalid registering */ if(!wg_register_external_db(db, foo)) { if(printlevel) printf("Registering the local db in a shared db succeeded, should have failed\n"); wg_delete_local_database(foo); return 1; } } /* Records in parent db */ rec1 = (void *) wg_create_raw_record(db, 3); rec2 = (void *) wg_create_raw_record(db, 3); str1 = wg_encode_str(db, "hello", NULL); wg_set_new_field(db, rec1, 0, str1); wg_set_new_field(db, rec1, 1, wg_encode_str(db, "world", NULL)); wg_set_new_field(db, rec1, 2, wg_encode_double(db, 1.234)); wg_set_new_field(db, rec2, 0, wg_encode_record(db, rec1)); str2 = wg_encode_str(db, "bar", NULL); wg_set_new_field(db, rec2, 1, str2); /* Records in child db */ foorec1 = (void *) wg_create_raw_record(foo, 3); foorec2 = (void *) wg_create_raw_record(foo, 3); tmp = wg_encode_external_data(foo, db, str1); /* Try storing external data */ if(printlevel>1) { printf("Expecting an error: \"wg data handling error: "\ "External reference not recognized\".\n"); } if(!wg_set_new_field(foo, foorec1, 0, tmp)) { if(printlevel) printf("Storing external data succeeded, should have failed\n"); wg_delete_local_database(foo); return 1; } /* Test indexes */ if(printlevel>1) { printf("Testing child database index.\n"); } if(!childdb_mkindex(foo, 3)) { if(printlevel) printf("Child database index creation failed\n"); wg_delete_local_database(foo); return 1; } if(!childdb_ckindex(foo, 3, printlevel)) { if(printlevel) printf("Child database index test failed\n"); wg_delete_local_database(foo); return 1; } /* Test registering (should fail, as we have indexes) */ if(printlevel>1) { printf("Expecting an error: \"db memory allocation error: "\ "Database has indexes, external references not allowed\".\n"); } if(!wg_register_external_db(foo, db)) { if(printlevel) printf("Registering the external db succeeded, but we have indexes\n"); wg_delete_local_database(foo); return 1; } if(!childdb_dropindex(foo, 3)) { if(printlevel) printf("Dropping indexes failed\n"); wg_delete_local_database(foo); return 1; } /* Test registering again */ if(wg_register_external_db(foo, db)) { if(printlevel) printf("Registering the shared db in local db failed, should have succeeded\n"); wg_delete_local_database(foo); return 1; } if(printlevel>1) { printf("Expecting an error: \"index error: "\ "Database has external data, indexes disabled\".\n"); } if(childdb_mkindex(foo, 1)) { if(printlevel) printf("Child database index creation succeeded (should have failed)\n"); wg_delete_local_database(foo); return 1; } /* Storing external data should now work */ if(wg_set_new_field(foo, foorec1, 0, tmp)) { if(printlevel) printf("Storing external data failed, should have succeeded\n"); wg_delete_local_database(foo); return 1; } wg_set_new_field(foo, foorec1, 1, wg_encode_str(foo, "local data", NULL)); tmp = wg_encode_external_data(foo, db, wg_encode_record(db, rec1)); wg_set_new_field(foo, foorec2, 0, tmp); wg_set_new_field(foo, foorec2, 1, wg_encode_str(foo, "more local data", NULL)); tmp = wg_encode_external_data(foo, db, str2); wg_set_new_field(foo, foorec2, 2, tmp); if(printlevel>1) { printf("Testing data comparing.\n"); } /* Test comparing */ foorec3 = (void *) wg_create_raw_record(foo, 3); foorec4 = (void *) wg_create_raw_record(foo, 3); wg_set_new_field(foo, foorec3, 0, wg_encode_str(foo, "hello", NULL)); wg_set_new_field(foo, foorec3, 1, wg_encode_str(foo, "world", NULL)); wg_set_new_field(foo, foorec3, 2, wg_encode_double(foo, 1.234)); wg_set_new_field(foo, foorec4, 0, wg_encode_record(foo, foorec3)); wg_set_new_field(foo, foorec4, 1, wg_encode_str(foo, "more local data", NULL)); tmp = wg_encode_external_data(foo, db, str2); wg_set_new_field(foo, foorec4, 2, tmp); #if WG_COMPARE_REC_DEPTH > 2 /* foorec2 and foorec4 should be equal */ if(WG_COMPARE(foo, wg_encode_record(foo, foorec2), wg_encode_record(foo, foorec4)) != WG_EQUAL) { if(printlevel) printf("foorec2 and foorec4 were not equal, but should be.\n"); wg_delete_local_database(foo); return 1; } /* rec1 and foorec3 should be equal */ if(WG_COMPARE(foo, wg_encode_external_data(foo, db, wg_encode_record(db, rec1)), wg_encode_record(foo, foorec3)) != WG_EQUAL) { if(printlevel) printf("rec1 and foorec3 were not equal, but should be.\n"); wg_delete_local_database(foo); return 1; } #endif /* sanity check: foorec3 and foorec4 should not be equal */ if(WG_COMPARE(foo, wg_encode_record(foo, foorec3), wg_encode_record(foo, foorec4)) == WG_EQUAL) { if(printlevel) printf("foorec3 and foorec4 were equal, but should not be.\n"); wg_delete_local_database(foo); return 1; } #ifdef USE_BACKLINKING /* Test deleting */ if(wg_delete_record(db, rec1) != -1) { if(printlevel) printf("Deleting referenced parent rec1 succeeded (should have failed)\n"); wg_delete_local_database(foo); return 1; } #else if(wg_delete_record(db, rec1) != 0) { if(printlevel) printf("Deleting parent rec1 failed (should have succeeded)\n"); wg_delete_local_database(foo); return 1; } #endif if(wg_delete_record(db, rec2) != 0) { if(printlevel) printf("Deleting non-referenced parent rec2 failed (should have succeeded)\n"); wg_delete_local_database(foo); return 1; } if(wg_delete_record(foo, foorec2) != 0) { if(printlevel) printf("Deleting child foorec2 failed (should have succeeded)\n"); wg_delete_local_database(foo); return 1; } /* right now string refcounts are a bit fishy... skip this */ /* wg_set_field(foo, foorec4, 2, tmp); */ /* this should fail, but we don't want to interact with the * filesystem in these automated tests wg_dump(foo, "invalid.bin");*/ wg_delete_local_database(foo); if(printlevel>1) printf("********* child database test successful ********** \n"); #else printf("child databases disabled, skipping checks\n"); #endif return 0; } /* ---------------- schema/JSON related tests ----------------- */ /* * Run this on a dedicated database to check the effects * of param bits and deleting. */ static gint wg_check_schema(void* db, int printlevel) { void *rec, *arec, *orec, *trec; gint *gptr; gint tmp1, tmp2, tmp3; if(printlevel>1) { printf("********* testing schema functions ********** \n"); } tmp1 = wg_encode_int(db, 99); tmp2 = wg_encode_int(db, 98); tmp3 = wg_encode_int(db, 97); /* Triple */ rec = wg_create_triple(db, tmp1, tmp2, tmp3, 0); /* Check the record (fields and meta bits). * it is not a param. */ gptr = ((gint *) rec + RECORD_META_POS); if(*gptr) { if(printlevel) { printf("plain triple is expected to have no meta bits\n"); } return 1; } gptr = ((gint *) rec + RECORD_HEADER_GINTS + WG_SCHEMA_TRIPLE_OFFSET); if(*gptr != tmp1) { if(printlevel) printf("triple field 1 does not match\n"); return 1; } if(*(gptr+1) != tmp2) { if(printlevel) printf("triple field 2 does not match\n"); return 1; } if(*(gptr+2) != tmp3) { if(printlevel) printf("triple field 3 does not match\n"); return 1; } /* the next triple is a param. */ rec = wg_create_triple(db, tmp1, tmp2, tmp3, 1); gptr = ((gint *) rec + RECORD_META_POS); if(*gptr != (RECORD_META_NOTDATA|RECORD_META_MATCH)) { if(printlevel) { #ifndef _WIN32 printf("param triple had invalid meta bits (%td)\n", *gptr); #else printf("param triple had invalid meta bits (%Id)\n", *gptr); #endif } return 1; } /* kv-pair */ rec = wg_create_kvpair(db, tmp2, tmp3, 1); /* Check the record (fields and meta bits). * it is a param. */ gptr = ((gint *) rec + RECORD_META_POS); if(*gptr != (RECORD_META_NOTDATA|RECORD_META_MATCH)) { if(printlevel) { #ifndef _WIN32 printf("param kv-pair had invalid meta bits (%td)\n", *gptr); #else printf("param kv-pair had invalid meta bits (%Id)\n", *gptr); #endif } return 1; } gptr = ((gint *) rec + RECORD_HEADER_GINTS + WG_SCHEMA_TRIPLE_OFFSET); if(*gptr != 0) { if(printlevel) printf("kv-pair prefix is not NULL\n"); return 1; } if(*(gptr+1) != tmp2) { if(printlevel) printf("kv-pair key does not match\n"); return 1; } if(*(gptr+2) != tmp3) { if(printlevel) printf("kv-pair value does not match\n"); return 1; } /* this is not a param. */ rec = wg_create_triple(db, tmp1, tmp2, tmp3, 0); gptr = ((gint *) rec + RECORD_META_POS); if(*gptr) { if(printlevel) { printf("plain kv-pair is expected to have no meta bits\n"); } return 1; } /* params should be invisible */ if(check_db_rows(db, 2, printlevel)) { if(printlevel) printf("row count check failed (should have 2 non-param rows).\n"); return 1; } /* Object */ orec = wg_create_object(db, 1, 0, 0); if(wg_get_record_len(db, orec) != 1) { if(printlevel) { printf("object had invalid length\n"); } return 1; } gptr = ((gint *) orec + RECORD_META_POS); if(*gptr != RECORD_META_OBJECT) { if(printlevel) { #ifndef _WIN32 printf("object (nonparam) had invalid meta bits (%td)\n", *gptr); #else printf("object (nonparam) had invalid meta bits (%Id)\n", *gptr); #endif } return 1; } wg_set_field(db, orec, 0, wg_encode_record(db, rec)); /* Array. It has the document bit set. */ arec = wg_create_array(db, 4, 1, 0); if(wg_get_record_len(db, arec) != 4) { if(printlevel) { printf("array had invalid length\n"); } return 1; } gptr = ((gint *) arec + RECORD_META_POS); if(*gptr != (RECORD_META_ARRAY|RECORD_META_DOC)) { if(printlevel) { #ifndef _WIN32 printf("array (doc, nonparam) had invalid meta bits (%td)\n", *gptr); #else printf("array (doc, nonparam) had invalid meta bits (%Id)\n", *gptr); #endif } return 1; } /* Form the document. */ wg_set_field(db, arec, 0, tmp3); wg_set_field(db, arec, 1, tmp2); wg_set_field(db, arec, 2, tmp1); wg_set_field(db, arec, 3, wg_encode_record(db, orec)); #ifdef USE_BACKLINKING /* Locate the document through an element. */ trec = wg_find_document(db, rec); if(trec != arec) { if(printlevel) { printf("wg_find_document() failed\n"); } return 1; } #endif if(wg_delete_document(db, arec)) { if(printlevel) { printf("wg_delete_document() failed\n"); } return 1; } /* of the two rows in db earlier, one was included in the * deleted document. One should be remaining. */ if(check_db_rows(db, 1, printlevel)) { if(printlevel) printf("Invalid number of remaining rows after deleting.\n"); return 1; } /* Check the param bits of object and array. */ orec = wg_create_object(db, 5, 0, 1); gptr = ((gint *) orec + RECORD_META_POS); if(*gptr != (RECORD_META_OBJECT|RECORD_META_NOTDATA|RECORD_META_MATCH)) { if(printlevel) { #ifndef _WIN32 printf("object (param) had invalid meta bits (%td)\n", *gptr); #else printf("object (param) had invalid meta bits (%Id)\n", *gptr); #endif } return 1; } arec = wg_create_array(db, 6, 0, 1); gptr = ((gint *) arec + RECORD_META_POS); if(*gptr != (RECORD_META_ARRAY|RECORD_META_NOTDATA|RECORD_META_MATCH)) { if(printlevel) { #ifndef _WIN32 printf("array (param) had invalid meta bits (%td)\n", *gptr); #else printf("array (param) had invalid meta bits (%Id)\n", *gptr); #endif } return 1; } /* we added params, row count should not increase. */ if(check_db_rows(db, 1, printlevel)) { if(printlevel) printf("Invalid number of remaining rows after deleting.\n"); return 1; } if(printlevel>1) printf("********* schema test successful ********** \n"); return 0; } /* * Test JSON parsing. This produces some errors in stderr * which is expected (rely on the return value to check for success). */ static gint wg_check_json_parsing(void* db, int printlevel) { void *doc, *rec; gint enc; char *json1 = "[7,8,9]"; /* ok */ char *json2 = "{ \"a\":{\n\"b\": 55.0\n}, \"c\"\n:\"hello\","\ "\"d\"\t:[\n]}"; /* ok */ char *json3 = "25"; /* fail */ char *json4 = "{ \"a\":{\"b\": 55.0}, \"c\":\"hello\""; /* fail */ if(printlevel>1) { printf("********* testing JSON parsing functions ********** \n"); } /* parse input buf. */ doc = NULL; if(wg_parse_json_document(db, json1, &doc)) { if(printlevel) printf("Parsing a valid document failed.\n"); return 1; } if(!doc) { if(printlevel) printf("JSON parser did not return a document.\n"); return 1; } /* examine structure */ if(wg_get_record_len(db, doc) != 3) { if(printlevel) printf("Document structure error: bad object length.\n"); return 1; } if(is_special_record(doc) || !is_schema_document(doc) ||\ !is_schema_array(doc)) { if(printlevel) { printf("Document structure error: invalid meta type\n"); } return 1; } /* field contents */ enc = wg_get_field(db, doc, 0); if(wg_get_encoded_type(db, enc) != WG_INTTYPE) { if(printlevel) printf("Document structure error: bad array element(0).\n"); return 1; } if(wg_decode_int(db, enc) != 7) { if(printlevel) printf("Document structure error: bad array element value(0).\n"); return 1; } enc = wg_get_field(db, doc, 1); if(wg_get_encoded_type(db, enc) != WG_INTTYPE) { if(printlevel) printf("Document structure error: bad array element(1).\n"); return 1; } if(wg_decode_int(db, enc) != 8) { if(printlevel) printf("Document structure error: bad array element value(1).\n"); return 1; } enc = wg_get_field(db, doc, 2); if(wg_get_encoded_type(db, enc) != WG_INTTYPE) { if(printlevel) printf("Document structure error: bad array element(2).\n"); return 1; } if(wg_decode_int(db, enc) != 9) { if(printlevel) printf("Document structure error: bad array element value(2).\n"); return 1; } /* Use the param parser to get direct access to the * document structure. */ doc = NULL; if(wg_parse_json_param(db, json2, &doc)) { if(printlevel) printf("Parsing a valid document failed.\n"); return 1; } if(!doc) { if(printlevel) printf("Param parser did not return a document.\n"); return 1; } /* examine structure */ if(wg_get_record_len(db, doc) != 3) { if(printlevel) printf("Document structure error: bad object length.\n"); return 1; } if(!is_special_record(doc) || !is_schema_document(doc) ||\ !is_schema_object(doc)) { if(printlevel) { printf("Document structure error: invalid meta type\n"); } return 1; } /* first kv-pair */ enc = wg_get_field(db, doc, 0); if(wg_get_encoded_type(db, enc) != WG_RECORDTYPE) { if(printlevel) printf("Document structure error: bad object element(0).\n"); return 1; } rec = wg_decode_record(db, enc); enc = wg_get_field(db, rec, WG_SCHEMA_KEY_OFFSET); if(wg_get_encoded_type(db, enc) != WG_STRTYPE) { if(printlevel) printf("Document structure error: bad key type.\n"); return 1; } if(strncmp("a", wg_decode_str(db, enc), 1)) { if(printlevel) printf("Document structure error: bad key string.\n"); return 1; } enc = wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET); if(wg_get_encoded_type(db, enc) != WG_RECORDTYPE) { if(printlevel) printf("Document structure error: bad value type.\n"); return 1; } rec = wg_decode_record(db, enc); if(wg_get_record_len(db, rec) != 1) { if(printlevel) printf("Document structure error: bad sub-object length.\n"); return 1; } if(!is_schema_object(rec)) { if(printlevel) { printf("Document structure error: sub-object has invalid meta type\n"); } } enc = wg_get_field(db, rec, 0); if(wg_get_encoded_type(db, enc) != WG_RECORDTYPE) { if(printlevel) printf("Document structure error: bad sub-object element(0).\n"); return 1; } rec = wg_decode_record(db, enc); enc = wg_get_field(db, rec, WG_SCHEMA_KEY_OFFSET); if(wg_get_encoded_type(db, enc) != WG_STRTYPE) { if(printlevel) printf("Document structure error: bad subobj key type.\n"); return 1; } if(strncmp("b", wg_decode_str(db, enc), 1)) { if(printlevel) printf("Document structure error: bad subobj key string.\n"); return 1; } enc = wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET); if(wg_get_encoded_type(db, enc) != WG_DOUBLETYPE) { if(printlevel) printf("Document structure error: bad subobj value type.\n"); return 1; } if(wg_decode_double(db, enc) >= 55.1 ||\ wg_decode_double(db, enc) <= 54.9) { if(printlevel) printf("Document structure error: bad subobj value.\n"); return 1; } /* second kv-pair */ enc = wg_get_field(db, doc, 1); if(wg_get_encoded_type(db, enc) != WG_RECORDTYPE) { if(printlevel) printf("Document structure error: bad object element(1).\n"); return 1; } rec = wg_decode_record(db, enc); enc = wg_get_field(db, rec, WG_SCHEMA_KEY_OFFSET); if(wg_get_encoded_type(db, enc) != WG_STRTYPE) { if(printlevel) printf("Document structure error: bad key type.\n"); return 1; } if(strncmp("c", wg_decode_str(db, enc), 1)) { if(printlevel) printf("Document structure error: bad key string.\n"); return 1; } enc = wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET); if(wg_get_encoded_type(db, enc) != WG_STRTYPE) { if(printlevel) printf("Document structure error: value type.\n"); return 1; } if(strncmp("hello", wg_decode_str(db, enc), 5)) { if(printlevel) printf("Document structure error: bad value.\n"); return 1; } /* third kv-pair */ enc = wg_get_field(db, doc, 2); if(wg_get_encoded_type(db, enc) != WG_RECORDTYPE) { if(printlevel) printf("Document structure error: bad object element(0).\n"); return 1; } rec = wg_decode_record(db, enc); enc = wg_get_field(db, rec, WG_SCHEMA_KEY_OFFSET); if(wg_get_encoded_type(db, enc) != WG_STRTYPE) { if(printlevel) printf("Document structure error: bad key type.\n"); return 1; } if(strncmp("d", wg_decode_str(db, enc), 1)) { if(printlevel) printf("Document structure error: bad key string.\n"); return 1; } enc = wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET); if(wg_get_encoded_type(db, enc) != WG_RECORDTYPE) { if(printlevel) printf("Document structure error: bad value type.\n"); return 1; } rec = wg_decode_record(db, enc); if(!is_schema_array(rec)) { if(printlevel) { printf("Document structure error: bad value (array expected)\n"); } } if(wg_get_record_len(db, rec) != 0) { if(printlevel) printf("Document structure error: bad array length.\n"); return 1; } /* Invalid documents, expect a failure. */ if(printlevel>1) printf("testing invalid documents, the following errors are expected.\n"); if(!wg_check_json(db, NULL)) { if(printlevel) printf("Checking an invalid document succeeded (expected to fail).\n"); return 1; } if(!wg_check_json(db, json3)) { if(printlevel) printf("Checking an invalid document succeeded (expected to fail).\n"); return 1; } if(!wg_parse_json_document(db, json3, NULL)) { if(printlevel) printf("Parsing an invalid document succeeded.\n"); return 1; } if(!wg_check_json(db, json4)) { if(printlevel) printf("Checking an invalid document succeeded (expected to fail).\n"); return 1; } if(!wg_parse_json_param(db, json4, &doc)) { if(printlevel) printf("Parsing an invalid document succeeded.\n"); return 1; } if(printlevel>1) printf("********* JSON parsing test successful ********** \n"); return 0; } /* * Returns 1 if the offset is in list. * Returns 0 otherwise. */ static int is_offset_in_list(void *db, gint reclist_offset, gint offset) { if(reclist_offset > 0) { gint *nextoffset = &reclist_offset; while(*nextoffset) { gcell *rec_cell = (gcell *) offsettoptr(db, *nextoffset); if(rec_cell->car == offset) return 1; nextoffset = &(rec_cell->cdr); } } return 0; } /* * Test index hash (low-level functions) */ static gint wg_check_idxhash(void* db, int printlevel) { db_hash_area_header ha; struct { char *data; gint offsets[10]; int delidx; } rowdata[] = { { "0iQ1vMvGX5wfsjLTssyx", { 5709281, 5769186, 0, 0, 0, 0, 0, 0, 0, 0 }, 1 }, { "1jP3hJxO61QVscBEKu9", { 3510018, 8944261, 8172536, 4346587, 0, 0, 0, 0, 0, 0 }, 2 }, { "yLMt2eSQuIi3ChQlI0", { 6587099, 6385516, 0, 0, 0, 0, 0, 0, 0, 0 }, 1 }, { "ZlGS9cVX7fE1v7H6m", { 2059694, 1981000, 8360987, 752526, 6435820, 240982, 323628, 8875951, 0, 0 }, 1 }, { "duflillyRviJ1ZvH", { 6711262, 9685175, 4070003, 5977585, 9671591, 5321015, 7499127, 9101853, 0, 0 }, 2 }, { "USLP83gH6f4pNYJ", { 8759349, 436333, 0, 0, 0, 0, 0, 0, 0, 0 }, 1 }, { "yHIDgxlEA7RLAx", { 7613500, 534106, 4361094, 1506219, 0, 0, 0, 0, 0, 0 }, 1 }, { " ", { 6588510, 6253610, 9020726, 8514572, 9378303, 1100373, 0, 0, 0, 0 }, 2 }, { " ", { 8185484, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, { "yHIDgxlEA7R", { 2542797, 6481658, 214793, 943434, 2934816, 9503963, 1374313, 0, 0, 0 }, 4 }, { NULL, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, -1 } }; int i; if(printlevel>1) { printf("********* testing index hash functions ********** \n"); } /* Create a tiny hash table to allow hash chains to be created. */ if(wg_create_hash(db, &ha, 4)) { if(printlevel) printf("Failed to create the hash table.\n"); return 1; } /* Insert rows in order of columns */ for(i=0; i<10; i++) { int j; for(j=0; rowdata[j].data; j++) { if(rowdata[j].offsets[i]) { if(wg_idxhash_store(db, &ha, rowdata[j].data, strlen(rowdata[j].data), rowdata[j].offsets[i])) { if(printlevel) printf("Hash table insertion failed (j=%d i=%d).\n", j, i); return 1; } } } } /* Check that each offset is present */ for(i=0; rowdata[i].data; i++) { int j; gint list = wg_idxhash_find(db, &ha, rowdata[i].data, strlen(rowdata[i].data)); for(j=0; j<10 && rowdata[i].offsets[j]; j++) { if(!is_offset_in_list(db, list, rowdata[i].offsets[j])) { if(printlevel) printf("Offset missing in hash table (i=%d j=%d).\n", i, j); return 1; } } } /* Delete the rows designated by delidx */ for(i=0; rowdata[i].data; i++) { if(wg_idxhash_remove(db, &ha, rowdata[i].data, strlen(rowdata[i].data), rowdata[i].offsets[rowdata[i].delidx])) { if(printlevel) printf("Hash table deletion failed (i=%d delidx=%d).\n", i, rowdata[i].delidx); return 1; } } /* Check that the deleted row is not present and that all the others are */ for(i=0; rowdata[i].data; i++) { int j; gint list = wg_idxhash_find(db, &ha, rowdata[i].data, strlen(rowdata[i].data)); for(j=0; j<10 && rowdata[i].offsets[j]; j++) { if(j == rowdata[i].delidx) { /* Should be missing */ if(is_offset_in_list(db, list, rowdata[i].offsets[j])) { if(printlevel) printf("Offset not correctly deleted (i=%d delidx=%d).\n", i, rowdata[i].delidx); return 1; } } else { /* Should be present */ if(!is_offset_in_list(db, list, rowdata[i].offsets[j])) { if(printlevel) printf("Offset missing in hash table (i=%d j=%d).\n", i, j); return 1; } } } } if(printlevel>1) printf("********* index hash test successful ********** \n"); return 0; } /* --------------------- query testing ------------------------ */ /** * Fetch all rows where "col" "cond" "val" is true * (where cond is a comparison operator - equal, less than etc) * Check that the val matches the field value in returned records. * Check that the number of rows matches the expected value */ static int check_matching_rows(void *db, int col, int cond, void *val, gint type, int expected, int printlevel) { void *rec = NULL; wg_query *query = NULL; wg_query_arg arglist; int cnt; arglist.column = col; arglist.cond = cond; switch(type) { case WG_INTTYPE: arglist.value = wg_encode_query_param_int(db, *((gint *) val)); break; case WG_DOUBLETYPE: arglist.value = wg_encode_query_param_double(db, *((double *) val)); break; case WG_STRTYPE: arglist.value = wg_encode_query_param_str(db, (char *) val, NULL); break; default: return -1; } query = wg_make_query(db, NULL, 0, &arglist, 1); if(!query) { return -2; } if(query->res_count != expected) { if(printlevel) printf("check_matching_rows: res_count mismatch (%d != %d)\n", (int) query->res_count, expected); return -3; } cnt = 0; while((rec = wg_fetch(db, query))) { gint enc = wg_get_field(db, rec, col); if(cond == WG_COND_EQUAL) { switch(type) { case WG_INTTYPE: if(wg_decode_int(db, enc) != *((int *) val)) { if(printlevel) printf("check_matching_rows: int value mismatch\n"); return -4; } break; case WG_DOUBLETYPE: if(wg_decode_double(db, enc) != *((double *) val)) { if(printlevel) printf("check_matching_rows: double value mismatch\n"); return -4; } break; case WG_STRTYPE: if(strcmp(wg_decode_str(db, enc), (char *) val)) { if(printlevel) printf("check_matching_rows: string value mismatch\n"); return -4; } break; default: break; } } cnt++; } if(cnt != expected) { if(printlevel) printf("check_matching_rows: actual count mismatch (%d != %d)\n", cnt, expected); return -5; } wg_free_query(db, query); wg_free_query_param(db, arglist.value); return 0; } /** * version of check_matching_rows() using wg_find_record_*() */ static int check_matching_rows_find(void *db, int col, int cond, void *val, gint type, int expected, int printlevel) { void *rec = NULL; int cnt = 0; for(;;) { switch(type) { case WG_INTTYPE: rec = wg_find_record_int(db, col, cond, *((int *) val), rec); break; case WG_DOUBLETYPE: rec = wg_find_record_double(db, col, cond, *((double *) val), rec); break; case WG_STRTYPE: rec = wg_find_record_str(db, col, cond, (char *) val, rec); break; default: break; } if(!rec) break; cnt++; } if(cnt != expected) { if(printlevel) printf("check_matching_rows_find: actual count mismatch (%d != %d)\n", cnt, expected); return -5; } return 0; } /** * Count db rows */ static int check_db_rows(void *db, int expected, int printlevel) { void *rec = NULL; int cnt; rec = wg_get_first_record(db); cnt = 0; while(rec) { cnt++; rec = wg_get_next_record(db, rec); } if(cnt != expected) { if(printlevel) printf("check_db_rows: actual count mismatch (%d != %d)\n", cnt, expected); return -1; } return 0; } /** * Basic query tests */ static gint wg_test_query(void *db, int magnitude, int printlevel) { const int dbsize = 50*magnitude; int i, j, k; void *rec = NULL; if(wg_column_to_index_id(db, 0, WG_INDEX_TYPE_TTREE, NULL, 0) == -1) { if(printlevel > 1) printf("no index found on column 0, creating.\n"); if(wg_create_index(db, 0, WG_INDEX_TYPE_TTREE, NULL, 0)) { if(printlevel) printf("index creation failed, aborting.\n"); return -3; } } if(printlevel > 1) printf("------- Inserting test data --------\n"); /* Create predictable data */ for(i=0; i 1) printf("no index found on column 2, creating.\n"); if(wg_create_index(db, 2, WG_INDEX_TYPE_TTREE, NULL, 0)) { if(printlevel) printf("index creation failed, aborting.\n"); return -3; } } if(printlevel > 1) printf("------- Running read query tests --------\n"); /* Content check read queries */ for(i=0; i 1) printf("------- Running find tests --------\n"); /* Content check read queries */ for(i=0; i 1) printf("------- Updating test data --------\n"); /* Update queries */ for(i=0; i 1) printf("------- Running read query tests --------\n"); /* Content check read queries, iteration 2 */ for(i=0; i 1) printf("------- Running delete queries --------\n"); /* Delete query */ for(i=0; i 1) printf("------- Checking row count --------\n"); /* Database scan */ if(check_db_rows(db, dbsize * (50 * 50 - 30 * 20), printlevel)) { if(printlevel) printf("row count check failed.\n"); return -7; } return 0; } /* ------------------------- log testing ------------------------ */ #ifndef _WIN32 #define LOG_TESTFILE "/tmp/wgdb.logtest" #else #define LOG_TESTFILE "c:\\windows\\temp\\wgdb.logtest" #endif static gint wg_check_log(void* db, int printlevel) { #if defined(USE_DBLOG) db_memsegment_header* dbh = dbmemsegh(db); db_handle_logdata *ld = ((db_handle *) db)->logdata; void *clonedb; void *rec1, *rec2; gint tmp, str1, str2; char logfn[100]; int i, err, pid; int fd; if(printlevel>1) { printf("********* testing journal logging ********** \n"); } /* Set up the temporary log. We don't use the standard method as * that might interfere with real database logs. Also, normally * local databases are not logged. */ #ifndef _WIN32 pid = getpid(); #else pid = _getpid(); #endif snprintf(logfn, 99, "%s.%d", LOG_TESTFILE, pid); logfn[99] = '\0'; #ifdef _WIN32 if(_sopen_s(&fd, logfn, _O_CREAT|_O_APPEND|_O_BINARY|_O_RDWR, _SH_DENYNO, _S_IREAD|_S_IWRITE)) { #else if((fd = open(logfn, O_CREAT|O_APPEND|O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) == -1) { #endif if(printlevel) printf("Failed to open the test journal\n"); return 1; } #ifndef _WIN32 if(write(fd, WG_JOURNAL_MAGIC, WG_JOURNAL_MAGIC_BYTES) != \ WG_JOURNAL_MAGIC_BYTES) { if(printlevel) printf("Failed to initialize the test journal\n"); close(fd); return 1; } #else if(_write(fd, WG_JOURNAL_MAGIC, WG_JOURNAL_MAGIC_BYTES) != \ WG_JOURNAL_MAGIC_BYTES) { if(printlevel) printf("Failed to initialize the test journal\n"); _close(fd); return 1; } #endif ld->fd = fd; ld->serial = dbh->logging.serial; dbh->logging.active = 1; /* Do various operations in the database: * Encode short/long strings, doubles, ints * Create records (also with different meta bits) * Delete records * Set fields */ str1 = wg_encode_str(db, "0000000001000000000200000000030000000004", NULL); str2 = wg_encode_str(db, "00000000010000000002", NULL); tmp = wg_encode_double(db, -6543.3412); rec1 = wg_create_record(db, 7); wg_set_field(db, rec1, 4, str1); wg_set_field(db, rec1, 5, str2); wg_set_field(db, rec1, 6, tmp); if(printlevel) printf("Expecting a field index error:\n"); wg_set_field(db, rec1, 7, 0); /* Failed operation, shouldn't be logged */ rec2 = wg_create_record(db, 6); wg_set_field(db, rec2, 1, str1); wg_set_field(db, rec2, 3, str2); wg_set_field(db, rec2, 5, tmp); wg_delete_record(db, rec1); rec1 = wg_create_record(db, 10); for(i=0; i<10; i++) wg_set_field(db, rec1, i, wg_encode_int(db, (~((gint) 0))-i)); rec1 = wg_create_object(db, 1, 0, 0); rec1 = wg_create_array(db, 4, 1, 0); #ifndef _WIN32 close(ld->fd); #else _close(ld->fd); #endif ld->fd = -1; /* Replay the log in a clone database. * Note that replay normally restarts logging using the * standard configuration, but here this is not the case as * the logging.active flag is not set in the local database. */ clonedb = wg_attach_local_database(800000); if(!clonedb) { if(printlevel) printf("Failed to create a second memory database\n"); remove(logfn); return 1; } if(wg_replay_log(clonedb, logfn)) { if(printlevel) printf("Failed to replay the journal\n"); wg_delete_local_database(clonedb); remove(logfn); return 1; } err = 0; /* Compare the databases */ rec1 = wg_get_first_record(db); rec2 = wg_get_first_record(clonedb); while(rec1) { int len1, len2; gint meta1, meta2; if(!rec2) { if(printlevel) printf("Error: clone database had fewer records\n"); err = 1; break; } len1 = wg_get_record_len(db, rec1); len2 = wg_get_record_len(clonedb, rec2); if(len1 != len2) { if(printlevel) printf("Error: records had different lengths\n"); err = 1; break; } meta1 = *((gint *) rec1 + RECORD_META_POS); meta2 = *((gint *) rec2 + RECORD_META_POS); if(meta1 != meta2) { if(printlevel) printf("Error: records had different metadata\n"); err = 1; break; } for(i=0; i1) printf("********* journal logging test successful ********** \n"); return 0; #else printf("logging disabled, skipping checks\n"); return 77; #endif } /* ------------------ bulk testdata generation ---------------- */ /* Asc/desc/mix integer data functions originally written by Enar Reilent. * these functions will generate integer data of given * record size into database. */ /** Generate integer data with ascending values * */ int wg_genintdata_asc(void *db, int databasesize, int recordsize){ int i, j, tmp; void *rec; wg_int value = 0; int increment = 1; int incrementincrement = 17; int k = 0; for (i=0;i", (int) ptrdata); //len = strlen(buf); //if(buflen - len > 1) // snprint_record(db, (wg_int*)ptrdata, buf+len, buflen-len); break; case WG_INTTYPE: intdata = wg_decode_int(db, enc); if (issmallint(enc)) snprintf(buf, buflen, "smallint:%d", intdata); else snprintf(buf, buflen, "longint:%d", intdata); break; case WG_DOUBLETYPE: doubledata = wg_decode_double(db, enc); snprintf(buf, buflen, "double:%f", doubledata); break; case WG_STRTYPE: strdata = wg_decode_str(db, enc); if ((enc&NORMALPTRMASK)==LONGSTRBITS) { /*fieldoffset=decode_longstr_offset(enc)+LONGSTR_META_POS*sizeof(gint);*/ //printf("fieldoffset %d\n",fieldoffset); /*tmp=dbfetch(db,fieldoffset); */ offset=decode_longstr_offset(enc); refc=dbfetch(db,offset+LONGSTR_REFCOUNT_POS*sizeof(gint)); if (1) { //(tmp&LONGSTR_META_TYPEMASK)==WG_STRTYPE) { snprintf(buf, buflen, "longstr: len %d refcount %d str \"%s\" extrastr \"%s\"", (int) wg_decode_unistr_len(db,enc,type), (int) refc, wg_decode_unistr(db,enc,type), wg_decode_unistr_lang(db,enc,type)); } /* } else if ((tmp&LONGSTR_META_TYPEMASK)==WG_URITYPE) { snprintf(buf, buflen, "uri:\"%s\"", strdata); } else if ((tmp&LONGSTR_META_TYPEMASK)==WG_XMLLITERALTYPE) { snprintf(buf, buflen, "xmlliteral:\"%s\"", strdata); } else { snprintf(buf, buflen, "unknown_str_subtype %d",tmp&LONGSTR_META_TYPEMASK); } */ } else { snprintf(buf, buflen, "shortstr: len %d str \"%s\"", (int) wg_decode_str_len(db,enc), wg_decode_str(db,enc)); } break; case WG_URITYPE: strdata = wg_decode_uri(db, enc); exdata = wg_decode_uri_prefix(db, enc); snprintf(buf, buflen, "uri:\"%s%s\"", exdata, strdata); break; case WG_XMLLITERALTYPE: strdata = wg_decode_xmlliteral(db, enc); exdata = wg_decode_xmlliteral_xsdtype(db, enc); snprintf(buf, buflen, "xmlliteral:\"%s\"", exdata, strdata); break; case WG_BLOBTYPE: //strdata = wg_decode_blob(db, enc); //exdata = wg_decode_xmlliteral_xsdtype(db, enc); snprintf(buf, buflen, "blob: len %d extralen %d", (int) wg_decode_blob_len(db,enc), (int) wg_decode_blob_type_len(db,enc)); break; case WG_CHARTYPE: intdata = wg_decode_char(db, enc); snprintf(buf, buflen, "char:%c", (char) intdata); break; case WG_DATETYPE: intdata = wg_decode_date(db, enc); wg_strf_iso_datetime(db,intdata,0,strbuf); strbuf[10]=0; snprintf(buf, buflen, "date:%s", intdata,strbuf); break; case WG_TIMETYPE: intdata = wg_decode_time(db, enc); wg_strf_iso_datetime(db,1,intdata,strbuf); snprintf(buf, buflen, "time:%s",intdata,strbuf+11); break; default: snprintf(buf, buflen, ""); break; } printf("enc %d %s", (int) enc, buf); } /** * General sanity checks */ static int check_sanity(void *db) { #ifdef HAVE_64BIT_GINT if(sizeof(gint) != 8) { printf("gint size sanity check failed\n"); return 1; } #else if(sizeof(gint) != 4) { printf("gint size sanity check failed\n"); return 1; } #endif return 0; } #ifdef __cplusplus } #endif whitedb-0.7.3/Test/rtest.h0000644000175000001440000000207312421471034012315 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009,2010 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file rtest.h * Reasoner testing functions. * */ #ifndef DEFINED_RTEST_H #define DEFINED_RTEST_H #include "../Reasoner/glb.h" int wg_test_reasoner(int argc, char **argv); static int wr_test_subsume_cl(glb* g, cvec clvec, char* clstr, int expres, int p); #endif whitedb-0.7.3/Test/dbtest.h0000644000175000001440000000334312421471034012442 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2009,2010,2012,2013,2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbtest.h * Public headers for database testing procedures. */ #ifndef DEFINED_DBTEST_H #define DEFINED_DBTEST_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* ====== general typedefs and macros ======= */ #define WG_TEST_COMMON 0x01 #define WG_TEST_INDEX 0x02 #define WG_TEST_QUERY 0x04 #define WG_TEST_LOG 0x08 #define WG_TEST_QUICK (WG_TEST_COMMON|WG_TEST_LOG) #define WG_TEST_FULL (WG_TEST_QUICK|WG_TEST_INDEX|WG_TEST_QUERY) /* ==== Protos ==== */ int wg_run_tests(int tests, int printlevel); void wg_show_db_memsegment_header(void* db); int wg_genintdata_asc(void *db, int databasesize, int recordsize); int wg_genintdata_desc(void *db, int databasesize, int recordsize); int wg_genintdata_mix(void *db, int databasesize, int recordsize); void wg_debug_print_value(void *db, gint data); /* ------- testing ------------ */ #endif /* DEFINED_DBTEST_H */ whitedb-0.7.3/Test/Makefile.am0000644000175000001440000000024412421471034013035 00000000000000# # - - - - main db sources - - - noinst_LTLIBRARIES = libTest.la libTest_la_SOURCES = dbtest.c dbtest.h if REASONER libTest_la_SOURCES += rtest.c rtest.h endif whitedb-0.7.3/Test/rtest.c0000644000175000001440000004447712421471034012326 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009,2010 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file rtest.c * Reasoner testing functions. * */ /* ====== Includes =============== */ #include #include #include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "../Db/dballoc.h" #include "../Db/dbmem.h" #include "../Db/dbdata.h" //#include "../Db/dbapi.h" #include "../Db/dbdump.h" #include "../Db/dblog.h" #include "../Db/dbquery.h" #include "../Db/dbutil.h" #include "../Parser/dbparse.h" #include "../Reasoner/rincludes.h" #include "../Reasoner/rmain.h" #include "rtest.h" /* ====== Private headers and defs ======== */ /* ======= Private protos ================ */ static int wr_test_reasoner_otterparser(glb* g,int p); static int wr_test_coretests(glb* g,int p); static int wr_test_eq(glb* g, cvec clvec, char* clstr, int expres, int p); static int wr_test_unify(glb* g, cvec clvec, char* clstr, int expres, int p); static int wr_test_match(glb* g, cvec clvec, char* clstr, int expres, int p); static int wr_test_unify(glb* g, cvec clvec, char* clstr, int expres, int p); static int wr_litinf_is_clear(glb* g,vec v); /* ====== Functions ============== */ /** Run reasoner tests. * Allows each test to be run in separate locally allocated databases, * if necessary. * * returns 0 if no errors. * otherwise returns error code. */ int wg_test_reasoner(int argc, char **argv) { void* db=NULL; glb* g; int tmp=0; int p=2; int localflag=1; printf("******** wg_test_reasoner starts ********* \n"); if (localflag) db=wg_attach_local_database(500000); if (db==NULL) { if (p) printf("failed to initialize database\n"); return 1; } g=wr_glb_new_full(db); if (g==NULL) { if (p) printf("failed to initialize reasoner globals\n"); return 1; } if (tmp==0) tmp=wr_test_reasoner_otterparser(g,p); if (tmp) { if (p) printf("failed to parse otter text\n"); return 1; } tmp=wr_test_coretests(g,p); //wr_init_active_passive_lists_std(g); //res=wr_genloop(g); //printf("\nresult %d\n",res); //printf("----------------------------------\n"); //wr_show_stats(g); //printf("----------------------------------\n"); wr_glb_free(g); if (!tmp) { if (p) printf("******** wg_test_reasoner ends OK ********\n"); } else { if (p) printf("******** wg_test_reasoner ends with an error ********\n"); } if (localflag) wg_delete_local_database(db); return tmp; } static int wr_test_reasoner_otterparser(glb* g,int p) { int err; int res=0; char* otterstr; int ottestrlen; otterstr="p(3). -p(?X) | =(?X,2)."; ottestrlen=strlen(otterstr); if (p>0) printf("--------- wr_test_reasoner_otterparser starts ---------\n"); //err = wr_import_otter_file(g,"otter.txt",otterstr,ottestrlen); err = wr_import_otter_file(g,"Rexamples/otter.txt",NULL,NULL); if(!err) { if (p>1) printf("Data imported from otter file OK\n"); res=0; } else if(err<-1) { if (p>0) printf("Fatal error when importing otter file, data may be partially imported\n"); res=1; } else { if (p>0) printf("Import failed.\n"); res=1; } if (p>0) printf("--------- wr_test_reasoner_otterparser ends ---------\n"); return res; } static int wr_test_coretests(glb* g,int p) { int tmp=0; cvec clvec; if (p>0) printf("--------- wr_test_reasoner_coretests starts ---------\n"); clvec=wr_cvec_new(g,1000); if (clvec==NULL) { printf("cannot allocate cvec in wr_test_coretests\n"); return 1; } (g->print_initial_parser_result)=0; (g->print_generic_parser_result)=0; if (p>0) printf("- - - wr_equal_term tests - - -\n"); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1). m(1).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1). ?X(1).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1). 'a'(1).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,-1,0,2,100000). p(1,-1,0,2,100000).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,10). p(1,20).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1.23456). p(1.23456).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1.0). p(1.0).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1.0,-10.2,10000.00001). p(1.0,-10.2,10000.00001).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1.0,-10.2,10000.00001). p(1,-10.2,10000.00001).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(a,'a1a1a1a1a1a1a1a1a1a1'). p(a,'a1a1a1a1a1a1a1a1a1a1').",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(a,'a1a1a1a1a1a1a1a1a1a1'). p(a,'a1a1a1a1a1a1a1a1a1a2').",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"abc\"). p(\"abc\").",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"abc\",\"x\"). p(\"abc\",\"x\").",1,p); //if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"abc\",\"\",\"x\"). p(\"abc\",\"\",\"x\").",1,p); //if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"abc\",\"\",\"x\"). p(\"abc\",\"\",\"y\").",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"abc\",\"xxc\"). p(\"abc\",\"xxC\").",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"0123456789012345678901234567890123456789\").\ p(\"0123456789012345678901234567890123456789\").",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"0123456789012345678901234567890123456789\").\ p(\"012345678901234567890123456789012345678\").",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"01234567890123456789012345678901234567a9\").\ p(\"01234567890123456789012345678901234567b9\").",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(a,bbbb,c). p(a,bbbb,c).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(a,bbbb,c). p(a,bbbd,c).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(a,bbbb). p(a,\"bbbb\").",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(a,bbbb). p(a,'bbbb').",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(a,'bbbb'). p(a,\"bbbb\").",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(?X,10). p(?X,10).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(?X,10). p(X,10).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(?X,?Y). p(?X,?Y).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(?X,?X). p(?X,?Y).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,f(a,f(1,2,c),g(1))). p(1,f(a,f(1,2,c),g(1))).",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,f(a,f(1,2,c),g(1))). p(1,f(a,f(1,3,c),g(1))).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,f(a,f(1,2,c),g(1))). p(1,f(a,f(1,?X,c),g(1))).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,f(a,f(1,2,c),g(1))). p(1,f(a,D,g(1))).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,f(a,f(1,b,c),g(1))). p(1,f(a,f(1,\"b\",c),g(1))).",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(1,f(a,f(1,\"b\",c),g(1))). p(1,f(a,f(1,\"b\",c),g(1))).",1,p); if (p>0) printf("- - - wr_unify_term const case tests - - -\n"); if (!tmp) tmp=wr_test_unify(g,clvec,"p(1,-1,0,2,100000) | p(1,-1,0,2,100000).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(1,10) | p(1,20).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(1.23456) | p(1.23456).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(1.0) | p(1.0).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(1.0,-10.2,10000.00001) | p(1.0,-10.2,10000.00001).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(1.0,-10.2,10000.00001) | p(1,-10.2,10000.00001).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,'a1a1a1a1a1a1a1a1a1a1') | p(a,'a1a1a1a1a1a1a1a1a1a1').",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,'a1a1a1a1a1a1a1a1a1a1') | p(a,'a1a1a1a1a1a1a1a1a1a2').",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(\"abc\") | p(\"abc\").",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(\"abc\",\"x\") | p(\"abc\",\"x\").",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,bbbb,c) | p(a,bbbb,c).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,bbbb,c) | p(a,bbbd,c).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(\"0123456789012345678901234567890123456789\") |\ p(\"0123456789012345678901234567890123456789\").",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"0123456789012345678901234567890123456789\") |\ p(\"012345678901234567890123456789012345678\").",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"01234567890123456789012345678901234567a9\") |\ p(\"01234567890123456789012345678901234567b9\").",0,p); if (p>0) printf("- - - wr_unify_term var case tests - - -\n"); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,10) | p(?X,10).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,10) | p(X,10).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?Y) | p(a,b).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,b) | p(?X,?Y).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?X) | p(a,b).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,b) | p(?X,?X).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?X) | p(?X,?X).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?X) | p(?X,?Y).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X) | p(f(f(f(?X)))).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(f(f(f(?X)))) | p(?X).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X) | p(f(f(f(?Y)))).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?X) | p(?X,f(f(f(?X)))).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?X) | p(?X,f(f(f(?Y)))).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?X) | p(?Y,f(f(f(?Y)))).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,b,?X,?Y) | p(?U,?V,?U,?V).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,b,?X,?Y) | p(?U,?V,?U,?U).",1,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(a,b,?X,?X) | p(?U,?V,?U,?V).",0,p); if (!tmp) tmp=wr_test_unify(g,clvec,"p(?X,?X,f(?B)) | p(?A,?B,?A).",0,p); if (p>0) printf("- - - wr_match_term const case tests - - -\n"); if (!tmp) tmp=wr_test_match(g,clvec,"p(1,-1,0,2,100000) | p(1,-1,0,2,100000).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(1,10) | p(1,20).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(1.23456) | p(1.23456).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(1.0) | p(1.0).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(1.0,-10.2,10000.00001) | p(1.0,-10.2,10000.00001).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(1.0,-10.2,10000.00001) | p(1,-10.2,10000.00001).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,'a1a1a1a1a1a1a1a1a1a1') | p(a,'a1a1a1a1a1a1a1a1a1a1').",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,'a1a1a1a1a1a1a1a1a1a1') | p(a,'a1a1a1a1a1a1a1a1a1a2').",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(\"abc\") | p(\"abc\").",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(\"abc\",\"x\") | p(\"abc\",\"x\").",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,bbbb,c) | p(a,bbbb,c).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,bbbb,c) | p(a,bbbd,c).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(\"0123456789012345678901234567890123456789\") |\ p(\"0123456789012345678901234567890123456789\").",1,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"0123456789012345678901234567890123456789\") |\ p(\"012345678901234567890123456789012345678\").",0,p); if (!tmp) tmp=wr_test_eq(g,clvec,"p(\"01234567890123456789012345678901234567a9\") |\ p(\"01234567890123456789012345678901234567b9\").",0,p); if (p>0) printf("- - - wr_match_term var case tests - - -\n"); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,10) | p(?X,10).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,10) | p(X,10).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?Y) | p(a,b).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,b) | p(?X,?Y).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?X) | p(a,b).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,b) | p(?X,?X).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?X) | p(?X,?X).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?X) | p(?X,?Y).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X) | p(f(f(f(?X)))).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(f(f(f(?X)))) | p(?X).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X) | p(f(f(f(?Y)))).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?X) | p(?X,f(f(f(?X)))).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?X) | p(?X,f(f(f(?Y)))).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?X) | p(?Y,f(f(f(?Y)))).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,b,?X,?Y) | p(?U,?V,?U,?V).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?U,?V,?U,?V) | p(a,b,?X,?Y).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?U,?V,?U,?V) | p(a,?X,a,?X).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(a,b,?X,?Y) | p(?U,?V,?U,?U).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?X,?X,f(?B)) | p(?A,?B,?A).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?A,?B,?A) | p(?X,?X,f(?B)).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(g(?A,?B,?A)) | p(g(?X,?X,f(?B))).",0,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(?A,?B,?A) | p(f(?A),?X,f(?A)).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(g(?A,?B,?A)) | p(g(f(?A),?X,f(?A))).",1,p); if (!tmp) tmp=wr_test_match(g,clvec,"p(f(?X),?X) | p(f(?X),?Y).",0,p); if (p>0) printf("- - - wr_subsume_cl tests - - -\n"); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(1). p(1).",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X). p(?X).",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X). p(1).",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(1). p(?X).",0,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(1). p(?X) | p(1).",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(1). p(1). ",0,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(1). p(?X) | p(1). ",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(1). p(1) | p(?X). ",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(1). p(?X) | p(2). ",0,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?Y). p(?X) | p(?X). ",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?X). p(a) | m(b). ",0,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?X). p(a) | p(b). ",0,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?X). p(?X) | m(?Y). ",0,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?X). p(?X) | p(?Y). ",0,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?X). p(a) | p(b) | p(b). ",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?X) | p(?Y). p(c) | p(a) | p(b) | p(b). ",1,p); if (!tmp) tmp=wr_test_subsume_cl(g,clvec,"p(?X) | p(?X) | p(?Y). p(c) | p(?X) | p(?Y) | p(?Z). ",0,p); if (p>0) printf("--------- wr_test_reasoner_coretests ends ---------\n"); free(clvec); return tmp; } static int wr_test_eq(glb* g, cvec clvec, char* clstr, int expres, int p) { int res,tmp; gint t1,t2; if (p>1) printf("eq testing %s expected %d ",clstr,expres); tmp=wr_import_otter_file(g,NULL,clstr,clvec); if (tmp) { if (p>0) printf("\neq testing %s: otter import failed\n",clstr); return 1; } t1=rpto(g,clvec[2]); t2=rpto(g,clvec[3]); res=1; if (wr_equal_term(g,t1,t2,1)) { if (expres) res=0; } else { if (!expres) res=0; } if (p>1) { if (res) printf("test FAILED\n"); else printf("test OK\n"); } return res; } static int wr_test_unify(glb* g, cvec clvec, char* clstr, int expres, int p) { //void* db=g->db; int res,tmp; gptr cl; gint t1,t2; if (p>1) printf("unify testing %s expected %d ",clstr,expres); tmp=wr_import_otter_file(g,NULL,clstr,clvec); if (tmp) { if (p>0) printf("\nunify testing %s: otter import failed\n",clstr); return 1; } cl=(gptr)(clvec[2]); t1=wg_get_rule_clause_atom(db,cl,0); t2=wg_get_rule_clause_atom(db,cl,1); res=1; wr_clear_all_varbanks(g); tmp=wr_unify_term(g,t1,t2,1); wr_clear_varstack(g,g->varstack); if (!wr_varbanks_are_clear(g,g->varbanks)) { if (p>1) { printf(" varbanks NOT CLEARED, test FAILED\n"); } return 1; } if (tmp) { if (expres) res=0; } else { if (!expres) res=0; } if (p>1) { if (res) printf("test FAILED\n"); else printf("test OK\n"); } return res; } static int wr_test_match(glb* g, cvec clvec, char* clstr, int expres, int p) { //void* db=g->db; int res,tmp; gptr cl; gint t1,t2; if (p>1) printf("match testing %s expected %d ",clstr,expres); tmp=wr_import_otter_file(g,NULL,clstr,clvec); if (tmp) { if (p>0) printf("\nmatch testing %s: otter import failed\n",clstr); return 1; } cl=(gptr)(clvec[2]); t1=wg_get_rule_clause_atom(db,cl,0); t2=wg_get_rule_clause_atom(db,cl,1); res=1; wr_clear_all_varbanks(g); tmp=wr_match_term(g,t1,t2,1); wr_clear_varstack(g,g->varstack); if (!wr_varbanks_are_clear(g,g->varbanks)) { if (p>1) { printf(" varbanks NOT CLEARED, test FAILED\n"); } return 1; } if (tmp) { if (expres) res=0; } else { if (!expres) res=0; } if (p>1) { if (res) printf("test FAILED\n"); else printf("test OK\n"); } return res; } static int wr_test_subsume_cl(glb* g, cvec clvec, char* clstr, int expres, int p) { //void* db=g->db; int res,tmp; gptr cl1,cl2; int i2; if (p>1) printf("subsume_cl testing %s expected %d ",clstr,expres); tmp=wr_import_otter_file(g,NULL,clstr,clvec); if (tmp) { if (p>0) printf("\nunify testing %s: otter import failed\n",clstr); return 1; } // cl order is reversed!! cl1=(gptr)(clvec[3]); cl2=(gptr)(clvec[2]); res=1; wr_clear_all_varbanks(g); for(i2=1;i2<=(g->tmp_litinf_vec)[0];i2++) (g->tmp_litinf_vec)[i2]=0; tmp=wr_subsume_cl(g,cl1,cl2,1); //wr_clear_varstack(g,g->varstack); if (!wr_varbanks_are_clear(g,g->varbanks)) { if (p>1) { printf(" varbanks NOT CLEARED, test FAILED\n"); } return 1; } // no need for g->tmp_litinf_vec to be clear //if (!wr_litinf_is_clear(g,g->tmp_litinf_vec)) { // if (p>1) { // printf(" litinfo NOT CLEARED, test FAILED\n"); // } // return 1; //} if (tmp) { if (expres) res=0; } else { if (!expres) res=0; } if (p>1) { if (res) printf("test FAILED\n"); else printf("test OK\n"); } return res; } /* static int wr_litinf_is_clear(glb* g,vec v) { int i; for(i=1;i&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @REASONER_TRUE@am__append_1 = rtest.c rtest.h subdir = Test DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libTest_la_LIBADD = am__libTest_la_SOURCES_DIST = dbtest.c dbtest.h rtest.c rtest.h @REASONER_TRUE@am__objects_1 = rtest.lo am_libTest_la_OBJECTS = dbtest.lo $(am__objects_1) libTest_la_OBJECTS = $(am_libTest_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libTest_la_SOURCES) DIST_SOURCES = $(am__libTest_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PRTDIAG = @PRTDIAG@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_INCLUDES = @PYTHON_INCLUDES@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RAPTOR_CONFIG = @RAPTOR_CONFIG@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libTest.la libTest_la_SOURCES = dbtest.c dbtest.h $(am__append_1) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Test/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Test/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libTest.la: $(libTest_la_OBJECTS) $(libTest_la_DEPENDENCIES) $(EXTRA_libTest_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libTest_la_OBJECTS) $(libTest_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtest.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: whitedb-0.7.3/Test/log.test0000755000175000001440000000006112421471034012463 00000000000000#!/bin/sh Main/selftest log ERR=$? exit ${ERR} whitedb-0.7.3/Test/common.test0000755000175000001440000000006412421471034013175 00000000000000#!/bin/sh Main/selftest common ERR=$? exit ${ERR} whitedb-0.7.3/Db/0000755000175000001440000000000012426224010010462 500000000000000whitedb-0.7.3/Db/dbindex.h0000644000175000001440000001166512421471034012206 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Enar Reilent 2009, Priit Järv 2010,2011,2013 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dblock.h * Public headers for indexing routines */ #ifndef DEFINED_DBINDEX_H #define DEFINED_DBINDEX_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* For gint data type */ #include "dbdata.h" /* ==== Public macros ==== */ #define REALLY_BOUNDING_NODE 0 #define DEAD_END_LEFT_NOT_BOUNDING 1 #define DEAD_END_RIGHT_NOT_BOUNDING 2 #ifdef TTREE_CHAINED_NODES #define TNODE_SUCCESSOR(d, x) (x->succ_offset) #define TNODE_PREDECESSOR(d, x) (x->pred_offset) #else #define TNODE_SUCCESSOR(d, x) (x->right_child_offset ? \ wg_ttree_find_lub_node(d, x->right_child_offset) : \ wg_ttree_find_leaf_successor(d, ptrtooffset(d, x))) #define TNODE_PREDECESSOR(d, x) (x->left_child_offset ? \ wg_ttree_find_glb_node(d, x->left_child_offset) : \ wg_ttree_find_leaf_predecessor(d, ptrtooffset(d, x))) #endif /* Check if record matches index (takes pointer arguments) */ #ifndef USE_INDEX_TEMPLATE #define MATCH_TEMPLATE(d, h, r) 1 #else #define MATCH_TEMPLATE(d, h, r) (h->template_offset ? \ wg_match_template(d, \ (wg_index_template *) offsettoptr(d, h->template_offset), r) : 1) #endif #define WG_INDEX_TYPE_TTREE 50 #define WG_INDEX_TYPE_TTREE_JSON 51 #define WG_INDEX_TYPE_HASH 60 #define WG_INDEX_TYPE_HASH_JSON 61 /* Index header helpers */ #define TTREE_ROOT_NODE(x) (x->ctl.t.offset_root_node) #ifdef TTREE_CHAINED_NODES #define TTREE_MIN_NODE(x) (x->ctl.t.offset_min_node) #define TTREE_MAX_NODE(x) (x->ctl.t.offset_max_node) #endif #define HASHIDX_ARRAYP(x) (&(x->ctl.h.hasharea)) /* ====== data structures ======== */ /** structure of t-node * (array of data pointers, pointers to parent/children nodes, control data) * overall size is currently 64 bytes (cache line?) if array size is 10, * with extra node chaining pointers the array size defaults to 8. */ struct wg_tnode{ gint parent_offset; gint current_max; /** encoded value */ gint current_min; /** encoded value */ short number_of_elements; unsigned char left_subtree_height; unsigned char right_subtree_height; gint array_of_values[WG_TNODE_ARRAY_SIZE]; gint left_child_offset; gint right_child_offset; #ifdef TTREE_CHAINED_NODES gint succ_offset; /** forward (smaller to larger) sequential chain */ gint pred_offset; /** backward sequential chain */ #endif }; /* ==== Protos ==== */ /* API functions (copied in indexapi.h) */ gint wg_create_index(void *db, gint column, gint type, gint *matchrec, gint reclen); gint wg_create_multi_index(void *db, gint *columns, gint col_count, gint type, gint *matchrec, gint reclen); gint wg_drop_index(void *db, gint index_id); gint wg_column_to_index_id(void *db, gint column, gint type, gint *matchrec, gint reclen); gint wg_multi_column_to_index_id(void *db, gint *columns, gint col_count, gint type, gint *matchrec, gint reclen); gint wg_get_index_type(void *db, gint index_id); void * wg_get_index_template(void *db, gint index_id, gint *reclen); void * wg_get_all_indexes(void *db, gint *count); /* WhiteDB internal functions */ gint wg_search_ttree_index(void *db, gint index_id, gint key); #ifndef TTREE_CHAINED_NODES gint wg_ttree_find_glb_node(void *db, gint nodeoffset); gint wg_ttree_find_lub_node(void *db, gint nodeoffset); gint wg_ttree_find_leaf_predecessor(void *db, gint nodeoffset); gint wg_ttree_find_leaf_successor(void *db, gint nodeoffset); #endif gint wg_search_ttree_rightmost(void *db, gint rootoffset, gint key, gint *result, struct wg_tnode *rb_node); gint wg_search_ttree_leftmost(void *db, gint rootoffset, gint key, gint *result, struct wg_tnode *lb_node); gint wg_search_tnode_first(void *db, gint nodeoffset, gint key, gint column); gint wg_search_tnode_last(void *db, gint nodeoffset, gint key, gint column); gint wg_search_hash(void *db, gint index_id, gint *values, gint count); #ifdef USE_INDEX_TEMPLATE gint wg_match_template(void *db, wg_index_template *tmpl, void *rec); #endif gint wg_index_add_field(void *db, void *rec, gint column); gint wg_index_add_rec(void *db, void *rec); gint wg_index_del_field(void *db, void *rec, gint column); gint wg_index_del_rec(void *db, void *rec); #endif /* DEFINED_DBINDEX_H */ whitedb-0.7.3/Db/dbcompare.c0000644000175000001440000002121012421471034012503 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010,2011,2012,2013 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbcompare.c * Data comparison functions. */ /* ====== Includes =============== */ #include #ifdef __cplusplus extern "C" { #endif #include "dbdata.h" /* ====== Private headers and defs ======== */ #include "dbcompare.h" /* ====== Functions ============== */ /** Compare two encoded values * a, b - encoded values * returns WG_GREATER, WG_EQUAL or WG_LESSTHAN * assumes that a and b themselves are not equal and so * their decoded values need to be examined (which could still * be equal for some data types). * depth - recursion depth for records */ gint wg_compare(void *db, gint a, gint b, int depth) { /* a very simplistic version of the function: * - we get the types of the variables * - if the types match, compare the decoded values * - otherwise compare the type codes (not really scientific, * but will provide a means of ordering values). * * One important point that should be observed here is * that the returned values should be consistent when * comparing A to B and then B to A. This applies to cases * where we have no reason to think one is greater than * the other from the *user's* point of view, but for use * in T-tree index and similar, values need to be consistently * ordered. Examples include unknown types and record pointers * (once recursion depth runs out). */ /* XXX: might be able to save time here to mask and compare * the type bits instead */ gint typea = wg_get_encoded_type(db, a); gint typeb = wg_get_encoded_type(db, b); /* assume types are >2 (NULLs are always equal) and * <13 (not implemented as of now) * XXX: all of this will fall apart if type codes * are somehow rearranged :-) */ if(typeb==typea) { if(typea>WG_CHARTYPE) { /* > 9, not a string */ if(typea>WG_FIXPOINTTYPE) { /* date or time. Compare decoded gints */ gint deca, decb; if(typea==WG_DATETYPE) { deca = wg_decode_date(db, a); decb = wg_decode_date(db, b); } else if(typea==WG_TIMETYPE) { deca = wg_decode_time(db, a); decb = wg_decode_time(db, b); } else if(typea==WG_VARTYPE) { deca = wg_decode_var(db, a); decb = wg_decode_var(db, b); } else { /* anon const or other new type, no idea how to compare */ return (a>b ? WG_GREATER : WG_LESSTHAN); } return (deca>decb ? WG_GREATER : WG_LESSTHAN); } else { /* fixpoint, need to compare doubles */ double deca, decb; deca = wg_decode_fixpoint(db, a); decb = wg_decode_fixpoint(db, b); return (deca>decb ? WG_GREATER : WG_LESSTHAN); } } else if(typea (gint) decb ? WG_GREATER : WG_LESSTHAN); } else { int i; #ifdef USE_CHILD_DB void *parenta, *parentb; #endif int lena = wg_get_record_len(db, deca); int lenb = wg_get_record_len(db, decb); #ifdef USE_CHILD_DB /* Determine, if the records are inside the memory area beloning * to our current base address. If it is outside, the encoded * values inside the record contain offsets in relation to * a different base address and need to be translated. */ parenta = wg_get_rec_owner(db, deca); parentb = wg_get_rec_owner(db, decb); #endif /* XXX: Currently we're considering records of differing lengths * non-equal without comparing the elements */ if(lena!=lenb) return (lena>lenb ? WG_GREATER : WG_LESSTHAN); /* Recursively check each element in the record. If they * are not equal, break and return with the obtained value */ for(i=0; idecb ? WG_GREATER : WG_LESSTHAN); } else { /* WG_DOUBLETYPE */ double deca, decb; deca = wg_decode_double(db, a); decb = wg_decode_double(db, b); if(deca==decb) return WG_EQUAL; /* decoded doubles can be equal */ return (deca>decb ? WG_GREATER : WG_LESSTHAN); } } else { /* string */ /* Need to compare the characters. In case of 0-terminated * strings we use strcmp() directly, which in glibc is heavily * optimised. In case of blob type we need to query the length * and use memcmp(). */ char *deca, *decb, *exa=NULL, *exb=NULL; char buf[4]; gint res; if(typea==WG_STRTYPE) { /* lang is ignored */ deca = wg_decode_str(db, a); decb = wg_decode_str(db, b); } else if(typea==WG_URITYPE) { exa = wg_decode_uri_prefix(db, a); exb = wg_decode_uri_prefix(db, b); deca = wg_decode_uri(db, a); decb = wg_decode_uri(db, b); } else if(typea==WG_XMLLITERALTYPE) { exa = wg_decode_xmlliteral_xsdtype(db, a); exb = wg_decode_xmlliteral_xsdtype(db, b); deca = wg_decode_xmlliteral(db, a); decb = wg_decode_xmlliteral(db, b); } else if(typea==WG_CHARTYPE) { buf[0] = wg_decode_char(db, a); buf[1] = '\0'; buf[2] = wg_decode_char(db, b); buf[3] = '\0'; deca = buf; decb = &buf[2]; } else { /* WG_BLOBTYPE */ deca = wg_decode_blob(db, a); decb = wg_decode_blob(db, b); } if(exa || exb) { /* String type where extra information is significant * (we're ignoring this for plain strings and blobs). * If extra part is equal, normal comparison continues. If * one string is missing altogether, it is considered to be * smaller than the other string. */ if(!exb) { if(exa[0]) return WG_GREATER; } else if(!exa) { if(exb[0]) return WG_LESSTHAN; } else { res = strcmp(exa, exb); if(res > 0) return WG_GREATER; else if(res < 0) return WG_LESSTHAN; } } #if 0 /* paranoia check */ if(!deca || !decb) { if(decb) if(decb[0]) return WG_LESSTHAN; } else if(deca) { if(deca[0]) return WG_GREATER; } return WG_EQUAL; } #endif if(typea==WG_BLOBTYPE) { /* Blobs are not 0-terminated */ int lena = wg_decode_blob_len(db, a); int lenb = wg_decode_blob_len(db, b); res = memcmp(deca, decb, (lena < lenb ? lena : lenb)); if(!res) res = lena - lenb; } else { res = strcmp(deca, decb); } if(res > 0) return WG_GREATER; else if(res < 0) return WG_LESSTHAN; else return WG_EQUAL; } } else return (typea>typeb ? WG_GREATER : WG_LESSTHAN); } #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dblog.c0000644000175000001440000007471712421471034011662 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Andri Rebane 2009 * Copyright (c) Priit Järv 2013,2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dblog.c * DB logging support for WhiteDB memory database * */ /* ====== Includes =============== */ #include #include #include #include #include #ifdef _WIN32 #include #include #include #include #include #else #include #include #include #endif #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" #include "dbdata.h" #include "dbhash.h" /* ====== Private headers and defs ======== */ #include "dblog.h" #if defined(USE_DBLOG) && !defined(USE_DATABASE_HANDLE) #error Logging requires USE_DATABASE_HANDLE #endif #ifdef _WIN32 #define snprintf(s, sz, f, ...) _snprintf_s(s, sz+1, sz, f, ## __VA_ARGS__) #endif #ifndef _WIN32 #define JOURNAL_FAIL(f, e) \ close(f); \ return e; #else #define JOURNAL_FAIL(f, e) \ _close(f); \ return e; #endif #define GET_LOG_BYTE(d, f, v) \ if((v = fgetc(f)) == EOF) { \ return show_log_error(d, "Failed to read log entry"); \ } #define GET_LOG_CMD(d, f, v) \ if((v = fgetc(f)) == EOF) { \ if(feof(f)) break; \ else return show_log_error(d, "Failed to read log entry"); \ } /* Does not emit a message as fget_varint() does that already. */ #define GET_LOG_VARINT(d, f, v, e) \ if(fget_varint(d, f, (wg_uint *) &v)) { \ return e; \ } #ifdef HAVE_64BIT_GINT #define VARINT_SIZE 9 #else #define VARINT_SIZE 5 #endif /* ====== data structures ======== */ /* ======= Private protos ================ */ #ifdef USE_DBLOG static int backup_journal(void *db, char *journal_fn); static gint check_journal(void *db, int fd); static int open_journal(void *db, int create); static gint add_tran_offset(void *db, void *table, gint old, gint new); static gint add_tran_enc(void *db, void *table, gint old, gint new); static gint translate_offset(void *db, void *table, gint offset); static gint translate_encoded(void *db, void *table, gint enc); static gint recover_encode(void *db, FILE *f, gint type); static gint recover_journal(void *db, FILE *f, void *table); static gint write_log_buffer(void *db, void *buf, int buflen); #endif /* USE_DBLOG */ static gint show_log_error(void *db, char *errmsg); /* ====== Functions ============== */ #ifdef USE_DBLOG /** Check the file magic of the journal file. * * Since the files are opened in append mode, we don't need to * seek before or after reading the header (on Linux). */ static gint check_journal(void *db, int fd) { char buf[WG_JOURNAL_MAGIC_BYTES + 1]; #ifndef _WIN32 if(read(fd, buf, WG_JOURNAL_MAGIC_BYTES) != WG_JOURNAL_MAGIC_BYTES) { #else if(_read(fd, buf, WG_JOURNAL_MAGIC_BYTES) != WG_JOURNAL_MAGIC_BYTES) { #endif return show_log_error(db, "Error checking log file"); } buf[WG_JOURNAL_MAGIC_BYTES] = '\0'; if(strncmp(buf, WG_JOURNAL_MAGIC, WG_JOURNAL_MAGIC_BYTES)) { return show_log_error(db, "Bad log file magic"); } return 0; } /** Rename the existing journal. * * Uses a naming scheme of xxx.yy where xxx is the journal filename * and yy is a sequence number that is incremented. * * Returns 0 on success. * Returns -1 on failure. */ static int backup_journal(void *db, char *journal_fn) { int i, logidx, err; time_t oldest = 0; /* keep this buffer large enough to fit the backup counter length */ char journal_backup[WG_JOURNAL_FN_BUFSIZE + 10]; for(i=0, logidx=0; i tmp.st_mtime) { oldest = tmp.st_mtime; logidx = i; } } /* at this point, logidx points to either an available backup * filename or the oldest existing backup (which will be overwritten). * If all else fails, filename xxx.0 is used. */ snprintf(journal_backup, WG_JOURNAL_FN_BUFSIZE + 10, "%s.%d", journal_fn, logidx); #ifdef _WIN32 _unlink(journal_backup); #endif err = rename(journal_fn, journal_backup); if(!err) { db_memsegment_header* dbh = dbmemsegh(db); dbh->logging.serial++; /* new journal file */ } return err; } /** Open the journal file. * * In create mode, we also take care of the backup copy. */ static int open_journal(void *db, int create) { char journal_fn[WG_JOURNAL_FN_BUFSIZE]; db_memsegment_header* dbh = dbmemsegh(db); int addflags = 0; int fd = -1; #ifndef _WIN32 mode_t savemask = 0; #endif wg_journal_filename(db, journal_fn, WG_JOURNAL_FN_BUFSIZE); if(create) { #ifndef _WIN32 struct stat tmp; db_handle_logdata *ld = \ (db_handle_logdata *) (((db_handle *) db)->logdata); savemask = umask(ld->umask); addflags |= O_CREAT; #else struct _stat tmp; addflags |= _O_CREAT; #endif #ifndef _WIN32 if(!dbh->logging.dirty && !stat(journal_fn, &tmp)) { #else if(!dbh->logging.dirty && !_stat(journal_fn, &tmp)) { #endif if(backup_journal(db, journal_fn)) { show_log_error(db, "Failed to back up the existing journal."); goto abort; } } } #ifndef _WIN32 if((fd = open(journal_fn, addflags|O_APPEND|O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) == -1) { #else if(_sopen_s(&fd, journal_fn, addflags|_O_APPEND|_O_BINARY|_O_RDWR, _SH_DENYNO, _S_IREAD|_S_IWRITE)) { #endif show_log_error(db, "Error opening log file"); } abort: if(create) { #ifndef _WIN32 umask(savemask); #endif } return fd; } /** Varint encoder * this needs to be fast, so we don't check array size. It must * be at least 9 bytes. * based on http://stackoverflow.com/a/2982965 */ static size_t enc_varint(unsigned char *buf, wg_uint val) { buf[0] = (unsigned char)(val | 0x80); if(val >= (1 << 7)) { buf[1] = (unsigned char)((val >> 7) | 0x80); if(val >= (1 << 14)) { buf[2] = (unsigned char)((val >> 14) | 0x80); if(val >= (1 << 21)) { buf[3] = (unsigned char)((val >> 21) | 0x80); if(val >= (1 << 28)) { #ifndef HAVE_64BIT_GINT buf[4] = (unsigned char)(val >> 28); return 5; #else buf[4] = (unsigned char)((val >> 28) | 0x80); if(val >= ((wg_uint) 1 << 35)) { buf[5] = (unsigned char)((val >> 35) | 0x80); if(val >= ((wg_uint) 1 << 42)) { buf[6] = (unsigned char)((val >> 42) | 0x80); if(val >= ((wg_uint) 1 << 49)) { buf[7] = (unsigned char)((val >> 49) | 0x80); if(val >= ((wg_uint) 1 << 56)) { buf[8] = (unsigned char)(val >> 56); return 9; } else { buf[7] &= 0x7f; return 8; } } else { buf[6] &= 0x7f; return 7; } } else { buf[5] &= 0x7f; return 6; } } else { buf[4] &= 0x7f; return 5; } #endif } else { buf[3] &= 0x7f; return 4; } } else { buf[2] &= 0x7f; return 3; } } else { buf[1] &= 0x7f; return 2; } } else { buf[0] &= 0x7f; return 1; } } #if 0 /** Varint decoder * returns the number of bytes consumed (so that the caller * knows where the next value starts). Note that this approach * assumes we're using a read buffer - this is acceptable and * probably preferable when doing the journal replay. */ static size_t dec_varint(unsigned char *buf, wg_uint *val) { wg_uint tmp = buf[0] & 0x7f; if(buf[0] & 0x80) { tmp |= ((buf[1] & 0x7f) << 7); if(buf[1] & 0x80) { tmp |= ((buf[2] & 0x7f) << 14); if(buf[2] & 0x80) { tmp |= ((buf[3] & 0x7f) << 21); if(buf[3] & 0x80) { #ifndef HAVE_64BIT_GINT tmp |= (buf[4] << 28); *val = tmp; return 5; #else tmp |= ((wg_uint) (buf[4] & 0x7f) << 28); if(buf[4] & 0x80) { tmp |= ((wg_uint) (buf[5] & 0x7f) << 35); if(buf[5] & 0x80) { tmp |= ((wg_uint) (buf[6] & 0x7f) << 42); if(buf[6] & 0x80) { tmp |= ((wg_uint) (buf[7] & 0x7f) << 49); if(buf[7] & 0x80) { tmp |= ((wg_uint) buf[8] << 56); *val = tmp; return 9; } else { *val = tmp; return 8; } } else { *val = tmp; return 7; } } else { *val = tmp; return 6; } } else { *val = tmp; return 5; } #endif } else { *val = tmp; return 4; } } else { *val = tmp; return 3; } } else { *val = tmp; return 2; } } else { *val = tmp; return 1; } } #endif /** Read varint from a buffered stream * returns 0 on success * returns -1 on error */ static int fget_varint(void *db, FILE *f, wg_uint *val) { register int c; wg_uint tmp; GET_LOG_BYTE(db, f, c) tmp = c & 0x7f; if(c & 0x80) { GET_LOG_BYTE(db, f, c) tmp |= ((c & 0x7f) << 7); if(c & 0x80) { GET_LOG_BYTE(db, f, c) tmp |= ((c & 0x7f) << 14); if(c & 0x80) { GET_LOG_BYTE(db, f, c) tmp |= ((c & 0x7f) << 21); if(c & 0x80) { GET_LOG_BYTE(db, f, c) #ifndef HAVE_64BIT_GINT tmp |= (c << 28); #else tmp |= ((wg_uint) (c & 0x7f) << 28); if(c & 0x80) { GET_LOG_BYTE(db, f, c) tmp |= ((wg_uint) (c & 0x7f) << 35); if(c & 0x80) { GET_LOG_BYTE(db, f, c) tmp |= ((wg_uint) (c & 0x7f) << 42); if(c & 0x80) { GET_LOG_BYTE(db, f, c) tmp |= ((wg_uint) (c & 0x7f) << 49); if(c & 0x80) { GET_LOG_BYTE(db, f, c) tmp |= ((wg_uint) c << 56); } } } } #endif } } } } *val = tmp; return 0; } /** Add a log recovery translation entry * Uses extendible gint hashtable internally. */ static gint add_tran_offset(void *db, void *table, gint old, gint new) { return wg_ginthash_addkey(db, table, old, new); } /** Wrapper around add_tran_offset() to handle encoded data * */ static gint add_tran_enc(void *db, void *table, gint old, gint new) { if(isptr(old)) { gint offset, newoffset; switch(old & NORMALPTRMASK) { case LONGSTRBITS: offset = decode_longstr_offset(old); newoffset = decode_longstr_offset(new); return add_tran_offset(db, table, offset, newoffset); case SHORTSTRBITS: offset = decode_shortstr_offset(old); newoffset = decode_shortstr_offset(new); return add_tran_offset(db, table, offset, newoffset); case FULLDOUBLEBITS: offset = decode_fulldouble_offset(old); newoffset = decode_fulldouble_offset(new); return add_tran_offset(db, table, offset, newoffset); case FULLINTBITSV0: case FULLINTBITSV1: offset = decode_fullint_offset(old); newoffset = decode_fullint_offset(new); return add_tran_offset(db, table, offset, newoffset); default: return 0; } } return 0; } /** Translate a log offset * */ static gint translate_offset(void *db, void *table, gint offset) { gint newoffset; if(wg_ginthash_getkey(db, table, offset, &newoffset)) return offset; else return newoffset; } /** Wrapper around translate_offset() to handle encoded data * */ static gint translate_encoded(void *db, void *table, gint enc) { if(isptr(enc)) { gint offset; switch(enc & NORMALPTRMASK) { case DATARECBITS: return translate_offset(db, table, enc); case LONGSTRBITS: offset = decode_longstr_offset(enc); return encode_longstr_offset(translate_offset(db, table, offset)); case SHORTSTRBITS: offset = decode_shortstr_offset(enc); return encode_shortstr_offset(translate_offset(db, table, offset)); case FULLDOUBLEBITS: offset = decode_fulldouble_offset(enc); return encode_fulldouble_offset(translate_offset(db, table, offset)); case FULLINTBITSV0: case FULLINTBITSV1: offset = decode_fullint_offset(enc); return encode_fullint_offset(translate_offset(db, table, offset)); default: return enc; } } return enc; } /** Parse an encode entry from the log. * */ gint recover_encode(void *db, FILE *f, gint type) { char *strbuf, *extbuf; gint length = 0, extlength = 0, enc; int intval; double doubleval; switch(type) { case WG_INTTYPE: if(fread((char *) &intval, sizeof(int), 1, f) != 1) { show_log_error(db, "Failed to read log entry"); return WG_ILLEGAL; } return wg_encode_int(db, intval); case WG_DOUBLETYPE: if(fread((char *) &doubleval, sizeof(double), 1, f) != 1) { show_log_error(db, "Failed to read log entry"); return WG_ILLEGAL; } return wg_encode_double(db, doubleval); case WG_STRTYPE: case WG_URITYPE: case WG_XMLLITERALTYPE: case WG_ANONCONSTTYPE: case WG_BLOBTYPE: /* XXX: no encode func for this yet */ /* strings with extdata */ GET_LOG_VARINT(db, f, length, WG_ILLEGAL) GET_LOG_VARINT(db, f, extlength, WG_ILLEGAL) strbuf = (char *) malloc(length + 1); if(!strbuf) { show_log_error(db, "Failed to allocate buffers"); return WG_ILLEGAL; } if(fread(strbuf, 1, length, f) != length) { show_log_error(db, "Failed to read log entry"); free(strbuf); return WG_ILLEGAL; } strbuf[length] = '\0'; if(extlength) { extbuf = (char *) malloc(extlength + 1); if(!extbuf) { free(strbuf); show_log_error(db, "Failed to allocate buffers"); return WG_ILLEGAL; } if(fread(extbuf, 1, extlength, f) != extlength) { show_log_error(db, "Failed to read log entry"); free(strbuf); free(extbuf); return WG_ILLEGAL; } extbuf[extlength] = '\0'; } else { extbuf = NULL; } enc = wg_encode_unistr(db, strbuf, extbuf, type); free(strbuf); if(extbuf) free(extbuf); return enc; default: break; } return show_log_error(db, "Unsupported data type"); } /** Parse the journal file. Used internally only. * */ static gint recover_journal(void *db, FILE *f, void *table) { int c; gint length = 0, offset = 0, newoffset; gint col = 0, enc = 0, newenc, meta = 0; void *rec; for(;;) { GET_LOG_CMD(db, f, c) switch((unsigned char) c & WG_JOURNAL_ENTRY_CMDMASK) { case WG_JOURNAL_ENTRY_CRE: GET_LOG_VARINT(db, f, length, -1) GET_LOG_VARINT(db, f, offset, -1) rec = wg_create_record(db, length); if(offset != 0) { /* XXX: should we have even tried if this failed earlier? */ if(!rec) { return show_log_error(db, "Failed to create a new record"); } newoffset = ptrtooffset(db, rec); if(newoffset != offset) { if(add_tran_offset(db, table, offset, newoffset)) { return show_log_error(db, "Failed to parse log "\ "(out of translation memory)"); } } } break; case WG_JOURNAL_ENTRY_DEL: GET_LOG_VARINT(db, f, offset, -1) newoffset = translate_offset(db, table, offset); rec = offsettoptr(db, newoffset); if(wg_delete_record(db, rec) < -1) { return show_log_error(db, "Failed to delete a record"); } break; case WG_JOURNAL_ENTRY_ENC: newenc = recover_encode(db, f, (unsigned char) c & WG_JOURNAL_ENTRY_TYPEMASK); GET_LOG_VARINT(db, f, enc, -1) if(enc != WG_ILLEGAL) { /* Encode was supposed to succeed */ if(newenc == WG_ILLEGAL) { return -1; } if(newenc != enc) { if(add_tran_enc(db, table, enc, newenc)) { return show_log_error(db, "Failed to parse log "\ "(out of translation memory)"); } } } break; case WG_JOURNAL_ENTRY_SET: GET_LOG_VARINT(db, f, offset, -1) GET_LOG_VARINT(db, f, col, -1) GET_LOG_VARINT(db, f, enc, -1) newoffset = translate_offset(db, table, offset); rec = offsettoptr(db, newoffset); newenc = translate_encoded(db, table, enc); if(wg_set_field(db, rec, col, newenc)) { return show_log_error(db, "Failed to set field data"); } break; case WG_JOURNAL_ENTRY_META: GET_LOG_VARINT(db, f, offset, -1) GET_LOG_VARINT(db, f, meta, -1) newoffset = translate_offset(db, table, offset); rec = offsettoptr(db, newoffset); *((gint *) rec + RECORD_META_POS) = meta; break; default: return show_log_error(db, "Invalid log entry"); } } return 0; } #endif /* USE_DBLOG */ /** Return the name of the current journal * */ void wg_journal_filename(void *db, char *buf, size_t buflen) { #ifdef USE_DBLOG db_memsegment_header* dbh = dbmemsegh(db); #ifndef _WIN32 snprintf(buf, buflen, "%s.%td", WG_JOURNAL_FILENAME, dbh->key); #else snprintf(buf, buflen, "%s.%Id", WG_JOURNAL_FILENAME, dbh->key); #endif buf[buflen-1] = '\0'; #else buf[0] = '\0'; #endif } /** Set up the logging area in the database handle * Normally called when opening the database connection. */ gint wg_init_handle_logdata(void *db) { #ifdef USE_DBLOG db_handle_logdata **ld = \ (db_handle_logdata **) &(((db_handle *) db)->logdata); *ld = malloc(sizeof(db_handle_logdata)); if(!(*ld)) { return show_log_error(db, "Error initializing local log data"); } memset(*ld, 0, sizeof(db_handle_logdata)); (*ld)->fd = -1; #endif return 0; } /** Clean up the state of logging in the database handle. * Normally called when closing the database connection. */ void wg_cleanup_handle_logdata(void *db) { #ifdef USE_DBLOG db_handle_logdata *ld = \ (db_handle_logdata *) (((db_handle *) db)->logdata); if(ld) { if(ld->fd >= 0) { #ifndef _WIN32 close(ld->fd); #else _close(ld->fd); #endif ld->fd = -1; } free(ld); ((db_handle *) db)->logdata = NULL; } #endif } /** Set journal file umask. * This needs to be done separately from initializing the logging * data in the handle, as the mask may be derived from the * permissions of the shared memory segment and this is not * guaranteed to exist during the handle initialization. * Returns the old mask. */ int wg_log_umask(void *db, int cmask) { int prev = 0; #ifdef USE_DBLOG db_handle_logdata *ld = \ (db_handle_logdata *) (((db_handle *) db)->logdata); if(ld) { prev = ld->umask; ld->umask = cmask & 0777; } #endif return prev; } /** Activate logging * * When successful, does the following: * opens the logfile and initializes it; * sets the logging active flag. * * Security concerns: * - the log file name is compiled in (so we can't trick other * processes into writing over files they're not supposed to) * - the log file has a magic header (see above, avoid accidentally * destroying files) * - the process that initialized logging needs to have write * access to the log file. * * Returns 0 on success * Returns -1 when logging is already active * Returns -2 when the function failed and logging is not active * Returns -3 when additionally, the log file was possibly destroyed */ gint wg_start_logging(void *db) { #ifdef USE_DBLOG db_memsegment_header* dbh = dbmemsegh(db); /* db_handle_logdata *ld = ((db_handle *) db)->logdata;*/ int fd; if(dbh->logging.active) { show_log_error(db, "Logging is already active"); return -1; } if((fd = open_journal(db, 1)) == -1) { show_log_error(db, "Error opening log file"); return -2; } if(!dbh->logging.dirty) { /* logfile is clean, re-initialize */ /* fseek(f, 0, SEEK_SET); */ #ifndef _WIN32 ftruncate(fd, 0); /* XXX: this is a no-op with backups */ if(write(fd, WG_JOURNAL_MAGIC, WG_JOURNAL_MAGIC_BYTES) != \ WG_JOURNAL_MAGIC_BYTES) { #else _chsize_s(fd, 0); if(_write(fd, WG_JOURNAL_MAGIC, WG_JOURNAL_MAGIC_BYTES) != \ WG_JOURNAL_MAGIC_BYTES) { #endif show_log_error(db, "Error initializing log file"); JOURNAL_FAIL(fd, -3) } } else { /* check the magic header */ if(check_journal(db, fd)) { JOURNAL_FAIL(fd, -2) } } #if 0 /* Keep using this handle */ ld->fd = fd; ld->serial = dbh->logging.serial; #else #ifndef _WIN32 close(fd); #else _close(fd); #endif #endif dbh->logging.active = 1; return 0; #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /** Turn journal logging off. * * Returns 0 on success * Returns non-zero on failure */ gint wg_stop_logging(void *db) { #ifdef USE_DBLOG db_memsegment_header* dbh = dbmemsegh(db); if(!dbh->logging.active) { show_log_error(db, "Logging is not active"); return -1; } dbh->logging.active = 0; return 0; #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /** Replay journal file. * * Requires exclusive access to the database. * Marks the log as clean, but does not re-initialize the file. * * Returns 0 on success * Returns -1 on non-fatal error (database unmodified) * Returns -2 on fatal error (database inconsistent) */ gint wg_replay_log(void *db, char *filename) { #ifdef USE_DBLOG db_memsegment_header* dbh = dbmemsegh(db); gint active, err = 0; void *tran_tbl; int fd; FILE *f; #ifndef _WIN32 if((fd = open(filename, O_RDONLY)) == -1) { #else if(_sopen_s(&fd, filename, _O_RDONLY|_O_BINARY, _SH_DENYNO, 0)) { #endif show_log_error(db, "Error opening log file"); return -1; } if(check_journal(db, fd)) { err = -1; goto abort2; } active = dbh->logging.active; dbh->logging.active = 0; /* turn logging off before restoring */ /* Reading can be done with buffered IO */ #ifndef _WIN32 f = fdopen(fd, "r"); #else f = _fdopen(fd, "rb"); #endif /* XXX: may consider fcntl-locking here */ /* restore the log contents */ tran_tbl = wg_ginthash_init(db); if(!tran_tbl) { show_log_error(db, "Failed to create log translation table"); err = -1; goto abort1; } if(recover_journal(db, f, tran_tbl)) { err = -2; goto abort0; } dbh->logging.dirty = 0; /* on success, set the log as clean. */ abort0: wg_ginthash_free(db, tran_tbl); abort1: fclose(f); abort2: if(!err && active) { if(wg_start_logging(db)) { show_log_error(db, "Log restored but failed to reactivate logging"); err = -2; } } return err; #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } #ifdef USE_DBLOG /** Write a byte buffer to the log file. * */ static gint write_log_buffer(void *db, void *buf, int buflen) { db_memsegment_header* dbh = dbmemsegh(db); db_handle_logdata *ld = \ (db_handle_logdata *) (((db_handle *) db)->logdata); if(ld->fd >= 0 && ld->serial != dbh->logging.serial) { /* Stale file descriptor, get a new one */ #ifndef _WIN32 close(ld->fd); #else _close(ld->fd); #endif ld->fd = -1; } if(ld->fd < 0) { int fd; if((fd = open_journal(db, 0)) == -1) { show_log_error(db, "Error opening log file"); } else { if(check_journal(db, fd)) { #ifndef _WIN32 close(fd); #else _close(fd); #endif } else { /* fseek(f, 0, SEEK_END); */ ld->fd = fd; ld->serial = dbh->logging.serial; } } } if(ld->fd < 0) return -1; /* Always mark log as dirty when writing something */ dbh->logging.dirty = 1; #ifndef _WIN32 if(write(ld->fd, (char *) buf, buflen) != buflen) { #else if(_write(ld->fd, (char *) buf, buflen) != buflen) { #endif show_log_error(db, "Error writing to log file"); JOURNAL_FAIL(ld->fd, -5) } return 0; } #endif /* USE_DBLOG */ /* * Operations (and data) logged: * * WG_JOURNAL_ENTRY_CRE - create a record (length) * followed by a single varint field that contains the newly allocated offset * WG_JOURNAL_ENTRY_DEL - delete a record (offset) * WG_JOURNAL_ENTRY_ENC - encode a value (data bytes, extdata if applicable) * followed by a single varint field that contains the encoded value * WG_JOURNAL_ENTRY_SET - set a field value (record offset, column, encoded value) * WG_JOURNAL_ENTRY_META - set the metadata of a record * * lengths, offsets and encoded values are stored as varints */ /** Log the creation of a record. * This call should always be followed by wg_log_encval() * * We assume that dbh->logging.active flag is checked before calling this. */ gint wg_log_create_record(void *db, gint length) { #ifdef USE_DBLOG unsigned char buf[1 + VARINT_SIZE], *optr; buf[0] = WG_JOURNAL_ENTRY_CRE; optr = &buf[1]; optr += enc_varint(optr, (wg_uint) length); return write_log_buffer(db, (void *) buf, optr - buf); #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /** Log the deletion of a record. * */ gint wg_log_delete_record(void *db, gint enc) { #ifdef USE_DBLOG unsigned char buf[1 + VARINT_SIZE], *optr; buf[0] = WG_JOURNAL_ENTRY_DEL; optr = &buf[1]; optr += enc_varint(optr, (wg_uint) enc); return write_log_buffer(db, (void *) buf, optr - buf); #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /** Log the result of an encode operation. Also handles records. * * If the encode function or record creation failed, call this * with WG_ILLEGAL to indicate the failure of the operation. */ gint wg_log_encval(void *db, gint enc) { #ifdef USE_DBLOG unsigned char buf[VARINT_SIZE]; size_t buflen = enc_varint(buf, (wg_uint) enc); return write_log_buffer(db, (void *) buf, buflen); #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /** Log an encode operation. * * This is the most expensive log operation as we need to write the * chunk of data to be encoded. */ gint wg_log_encode(void *db, gint type, void *data, gint length, void *extdata, gint extlength) { #ifdef USE_DBLOG unsigned char *buf, *optr, *oend, *iptr; size_t buflen = 0; int err; switch(type) { case WG_NULLTYPE: case WG_RECORDTYPE: case WG_CHARTYPE: case WG_DATETYPE: case WG_TIMETYPE: case WG_VARTYPE: case WG_FIXPOINTTYPE: /* Shared memory not altered, don't log */ return 0; break; case WG_INTTYPE: /* int argument */ if(fits_smallint(*((int *) data))) { return 0; /* self-contained, don't log */ } else { buflen = 1 + sizeof(int); buf = (unsigned char *) malloc(buflen); optr = buf + 1; *((int *) optr) = *((int *) data); } break; case WG_DOUBLETYPE: /* double precision argument */ buflen = 1 + sizeof(double); buf = (unsigned char *) malloc(buflen); optr = buf + 1; *((double *) optr) = *((double *) data); break; case WG_STRTYPE: case WG_URITYPE: case WG_XMLLITERALTYPE: case WG_ANONCONSTTYPE: case WG_BLOBTYPE: /* XXX: no encode func for this yet */ /* strings with extdata */ buflen = 1 + 2*VARINT_SIZE + length + extlength; buf = (unsigned char *) malloc(buflen); /* data and extdata length */ optr = buf + 1; optr += enc_varint(optr, (wg_uint) length); optr += enc_varint(optr, (wg_uint) extlength); buflen -= 1 + 2*VARINT_SIZE - (optr - buf); /* actual size known */ /* data */ oend = optr + length; iptr = (unsigned char *) data; while(optr < oend) *(optr++) = *(iptr++); /* extdata */ oend = optr + extlength; iptr = (unsigned char *) extdata; while(optr < oend) *(optr++) = *(iptr++); break; default: return show_log_error(db, "Unsupported data type"); } /* Add a fixed prefix */ buf[0] = WG_JOURNAL_ENTRY_ENC | type; err = write_log_buffer(db, (void *) buf, buflen); free(buf); return err; #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /** Log setting a data field. * * We assume that dbh->logging.active flag is checked before calling this. */ gint wg_log_set_field(void *db, void *rec, gint col, gint data) { #ifdef USE_DBLOG unsigned char buf[1 + 3*VARINT_SIZE], *optr; buf[0] = WG_JOURNAL_ENTRY_SET; optr = &buf[1]; optr += enc_varint(optr, (wg_uint) ptrtooffset(db, rec)); optr += enc_varint(optr, (wg_uint) col); optr += enc_varint(optr, (wg_uint) data); return write_log_buffer(db, (void *) buf, optr - buf); #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /** Log setting metadata * * We assume that dbh->logging.active flag is checked before calling this. */ gint wg_log_set_meta(void *db, void *rec, gint meta) { #ifdef USE_DBLOG unsigned char buf[1 + 2*VARINT_SIZE], *optr; buf[0] = WG_JOURNAL_ENTRY_META; optr = &buf[1]; optr += enc_varint(optr, (wg_uint) ptrtooffset(db, rec)); optr += enc_varint(optr, (wg_uint) meta); return write_log_buffer(db, (void *) buf, optr - buf); #else return show_log_error(db, "Logging is disabled"); #endif /* USE_DBLOG */ } /* ------------ error handling ---------------- */ static gint show_log_error(void *db, char *errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg log error: %s.\n", errmsg); #endif return -1; } #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dbdump.c0000644000175000001440000002203112421471034012024 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Andri Rebane 2009, Priit Järv 2009,2010,2013,2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbdump.c * DB dumping support for WhiteDB memory database * */ /* ====== Includes =============== */ #include #include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include #endif #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" #include "dbmem.h" #include "dblock.h" #include "dblog.h" /* ====== Private headers and defs ======== */ #include "dbdump.h" #include "crc1.h" /* ======= Private protos ================ */ static gint show_dump_error(void *db, char *errmsg); static gint show_dump_error_str(void *db, char *errmsg, char *str); /* ====== Functions ============== */ /** dump shared memory to the disk. * Returns 0 when successful (no error). * -1 non-fatal error (db may continue) * -2 fatal error (should abort db) * This function is parallel-safe (may run during normal db usage) */ gint wg_dump(void * db,char fileName[]) { return wg_dump_internal(db, fileName, 1); } /** Handle the actual dumping (called by the API wrapper) * if locking is non-zero, properly acquire locks on the database. * Otherwise do a rescue dump by copying the memory image without locking. */ gint wg_dump_internal(void * db, char fileName[], int locking) { FILE *f; db_memsegment_header* dbh = dbmemsegh(db); gint dbsize = dbh->free; /* first unused offset - 0 = db size */ #ifdef USE_DBLOG gint active; #endif gint err = -1; gint lock_id = 0; gint32 crc; #ifdef CHECK if(dbh->extdbs.count != 0) { show_dump_error(db, "Database contains external references"); } #endif /* Open the dump file */ #ifdef _WIN32 if(fopen_s(&f, fileName, "wb")) { #else if(!(f = fopen(fileName, "wb"))) { #endif show_dump_error(db, "Error opening file"); return -1; } #ifndef USE_DBLOG /* Get shared lock on the db */ if(locking) { lock_id = db_rlock(db, DEFAULT_LOCK_TIMEOUT); if(!lock_id) { show_dump_error(db, "Failed to lock the database for dump"); return -1; } } #else /* Get exclusive lock on the db, we need to modify the logging area */ if(locking) { lock_id = db_wlock(db, DEFAULT_LOCK_TIMEOUT); if(!lock_id) { show_dump_error(db, "Failed to lock the database for dump"); return -1; } } active = dbh->logging.active; if(active) { wg_stop_logging(db); } #endif /* Compute the CRC32 of the used area */ crc = update_crc32(dbmemsegbytes(db), dbsize, 0x0); /* Now, write the memory area to file */ if(fwrite(dbmemseg(db), dbsize, 1, f) == 1) { /* Overwrite checksum field */ fseek(f, ptrtooffset(db, &(dbh->checksum)), SEEK_SET); if(fwrite(&crc, sizeof(gint32), 1, f) == 1) { err = 0; } } if(err) show_dump_error(db, "Error writing file"); #ifndef USE_DBLOG /* We're done writing */ if(locking) { if(!db_rulock(db, lock_id)) { show_dump_error(db, "Failed to unlock the database"); err = -2; /* This error should be handled as fatal */ } } #else /* restart logging */ if(active) { dbh->logging.dirty = 0; if(wg_start_logging(db)) { err = -2; /* Failed to re-initialize log */ } } if(locking) { if(!db_wulock(db, lock_id)) { show_dump_error(db, "Failed to unlock the database"); err = -2; /* Write lock failure --> fatal */ } } #endif fflush(f); fclose(f); return err; } /* This has to be large enough to hold all the relevant * fields in the header during the first pass of the read. * (Currently this is the first 24 bytes of the dump file) */ #define BUFSIZE 8192 /** Check dump file for compatibility and errors. * Returns 0 when successful (no error). * -1 on system error (cannot open file, no memory) * -2 header is incompatible * -3 on file integrity error (size mismatch, CRC32 error). * * Sets minsize to minimum required segment size and maxsize * to original memory image size if check was successful. Otherwise * the contents of these variables may be undefined. */ gint wg_check_dump(void *db, char fileName[], gint *minsize, gint *maxsize) { char *buf; FILE *f; gint len, filesize; gint32 crc, dump_crc; gint err = -1; /* Attempt to open the dump file */ #ifdef _WIN32 if(fopen_s(&f, fileName, "rb")) { #else if(!(f = fopen(fileName, "rb"))) { #endif show_dump_error(db, "Error opening file"); return -1; } buf = (char *) malloc(BUFSIZE); if(!buf) { show_dump_error(db, "malloc error in wg_import_dump"); goto abort1; } /* First pass of reading. Examine the header. */ if(fread(buf, BUFSIZE, 1, f) != 1) { show_dump_error(db, "Error reading dump header"); goto abort2; } if(wg_check_header_compat((db_memsegment_header *) buf)) { show_dump_error_str(db, "Incompatible dump file", fileName); wg_print_code_version(); wg_print_header_version((db_memsegment_header *) buf, 1); err = -2; goto abort2; } *minsize = ((db_memsegment_header *) buf)->free; *maxsize = ((db_memsegment_header *) buf)->size; /* Now check file integrity. */ dump_crc = ((db_memsegment_header *) buf)->checksum; ((db_memsegment_header *) buf)->checksum = 0; len = BUFSIZE; filesize = 0; crc = 0; do { filesize += len; crc = update_crc32(buf, len, crc); } while((len=fread(buf,1,BUFSIZE,f)) > 0); if(filesize != *minsize) { show_dump_error_str(db, "File size incorrect", fileName); err = -3; } else if(crc != dump_crc) { show_dump_error_str(db, "File CRC32 incorrect", fileName); err = -3; } else err = 0; abort2: free(buf); abort1: fclose(f); return err; } /** Import database dump from disk. * Returns 0 when successful (no error). * -1 non-fatal error (db may continue) * -2 fatal error (should abort db) * * this function is NOT parallel-safe. Other processes accessing * db concurrently may cause undefined behaviour (including data loss) */ gint wg_import_dump(void * db,char fileName[]) { db_memsegment_header* dumph; FILE *f; db_memsegment_header* dbh = dbmemsegh(db); gint dbsize = -1, newsize; gint err = -1; #ifdef USE_DBLOG gint active = dbh->logging.active; #endif /* Attempt to open the dump file */ #ifdef _WIN32 if(fopen_s(&f, fileName, "rb")) { #else if(!(f = fopen(fileName, "rb"))) { #endif show_dump_error(db, "Error opening file"); return -1; } /* Examine the dump header. We only read the size, it is * implied that the integrity and compatibility were verified * earlier. */ dumph = (db_memsegment_header *) malloc(sizeof(db_memsegment_header)); if(!dumph) { show_dump_error(db, "malloc error in wg_import_dump"); } else if(fread(dumph, sizeof(db_memsegment_header), 1, f) != 1) { show_dump_error(db, "Error reading dump header"); } else { dbsize = dumph->free; if(dumph->extdbs.count != 0) { show_dump_error(db, "Dump contains external references"); goto abort; } } if(dumph) free(dumph); /* 0 > dbsize >= dbh->size indicates that we were able to read the dump * and it contained a memory image that fits in our current shared memory. */ if(dbh->size < dbsize) { show_dump_error(db, "Data does not fit in shared memory area"); } else if(dbsize > 0) { /* We have a compatible dump file. */ newsize = dbh->size; fseek(f, 0, SEEK_SET); if(fread(dbmemseg(db), dbsize, 1, f) != 1) { show_dump_error(db, "Error reading dump file"); err = -2; /* database is in undetermined state now */ } else { err = 0; dbh->size = newsize; dbh->checksum = 0; } } abort: fclose(f); /* any errors up to now? */ if(err) return err; /* Initialize db state */ #ifdef USE_DBLOG /* restart logging */ dbh->logging.dirty = 0; dbh->logging.active = 0; if(active) { /* state inherited from memory */ if(wg_start_logging(db)) { return -2; /* Failed to re-initialize log */ } } #endif return wg_init_locks(db); } /* ------------ error handling ---------------- */ static gint show_dump_error(void *db, char *errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg dump error: %s.\n", errmsg); #endif return -1; } static gint show_dump_error_str(void *db, char *errmsg, char *str) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg dump error: %s: %s.\n", errmsg, str); #endif return -1; } #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dbdata.h0000644000175000001440000005035712421471034012011 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2009,2010,2011,2013,2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbdata.h * Datatype encoding defs and public headers for actual data handling procedures. */ #ifndef DEFINED_DBDATA_H #define DEFINED_DBDATA_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" // ============= external funs defs ============ #ifndef _WIN32 extern double round(double); #else /* round as a macro (no libm equivalent for MSVC) */ #define round(x) ((double) floor((double) x + 0.5)) #endif // ============= api part starts ================ /* --- built-in data type numbers ----- */ /* the built-in data types are primarily for api purposes. internally, some of these types like int, str etc have several different ways to encode along with different bit masks */ #define WG_NULLTYPE 1 #define WG_RECORDTYPE 2 #define WG_INTTYPE 3 #define WG_DOUBLETYPE 4 #define WG_STRTYPE 5 #define WG_XMLLITERALTYPE 6 #define WG_URITYPE 7 #define WG_BLOBTYPE 8 #define WG_CHARTYPE 9 #define WG_FIXPOINTTYPE 10 #define WG_DATETYPE 11 #define WG_TIMETYPE 12 #define WG_ANONCONSTTYPE 13 // not implemented yet #define WG_VARTYPE 14 // not implemented yet /* Illegal encoded data indicator */ #define WG_ILLEGAL 0xff /* prototypes of wg database api functions */ typedef ptrdiff_t wg_int; typedef size_t wg_uint; // used in time enc /* -------- creating and scanning records --------- */ void* wg_create_record(void* db, wg_int length); ///< returns NULL when error, ptr to rec otherwise void* wg_create_raw_record(void* db, wg_int length); ///< returns NULL when error, ptr to rec otherwise wg_int wg_delete_record(void* db, void *rec); ///< returns 0 on success, non-0 on error void* wg_get_first_record(void* db); ///< returns NULL when error or no recs void* wg_get_next_record(void* db, void* record); ///< returns NULL when error or no more recs void* wg_get_first_raw_record(void* db); void* wg_get_next_raw_record(void* db, void* record); void *wg_get_first_parent(void* db, void *record); void *wg_get_next_parent(void* db, void* record, void *parent); /* -------- setting and fetching record field values --------- */ wg_int wg_get_record_len(void* db, void* record); ///< returns negative int when error wg_int* wg_get_record_dataarray(void* db, void* record); ///< pointer to record data array start // following field setting functions return negative int when err, 0 when ok wg_int wg_set_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_new_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_int_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_double_field(void* db, void* record, wg_int fieldnr, double data); wg_int wg_set_str_field(void* db, void* record, wg_int fieldnr, char* data); wg_int wg_update_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data, wg_int old_data); wg_int wg_set_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_add_int_atomic_field(void* db, void* record, wg_int fieldnr, int data); wg_int wg_get_field(void* db, void* record, wg_int fieldnr); // returns 0 when error wg_int wg_get_field_type(void* db, void* record, wg_int fieldnr); // returns 0 when error /* ---------- general operations on encoded data -------- */ wg_int wg_get_encoded_type(void* db, wg_int data); char* wg_get_type_name(void* db, wg_int type); wg_int wg_free_encoded(void* db, wg_int data); /* -------- encoding and decoding data: records contain encoded data only ---------- */ // null wg_int wg_encode_null(void* db, char* data); char* wg_decode_null(void* db, wg_int data); // int wg_int wg_encode_int(void* db, wg_int data); wg_int wg_decode_int(void* db, wg_int data); // char wg_int wg_encode_char(void* db, char data); char wg_decode_char(void* db, wg_int data); // double wg_int wg_encode_double(void* db, double data); double wg_decode_double(void* db, wg_int data); // fixpoint wg_int wg_encode_fixpoint(void* db, double data); double wg_decode_fixpoint(void* db, wg_int data); // date and time wg_int wg_encode_date(void* db, int data); int wg_decode_date(void* db, wg_int data); wg_int wg_encode_time(void* db, int data); int wg_decode_time(void* db, wg_int data); int wg_current_utcdate(void* db); int wg_current_localdate(void* db); int wg_current_utctime(void* db); int wg_current_localtime(void* db); int wg_strf_iso_datetime(void* db, int date, int time, char* buf); int wg_strp_iso_date(void* db, char* buf); int wg_strp_iso_time(void* db, char* inbuf); int wg_ymd_to_date(void* db, int yr, int mo, int day); int wg_hms_to_time(void* db, int hr, int min, int sec, int prt); void wg_date_to_ymd(void* db, int date, int *yr, int *mo, int *day); void wg_time_to_hms(void* db, int time, int *hr, int *min, int *sec, int *prt); //record wg_int wg_encode_record(void* db, void* data); void* wg_decode_record(void* db, wg_int data); // str (standard C string: zero-terminated array of chars) // along with optional attached language indicator str wg_int wg_encode_str(void* db, char* str, char* lang); ///< let lang==NULL if not used char* wg_decode_str(void* db, wg_int data); char* wg_decode_str_lang(void* db, wg_int data); wg_int wg_decode_str_len(void* db, wg_int data); wg_int wg_decode_str_lang_len(void* db, wg_int data); wg_int wg_decode_str_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_str_lang_copy(void* db, wg_int data, char* langbuf, wg_int buflen); // xmlliteral (standard C string: zero-terminated array of chars) // along with obligatory attached xsd:type str wg_int wg_encode_xmlliteral(void* db, char* str, char* xsdtype); char* wg_decode_xmlliteral(void* db, wg_int data); char* wg_decode_xmlliteral_xsdtype(void* db, wg_int data); wg_int wg_decode_xmlliteral_len(void* db, wg_int data); wg_int wg_decode_xmlliteral_xsdtype_len(void* db, wg_int data); wg_int wg_decode_xmlliteral_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_xmlliteral_xsdtype_copy(void* db, wg_int data, char* strbuf, wg_int buflen); // uri (standard C string: zero-terminated array of chars) // along with an optional prefix str wg_int wg_encode_uri(void* db, char* str, char* prefix); char* wg_decode_uri(void* db, wg_int data); char* wg_decode_uri_prefix(void* db, wg_int data); wg_int wg_decode_uri_len(void* db, wg_int data); wg_int wg_decode_uri_prefix_len(void* db, wg_int data); wg_int wg_decode_uri_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_uri_prefix_copy(void* db, wg_int data, char* strbuf, wg_int buflen); // blob (binary large object, i.e. any kind of data) // along with an obligatory length in bytes wg_int wg_encode_blob(void* db, char* str, char* type, wg_int len); char* wg_decode_blob(void* db, wg_int data); char* wg_decode_blob_type(void* db, wg_int data); wg_int wg_decode_blob_len(void* db, wg_int data); wg_int wg_decode_blob_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_blob_type_len(void* db, wg_int data); wg_int wg_decode_blob_type_copy(void* db, wg_int data, char* langbuf, wg_int buflen); // anonconst wg_int wg_encode_anonconst(void* db, char* str); char* wg_decode_anonconst(void* db, wg_int data); // var wg_int wg_encode_var(void* db, wg_int varnr); wg_int wg_decode_var(void* db, wg_int data); // ================ api part ends ================ /* Record header structure. Position 0 is always reserved * for size. */ #define RECORD_HEADER_GINTS 3 #define RECORD_META_POS 1 /** metainfo, reserved for future use */ #define RECORD_BACKLINKS_POS 2 /** backlinks structure offset */ #define LITTLEENDIAN 1 ///< (intel is little-endian) difference in encoding tinystr //#define USETINYSTR 1 ///< undef to prohibit usage of tinystr /* Record meta bits. */ #define RECORD_META_NOTDATA 0x1 /** Record is a "special" record (not data) */ #define RECORD_META_MATCH 0x2 /** "match" record (needs NOTDATA as well) */ #define RECORD_META_DOC 0x10 /** schema bits: top-level document */ #define RECORD_META_OBJECT 0x20 /** schema bits: object */ #define RECORD_META_ARRAY 0x40 /** schema bits: array */ #define is_special_record(r) (*((gint *) r + RECORD_META_POS) &\ RECORD_META_NOTDATA) #define is_plain_record(r) (*((gint *) r + RECORD_META_POS) == 0) #define is_schema_array(r) (*((gint *) r + RECORD_META_POS) &\ RECORD_META_ARRAY) #define is_schema_object(r) (*((gint *) r + RECORD_META_POS) &\ RECORD_META_OBJECT) #define is_schema_document(r) (*((gint *) r + RECORD_META_POS) &\ RECORD_META_DOC) // recognising gint types as gb types: bits, shifts, masks /* special value null (unassigned) integer 0 Pointers to word-len ints end with ?01 = not eq Pointers to data records end with 000 = not eq Pointers to long string records end with 100 = eq Pointers to doubleword-len doubles end with 010 = not eq Pointers to 32byte string records end with 110 = not eq Immediate integers end with 011 = is eq (Other immediates 111 (continued below)) Immediate vars end with 0111 // not implemented yet Immediate short fixpoints 0000 1111 = is eq Immediate chars 0001 1111 = is eq Immediate dates 0010 1111 = is eq Immediate times 0011 1111 = is eq // Immediate tiny strings 0100 1111 = is eq // not used yet Immediate anon constants 0101 1111 = is eq // not implemented yet */ /* --- encoding and decoding basic data ---- */ #define SMALLINTBITS 0x3 ///< int ends with 011 #define SMALLINTSHFT 3 #define SMALLINTMASK 0x7 #define fits_smallint(i) ((((i)<>SMALLINTSHFT)==i) #define encode_smallint(i) (((i)<>SMALLINTSHFT) #define FULLINTBITS 0x1 ///< full int ptr ends with 01 #define FULLINTBITSV0 0x1 ///< full int type as 3-bit nr version 0: 001 #define FULLINTBITSV1 0x5 ///< full int type as 3-bit nr version 1: 101 #define FULLINTMASK 0x3 #define encode_fullint_offset(i) ((i)|FULLINTBITS) #define decode_fullint_offset(i) ((i) & ~FULLINTMASK) #define DATARECBITS 0x0 ///< datarec ptr ends with 000 #define DATARECMASK 0x7 #define encode_datarec_offset(i) (i) #define decode_datarec_offset(i) (i) #define LONGSTRBITS 0x4 ///< longstr ptr ends with 100 #define LONGSTRMASK 0x7 #define encode_longstr_offset(i) ((i)|LONGSTRBITS) #define decode_longstr_offset(i) ((i) & ~LONGSTRMASK) #define FULLDOUBLEBITS 0x2 ///< full double ptr ends with 010 #define FULLDOUBLEMASK 0x7 #define encode_fulldouble_offset(i) ((i)|FULLDOUBLEBITS) #define decode_fulldouble_offset(i) ((i) & ~FULLDOUBLEMASK) #define SHORTSTRBITS 0x6 ///< short str ptr ends with 110 #define SHORTSTRMASK 0x7 #define encode_shortstr_offset(i) ((i)|SHORTSTRBITS) #define decode_shortstr_offset(i) ((i) & ~SHORTSTRMASK) /* --- encoding and decoding other data ---- */ #define VARMASK 0xf #define VARSHFT 4 #define VARBITS 0x7 ///< var ends with 0111 #define fits_var(i) ((((i)<>VARSHFT)==i) #define encode_var(i) (((i)<>VARSHFT) #define CHARMASK 0xff #define CHARSHFT 8 #define CHARBITS 0x1f ///< char ends with 0001 1111 #define encode_char(i) (((i)<>CHARSHFT) #define DATEMASK 0xff #define DATESHFT 8 #define DATEBITS 0x2f ///< date ends with 0010 1111 #define MAXDATE 128*255*255 #define MINDATE -128*255*255 #define fits_date(i) (((i)<=MAXDATE) && ((i)>=MINDATE)) #define encode_date(i) (((i)<>DATESHFT) #define TIMEMASK 0xff #define TIMESHFT 8 #define TIMEBITS 0x3f ///< time ends with 0011 1111 #define MAXTIME 24*60*60*100 #define MINTIME 0 #define fits_time(i) (((i)<=MAXTIME) && ((i)>=MINTIME)) #define encode_time(i) (((i)<>TIMESHFT)) #define FIXPOINTMASK 0xff #define FIXPOINTSHFT 8 #define FIXPOINTBITS 0xf ///< fixpoint ends with 0000 1111 #define MAXFIXPOINT 800 #define MINFIXPOINT -800 #define FIXPOINTDIVISOR 10000.0 #define fits_fixpoint(i) (((i)<=MAXFIXPOINT) && ((i)>=MINFIXPOINT)) #define encode_fixpoint(i) ((((int)(round((i)*(double)FIXPOINTDIVISOR)))<>FIXPOINTSHFT)/(double)FIXPOINTDIVISOR)) #define TINYSTRMASK 0xff #define TINYSTRSHFT 8 #define TINYSTRBITS 0x4f ///< tiny str ends with 0100 1111 #define ANONCONSTMASK 0xff #define ANONCONSTSHFT 8 #define ANONCONSTBITS 0x5f ///< anon const ends with 0101 1111 #define encode_anonconst(i) (((i)<>ANONCONSTSHFT) /* --- recognizing data ---- */ #define NORMALPTRMASK 0x7 ///< all pointers except fullint #define NONPTRBITS 0x3 #define LASTFOURBITSMASK 0xf #define PRELASTFOURBITSMASK 0xf0 #define LASTBYTEMASK 0xff #define isptr(i) ((i) && (((i)&NONPTRBITS)!=NONPTRBITS)) #define isdatarec(i) (((i)&DATARECMASK)==DATARECBITS) #define isfullint(i) (((i)&FULLINTMASK)==FULLINTBITS) #define isfulldouble(i) (((i)&FULLDOUBLEMASK)==FULLDOUBLEBITS) #define isshortstr(i) (((i)&SHORTSTRMASK)==SHORTSTRBITS) #define islongstr(i) (((i)&LONGSTRMASK)==LONGSTRBITS) #define issmallint(i) (((i)&SMALLINTMASK)==SMALLINTBITS) #define isvar(i) (((i)&VARMASK)==VARBITS) #define ischar(i) (((i)&CHARMASK)==CHARBITS) #define isfixpoint(i) (((i)&FIXPOINTMASK)==FIXPOINTBITS) #define isdate(i) (((i)&DATEMASK)==DATEBITS) #define istime(i) (((i)&TIMEMASK)==TIMEBITS) #define istinystr(i) (((i)&TINYSTRMASK)==TINYSTRBITS) #define isanonconst(i) (((i)&ANONCONSTMASK)==ANONCONSTBITS) #define isimmediatedata(i) ((i)==0 || (!isptr(i) && !isfullint(i))) /* ------ metainfo and special data items --------- */ #define datarec_size_bytes(i) (getusedobjectwantedbytes(i)) #define datarec_end_ptr(i) /* --------- record and longstr data object structure ---------- */ /* record data object gint usage from start: 0: encodes length in bytes. length is aligned to sizeof gint 1: pointer to next sibling 2: pointer to prev sibling or parent 3: data gints ... ---- conventional database rec ---------- car1: id: 10 model: ford licenceplate: 123LGH owner: 20 (we will have ptr to rec 20) car2: id: 11 model: opel licenceplate: 456RMH owner: 20 (we will have ptr to rec 20) person1: parents: list of pointers to person1? id: 20 fname: John lname: Brown ---- xml node ------- xml-corresponding rdf triplets _10 model ford _10 licenceplate 123LGH _11 model opel _11 licenceplate 456RMH _20 fname john _20 lname brown _20 owns _10 _20 owns _11 (?x fname john) & (?x lname brown) & (?x owns ?y) & (?y model ford) => answer(?y) solution: - locate from value index brown - instantiate ?x with _20 - scan _20 value occurrences with pred lname to find john - scan _20 subject occurrences with pred owns to find _10 - scan _10 subject occurrences with pred model to find ford ----normal rdf triplets ----- _10 model ford _10 licenceplate 123LGH _10 owner _20 _11 model opel _11 licenceplate 456RMH _11 owner _20 _20 fname john _20 lname brown (?x fname john) & (?x lname brown) & (?y owner ?x) & (?y model ford) => answer(?y) solution: - locate from value index brown - instantiate ?x with _20 - scan _20 value occurrences with pred lname to find john - scan _20 value occurrences with pred owner to find _10 - scan _10 subject occurrences with pred model to find ford --------- fromptr structure ------- fld 1 pts to either directly (single) occurrence or rec of occurrences: single occ case: - last bit zero indicates direct ptr to rec - two previous bits indicate position in rec (0-3) multiple (or far pos) case: - last bit 1 indicates special pos list array ptr: pos array: recsize position fld nr, ptr to (single) rec or to corresp list of recs position fld nr, ptr to (single) rec or to corresp list o recs ... where corresp list is made of pairs (list cells): ptr to rec ptr to next list cell alternative: ptr to rec ptr to rec ptr to rec ptr to rec ptr to next block */ /* record data object gint usage from start: 0: encodes data obj length in bytes. length is aligned to sizeof gint 1: metainfo, incl object type: - last byte object type - top-level/dependent bit - original/derived bit 2: backlinks 3: actual gints .... ... */ /* longstr/xmlliteral/uri/blob data object gint usage from start: 0: encodes data obj length in bytes. length is aligned to sizeof gint 1: metainfo, incl object type (longstr/xmlliteral/uri/blob/datarec etc): - last byte object type - byte before last: nr to delete from obj length to get real actual-bytes length 2: refcount 3: backlinks 4: pointer to next longstr in the hash bucket, 0 if no following 5: lang/xsdtype/namespace str (offset): if 0 not present 6: actual bytes .... ... */ #define LONGSTR_HEADER_GINTS 6 /** including obj length gint */ #define LONGSTR_META_POS 1 /** metainfo, incl object type (longstr/xmlliteral/uri/blob/datarec etc) last byte (low 0) object type (WG_STRTYPE,WG_XMLLITERALTYPE, etc) byte before last (low 1): lendif: nr to delete from obj length to get real actual-bytes length of str low 2: unused low 3: unused */ #define LONGSTR_META_LENDIFMASK 0xFF00 /** second lowest bytes contains lendif*/ #define LONGSTR_META_LENDIFSHFT 8 /** shift 8 bits right to get lendif */ #define LONGSTR_META_TYPEMASK 0xFF /*** lowest byte contains actual subtype: str,uri,xmllliteral */ #define LONGSTR_REFCOUNT_POS 2 /** reference count, if 0, delete*/ #define LONGSTR_BACKLINKS_POS 3 /** backlinks structure offset */ #define LONGSTR_HASHCHAIN_POS 4 /** offset of next longstr in the hash bucket, 0 if no following */ #define LONGSTR_EXTRASTR_POS 5 /** lang/xsdtype/namespace str (encoded offset): if 0 not present */ /* --------- error handling ------------ */ #define recordcheck(db,record,fieldnr,opname) { \ if (!dbcheck(db)) {\ show_data_error_str(db,"wrong database pointer given to ",opname);\ return -1;\ }\ if (fieldnr<0 || getusedobjectwantedgintsnr(*((gint*)record))<=fieldnr+RECORD_HEADER_GINTS) {\ show_data_error_str(db,"wrong field number given to ",opname);\ return -2;\ }\ } /* ==== Protos ==== */ //void free_field_data(void* db,gint fielddata, gint fromrecoffset, gint fromrecfield); gint wg_encode_unistr(void* db, char* str, char* lang, gint type); ///< let lang==NULL if not used gint wg_encode_uniblob(void* db, char* str, char* lang, gint type, gint len); char* wg_decode_unistr(void* db, wg_int data, gint type); char* wg_decode_unistr_lang(void* db, wg_int data, gint type); gint wg_decode_unistr_len(void* db, wg_int data, gint type); gint wg_decode_unistr_lang_len(void* db, wg_int data, gint type); gint wg_decode_unistr_copy(void* db, wg_int data, char* strbuf, wg_int buflen, gint type); gint wg_decode_unistr_lang_copy(void* db, wg_int data, char* langbuf, wg_int buflen, gint type); gint wg_encode_external_data(void *db, void *extdb, gint encoded); #ifdef USE_CHILD_DB gint wg_translate_hdroffset(void *db, void *exthdr, gint encoded); void *wg_get_rec_owner(void *db, void *rec); #endif #ifdef USE_RECPTR_BITMAP gint wg_recptr_check(void *db,void *ptr); #endif #endif /* DEFINED_DBDATA_H */ whitedb-0.7.3/Db/dblock.c0000644000175000001440000010143312421471034012013 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2009, 2010, 2011, 2013, 2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dblock.c * Concurrent access support for WhiteDB memory database * * Note: this file contains compiler and target-specific code. * For compiling on plaforms that do not have support for * specific opcodes needed for atomic operations and spinlocks, * locking may be disabled by ./configure --disable-locking * or by editing the appropriate config-xxx.h file. This will * allow the code to compile, but concurrent access will NOT * work. */ /* ====== Includes =============== */ #include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #else #include #include #endif #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" #include "dblock.h" #if (LOCK_PROTO==TFQUEUE) #ifdef __linux__ #include #include #include #include #endif #endif /* ====== Private headers and defs ======== */ #define compare_and_swap wg_compare_and_swap // wg_ prefix used in dblock.h, non-wg below #ifndef LOCK_PROTO #define DUMMY_ATOMIC_OPS /* allow compilation on unsupported platforms */ #endif #if (LOCK_PROTO==RPSPIN) || (LOCK_PROTO==WPSPIN) #define WAFLAG 0x1 /* writer active flag */ #define RC_INCR 0x2 /* increment step for reader count */ #else /* classes of locks. */ #define LOCKQ_READ 0x02 #define LOCKQ_WRITE 0x04 #endif /* Macro to emit Pentium 4 "pause" instruction. */ #if !defined(LOCK_PROTO) #define MM_PAUSE #elif defined(__GNUC__) #if defined(__SSE2__) #define MM_PAUSE {\ __asm__ __volatile__("pause;\n");\ } #else #define MM_PAUSE #endif #elif defined(_WIN32) #include #define MM_PAUSE { _mm_pause(); } #endif /* Helper function for implementing atomic operations * with gcc 4.3 / ARM EABI by Julian Brown. * This works on Linux ONLY. */ #if defined(__ARM_EABI__) && defined(__linux__) typedef int (kernel_cmpxchg_t) (int oldval, int newval, int *ptr); #define kernel_cmpxchg (*(kernel_cmpxchg_t *) 0xffff0fc0) #endif /* For easier testing of GCC version */ #ifdef __GNUC__ #define GCC_VERSION (__GNUC__ * 10000 \ + __GNUC_MINOR__ * 100 \ + __GNUC_PATCHLEVEL__) #endif /* Spinlock timings * SPIN_COUNT: how many cycles until CPU is yielded * SLEEP_MSEC and SLEEP_NSEC: increment of wait time after each cycle */ #ifdef _WIN32 #define SPIN_COUNT 100000 /* Windows scheduling seems to force this */ #define SLEEP_MSEC 1 /* minimum resolution is 1 millisecond */ #else #define SPIN_COUNT 500 /* shorter spins perform better with Linux */ #define SLEEP_NSEC 500000 /* 500 microseconds */ #endif #ifdef _WIN32 #define INIT_SPIN_TIMEOUT(t) #else /* timings are in nsec */ #define INIT_SPIN_TIMEOUT(t) \ if(t > INT_MAX/1000000) /* hack: primitive overflow protection */ \ t = INT_MAX; \ else \ t *= 1000000; #endif #ifdef _WIN32 #define UPDATE_SPIN_TIMEOUT(t, ts) t -= ts; #else #define UPDATE_SPIN_TIMEOUT(t, ts) t -= ts.tv_nsec; #endif #define INIT_QLOCK_TIMEOUT(t, ts) \ ts.tv_sec = t / 1000; \ ts.tv_nsec = t % 1000; #define ALLOC_LOCK(d, l) \ l = alloc_lock(d); \ if(!l) { \ unlock_queue(d); \ show_lock_error(d, "Failed to allocate lock"); \ return 0; \ } #define DEQUEUE_LOCK(d, dbh, l, lp) \ if(lp->prev) { \ lock_queue_node *pp = offsettoptr(d, lp->prev); \ pp->next = lp->next; \ } \ if(lp->next) { \ lock_queue_node *np = offsettoptr(d, lp->next); \ np->prev = lp->prev; \ } else if(dbh->locks.tail == l) { \ dbh->locks.tail = lp->prev; \ } /* ======= Private protos ================ */ #if (LOCK_PROTO==WPSPIN) static void atomic_increment(volatile gint *ptr, gint incr); #endif #if (LOCK_PROTO==WPSPIN) || (LOCK_PROTO==RPSPIN) static void atomic_and(volatile gint *ptr, gint val); #endif #if (LOCK_PROTO==RPSPIN) static gint fetch_and_add(volatile gint *ptr, gint incr); #endif #if 0 /* unused */ static gint fetch_and_store(volatile gint *ptr, gint val); #endif // static gint compare_and_swap(volatile gint *ptr, gint oldv, gint newv); #if (LOCK_PROTO==TFQUEUE) static gint alloc_lock(void * db); static void free_lock(void * db, gint node); /*static gint deref_link(void *db, volatile gint *link);*/ #ifdef __linux__ #ifndef USE_LOCK_TIMEOUT static void futex_wait(volatile gint *addr1, int val1); #endif static int futex_trywait(volatile gint *addr1, int val1, struct timespec *timeout); static void futex_wake(volatile gint *addr1, int val1); #endif #endif static gint show_lock_error(void *db, char *errmsg); /* ====== Functions ============== */ /* -------------- helper functions -------------- */ /* * System- and platform-dependent atomic operations */ /** Atomic increment. On x86 platform, this is internally * the same as fetch_and_add(). */ #if (LOCK_PROTO==WPSPIN) static void atomic_increment(volatile gint *ptr, gint incr) { #if defined(DUMMY_ATOMIC_OPS) *ptr += incr; #elif defined(__GNUC__) #if defined(_MIPS_ARCH) gint tmp1, tmp2; /* XXX: any way to get rid of these? */ __asm__ __volatile__( ".set noreorder\n\t" "1: ll %0,%4\n\t" /* load old */ "add %1,%0,%3\n\t" /* compute tmp2=tmp1+incr */ "sc %1,%2\n\t" /* store new */ "beqz %1,1b\n\t" /* SC failed, retry */ "sync\n\t" ".set reorder\n\t" : "=&r" (tmp1), "=&r" (tmp2), "=m" (*ptr) : "r" (incr), "m" (*ptr) : "memory"); #elif (GCC_VERSION < 40400) && defined(__ARM_EABI__) && defined(__linux__) gint failure, tmp; do { tmp = *ptr; failure = kernel_cmpxchg(tmp, tmp + incr, (int *) ptr); } while (failure != 0); #else /* try gcc intrinsic */ __sync_fetch_and_add(ptr, incr); #endif #elif defined(_WIN32) _InterlockedExchangeAdd(ptr, incr); #else #error Atomic operations not implemented for this compiler #endif } #endif /** Atomic AND operation. */ #if (LOCK_PROTO==WPSPIN) || (LOCK_PROTO==RPSPIN) static void atomic_and(volatile gint *ptr, gint val) { #if defined(DUMMY_ATOMIC_OPS) *ptr &= val; #elif defined(__GNUC__) #if defined(_MIPS_ARCH) gint tmp1, tmp2; __asm__ __volatile__( ".set noreorder\n\t" "1: ll %0,%4\n\t" /* load old */ "and %1,%0,%3\n\t" /* compute tmp2=tmp1 & val; */ "sc %1,%2\n\t" /* store new */ "beqz %1,1b\n\t" /* SC failed, retry */ "sync\n\t" ".set reorder\n\t" : "=&r" (tmp1), "=&r" (tmp2), "=m" (*ptr) : "r" (val), "m" (*ptr) : "memory"); #elif (GCC_VERSION < 40400) && defined(__ARM_EABI__) && defined(__linux__) gint failure, tmp; do { tmp = *ptr; failure = kernel_cmpxchg(tmp, tmp & val, (int *) ptr); } while (failure != 0); #else /* try gcc intrinsic */ __sync_fetch_and_and(ptr, val); #endif #elif defined(_WIN32) _InterlockedAnd(ptr, val); #else #error Atomic operations not implemented for this compiler #endif } #endif /** Atomic OR operation. */ #if 0 /* unused */ static void atomic_or(volatile gint *ptr, gint val) { #if defined(DUMMY_ATOMIC_OPS) *ptr |= val; #elif defined(__GNUC__) #if defined(_MIPS_ARCH) gint tmp1, tmp2; __asm__ __volatile__( ".set noreorder\n\t" "1: ll %0,%4\n\t" /* load old */ "or %1,%0,%3\n\t" /* compute tmp2=tmp1 | val; */ "sc %1,%2\n\t" /* store new */ "beqz %1,1b\n\t" /* SC failed, retry */ "sync\n\t" ".set reorder\n\t" : "=&r" (tmp1), "=&r" (tmp2), "=m" (*ptr) : "r" (val), "m" (*ptr) : "memory"); #elif (GCC_VERSION < 40400) && defined(__ARM_EABI__) && defined(__linux__) gint failure, tmp; do { tmp = *ptr; failure = kernel_cmpxchg(tmp, tmp | val, (int *) ptr); } while (failure != 0); #else /* try gcc intrinsic */ __sync_fetch_and_or(ptr, val); #endif #elif defined(_WIN32) _InterlockedOr(ptr, val); #else #error Atomic operations not implemented for this compiler #endif } #endif /** Fetch and (dec|inc)rement. Returns value before modification. */ #if (LOCK_PROTO==RPSPIN) static gint fetch_and_add(volatile gint *ptr, gint incr) { #if defined(DUMMY_ATOMIC_OPS) gint tmp = *ptr; *ptr += incr; return tmp; #elif defined(__GNUC__) #if defined(_MIPS_ARCH) gint ret, tmp; __asm__ __volatile__( ".set noreorder\n\t" "1: ll %0,%4\n\t" /* load old */ "add %1,%0,%3\n\t" /* compute tmp=ret+incr */ "sc %1,%2\n\t" /* store new */ "beqz %1,1b\n\t" /* SC failed, retry */ "sync\n\t" ".set reorder\n\t" : "=&r" (ret), "=&r" (tmp), "=m" (*ptr) : "r" (incr), "m" (*ptr) : "memory"); return ret; #elif (GCC_VERSION < 40400) && defined(__ARM_EABI__) && defined(__linux__) gint failure, tmp; do { tmp = *ptr; failure = kernel_cmpxchg(tmp, tmp + incr, (int *) ptr); } while (failure != 0); return tmp; #else /* try gcc intrinsic */ return __sync_fetch_and_add(ptr, incr); #endif #elif defined(_WIN32) return _InterlockedExchangeAdd(ptr, incr); #else #error Atomic operations not implemented for this compiler #endif } #endif /** Atomic fetch and store. Swaps two values. */ #if 0 /* unused */ static gint fetch_and_store(volatile gint *ptr, gint val) { /* Despite the name, the GCC builtin should just * issue XCHG operation. There is no testing of * anything, just lock the bus and swap the values, * as per Intel's opcode reference. * * XXX: not available on all compiler targets :-( */ #if defined(DUMMY_ATOMIC_OPS) gint tmp = *ptr; *ptr = val; return tmp; #elif defined(__GNUC__) #if defined(_MIPS_ARCH) gint ret, tmp; __asm__ __volatile__( ".set noreorder\n\t" "1: ll %0,%4\n\t" /* load old */ "move %1,%3\n\t" "sc %1,%2\n\t" /* store new */ "beqz %1,1b\n\t" /* SC failed, retry */ "sync\n\t" ".set reorder\n\t" : "=&r" (ret), "=&r" (tmp), "=m" (*ptr) : "r" (val), "m" (*ptr) : "memory"); return ret; #elif (GCC_VERSION < 40400) && defined(__ARM_EABI__) && defined(__linux__) gint failure, oldval; do { oldval = *ptr; failure = kernel_cmpxchg(oldval, val, (int *) ptr); } while (failure != 0); return oldval; #else /* try gcc intrinsic */ return __sync_lock_test_and_set(ptr, val); #endif #elif defined(_WIN32) return _InterlockedExchange(ptr, val); #else #error Atomic operations not implemented for this compiler #endif } #endif /** Compare and swap. If value at ptr equals old, set it to * new and return 1. Otherwise the function returns 0. */ gint wg_compare_and_swap(volatile gint *ptr, gint oldv, gint newv) { #if defined(DUMMY_ATOMIC_OPS) if(*ptr == oldv) { *ptr = newv; return 1; } return 0; #elif defined(__GNUC__) #if defined(_MIPS_ARCH) gint ret; __asm__ __volatile__( ".set noreorder\n\t" "1: ll %0,%4\n\t" "bne %0,%2,2f\n\t" /* *ptr!=oldv, return *ptr */ "move %0,%3\n\t" "sc %0,%1\n\t" "beqz %0,1b\n\t" /* SC failed, retry */ "move %0,%2\n\t" /* return oldv (*ptr==newv now) */ "2: sync\n\t" ".set reorder\n\t" : "=&r" (ret), "=m" (*ptr) : "r" (oldv), "r" (newv), "m" (*ptr) : "memory"); return ret == oldv; #elif (GCC_VERSION < 40400) && defined(__ARM_EABI__) && defined(__linux__) gint failure = kernel_cmpxchg(oldv, newv, (int *) ptr); return (failure == 0); #else /* try gcc intrinsic */ return __sync_bool_compare_and_swap(ptr, oldv, newv); #endif #elif defined(_WIN32) return (_InterlockedCompareExchange(ptr, newv, oldv) == oldv); #else #error Atomic operations not implemented for this compiler #endif } /* ----------- read and write transaction support ----------- */ /* * Read and write transactions are currently realized using database * level locking. The rest of the db API is implemented independently - * therefore use of the locking routines does not automatically guarantee * isolation, rather, all of the concurrently accessing clients are expected * to follow the same protocol. */ /** Start write transaction * Current implementation: acquire database level exclusive lock */ gint wg_start_write(void * db) { return db_wlock(db, DEFAULT_LOCK_TIMEOUT); } /** End write transaction * Current implementation: release database level exclusive lock */ gint wg_end_write(void * db, gint lock) { return db_wulock(db, lock); } /** Start read transaction * Current implementation: acquire database level shared lock */ gint wg_start_read(void * db) { return db_rlock(db, DEFAULT_LOCK_TIMEOUT); } /** End read transaction * Current implementation: release database level shared lock */ gint wg_end_read(void * db, gint lock) { return db_rulock(db, lock); } /* * The following functions implement a giant shared/exclusive * lock on the database. * * Algorithms used for locking: * * 1. Simple reader-preference lock using a single global sync * variable (described by Mellor-Crummey & Scott '92). * 2. A writer-preference spinlock based on the above. * 3. A task-fair lock implemented using a queue. Similar to * the queue-based MCS rwlock, but uses futexes to synchronize * the waiting processes. */ #if (LOCK_PROTO==RPSPIN) /** Acquire database level exclusive lock (reader-preference spinlock) * Blocks until lock is acquired. * If USE_LOCK_TIMEOUT is defined, may return without locking */ #ifdef USE_LOCK_TIMEOUT gint db_rpspin_wlock(void * db, gint timeout) { #else gint db_rpspin_wlock(void * db) { #endif int i; #ifdef _WIN32 int ts; #else struct timespec ts; #endif volatile gint *gl; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_wlock"); return 0; } #endif gl = (gint *) offsettoptr(db, dbmemsegh(db)->locks.global_lock); /* First attempt at getting the lock without spinning */ if(compare_and_swap(gl, 0, WAFLAG)) return 1; #ifdef _WIN32 ts = SLEEP_MSEC; #else ts.tv_sec = 0; ts.tv_nsec = SLEEP_NSEC; #endif #ifdef USE_LOCK_TIMEOUT INIT_SPIN_TIMEOUT(timeout) #endif /* Spin loop */ for(;;) { for(i=0; ilocks.global_lock); /* Clear the writer active flag */ atomic_and(gl, ~(WAFLAG)); return 1; } /** Acquire database level shared lock (reader-preference spinlock) * Increments reader count, blocks until there are no active * writers. * If USE_LOCK_TIMEOUT is defined, may return without locking. */ #ifdef USE_LOCK_TIMEOUT gint db_rpspin_rlock(void * db, gint timeout) { #else gint db_rpspin_rlock(void * db) { #endif int i; #ifdef _WIN32 int ts; #else struct timespec ts; #endif volatile gint *gl; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_rlock"); return 0; } #endif gl = (gint *) offsettoptr(db, dbmemsegh(db)->locks.global_lock); /* Increment reader count atomically */ fetch_and_add(gl, RC_INCR); /* Try getting the lock without pause */ if(!((*gl) & WAFLAG)) return 1; #ifdef _WIN32 ts = SLEEP_MSEC; #else ts.tv_sec = 0; ts.tv_nsec = SLEEP_NSEC; #endif #ifdef USE_LOCK_TIMEOUT INIT_SPIN_TIMEOUT(timeout) #endif /* Spin loop */ for(;;) { for(i=0; ilocks.global_lock); /* Decrement reader count */ fetch_and_add(gl, -RC_INCR); return 1; } #elif (LOCK_PROTO==WPSPIN) /** Acquire database level exclusive lock (writer-preference spinlock) * Blocks until lock is acquired. */ #ifdef USE_LOCK_TIMEOUT gint db_wpspin_wlock(void * db, gint timeout) { #else gint db_wpspin_wlock(void * db) { #endif int i; #ifdef _WIN32 int ts; #else struct timespec ts; #endif volatile gint *gl, *w; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_wlock"); return 0; } #endif gl = (gint *) offsettoptr(db, dbmemsegh(db)->locks.global_lock); w = (gint *) offsettoptr(db, dbmemsegh(db)->locks.writers); /* Let the readers know a writer is present */ atomic_increment(w, 1); /* First attempt at getting the lock without spinning */ if(compare_and_swap(gl, 0, WAFLAG)) return 1; #ifdef _WIN32 ts = SLEEP_MSEC; #else ts.tv_sec = 0; ts.tv_nsec = SLEEP_NSEC; #endif #ifdef USE_LOCK_TIMEOUT INIT_SPIN_TIMEOUT(timeout) #endif /* Spin loop */ for(;;) { for(i=0; ilocks.global_lock); w = (gint *) offsettoptr(db, dbmemsegh(db)->locks.writers); /* Clear the writer active flag */ atomic_and(gl, ~(WAFLAG)); /* writers-- */ atomic_increment(w, -1); return 1; } /** Acquire database level shared lock (writer-preference spinlock) * Blocks until there are no active or waiting writers, then increments * reader count atomically. */ #ifdef USE_LOCK_TIMEOUT gint db_wpspin_rlock(void * db, gint timeout) { #else gint db_wpspin_rlock(void * db) { #endif int i; #ifdef _WIN32 int ts; #else struct timespec ts; #endif volatile gint *gl, *w; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_rlock"); return 0; } #endif gl = (gint *) offsettoptr(db, dbmemsegh(db)->locks.global_lock); w = (gint *) offsettoptr(db, dbmemsegh(db)->locks.writers); /* Try locking without spinning */ if(!(*w)) { gint readers = (*gl) & ~WAFLAG; if(compare_and_swap(gl, readers, readers + RC_INCR)) return 1; } #ifdef USE_LOCK_TIMEOUT INIT_SPIN_TIMEOUT(timeout) #endif for(;;) { #ifdef _WIN32 ts = SLEEP_MSEC; #else ts.tv_sec = 0; ts.tv_nsec = SLEEP_NSEC; #endif /* Spin-wait until writers disappear */ while(*w) { for(i=0; ilocks.global_lock); /* Decrement reader count */ atomic_increment(gl, -RC_INCR); return 1; } #elif (LOCK_PROTO==TFQUEUE) /** Acquire the queue mutex. */ static void lock_queue(void * db) { int i; #ifdef _WIN32 int ts; #else struct timespec ts; #endif volatile gint *gl; /* skip the database pointer check, this function is not called directly */ gl = (gint *) offsettoptr(db, dbmemsegh(db)->locks.queue_lock); /* First attempt at getting the lock without spinning */ if(compare_and_swap(gl, 0, 1)) return; #ifdef _WIN32 ts = SLEEP_MSEC; #else ts.tv_sec = 0; ts.tv_nsec = SLEEP_NSEC; #endif /* Spin loop */ for(;;) { for(i=0; ilocks.queue_lock); *gl = 0; } /** Acquire database level exclusive lock (task-fair queued lock) * Blocks until lock is acquired. * If USE_LOCK_TIMEOUT is defined, may return without locking */ #ifdef USE_LOCK_TIMEOUT gint db_tfqueue_wlock(void * db, gint timeout) { #else gint db_tfqueue_wlock(void * db) { #endif #ifdef _WIN32 int ts; #else struct timespec ts; #endif gint lock, prev; lock_queue_node *lockp; db_memsegment_header* dbh; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_wlock"); return 0; } #endif dbh = dbmemsegh(db); lock_queue(db); ALLOC_LOCK(db, lock) prev = dbh->locks.tail; dbh->locks.tail = lock; lockp = (lock_queue_node *) offsettoptr(db, lock); lockp->class = LOCKQ_WRITE; lockp->prev = prev; lockp->next = 0; if(prev) { lock_queue_node *prevp = offsettoptr(db, prev); prevp->next = lock; lockp->waiting = 1; } else { lockp->waiting = 0; } unlock_queue(db); if(lockp->waiting) { #ifdef __linux__ #ifdef USE_LOCK_TIMEOUT INIT_QLOCK_TIMEOUT(timeout, ts) if(futex_trywait(&lockp->waiting, 1, &ts) == ETIMEDOUT) { lock_queue(db); DEQUEUE_LOCK(db, dbh, lock, lockp) free_lock(db, lock); unlock_queue(db); return 0; } #else futex_wait(&lockp->waiting, 1); #endif #else /* XXX: add support for other platforms */ #error This code needs Linux SYS_futex service to function #endif } return lock; } /** Release database level exclusive lock (task-fair queued lock) */ gint db_tfqueue_wulock(void * db, gint lock) { lock_queue_node *lockp; db_memsegment_header* dbh; volatile gint *syn_addr = NULL; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_wulock"); return 0; } #endif dbh = dbmemsegh(db); lockp = (lock_queue_node *) offsettoptr(db, lock); lock_queue(db); if(lockp->next) { lock_queue_node *nextp = offsettoptr(db, lockp->next); nextp->waiting = 0; nextp->prev = 0; /* we're a writer lock, head of the queue */ syn_addr = &nextp->waiting; } else if(dbh->locks.tail == lock) { dbh->locks.tail = 0; } free_lock(db, lock); unlock_queue(db); if(syn_addr) { #ifdef __linux__ futex_wake(syn_addr, 1); #else /* XXX: add support for other platforms */ #error This code needs Linux SYS_futex service to function #endif } return 1; } /** Acquire database level shared lock (task-fair queued lock) * If USE_LOCK_TIMEOUT is defined, may return without locking. */ #ifdef USE_LOCK_TIMEOUT gint db_tfqueue_rlock(void * db, gint timeout) { #else gint db_tfqueue_rlock(void * db) { #endif #ifdef _WIN32 int ts; #else struct timespec ts; #endif gint lock, prev; lock_queue_node *lockp; db_memsegment_header* dbh; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_rlock"); return 0; } #endif dbh = dbmemsegh(db); lock_queue(db); ALLOC_LOCK(db, lock) prev = dbh->locks.tail; dbh->locks.tail = lock; lockp = (lock_queue_node *) offsettoptr(db, lock); lockp->class = LOCKQ_READ; lockp->prev = prev; lockp->next = 0; if(prev) { lock_queue_node *prevp = (lock_queue_node *) offsettoptr(db, prev); prevp->next = lock; if(prevp->class == LOCKQ_READ && prevp->waiting == 0) { lockp->waiting = 0; } else { lockp->waiting = 1; } } else { lockp->waiting = 0; } unlock_queue(db); if(lockp->waiting) { volatile gint *syn_addr = NULL; #ifdef __linux__ #ifdef USE_LOCK_TIMEOUT INIT_QLOCK_TIMEOUT(timeout, ts) if(futex_trywait(&lockp->waiting, 1, &ts) == ETIMEDOUT) { lock_queue(db); DEQUEUE_LOCK(db, dbh, lock, lockp) free_lock(db, lock); unlock_queue(db); return 0; } #else futex_wait(&lockp->waiting, 1); #endif #else /* XXX: add support for other platforms */ #error This code needs Linux SYS_futex service to function #endif lock_queue(db); if(lockp->next) { lock_queue_node *nextp = offsettoptr(db, lockp->next); if(nextp->class == LOCKQ_READ && nextp->waiting) { nextp->waiting = 0; syn_addr = &nextp->waiting; } } unlock_queue(db); if(syn_addr) { #ifdef __linux__ futex_wake(syn_addr, 1); #else /* XXX: add support for other platforms */ #error This code needs Linux SYS_futex service to function #endif } } return lock; } /** Release database level shared lock (task-fair queued lock) */ gint db_tfqueue_rulock(void * db, gint lock) { lock_queue_node *lockp; db_memsegment_header* dbh; volatile gint *syn_addr = NULL; #ifdef CHECK if (!dbcheck(db)) { show_lock_error(db, "Invalid database pointer in db_rulock"); return 0; } #endif dbh = dbmemsegh(db); lockp = (lock_queue_node *) offsettoptr(db, lock); lock_queue(db); if(lockp->prev) { lock_queue_node *prevp = offsettoptr(db, lockp->prev); prevp->next = lockp->next; } if(lockp->next) { lock_queue_node *nextp = offsettoptr(db, lockp->next); nextp->prev = lockp->prev; if(nextp->waiting && (!lockp->prev || nextp->class == LOCKQ_READ)) { nextp->waiting = 0; syn_addr = &nextp->waiting; } } else if(dbh->locks.tail == lock) { dbh->locks.tail = lockp->prev; } free_lock(db, lock); unlock_queue(db); if(syn_addr) { #ifdef __linux__ futex_wake(syn_addr, 1); #else /* XXX: add support for other platforms */ #error This code needs Linux SYS_futex service to function #endif } return 1; } #endif /* LOCK_PROTO */ /** Initialize locking subsystem. * Not parallel-safe, so should be run during database init. * * Note that this function is called even if locking is disabled. */ gint wg_init_locks(void * db) { #if (LOCK_PROTO==TFQUEUE) gint i, chunk_wall; lock_queue_node *tmp = NULL; #endif db_memsegment_header* dbh; #ifdef CHECK if (!dbcheck(db) && !dbcheckinit(db)) { show_lock_error(db, "Invalid database pointer in wg_init_locks"); return -1; } #endif dbh = dbmemsegh(db); #if (LOCK_PROTO==TFQUEUE) chunk_wall = dbh->locks.storage + dbh->locks.max_nodes*SYN_VAR_PADDING; for(i=dbh->locks.storage; inext_cell = i; /* offset of next cell */ } tmp->next_cell=0; /* last node */ /* top of the stack points to first cell in chunk */ dbh->locks.freelist = dbh->locks.storage; /* reset the state */ dbh->locks.tail = 0; /* 0 is considered invalid offset==>no value */ dbstore(db, dbh->locks.queue_lock, 0); #else dbstore(db, dbh->locks.global_lock, 0); dbstore(db, dbh->locks.writers, 0); #endif return 0; } #if (LOCK_PROTO==TFQUEUE) /* ---------- memory management for queued locks ---------- */ /* * Queued locks algorithm assumes allocating memory cells * for each lock. These cells need to be memory-aligned to * allow spinlocks run locally, but more importantly, allocation * and freeing of the cells has to be implemented in a lock-free * manner. * * The method used in the initial implementation is freelist * with reference counts (generally described by Valois '95, * actual code is based on examples from * http://www.non-blocking.com/Eng/services-technologies_non-blocking-lock-free.htm) * * XXX: code untested currently * XXX: Mellor-Crummey & Scott algorithm possibly does not need * refcounts. If so, they should be #ifdef-ed out, but * kept for possible future expansion. */ /** Allocate memory cell for a lock. * Used internally only, so we assume the passed db pointer * is already validated. * * Returns offset to allocated cell. */ #if 0 static gint alloc_lock(void * db) { db_memsegment_header* dbh = dbmemsegh(db); lock_queue_node *tmp; for(;;) { gint t = dbh->locks.freelist; if(!t) return 0; /* end of chain :-( */ tmp = (lock_queue_node *) offsettoptr(db, t); fetch_and_add(&(tmp->refcount), 2); if(compare_and_swap(&(dbh->locks.freelist), t, tmp->next_cell)) { fetch_and_add(&(tmp->refcount), -1); /* clear lsb */ return t; } free_lock(db, t); } return 0; /* dummy */ } /** Release memory cell for a lock. * Used internally only. */ static void free_lock(void * db, gint node) { db_memsegment_header* dbh = dbmemsegh(db); lock_queue_node *tmp; volatile gint t; tmp = (lock_queue_node *) offsettoptr(db, node); /* Clear reference */ fetch_and_add(&(tmp->refcount), -2); /* Try to set lsb */ if(compare_and_swap(&(tmp->refcount), 0, 1)) { /* XXX: if(tmp->next_cell) free_lock(db, tmp->next_cell); */ do { t = dbh->locks.freelist; tmp->next_cell = t; } while (!compare_and_swap(&(dbh->locks.freelist), t, node)); } } /** De-reference (release pointer to) a link. * Used internally only. */ static gint deref_link(void *db, volatile gint *link) { lock_queue_node *tmp; volatile gint t; for(;;) { t = *link; if(t == 0) return 0; tmp = (lock_queue_node *) offsettoptr(db, t); fetch_and_add(&(tmp->refcount), 2); if(t == *link) return t; free_lock(db, t); } } #else /* Simple lock memory allocation (non lock-free) */ static gint alloc_lock(void * db) { db_memsegment_header* dbh = dbmemsegh(db); gint t = dbh->locks.freelist; lock_queue_node *tmp; if(!t) return 0; /* end of chain :-( */ tmp = (lock_queue_node *) offsettoptr(db, t); dbh->locks.freelist = tmp->next_cell; return t; } static void free_lock(void * db, gint node) { db_memsegment_header* dbh = dbmemsegh(db); lock_queue_node *tmp = (lock_queue_node *) offsettoptr(db, node); tmp->next_cell = dbh->locks.freelist; dbh->locks.freelist = node; } #endif #ifdef __linux__ /* Futex operations */ #ifndef USE_LOCK_TIMEOUT static void futex_wait(volatile gint *addr1, int val1) { syscall(SYS_futex, (void *) addr1, FUTEX_WAIT, val1, NULL); } #endif static int futex_trywait(volatile gint *addr1, int val1, struct timespec *timeout) { if(syscall(SYS_futex, (void *) addr1, FUTEX_WAIT, val1, timeout) == -1) return errno; /* On Linux, this is thread-safe. Caution needed however */ else return 0; } static void futex_wake(volatile gint *addr1, int val1) { syscall(SYS_futex, (void *) addr1, FUTEX_WAKE, val1); } #endif #endif /* LOCK_PROTO==TFQUEUE */ /* ------------ error handling ---------------- */ static gint show_lock_error(void *db, char *errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg locking error: %s.\n", errmsg); #endif return -1; } #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dbapi.h0000644000175000001440000003515612421471034011651 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2009,2010,2011,2013,2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbapi.h * * Wg database api for public use. * */ #ifndef DEFINED_DBAPI_H #define DEFINED_DBAPI_H /* For gint/wg_int types */ #include #ifdef __cplusplus extern "C" { #endif /* --- built-in data type numbers ----- */ /* the built-in data types are primarily for api purposes. internally, some of these types like int, str etc have several different ways to encode along with different bit masks */ #define WG_NULLTYPE 1 #define WG_RECORDTYPE 2 #define WG_INTTYPE 3 #define WG_DOUBLETYPE 4 #define WG_STRTYPE 5 #define WG_XMLLITERALTYPE 6 #define WG_URITYPE 7 #define WG_BLOBTYPE 8 #define WG_CHARTYPE 9 #define WG_FIXPOINTTYPE 10 #define WG_DATETYPE 11 #define WG_TIMETYPE 12 #define WG_ANONCONSTTYPE 13 #define WG_VARTYPE 14 /* Illegal encoded data indicator */ #define WG_ILLEGAL 0xff /* Query "arglist" parameters */ #define WG_COND_EQUAL 0x0001 /** = */ #define WG_COND_NOT_EQUAL 0x0002 /** != */ #define WG_COND_LESSTHAN 0x0004 /** < */ #define WG_COND_GREATER 0x0008 /** > */ #define WG_COND_LTEQUAL 0x0010 /** <= */ #define WG_COND_GTEQUAL 0x0020 /** >= */ /* Query types. Python extension module uses the API and needs these. */ #define WG_QTYPE_TTREE 0x01 #define WG_QTYPE_HASH 0x02 #define WG_QTYPE_SCAN 0x04 #define WG_QTYPE_PREFETCH 0x80 /* Direct access to field */ #define RECORD_HEADER_GINTS 3 #define wg_field_addr(db,record,fieldnr) (((wg_int*)(record))+RECORD_HEADER_GINTS+(fieldnr)) /* WhiteDB data types */ typedef ptrdiff_t wg_int; typedef size_t wg_uint; /** Query argument list object */ typedef struct { wg_int column; /** column (field) number this argument applies to */ wg_int cond; /** condition (equal, less than, etc) */ wg_int value; /** encoded value */ } wg_query_arg; /** Query object */ typedef struct { wg_int qtype; /** Query type (T-tree, hash, full scan, prefetch) */ /* Argument list based query is the only one supported at the moment. */ wg_query_arg *arglist; /** check each row in result set against these */ wg_int argc; /** number of elements in arglist */ wg_int column; /** index on this column used */ /* Fields for T-tree query (XXX: some may be re-usable for * other types as well) */ wg_int curr_offset; wg_int end_offset; wg_int curr_slot; wg_int end_slot; wg_int direction; /* Fields for full scan */ wg_int curr_record; /** offset of the current record */ /* Fields for prefetch; with/without mpool */ void *mpool; /** storage for row offsets */ void *curr_page; /** current page of results */ wg_int curr_pidx; /** current index on page */ wg_uint res_count; /** number of rows in results */ } wg_query; /* prototypes of wg database api functions */ /* ------- attaching and detaching a database ----- */ void* wg_attach_database(char* dbasename, wg_int size); // returns a pointer to the database, NULL if failure void* wg_attach_existing_database(char* dbasename); // like wg_attach_database, but does not create a new base void* wg_attach_logged_database(char* dbasename, wg_int size); // like wg_attach_database, but activates journal logging on creation void* wg_attach_database_mode(char* dbasename, wg_int size, int mode); // like wg_attach_database, set shared segment permissions to "mode" void* wg_attach_logged_database_mode(char* dbasename, wg_int size, int mode); // like above, activate journal logging int wg_detach_database(void* dbase); // detaches a database: returns 0 if OK int wg_delete_database(char* dbasename); // deletes a database: returns 0 if OK /* ------- attaching and detaching a local db ----- */ void* wg_attach_local_database(wg_int size); void wg_delete_local_database(void* dbase); /* ------- functions to query database state ------ */ wg_int wg_database_freesize(void *db); wg_int wg_database_size(void *db); /* -------- creating and scanning records --------- */ void* wg_create_record(void* db, wg_int length); ///< returns NULL when error, ptr to rec otherwise void* wg_create_raw_record(void* db, wg_int length); ///< returns NULL when error, ptr to rec otherwise wg_int wg_delete_record(void* db, void *rec); ///< returns 0 on success, non-0 on error void* wg_get_first_record(void* db); ///< returns NULL when error or no recs void* wg_get_next_record(void* db, void* record); ///< returns NULL when error or no more recs void *wg_get_first_parent(void* db, void *record); void *wg_get_next_parent(void* db, void* record, void *parent); /* -------- setting and fetching record field values --------- */ wg_int wg_get_record_len(void* db, void* record); ///< returns negative int when error wg_int* wg_get_record_dataarray(void* db, void* record); ///< pointer to record data array start // following field setting functions return negative int when err, 0 when ok wg_int wg_set_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_new_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_int_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_double_field(void* db, void* record, wg_int fieldnr, double data); wg_int wg_set_str_field(void* db, void* record, wg_int fieldnr, char* data); wg_int wg_update_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data, wg_int old_data); wg_int wg_set_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_add_int_atomic_field(void* db, void* record, wg_int fieldnr, int data); wg_int wg_get_field(void* db, void* record, wg_int fieldnr); // returns 0 when error wg_int wg_get_field_type(void* db, void* record, wg_int fieldnr); // returns 0 when error /* ---------- general operations on encoded data -------- */ wg_int wg_get_encoded_type(void* db, wg_int data); wg_int wg_free_encoded(void* db, wg_int data); /* -------- encoding and decoding data: records contain encoded data only ---------- */ wg_int wg_encode_null(void* db, wg_int data); wg_int wg_decode_null(void* db, wg_int data); // int wg_int wg_encode_int(void* db, wg_int data); wg_int wg_decode_int(void* db, wg_int data); // double wg_int wg_encode_double(void* db, double data); double wg_decode_double(void* db, wg_int data); // fixpoint wg_int wg_encode_fixpoint(void* db, double data); double wg_decode_fixpoint(void* db, wg_int data); // date and time wg_int wg_encode_date(void* db, int data); int wg_decode_date(void* db, wg_int data); wg_int wg_encode_time(void* db, int data); int wg_decode_time(void* db, wg_int data); int wg_current_utcdate(void* db); int wg_current_localdate(void* db); int wg_current_utctime(void* db); int wg_current_localtime(void* db); int wg_strf_iso_datetime(void* db, int date, int time, char* buf); int wg_strp_iso_date(void* db, char* buf); int wg_strp_iso_time(void* db, char* inbuf); int wg_ymd_to_date(void* db, int yr, int mo, int day); int wg_hms_to_time(void* db, int hr, int min, int sec, int prt); void wg_date_to_ymd(void* db, int date, int *yr, int *mo, int *day); void wg_time_to_hms(void* db, int time, int *hr, int *min, int *sec, int *prt); // str (standard C string: zero-terminated array of chars) // along with optional attached language indicator str wg_int wg_encode_str(void* db, char* str, char* lang); ///< let lang==NULL if not used char* wg_decode_str(void* db, wg_int data); char* wg_decode_str_lang(void* db, wg_int data); wg_int wg_decode_str_len(void* db, wg_int data); wg_int wg_decode_str_lang_len(void* db, wg_int data); wg_int wg_decode_str_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_str_lang_copy(void* db, wg_int data, char* langbuf, wg_int buflen); // xmlliteral (standard C string: zero-terminated array of chars) // along with obligatory attached xsd:type str wg_int wg_encode_xmlliteral(void* db, char* str, char* xsdtype); char* wg_decode_xmlliteral(void* db, wg_int data); char* wg_decode_xmlliteral_xsdtype(void* db, wg_int data); wg_int wg_decode_xmlliteral_len(void* db, wg_int data); wg_int wg_decode_xmlliteral_xsdtype_len(void* db, wg_int data); wg_int wg_decode_xmlliteral_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_xmlliteral_xsdtype_copy(void* db, wg_int data, char* strbuf, wg_int buflen); // uri (standard C string: zero-terminated array of chars) // along with an optional namespace str wg_int wg_encode_uri(void* db, char* str, char* nspace); ///< let nspace==NULL if not used char* wg_decode_uri(void* db, wg_int data); char* wg_decode_uri_prefix(void* db, wg_int data); wg_int wg_decode_uri_len(void* db, wg_int data); wg_int wg_decode_uri_prefix_len(void* db, wg_int data); wg_int wg_decode_uri_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_uri_prefix_copy(void* db, wg_int data, char* strbuf, wg_int buflen); // blob (binary large object, i.e. any kind of data) // along with an obligatory length in bytes wg_int wg_encode_blob(void* db, char* str, char* type, wg_int len); char* wg_decode_blob(void* db, wg_int data); char* wg_decode_blob_type(void* db, wg_int data); wg_int wg_decode_blob_len(void* db, wg_int data); wg_int wg_decode_blob_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_blob_type_len(void* db, wg_int data); wg_int wg_decode_blob_type_copy(void* db, wg_int data, char* langbuf, wg_int buflen); /// ptr to record wg_int wg_encode_record(void* db, void* data); void* wg_decode_record(void* db, wg_int data); /// char wg_int wg_encode_char(void* db, char data); char wg_decode_char(void* db, wg_int data); // anonconst wg_int wg_encode_anonconst(void* db, char* str); char* wg_decode_anonconst(void* db, wg_int data); // var wg_int wg_encode_var(void* db, wg_int varnr); wg_int wg_decode_var(void* db, wg_int data); /* --- dumping and restoring -------- */ wg_int wg_dump(void * db,char* fileName); // dump shared memory database to the disk wg_int wg_import_dump(void * db,char* fileName); // import database from the disk wg_int wg_start_logging(void *db); /* activate journal logging globally */ wg_int wg_stop_logging(void *db); /* deactivate journal logging */ wg_int wg_replay_log(void *db, char *filename); /* restore from journal */ /* ---------- concurrency support ---------- */ wg_int wg_start_write(void * dbase); /* start write transaction */ wg_int wg_end_write(void * dbase, wg_int lock); /* end write transaction */ wg_int wg_start_read(void * dbase); /* start read transaction */ wg_int wg_end_read(void * dbase, wg_int lock); /* end read transaction */ /* ------------- utilities ----------------- */ void wg_print_db(void *db); void wg_print_record(void *db, wg_int* rec); void wg_snprint_value(void *db, wg_int enc, char *buf, int buflen); wg_int wg_parse_and_encode(void *db, char *buf); wg_int wg_parse_and_encode_param(void *db, char *buf); void wg_export_db_csv(void *db, char *filename); wg_int wg_import_db_csv(void *db, char *filename); /* ---------- query functions -------------- */ wg_query *wg_make_query(void *db, void *matchrec, wg_int reclen, wg_query_arg *arglist, wg_int argc); #define wg_make_prefetch_query wg_make_query wg_query *wg_make_query_rc(void *db, void *matchrec, wg_int reclen, wg_query_arg *arglist, wg_int argc, wg_uint rowlimit); void *wg_fetch(void *db, wg_query *query); void wg_free_query(void *db, wg_query *query); wg_int wg_encode_query_param_null(void *db, char *data); wg_int wg_encode_query_param_record(void *db, void *data); wg_int wg_encode_query_param_char(void *db, char data); wg_int wg_encode_query_param_fixpoint(void *db, double data); wg_int wg_encode_query_param_date(void *db, int data); wg_int wg_encode_query_param_time(void *db, int data); wg_int wg_encode_query_param_var(void *db, wg_int data); wg_int wg_encode_query_param_int(void *db, wg_int data); wg_int wg_encode_query_param_double(void *db, double data); wg_int wg_encode_query_param_str(void *db, char *data, char *lang); wg_int wg_encode_query_param_xmlliteral(void *db, char *data, char *xsdtype); wg_int wg_encode_query_param_uri(void *db, char *data, char *prefix); wg_int wg_free_query_param(void* db, wg_int data); void *wg_find_record(void *db, wg_int fieldnr, wg_int cond, wg_int data, void* lastrecord); void *wg_find_record_null(void *db, wg_int fieldnr, wg_int cond, char *data, void* lastrecord); void *wg_find_record_record(void *db, wg_int fieldnr, wg_int cond, void *data, void* lastrecord); void *wg_find_record_char(void *db, wg_int fieldnr, wg_int cond, char data, void* lastrecord); void *wg_find_record_fixpoint(void *db, wg_int fieldnr, wg_int cond, double data, void* lastrecord); void *wg_find_record_date(void *db, wg_int fieldnr, wg_int cond, int data, void* lastrecord); void *wg_find_record_time(void *db, wg_int fieldnr, wg_int cond, int data, void* lastrecord); void *wg_find_record_var(void *db, wg_int fieldnr, wg_int cond, wg_int data, void* lastrecord); void *wg_find_record_int(void *db, wg_int fieldnr, wg_int cond, int data, void* lastrecord); void *wg_find_record_double(void *db, wg_int fieldnr, wg_int cond, double data, void* lastrecord); void *wg_find_record_str(void *db, wg_int fieldnr, wg_int cond, char *data, void* lastrecord); void *wg_find_record_xmlliteral(void *db, wg_int fieldnr, wg_int cond, char *data, char *xsdtype, void* lastrecord); void *wg_find_record_uri(void *db, wg_int fieldnr, wg_int cond, char *data, char *prefix, void* lastrecord); /* ---------- child database handling ------ */ wg_int wg_register_external_db(void *db, void *extdb); wg_int wg_encode_external_data(void *db, void *extdb, wg_int encoded); /* ---------- JSON document I/O ------------ */ wg_int wg_parse_json_file(void *db, char *filename); wg_int wg_check_json(void *db, char *buf); wg_int wg_parse_json_document(void *db, char *buf, void **document); wg_int wg_parse_json_fragment(void *db, char *buf, void **document); #ifdef __cplusplus } #endif #endif /* DEFINED_DBAPI_H */ whitedb-0.7.3/Db/dbjson.c0000644000175000001440000005361412421471034012043 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2013, 2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbjson.c * WhiteDB JSON input and output. */ /* ====== Includes =============== */ #include #include #include /* ====== Private headers and defs ======== */ #ifdef __cplusplus extern "C" { #endif /*#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include #endif*/ #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dbdata.h" #include "dbcompare.h" #include "dbschema.h" #include "dbjson.h" #include "dbutil.h" #include "../json/yajl_api.h" #ifdef _WIN32 #define strncpy(d, s, sz) strncpy_s(d, sz+1, s, sz) #define strnlen strnlen_s #endif #ifdef USE_BACKLINKING #if !defined(WG_COMPARE_REC_DEPTH) || (WG_COMPARE_REC_DEPTH < 2) #error WG_COMPARE_REC_DEPTH not defined or too small #else #define MAX_DEPTH WG_COMPARE_REC_DEPTH #endif #else /* !USE_BACKLINKING */ #define MAX_DEPTH 99 /* no reason to limit */ #endif /* Commenting this out allows parsing literal value in input, but * the current code lacks the capability of representing them * (what record should they be stored in?) so there would be * no obvious benefit. */ #define CHECK_TOPLEVEL_STRUCTURE typedef enum { ARRAY, OBJECT } stack_entry_t; struct __stack_entry_elem { gint enc; struct __stack_entry_elem *next; }; typedef struct __stack_entry_elem stack_entry_elem; typedef struct { stack_entry_t type; stack_entry_elem *head; stack_entry_elem *tail; char last_key[80]; int size; } stack_entry; typedef struct { int state; stack_entry stack[MAX_DEPTH]; int stack_ptr; void *db; int isparam; int isdocument; void **document; } parser_context; /* ======= Private protos ================ */ static int push(parser_context *ctx, stack_entry_t type); static int pop(parser_context *ctx); static int add_elem(parser_context *ctx, gint enc); static int add_key(parser_context *ctx, char *key); static int add_literal(parser_context *ctx, gint val); static gint run_json_parser(void *db, char *buf, yajl_callbacks *cb, int isparam, int isdocument, void **document); static int check_push_cb(void* cb_ctx); static int check_pop_cb(void* cb_ctx); static int array_begin_cb(void* cb_ctx); static int array_end_cb(void* cb_ctx); static int object_begin_cb(void* cb_ctx); static int object_end_cb(void* cb_ctx); static int elem_integer_cb(void* cb_ctx, long long intval); static int elem_double_cb(void* cb_ctx, double doubleval); static int object_key_cb(void* cb_ctx, const unsigned char * strval, size_t strl); static int elem_string_cb(void* cb_ctx, const unsigned char * strval, size_t strl); static void print_cb(void *cb_ctx, const char *str, size_t len); static int pretty_print_json(void *db, yajl_gen *g, void *rec); static int pretty_print_jsonval(void *db, yajl_gen *g, gint enc); static gint show_json_error(void *db, char *errmsg); static gint show_json_error_fn(void *db, char *errmsg, char *filename); static gint show_json_error_byte(void *db, char *errmsg, int byte); /* ======== Data ========================= */ yajl_callbacks validate_cb = { NULL, NULL, NULL, NULL, NULL, NULL, check_push_cb, NULL, check_pop_cb, check_push_cb, check_pop_cb }; yajl_callbacks input_cb = { NULL, NULL, elem_integer_cb, elem_double_cb, NULL, elem_string_cb, object_begin_cb, object_key_cb, object_end_cb, array_begin_cb, array_end_cb }; /* ====== Functions ============== */ /** * Parse an input file. Does an initial pass to verify the syntax * of the input and passes it on to the document parser. * XXX: caches the data in memory, so this is very unsuitable * for large files. An alternative would be to feed bytes directly * to the document parser and roll the transaction back, if something fails; */ #define WG_JSON_INPUT_CHUNK 16384 gint wg_parse_json_file(void *db, char *filename) { char *buf = NULL; FILE *f = NULL; int count = 0, result = 0, bufsize = 0, depth = -1; yajl_handle hand = NULL; buf = malloc(WG_JSON_INPUT_CHUNK); if(!buf) { return show_json_error(db, "Failed to allocate memory"); } bufsize = WG_JSON_INPUT_CHUNK; if(!filename) { #ifdef _WIN32 printf("reading JSON from stdin, press CTRL-Z and ENTER when done\n"); #else printf("reading JSON from stdin, press CTRL-D when done\n"); #endif fflush(stdout); f = stdin; } else { #ifdef _WIN32 if(fopen_s(&f, filename, "r")) { #else if(!(f = fopen(filename, "r"))) { #endif show_json_error_fn(db, "Failed to open input", filename); result = -1; goto done; } } /* setup parser */ hand = yajl_alloc(&validate_cb, NULL, (void *) &depth); yajl_config(hand, yajl_allow_comments, 1); while(!feof(f)) { int rd = fread((void *) &buf[count], 1, WG_JSON_INPUT_CHUNK, f); if(rd == 0) { if(!feof(f)) { show_json_error_byte(db, "Read error", count); result = -1; } goto done; } if(yajl_parse(hand, (unsigned char *) &buf[count], rd) != yajl_status_ok) { unsigned char *errtxt = yajl_get_error(hand, 1, (unsigned char *) &buf[count], rd); show_json_error(db, (char *) errtxt); yajl_free_error(hand, errtxt); result = -1; goto done; } count += rd; if(count >= bufsize) { void *tmp = realloc(buf, bufsize + WG_JSON_INPUT_CHUNK); if(!tmp) { show_json_error(db, "Failed to allocate additional memory"); result = -1; goto done; } buf = tmp; bufsize += WG_JSON_INPUT_CHUNK; } } if(yajl_complete_parse(hand) != yajl_status_ok) { show_json_error(db, "Syntax error (JSON not properly terminated?)"); result = -1; goto done; } #ifdef CHECK_TOPLEVEL_STRUCTURE if(depth == -1) { show_json_error(db, "Top-level array or object is required in JSON"); result = -1; goto done; } #endif buf[count] = '\0'; result = wg_parse_json_document(db, buf, NULL); done: if(buf) free(buf); if(filename && f) fclose(f); if(hand) yajl_free(hand); return result; } /* Validate JSON data in a string buffer. * Does not insert data into the database, so this may be used * as a first pass before calling the wg_parse_*() functions. * * returns 0 for success. * returns -1 in case of a syntax error. */ gint wg_check_json(void *db, char *buf) { int count = 0, result = 0, depth = -1; char *iptr = buf; yajl_handle hand = NULL; #ifdef CHECK if(!buf) return show_json_error(db, "Invalid input buffer"); #endif /* setup parser */ hand = yajl_alloc(&validate_cb, NULL, (void *) &depth); yajl_config(hand, yajl_allow_comments, 1); while((count = strnlen(iptr, WG_JSON_INPUT_CHUNK)) > 0) { if(yajl_parse(hand, (unsigned char *) iptr, count) != yajl_status_ok) { show_json_error(db, "JSON parsing failed"); result = -1; goto done; } iptr += count; } if(yajl_complete_parse(hand) != yajl_status_ok) { show_json_error(db, "JSON parsing failed"); result = -1; } #ifdef CHECK_TOPLEVEL_STRUCTURE else if(depth == -1) { show_json_error(db, "Top-level array or object is required in JSON"); result = -1; } #endif done: if(hand) yajl_free(hand); return result; } /* Parse a JSON buffer. * The data is inserted in database using the JSON schema. * If parsing is successful, the pointer referred to by * **document will point to the top-level record. * If **document is NULL, the pointer is discarded. * * returns 0 for success. * returns -1 on non-fatal error. * returns -2 if database is left non-consistent due to an error. */ gint wg_parse_json_document(void *db, char *buf, void **document) { void *rec = NULL; gint retv = run_json_parser(db, buf, &input_cb, 0, 1, &rec); if(document) *document = rec; return retv; } /* Parse a JSON buffer. * Like wg_parse_json_document, except the top-level object or * array is not marked as a document. * * returns 0 for success. * returns -1 on non-fatal error. * returns -2 if database is left non-consistent due to an error. */ gint wg_parse_json_fragment(void *db, char *buf, void **document) { void *rec = NULL; gint retv = run_json_parser(db, buf, &input_cb, 0, 0, &rec); if(document) *document = rec; return retv; } /* Parse a JSON parameter(s). * The data is inserted in database as "special" records. * It does not make sense to call this function with NULL as the * third parameter, as that would imply data input semantics but * the records generated here are speficially flagged *non-data*. * * returns 0 for success. * returns -1 on non-fatal error. * returns -2 if database is left non-consistent due to an error. */ gint wg_parse_json_param(void *db, char *buf, void **document) { if(!document) { return show_json_error(db, "wg_parse_json_param: arg 3 cannot be NULL"); } return run_json_parser(db, buf, &input_cb, 1, 1, document); } /* Run JSON parser. * The data is inserted in the database. If there are any errors, the * database will currently remain in an inconsistent state, so beware. * * if isparam is specified, the data will not be indexed nor returned * by wg_get_*_record() calls. * * if isdocument is 0, the input will be treated as a fragment and * not as a full document. * * if the call is successful, *document contains a pointer to the * top-level record. * * returns 0 for success. * returns -1 on non-fatal error. * returns -2 if database is left non-consistent due to an error. */ static gint run_json_parser(void *db, char *buf, yajl_callbacks *cb, int isparam, int isdocument, void **document) { int count = 0, result = 0; yajl_handle hand = NULL; char *iptr = buf; parser_context ctx; /* setup context */ ctx.state = 0; ctx.stack_ptr = -1; ctx.db = db; ctx.isparam = isparam; ctx.isdocument = isdocument; ctx.document = document; /* setup parser */ hand = yajl_alloc(cb, NULL, (void *) &ctx); yajl_config(hand, yajl_allow_comments, 1); while((count = strnlen(iptr, WG_JSON_INPUT_CHUNK)) > 0) { if(yajl_parse(hand, (unsigned char *) iptr, count) != yajl_status_ok) { show_json_error(db, "JSON parsing failed"); result = -2; /* Fatal error */ goto done; } iptr += count; } if(yajl_complete_parse(hand) != yajl_status_ok) { show_json_error(db, "JSON parsing failed"); result = -2; /* Fatal error */ } done: if(hand) yajl_free(hand); return result; } static int check_push_cb(void* cb_ctx) { int *depth = (int *) cb_ctx; if(*depth == -1) *depth = 0; /* hack: something was pushed */ if(++(*depth) >= MAX_DEPTH) { return 0; } return 1; } static int check_pop_cb(void* cb_ctx) { int *depth = (int *) cb_ctx; --(*depth); return 1; } /** * Push an object or an array on the stack. */ static int push(parser_context *ctx, stack_entry_t type) { stack_entry *e; if(++ctx->stack_ptr >= MAX_DEPTH) /* paranoia, parser guards from this */ return 0; e = &ctx->stack[ctx->stack_ptr]; e->size = 0; e->type = type; e->head = NULL; e->tail = NULL; return 1; } /** * Pop an object or an array from the stack. * If this is not the top level in the document, the object is also added * as an element on the previous level. */ static int pop(parser_context *ctx) { stack_entry *e; void *rec; int ret, istoplevel; if(ctx->stack_ptr < 0) return 0; e = &ctx->stack[ctx->stack_ptr--]; /* is it a top level object? */ if(ctx->stack_ptr < 0) { istoplevel = 1; } else { istoplevel = 0; } if(e->type == ARRAY) { rec = wg_create_array(ctx->db, e->size, (istoplevel && ctx->isdocument), ctx->isparam); } else { rec = wg_create_object(ctx->db, e->size, (istoplevel && ctx->isdocument), ctx->isparam); } /* add elements to the database */ if(rec) { stack_entry_elem *curr = e->head; int i = 0; ret = 1; while(curr) { if(wg_set_field(ctx->db, rec, i++, curr->enc)) { ret = 0; break; } curr = curr->next; } if(istoplevel) *(ctx->document) = rec; } else { ret = 0; } /* free the elements */ while(e->head) { stack_entry_elem *tmp = e->head; e->head = e->head->next; free(tmp); } e->tail = NULL; e->size = 0; /* is it an element of something? */ if(!istoplevel && rec && ret) { gint enc = wg_encode_record(ctx->db, rec); ret = add_literal(ctx, enc); } return ret; } /** * Append an element to the current stack entry. */ static int add_elem(parser_context *ctx, gint enc) { stack_entry *e; stack_entry_elem *tmp; if(ctx->stack_ptr < 0 || ctx->stack_ptr >= MAX_DEPTH) return 0; /* paranoia */ e = &ctx->stack[ctx->stack_ptr]; tmp = (stack_entry_elem *) malloc(sizeof(stack_entry_elem)); if(!tmp) return 0; if(!e->tail) { e->head = tmp; } else { e->tail->next = tmp; } e->tail = tmp; e->size++; tmp->enc = enc; tmp->next = NULL; return 1; } /** * Store a key in the current stack entry. */ static int add_key(parser_context *ctx, char *key) { stack_entry *e; if(ctx->stack_ptr < 0 || ctx->stack_ptr >= MAX_DEPTH) return 0; /* paranoia */ e = &ctx->stack[ctx->stack_ptr]; strncpy(e->last_key, key, 80); e->last_key[79] = '\0'; return 1; } /** * Add a literal value. If it's inside an object, generate * a key-value pair using the last key. Otherwise insert * it directly. */ static int add_literal(parser_context *ctx, gint val) { stack_entry *e; if(ctx->stack_ptr < 0 || ctx->stack_ptr >= MAX_DEPTH) return 0; /* paranoia */ e = &ctx->stack[ctx->stack_ptr]; if(e->type == ARRAY) { return add_elem(ctx, val); } else { void *rec; gint key = wg_encode_str(ctx->db, e->last_key, NULL); if(key == WG_ILLEGAL) return 0; rec = wg_create_kvpair(ctx->db, key, val, ctx->isparam); if(!rec) return 0; return add_elem(ctx, wg_encode_record(ctx->db, rec)); } } #define OUT_INDENT(x,i,f) \ for(i=0; istack_ptr+1, i, stdout) printf("BEGIN ARRAY\n");*/ if(!push(ctx, ARRAY)) return 0; return 1; } static int array_end_cb(void* cb_ctx) { /* int i;*/ parser_context *ctx = (parser_context *) cb_ctx; if(!pop(ctx)) return 0; /* OUT_INDENT(ctx->stack_ptr+1, i, stdout) printf("END ARRAY\n");*/ return 1; } static int object_begin_cb(void* cb_ctx) { /* int i;*/ parser_context *ctx = (parser_context *) cb_ctx; /* OUT_INDENT(ctx->stack_ptr+1, i, stdout) printf("BEGIN object\n");*/ if(!push(ctx, OBJECT)) return 0; return 1; } static int object_end_cb(void* cb_ctx) { /* int i;*/ parser_context *ctx = (parser_context *) cb_ctx; if(!pop(ctx)) return 0; /* OUT_INDENT(ctx->stack_ptr+1, i, stdout) printf("END object\n");*/ return 1; } static int elem_integer_cb(void* cb_ctx, long long intval) { /* int i;*/ gint val; parser_context *ctx = (parser_context *) cb_ctx; val = wg_encode_int(ctx->db, (gint) intval); if(val == WG_ILLEGAL) return 0; if(!add_literal(ctx, val)) return 0; /* OUT_INDENT(ctx->stack_ptr+1, i, stdout) printf("INTEGER: %d\n", (int) intval);*/ return 1; } static int elem_double_cb(void* cb_ctx, double doubleval) { /* int i;*/ gint val; parser_context *ctx = (parser_context *) cb_ctx; val = wg_encode_double(ctx->db, doubleval); if(val == WG_ILLEGAL) return 0; if(!add_literal(ctx, val)) return 0; /* OUT_INDENT(ctx->stack_ptr+1, i, stdout) printf("FLOAT: %.6f\n", doubleval);*/ return 1; } static int object_key_cb(void* cb_ctx, const unsigned char * strval, size_t strl) { /* int i;*/ int res = 1; parser_context *ctx = (parser_context *) cb_ctx; char *buf = malloc(strl + 1); if(!buf) return 0; strncpy(buf, (char *) strval, strl); buf[strl] = '\0'; if(!add_key(ctx, buf)) { res = 0; } /* OUT_INDENT(ctx->stack_ptr+1, i, stdout) printf("KEY: %s\n", buf);*/ free(buf); return res; } static int elem_string_cb(void* cb_ctx, const unsigned char * strval, size_t strl) { /* int i;*/ int res = 1; gint val; parser_context *ctx = (parser_context *) cb_ctx; char *buf = malloc(strl + 1); if(!buf) return 0; strncpy(buf, (char *) strval, strl); buf[strl] = '\0'; val = wg_encode_str(ctx->db, buf, NULL); if(val == WG_ILLEGAL) { res = 0; } else if(!add_literal(ctx, val)) { res = 0; } /* OUT_INDENT(ctx->stack_ptr+1, i, stdout) printf("STRING: %s\n", buf);*/ free(buf); return res; } static void print_cb(void *cb_ctx, const char *str, size_t len) { FILE *f = (FILE *) cb_ctx; fwrite(str, len, 1, f); } /* * Print a JSON document. If a callback is given, it * should be of type (void) (void *, char *, size_t) where the first * pointer will be cast to FILE * stream. Otherwise the document will * be written to stdout. */ void wg_print_json_document(void *db, void *cb, void *cb_ctx, void *document) { yajl_gen g; if(!is_schema_document(document)) { /* Paranoia check. This increases the probability we're dealing * with records belonging to a proper schema. Omitting this check * would allow printing parts of documents as well. */ show_json_error(db, "Given record is not a document"); return; } g = yajl_gen_alloc(NULL); yajl_gen_config(g, yajl_gen_beautify, 1); if(cb) { yajl_gen_config(g, yajl_gen_print_callback, (yajl_print_t *) cb, cb_ctx); } else { yajl_gen_config(g, yajl_gen_print_callback, print_cb, (void *) stdout); } pretty_print_json(db, &g, document); yajl_gen_free(g); } /* * Recursively print JSON elements (using the JSON schema) * Returns 0 on success * Returns -1 on error. */ static int pretty_print_json(void *db, yajl_gen *g, void *rec) { if(is_schema_object(rec)) { gint i, reclen; if(yajl_gen_map_open(*g) != yajl_gen_status_ok) { return show_json_error(db, "Formatter failure"); } reclen = wg_get_record_len(db, rec); for(i=0; i. * */ /** @file dbquery.c * WhiteDB query engine. */ /* ====== Includes =============== */ #include #include #include /* ====== Private headers and defs ======== */ #ifdef __cplusplus extern "C" { #endif #include "dballoc.h" #include "dbquery.h" #include "dbcompare.h" #include "dbmpool.h" #include "dbschema.h" #include "dbhash.h" /* T-tree based scoring */ #define TTREE_SCORE_EQUAL 5 #define TTREE_SCORE_BOUND 2 #define TTREE_SCORE_NULL -1 /** penalty for null values, which * are likely to be abundant */ #define TTREE_SCORE_MASK 5 /** matching field in template */ /* Query flags for internal use */ #define QUERY_FLAGS_PREFETCH 0x1000 #define QUERY_RESULTSET_PAGESIZE 63 /* mpool is aligned, so we can align * the result pages too by selecting an * appropriate size */ /* Emulate array index when doing a scan of key-value pairs * in a JSON query. * If this is not desirable, commenting this out makes * scans somewhat faster. */ #define JSON_SCAN_UNWRAP_ARRAY struct __query_result_page { gint rows[QUERY_RESULTSET_PAGESIZE]; struct __query_result_page *next; }; typedef struct __query_result_page query_result_page; typedef struct { query_result_page *page; /** current page of results */ gint pidx; /** current index on page (reading) */ } query_result_cursor; typedef struct { void *mpool; /** storage for row offsets */ query_result_page *first_page; /** first page of results, for rewinding */ query_result_cursor wcursor; /** read cursor */ query_result_cursor rcursor; /** write cursor */ gint res_count; /** number of rows in results */ } query_result_set; /* ======= Private protos ================ */ static gint most_restricting_column(void *db, wg_query_arg *arglist, gint argc, gint *index_id); static gint check_arglist(void *db, void *rec, wg_query_arg *arglist, gint argc); static gint prepare_params(void *db, void *matchrec, gint reclen, wg_query_arg *arglist, gint argc, wg_query_arg **farglist, gint *fargc); static gint find_ttree_bounds(void *db, gint index_id, gint col, gint start_bound, gint end_bound, gint start_inclusive, gint end_inclusive, gint *curr_offset, gint *curr_slot, gint *end_offset, gint *end_slot); static wg_query *internal_build_query(void *db, void *matchrec, gint reclen, wg_query_arg *arglist, gint argc, gint flags, wg_uint rowlimit); static query_result_set *create_resultset(void *db); static void free_resultset(void *db, query_result_set *set); static void rewind_resultset(void *db, query_result_set *set); static gint append_resultset(void *db, query_result_set *set, gint offset); static gint fetch_resultset(void *db, query_result_set *set); static query_result_set *intersect_resultset(void *db, query_result_set *seta, query_result_set *setb); static gint check_and_merge_by_kv(void *db, void *rec, wg_json_query_arg *arg, query_result_set *next_set); static gint check_and_merge_by_key(void *db, void *rec, wg_json_query_arg *arg, query_result_set *next_set); static gint check_and_merge_recursively(void *db, void *rec, wg_json_query_arg *arg, query_result_set *next_set, int depth); static gint prepare_json_arglist(void *db, wg_json_query_arg *arglist, wg_json_query_arg **sorted_arglist, gint argc, gint *index_id, gint *vindex_id, gint *kindex_id); static gint encode_query_param_unistr(void *db, char *data, gint type, char *extdata, int length); static gint show_query_error(void* db, char* errmsg); /*static gint show_query_error_nr(void* db, char* errmsg, gint nr);*/ /* ====== Functions ============== */ /** Find most restricting column from query argument list * This is probably a reasonable approach to optimize queries * based on T-tree indexes, but might be difficult to combine * with hash indexes. * XXX: currently only considers the existence of T-tree * index and nothing else. */ static gint most_restricting_column(void *db, wg_query_arg *arglist, gint argc, gint *index_id) { struct column_score { gint column; int score; int index_id; }; struct column_score *sc; int i, j, mrc_score = -1; gint mrc = -1; db_memsegment_header* dbh = dbmemsegh(db); sc = (struct column_score *) malloc(argc * sizeof(struct column_score)); if(!sc) { show_query_error(db, "Failed to allocate memory"); return -1; } /* Scan through the arguments and calculate accumulated score * for each column. */ for(i=0; iindex_control_area_header.index_table[sc[i].column]; while(*ilist) { gcell *ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); if(hdr->type == WG_INDEX_TYPE_TTREE) { #ifdef USE_INDEX_TEMPLATE /* If index templates are available, we can increase the * score of the index if the template has any columns matching * the query parameters. On the other hand, in case of a * mismatch the index is unusable and has to be skipped. * The indexes are sorted in the order of fixed columns in * the template, so if there is a match, the search is * complete (remaining index are likely to be worse) */ if(hdr->template_offset) { wg_index_template *tmpl = \ (wg_index_template *) offsettoptr(db, hdr->template_offset); void *matchrec = offsettoptr(db, tmpl->offset_matchrec); gint reclen = wg_get_record_len(db, matchrec); for(j=0; jcar; break; } } #ifdef USE_INDEX_TEMPLATE nextindex: #endif ilist = &ilistelem->cdr; } } if(!sc[i].index_id) sc[i].score = 0; /* no index, score reset */ if(sc[i].score > mrc_score) { mrc_score = sc[i].score; mrc = sc[i].column; *index_id = sc[i].index_id; } } /* TODO: does the best score have no index? In that case, * try to locate an index that would restrict at least * some columns. */ free(sc); return mrc; } /** Check a record against list of conditions * returns 1 if the record matches * returns 0 if the record fails at least one condition */ static gint check_arglist(void *db, void *rec, wg_query_arg *arglist, gint argc) { int i, reclen; reclen = wg_get_record_len(db, rec); for(i=0; inumber_of_elements <= cs) { /* Crossed node boundary */ co = TNODE_SUCCESSOR(db, node); cs = 0; } } else if(boundtype == DEAD_END_RIGHT_NOT_BOUNDING) { /* Since exact value was not found, this case is exactly * the same as with the inclusive range. */ node = (struct wg_tnode *) offsettoptr(db, co); co = TNODE_SUCCESSOR(db, node); cs = 0; } else if(boundtype == DEAD_END_LEFT_NOT_BOUNDING) { /* No exact value in tree, same as inclusive range */ cs = 0; } } } /* Finding of the end of the range is more or less opposite * of finding the beginning. */ if(end_bound==WG_ILLEGAL) { /* Rightmost node in index */ #ifdef TTREE_CHAINED_NODES eo = TTREE_MAX_NODE(hdr); #else /* GLB search on root node returns the rightmost node in tree */ eo = wg_ttree_find_glb_node(db, TTREE_ROOT_NODE(hdr)); #endif if(eo) { node = (struct wg_tnode *) offsettoptr(db, eo); es = node->number_of_elements - 1; /* rightmost slot */ } } else { gint boundtype; if(end_inclusive) { /* Find the rightmost node with a given value and the * righmost slot that is equal or smaller than that value */ eo = wg_search_ttree_rightmost(db, TTREE_ROOT_NODE(hdr), end_bound, &boundtype, NULL); if(boundtype == REALLY_BOUNDING_NODE) { es = wg_search_tnode_last(db, eo, end_bound, col); if(es == -1) { show_query_error(db, "Ending index node was bad"); return -1; } } else if(boundtype == DEAD_END_RIGHT_NOT_BOUNDING) { /* Last node containing values in range. */ node = (struct wg_tnode *) offsettoptr(db, eo); es = node->number_of_elements - 1; } else if(boundtype == DEAD_END_LEFT_NOT_BOUNDING) { /* Previous node should be in range. */ node = (struct wg_tnode *) offsettoptr(db, eo); eo = TNODE_PREDECESSOR(db, node); if(eo) { node = (struct wg_tnode *) offsettoptr(db, eo); es = node->number_of_elements - 1; /* rightmost */ } } } else { /* For non-inclusive, we need the leftmost node and * the first slot-1. */ eo = wg_search_ttree_leftmost(db, TTREE_ROOT_NODE(hdr), end_bound, &boundtype, NULL); if(boundtype == REALLY_BOUNDING_NODE) { es = wg_search_tnode_first(db, eo, end_bound, col); if(es == -1) { show_query_error(db, "Ending index node was bad"); return -1; } es--; if(es < 0) { /* Crossed node boundary */ node = (struct wg_tnode *) offsettoptr(db, eo); eo = TNODE_PREDECESSOR(db, node); if(eo) { node = (struct wg_tnode *) offsettoptr(db, eo); es = node->number_of_elements - 1; } } } else if(boundtype == DEAD_END_RIGHT_NOT_BOUNDING) { /* No exact value in tree, same as inclusive range */ node = (struct wg_tnode *) offsettoptr(db, eo); es = node->number_of_elements - 1; } else if(boundtype == DEAD_END_LEFT_NOT_BOUNDING) { /* No exact value in tree, same as inclusive range */ node = (struct wg_tnode *) offsettoptr(db, eo); eo = TNODE_PREDECESSOR(db, node); if(eo) { node = (struct wg_tnode *) offsettoptr(db, eo); es = node->number_of_elements - 1; /* rightmost slot */ } } } } /* Now detect the cases where the above bound search * has produced a result with an empty range. */ if(co) { /* Value could be bounded inside a node, but actually * not present. Note that we require the end_slot to be * >= curr_slot, this implies that query->direction == 1. */ if(eo == co && es < cs) { co = 0; /* query will return no rows */ eo = 0; } else if(!eo) { /* If one offset is 0 the other should be forced to 0, so that * if we want to switch direction we won't run into any surprises. */ co = 0; } else { /* Another case we have to watch out for is when we have a * range that fits in the space between two nodes. In that case * the end offset will end up directly left of the start offset. */ node = (struct wg_tnode *) offsettoptr(db, co); if(eo == TNODE_PREDECESSOR(db, node)) { co = 0; /* no rows */ eo = 0; } } } else { eo = 0; /* again, if one offset is 0, * the other should be, too */ } *curr_offset = co; *curr_slot = cs; *end_offset = eo; *end_slot = es; return 0; } /** Create a query object. * * matchrec - array of encoded integers. Can be a pointer to a database record * or a user-allocated array. If reclen is 0, it is treated as a native * database record. If reclen is non-zero, reclen number of gint-sized * words is read, starting from the pointer. * * Fields of type WG_VARTYPE in matchrec are treated as wildcards. Other * types, including NULL, are used as "equals" conditions. * * arglist - array of wg_query_arg objects. The size is must be given * by argc. * * flags - type of query requested and other parameters * * rowlimit - maximum number of rows fetched. Only has an effect if * QUERY_FLAGS_PREFETCH is set. * * returns NULL if constructing the query fails. Otherwise returns a pointer * to a wg_query object. */ static wg_query *internal_build_query(void *db, void *matchrec, gint reclen, wg_query_arg *arglist, gint argc, gint flags, wg_uint rowlimit) { wg_query *query; wg_query_arg *full_arglist; gint fargc = 0; gint col, index_id = -1; int i; #ifdef CHECK if (!dbcheck(db)) { /* XXX: currently show_query_error would work too */ #ifdef WG_NO_ERRPRINT #else fprintf(stderr, "Invalid database pointer in wg_make_query.\n"); #endif return NULL; } #endif /* Check and prepare the parameters. If there was an error, * prepare_params() does it's own cleanup so we can (and should) * return immediately. */ if(prepare_params(db, matchrec, reclen, arglist, argc, &full_arglist, &fargc)) { return NULL; } query = (wg_query *) malloc(sizeof(wg_query)); if(!query) { show_query_error(db, "Failed to allocate memory"); if(full_arglist) free(full_arglist); return NULL; } if(fargc) { /* Find the best (hopefully) index to base the query on. * Then initialise the query object to the first row in the * query result set. * XXX: only considering T-tree indexes now. */ col = most_restricting_column(db, full_arglist, fargc, &index_id); } else { /* Create a "full scan" query with no arguments. */ index_id = -1; full_arglist = NULL; /* redundant/paranoia */ } if(index_id > 0) { int start_inclusive = 0, end_inclusive = 0; gint start_bound = WG_ILLEGAL; /* encoded values */ gint end_bound = WG_ILLEGAL; query->qtype = WG_QTYPE_TTREE; query->column = col; query->curr_offset = 0; query->curr_slot = -1; query->end_offset = 0; query->end_slot = -1; query->direction = 1; /* Determine the bounds for the given column/index. * * Examples of using rightmost and leftmost bounds in T-tree queries: * val = 5 ==> * find leftmost (A) and rightmost (B) nodes that contain value 5. * Follow nodes sequentially from A until B is reached. * val > 1 & val < 7 ==> * find rightmost node with value 1 (A). Find leftmost node with * value 7 (B). Find the rightmost value in A that still equals 1. * The value immediately to the right is the beginning of the result * set and the value immediately to the left of the first occurrence * of 7 in B is the end of the result set. * val > 1 & val <= 7 ==> * A is the same as above. Find rightmost node with value 7 (B). The * beginning of the result set is the same as above, the end is the * last slot in B with value 7. * val <= 1 ==> * find rightmost node with value 1. Find the last (rightmost) slot * containing 1. The result set begins with that value, scan left * until the end of chain is reached. */ for(i=0; i= 1 & val <= 1 */ if(start_bound==WG_ILLEGAL ||\ WG_COMPARE(db, start_bound, full_arglist[i].value)==WG_LESSTHAN) { start_bound = full_arglist[i].value; start_inclusive = 1; } if(end_bound==WG_ILLEGAL ||\ WG_COMPARE(db, end_bound, full_arglist[i].value)==WG_GREATER) { end_bound = full_arglist[i].value; end_inclusive = 1; } break; case WG_COND_LESSTHAN: /* No earlier right bound or new end bound is a smaller * value (reducing the result set). The result set is also * possibly reduced if the value is equal, because this * condition is non-inclusive. */ if(end_bound==WG_ILLEGAL ||\ WG_COMPARE(db, end_bound, full_arglist[i].value)!=WG_LESSTHAN) { end_bound = full_arglist[i].value; end_inclusive = 0; } break; case WG_COND_GREATER: /* No earlier left bound or new left bound is >= of old value */ if(start_bound==WG_ILLEGAL ||\ WG_COMPARE(db, start_bound, full_arglist[i].value)!=WG_GREATER) { start_bound = full_arglist[i].value; start_inclusive = 0; } break; case WG_COND_LTEQUAL: /* Similar to "less than", but inclusive */ if(end_bound==WG_ILLEGAL ||\ WG_COMPARE(db, end_bound, full_arglist[i].value)==WG_GREATER) { end_bound = full_arglist[i].value; end_inclusive = 1; } break; case WG_COND_GTEQUAL: /* Similar to "greater", but inclusive */ if(start_bound==WG_ILLEGAL ||\ WG_COMPARE(db, start_bound, full_arglist[i].value)==WG_LESSTHAN) { start_bound = full_arglist[i].value; start_inclusive = 1; } break; case WG_COND_NOT_EQUAL: /* Force use of full argument list to check each row in the result * set since we have a condition we cannot satisfy using * a continuous range of T-tree values alone */ query->column = -1; break; default: show_query_error(db, "Invalid condition (ignoring)"); break; } } /* Simple sanity check. Is start_bound greater than end_bound? */ if(start_bound!=WG_ILLEGAL && end_bound!=WG_ILLEGAL &&\ WG_COMPARE(db, start_bound, end_bound) == WG_GREATER) { /* return empty query */ query->argc = 0; query->arglist = NULL; free(full_arglist); return query; } /* Now find the bounding nodes for the query */ if(find_ttree_bounds(db, index_id, col, start_bound, end_bound, start_inclusive, end_inclusive, &query->curr_offset, &query->curr_slot, &query->end_offset, &query->end_slot)) { free(query); free(full_arglist); return NULL; } /* XXX: here we can reverse the direction and switch the start and * end nodes/slots, if "descending" sort order is needed. */ } else { /* Nothing better than full scan available */ void *rec; query->qtype = WG_QTYPE_SCAN; query->column = -1; /* no special column, entire argument list * should be checked for each row */ rec = wg_get_first_record(db); if(rec) query->curr_record = ptrtooffset(db, rec); else query->curr_record = 0; } /* Now attach the argument list to the query. If the query is based * on a column index, we will create a slimmer copy that does not contain * the conditions already satisfied by the index bounds. */ if(query->column == -1) { query->arglist = full_arglist; query->argc = fargc; } else { int cnt = 0; for(i=0; icolumn) cnt++; } /* The argument list is reduced, but still contains columns */ if(cnt) { int j; query->arglist = (wg_query_arg *) malloc(cnt * sizeof(wg_query_arg)); if(!query->arglist) { show_query_error(db, "Failed to allocate memory"); free(query); free(full_arglist); return NULL; } for(i=0, j=0; icolumn) { query->arglist[j].column = full_arglist[i].column; query->arglist[j].cond = full_arglist[i].cond; query->arglist[j++].value = full_arglist[i].value; } } } else query->arglist = NULL; query->argc = cnt; free(full_arglist); /* Now we have a reduced argument list, free * the original one */ } /* Now handle any post-processing required. */ if(flags & QUERY_FLAGS_PREFETCH) { query_result_page **prevnext; query_result_page *currpage; void *rec; query->curr_page = NULL; /* initialize as empty */ query->curr_pidx = 0; query->res_count = 0; /* XXX: could move this inside the loop (speeds up empty * query, slows down other queries) */ query->mpool = wg_create_mpool(db, sizeof(query_result_page)); if(!query->mpool) { show_query_error(db, "Failed to allocate result memory pool"); wg_free_query(db, query); return NULL; } i = QUERY_RESULTSET_PAGESIZE; prevnext = (query_result_page **) &(query->curr_page); while((rec = wg_fetch(db, query))) { if(i >= QUERY_RESULTSET_PAGESIZE) { currpage = (query_result_page *) \ wg_alloc_mpool(db, query->mpool, sizeof(query_result_page)); if(!currpage) { show_query_error(db, "Failed to allocate a resultset row"); wg_free_query(db, query); return NULL; } memset(currpage->rows, 0, sizeof(gint) * QUERY_RESULTSET_PAGESIZE); *prevnext = currpage; prevnext = &(currpage->next); currpage->next = NULL; i = 0; } currpage->rows[i++] = ptrtooffset(db, rec); query->res_count++; if(rowlimit && query->res_count >= rowlimit) break; } /* Finally, convert the query type. */ query->qtype = WG_QTYPE_PREFETCH; } return query; } /** Create a query object and pre-fetch all data rows. * * Allocates enough space to hold all row offsets, fetches them and stores * them in an array. Isolation is not guaranteed in any way, shape or form, * but can be implemented on top by the user. * * returns NULL if constructing the query fails. Otherwise returns a pointer * to a wg_query object. */ wg_query *wg_make_query(void *db, void *matchrec, gint reclen, wg_query_arg *arglist, gint argc) { return internal_build_query(db, matchrec, reclen, arglist, argc, QUERY_FLAGS_PREFETCH, 0); } /** Create a query object and pre-fetch rowlimit number of rows. * * returns NULL if constructing the query fails. Otherwise returns a pointer * to a wg_query object. */ wg_query *wg_make_query_rc(void *db, void *matchrec, gint reclen, wg_query_arg *arglist, gint argc, wg_uint rowlimit) { return internal_build_query(db, matchrec, reclen, arglist, argc, QUERY_FLAGS_PREFETCH, rowlimit); } /** Return next record from the query object * returns NULL if no more records */ void *wg_fetch(void *db, wg_query *query) { void *rec; #ifdef CHECK if (!dbcheck(db)) { /* XXX: currently show_query_error would work too */ #ifdef WG_NO_ERRPRINT #else fprintf(stderr, "Invalid database pointer in wg_fetch.\n"); #endif return NULL; } if(!query) { show_query_error(db, "Invalid query object"); return NULL; } #endif if(query->qtype == WG_QTYPE_SCAN) { for(;;) { void *next; if(!query->curr_record) { /* Query exhausted */ return NULL; } rec = offsettoptr(db, query->curr_record); /* Pre-fetch the next record */ next = wg_get_next_record(db, rec); if(next) query->curr_record = ptrtooffset(db, next); else query->curr_record = 0; /* Check the record against all conditions; if it does * not match, go to next iteration. */ if(!query->arglist || \ check_arglist(db, rec, query->arglist, query->argc)) return rec; } } else if(query->qtype == WG_QTYPE_TTREE) { struct wg_tnode *node; for(;;) { if(!query->curr_offset) { /* No more nodes to examine */ return NULL; } node = (struct wg_tnode *) offsettoptr(db, query->curr_offset); rec = offsettoptr(db, node->array_of_values[query->curr_slot]); /* Increment the slot/and or node cursors before we * return. If the current node does not satisfy the * argument list we may need to do this multiple times. */ if(query->curr_offset==query->end_offset && \ query->curr_slot==query->end_slot) { /* Last slot reached, mark the query as exchausted */ query->curr_offset = 0; } else { /* Some rows still left */ query->curr_slot += query->direction; if(query->curr_slot < 0) { #ifdef CHECK if(query->end_offset==query->curr_offset) { /* This should not happen */ show_query_error(db, "Warning: end slot mismatch, possible bug"); query->curr_offset = 0; } else { #endif query->curr_offset = TNODE_PREDECESSOR(db, node); if(query->curr_offset) { node = (struct wg_tnode *) offsettoptr(db, query->curr_offset); query->curr_slot = node->number_of_elements - 1; } #ifdef CHECK } #endif } else if(query->curr_slot >= node->number_of_elements) { #ifdef CHECK if(query->end_offset==query->curr_offset) { /* This should not happen */ show_query_error(db, "Warning: end slot mismatch, possible bug"); query->curr_offset = 0; } else { #endif query->curr_offset = TNODE_SUCCESSOR(db, node); query->curr_slot = 0; #ifdef CHECK } #endif } } /* If there are no extra conditions or the row satisfies * all the conditions, we can return. */ if(!query->arglist || \ check_arglist(db, rec, query->arglist, query->argc)) return rec; } } if(query->qtype == WG_QTYPE_PREFETCH) { if(query->curr_page) { query_result_page *currpage = (query_result_page *) query->curr_page; gint offset = currpage->rows[query->curr_pidx++]; if(!offset) { /* page not filled completely */ query->curr_page = NULL; return NULL; } else { if(query->curr_pidx >= QUERY_RESULTSET_PAGESIZE) { query->curr_page = (void *) (currpage->next); query->curr_pidx = 0; } } return offsettoptr(db, offset); } else return NULL; } else { show_query_error(db, "Unsupported query type"); return NULL; } } /** Release the memory allocated for the query */ void wg_free_query(void *db, wg_query *query) { if(query->arglist) free(query->arglist); if(query->qtype==WG_QTYPE_PREFETCH && query->mpool) wg_free_mpool(db, query->mpool); free(query); } /* ----------- query parameter preparing functions -------------*/ /* Types that use no storage are encoded * using standard API functions. */ gint wg_encode_query_param_null(void *db, char *data) { return wg_encode_null(db, data); } gint wg_encode_query_param_record(void *db, void *data) { return wg_encode_record(db, data); } gint wg_encode_query_param_char(void *db, char data) { return wg_encode_char(db, data); } gint wg_encode_query_param_fixpoint(void *db, double data) { return wg_encode_fixpoint(db, data); } gint wg_encode_query_param_date(void *db, int data) { return wg_encode_date(db, data); } gint wg_encode_query_param_time(void *db, int data) { return wg_encode_time(db, data); } gint wg_encode_query_param_var(void *db, gint data) { return wg_encode_var(db, data); } /* Types using storage are encoded by emulating the behaviour * of dbdata.c functions. Some assumptions are made about storage * size of the data (but similar assumptions exist in dbdata.c) */ gint wg_encode_query_param_int(void *db, gint data) { void *dptr; if(fits_smallint(data)) { return encode_smallint(data); } else { dptr=malloc(sizeof(gint)); if(!dptr) { show_query_error(db, "Failed to encode query parameter"); return WG_ILLEGAL; } *((gint *) dptr) = data; return encode_fullint_offset(ptrtooffset(db, dptr)); } } gint wg_encode_query_param_double(void *db, double data) { void *dptr; dptr=malloc(2*sizeof(gint)); if(!dptr) { show_query_error(db, "Failed to encode query parameter"); return WG_ILLEGAL; } *((double *) dptr) = data; return encode_fulldouble_offset(ptrtooffset(db, dptr)); } gint wg_encode_query_param_str(void *db, char *data, char *lang) { if(data) { return encode_query_param_unistr(db, data, WG_STRTYPE, lang, strlen(data)); } else { show_query_error(db, "NULL pointer given as parameter"); return WG_ILLEGAL; } } gint wg_encode_query_param_xmlliteral(void *db, char *data, char *xsdtype) { if(data) { return encode_query_param_unistr(db, data, WG_XMLLITERALTYPE, xsdtype, strlen(data)); } else { show_query_error(db, "NULL pointer given as parameter"); return WG_ILLEGAL; } } gint wg_encode_query_param_uri(void *db, char *data, char *prefix) { if(data) { return encode_query_param_unistr(db, data, WG_URITYPE, prefix, strlen(data)); } else { show_query_error(db, "NULL pointer given as parameter"); return WG_ILLEGAL; } } /* Encode shortstr- or longstr-compatible data in local memory. * string type without lang is handled as "short", ignoring the * actual length. All other types require longstr storage to * handle the extdata field. */ static gint encode_query_param_unistr(void *db, char *data, gint type, char *extdata, int length) { void *dptr; if(type == WG_STRTYPE && extdata == NULL) { dptr=malloc(length+1); if(!dptr) { show_query_error(db, "Failed to encode query parameter"); return WG_ILLEGAL; } memcpy((char *) dptr, data, length); ((char *) dptr)[length] = '\0'; return encode_shortstr_offset(ptrtooffset(db, dptr)); } else { size_t i; int extlen = 0; int dlen, lengints, lenrest; gint offset, meta; if(type != WG_BLOBTYPE) length++; /* include the terminating 0 */ /* Determine storage size */ lengints = length / sizeof(gint); lenrest = length % sizeof(gint); if(lenrest) lengints++; dlen = sizeof(gint) * (LONGSTR_HEADER_GINTS + lengints); /* Emulate the behaviour of wg_alloc_gints() */ if(dlen < MIN_VARLENOBJ_SIZE) dlen = MIN_VARLENOBJ_SIZE; if(dlen % 8) dlen += 4; if(extdata) { extlen = strlen(extdata); } dptr=malloc(dlen + (extdata ? extlen + 1 : 0)); if(!dptr) { show_query_error(db, "Failed to encode query parameter"); return WG_ILLEGAL; } offset = ptrtooffset(db, dptr); /* Copy the data, fill the remainder with zeroes */ memcpy((char *) dptr + (LONGSTR_HEADER_GINTS*sizeof(gint)), data, length); for(i=0; lenrest && ircursor.page = NULL; /* initialize as empty */ set->rcursor.pidx = 0; set->wcursor.page = NULL; set->wcursor.pidx = QUERY_RESULTSET_PAGESIZE; /* new page needed */ set->first_page = NULL; set->res_count = 0; set->mpool = wg_create_mpool(db, sizeof(query_result_page)); if(!set->mpool) { show_query_error(db, "Failed to allocate result memory pool"); free(set); return NULL; } return set; } /* * Free the resultset and it's memory pool */ static void free_resultset(void *db, query_result_set *set) { if(set->mpool) wg_free_mpool(db, set->mpool); free(set); } /* * Set the resultset pointers to the beginning of the * first results page. */ static void rewind_resultset(void *db, query_result_set *set) { set->rcursor.page = set->first_page; set->rcursor.pidx = 0; } /* * Append an offset to the result set. * returns 0 on success. * returns -1 on error. */ static gint append_resultset(void *db, query_result_set *set, gint offset) { if(set->wcursor.pidx >= QUERY_RESULTSET_PAGESIZE) { query_result_page *newpage = (query_result_page *) \ wg_alloc_mpool(db, set->mpool, sizeof(query_result_page)); if(!newpage) { return show_query_error(db, "Failed to allocate a resultset page"); } memset(newpage->rows, 0, sizeof(gint) * QUERY_RESULTSET_PAGESIZE); newpage->next = NULL; if(set->wcursor.page) { set->wcursor.page->next = newpage; } else { /* first_page==NULL implied */ set->first_page = newpage; set->rcursor.page = newpage; } set->wcursor.page = newpage; set->wcursor.pidx = 0; } set->wcursor.page->rows[set->wcursor.pidx++] = offset; set->res_count++; return 0; } /* * Fetch the next offset from the result set. * returns 0 if the set is exhausted. */ static gint fetch_resultset(void *db, query_result_set *set) { if(set->rcursor.page) { gint offset = set->rcursor.page->rows[set->rcursor.pidx++]; if(!offset) { /* page not filled completely. Mark set as exhausted. */ set->rcursor.page = NULL; } else { if(set->rcursor.pidx >= QUERY_RESULTSET_PAGESIZE) { set->rcursor.page = set->rcursor.page->next; set->rcursor.pidx = 0; } } return offset; } return 0; } #define NESTEDLOOP 0 #define HASHJOIN 1 /* * Create an intersection of two result sets. * Join strategy: * if the number of inner loops expected is low (i.e. the sets * are small), nested loop join is used. Otherwise, hash join * is used. * * Returns a new result set (can be empty). * Returns NULL on error. */ static query_result_set *intersect_resultset(void *db, query_result_set *seta, query_result_set *setb) { query_result_set *intersection; int strategy = HASHJOIN; if(!(intersection = create_resultset(db))) { return NULL; } if(seta->res_count * setb->res_count < 200) { strategy = NESTEDLOOP; /* don't bother with hash table */ } if(strategy == HASHJOIN) { void *hasht = NULL; gint offset; if(seta->res_count > setb->res_count) { query_result_set *tmp = seta; seta = setb; setb = tmp; } if(!(hasht = wg_dhash_init(db, seta->res_count))) { free_resultset(db, intersection); return NULL; } rewind_resultset(db, seta); while((offset = fetch_resultset(db, seta))) { if(wg_dhash_addkey(db, hasht, offset)) { free_resultset(db, intersection); wg_dhash_free(db, hasht); return NULL; } } rewind_resultset(db, setb); while((offset = fetch_resultset(db, setb))) { if(wg_dhash_haskey(db, hasht, offset)) { gint err = append_resultset(db, intersection, offset); if(err) { free_resultset(db, intersection); wg_dhash_free(db, hasht); return NULL; } } } wg_dhash_free(db, hasht); } else { /* nested loop strategy */ gint offseta; rewind_resultset(db, seta); while((offseta = fetch_resultset(db, seta))) { gint offsetb; rewind_resultset(db, setb); while((offsetb = fetch_resultset(db, setb))) { if(offseta == offsetb) { gint err = append_resultset(db, intersection, offseta); if(err) { free_resultset(db, intersection); return NULL; } break; } } } } return intersection; } /* * Create a result set that contains only unique rows. * Uniqueness test uses similar strategy to the intersect function * (hash table for membership test, but revert to nested loop if * low number of elements). * * Returns a new result set (can be empty). * Returns NULL on error. */ static query_result_set *unique_resultset(void *db, query_result_set *set) { gint offset; query_result_set *unique; int strategy = HASHJOIN; if(!(unique = create_resultset(db))) { return NULL; } if(set->res_count < 20) { strategy = NESTEDLOOP; /* don't bother with hash table */ } rewind_resultset(db, set); if(strategy == HASHJOIN) { void *hasht = NULL; if(!(hasht = wg_dhash_init(db, set->res_count))) { free_resultset(db, unique); return NULL; } while((offset = fetch_resultset(db, set))) { if(!wg_dhash_haskey(db, hasht, offset)) { gint err = append_resultset(db, unique, offset); if(!err) { err = wg_dhash_addkey(db, hasht, offset); } if(err) { free_resultset(db, unique); wg_dhash_free(db, hasht); return NULL; } } } wg_dhash_free(db, hasht); } else { /* nested loop */ while((offset = fetch_resultset(db, set))) { gint offsetu, found = 0; rewind_resultset(db, unique); while((offsetu = fetch_resultset(db, unique))) { if(offset == offsetu) { found = 1; break; } } if(!found) { /* We're now at the end of the set and may append normally. */ gint err = append_resultset(db, unique, offset); if(err) { free_resultset(db, unique); return NULL; } } } } return unique; } /* ------------------- (JSON) document query -------------------*/ /* Note the non-conventional return code values: * -1 adding the document failed * 1 adding the document succeeded * (0 is reserved for using this macro in a recursive function * to differentiate between matches and non-matches) */ #define ADD_DOC_TO_RESULTSET(db, rec, ns, rc) \ void *doc = wg_find_document(db, rec); \ if(doc) { \ if(!append_resultset(db, ns, ptrtooffset(db, doc))) \ rc = 1; \ else \ rc = -1; \ } else { \ rc = show_query_error(db, "Failed to retrieve the document"); \ } #define IF_ERR_CLEAN_UP(db, cr, ns, al, rc) \ if(rc < 0) { \ free_resultset(db, ns); \ if(cr) \ free_resultset(db, cr); \ if(al) \ free(al); \ return NULL; \ } #define ARGLIST_CLEANUP(al) \ if(al) \ free(al); #define ADD_DOC_ARRAY_UNWRAP(db, rec, ns, rc, k, v) \ void *arec = wg_decode_record(db, k); \ if(is_schema_array(arec)) { \ gint areclen = wg_get_record_len(db, arec); \ int j; \ for(j=0; j WG_SCHEMA_VALUE_OFFSET) { /* XXX: assume key * before value */ #ifndef JSON_SCAN_UNWRAP_ARRAY if(WG_COMPARE(db, wg_get_field(db, rec, WG_SCHEMA_KEY_OFFSET), arg->key) == WG_EQUAL &&\ WG_COMPARE(db, wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET), arg->value) == WG_EQUAL) { ADD_DOC_TO_RESULTSET(db, rec, next_set, rc) } #else if(WG_COMPARE(db, wg_get_field(db, rec, WG_SCHEMA_KEY_OFFSET), arg->key) == WG_EQUAL) { gint k = wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET); if(WG_COMPARE(db, k, arg->value) == WG_EQUAL) { /* Direct match. */ ADD_DOC_TO_RESULTSET(db, rec, next_set, rc) } else if(wg_get_encoded_type(db, k) == WG_RECORDTYPE) { /* No direct match, but if it is a record AND an array, * scan the array contents. */ ADD_DOC_ARRAY_UNWRAP(db, rec, next_set, rc, k, arg->value) } } #endif } return rc; } /* * Like check_and_merge_by_kv() except key comparison is skipped * (i.e. the caller is iterating over key index) */ static gint check_and_merge_by_key(void *db, void *rec, wg_json_query_arg *arg, query_result_set *next_set) { gint rc = 0; gint reclen = wg_get_record_len(db, rec); if(reclen > WG_SCHEMA_VALUE_OFFSET) { #ifndef JSON_SCAN_UNWRAP_ARRAY if(WG_COMPARE(db, wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET), arg->value) == WG_EQUAL) { ADD_DOC_TO_RESULTSET(db, rec, next_set, rc) } #else gint k = wg_get_field(db, rec, WG_SCHEMA_VALUE_OFFSET); if(WG_COMPARE(db, k, arg->value) == WG_EQUAL) { ADD_DOC_TO_RESULTSET(db, rec, next_set, rc) } else if(wg_get_encoded_type(db, k) == WG_RECORDTYPE) { ADD_DOC_ARRAY_UNWRAP(db, rec, next_set, rc, k, arg->value) } #endif } return rc; } /* * Check if the record or any of its children matches * the given key/value pair. The search is stopped upon * the first match. * * returns 1 if the record matches and is added to the resultset * returns 0 if the record does not match * returns -1 if the record matches, but adding fails */ static gint check_and_merge_recursively(void *db, void *rec, wg_json_query_arg *arg, query_result_set *next_set, int depth) { gint i, reclen, rc; rc = check_and_merge_by_kv(db, rec, arg, next_set); if(rc) /* successful match or an error */ return rc; if(depth <= 0) { return show_query_error(db, "scanning document: recursion too deep"); } reclen = wg_get_record_len(db, rec); for(i=0; i 1) { /* There is something to sort. In the future we can also sort by * cardinality here (provided that stats are available). */ gint i, j; tmp = malloc(sizeof(wg_json_query_arg) * argc); if(!tmp) { return show_query_error(db, "Failed to prepare query arguments"); } /* First pass: literal values only */ for(i=0, j=0; i 0 &&\ wg_get_encoded_type(db, arglist[i].value) != WG_RECORDTYPE) { /* Fetch the matching rows from the index, then retrieve the * documents they belong to. */ gint values[2]; gint reclist_offset; values[0] = arglist[i].key; values[1] = arglist[i].value; reclist_offset = wg_search_hash(db, index_id, values, 2); if(reclist_offset > 0) { gint *nextoffset = &reclist_offset; while(*nextoffset) { gcell *rec_cell = (gcell *) offsettoptr(db, *nextoffset); gint rc = -1; ADD_DOC_TO_RESULTSET(db, offsettoptr(db, rec_cell->car), next_set, rc) IF_ERR_CLEAN_UP(db, curr_res, next_set, sorted_arglist, rc) nextoffset = &(rec_cell->cdr); } } } #if 0 else if(vindex_id > 0) { /* XXX: unimplemented: scan T-tree for values */ } #endif else if(kindex_id > 0) { /* Hash index not usable, do a scan but leverage an index on the * key field to reduce the number of records visited. */ gint curr_offset = 0, curr_slot = -1, end_offset = 0, end_slot = -1; if(find_ttree_bounds(db, kindex_id, WG_SCHEMA_KEY_OFFSET, arglist[i].key, arglist[i].key, 1, 1, &curr_offset, &curr_slot, &end_offset, &end_slot)) { curr_offset = 0; } while(curr_offset) { gint rc; struct wg_tnode *node = (struct wg_tnode *) offsettoptr(db, curr_offset); void *rec = offsettoptr(db, node->array_of_values[curr_slot]); rc = check_and_merge_by_key(db, rec, &arglist[i], next_set); IF_ERR_CLEAN_UP(db, curr_res, next_set, sorted_arglist, rc) if(curr_offset==end_offset && curr_slot==end_slot) { break; } else { curr_slot += 1; /* direction implied as 1 */ if(curr_slot >= node->number_of_elements) { #ifdef CHECK if(end_offset==curr_offset) { show_query_error(db, "Warning: end slot mismatch, possible bug"); break; } else { #endif curr_offset = TNODE_SUCCESSOR(db, node); curr_slot = 0; #ifdef CHECK } #endif } } } } else if(curr_res) { /* No index, do a scan over the current resultset. This also happens if * the value is a complex structure. */ gint offset; rewind_resultset(db, curr_res); while((offset = fetch_resultset(db, curr_res))) { gint *rec = offsettoptr(db, offset); #ifndef USE_BACKLINKING gint rc = check_and_merge_recursively(db, rec, &arglist[i], next_set, 99); #else gint rc = check_and_merge_recursively(db, rec, &arglist[i], next_set, WG_COMPARE_REC_DEPTH); #endif IF_ERR_CLEAN_UP(db, curr_res, next_set, sorted_arglist, rc) } /* Skip merge in this iteration, next_set is a subset of curr_res */ free_resultset(db, curr_res); curr_res = NULL; } else { /* No index and no intermediate result to use, full * scan of database required. */ gint *rec = wg_get_first_record(db); while(rec) { gint rc = check_and_merge_by_kv(db, rec, &arglist[i], next_set); IF_ERR_CLEAN_UP(db, curr_res, next_set, sorted_arglist, rc) rec = wg_get_next_record(db, rec); } } /* Delete duplicate documents */ tmp_set = unique_resultset(db, next_set); free_resultset(db, next_set); if(!tmp_set) { if(curr_res) free_resultset(db, curr_res); ARGLIST_CLEANUP(sorted_arglist) return NULL; } else { next_set = tmp_set; } /* Update the query result */ if(curr_res) { /* Working resultset exists, create an intersection */ tmp_set = intersect_resultset(db, curr_res, next_set); free_resultset(db, curr_res); free_resultset(db, next_set); if(!tmp_set) { ARGLIST_CLEANUP(sorted_arglist) return NULL; } else { curr_res = tmp_set; } } else { /* This set becomes the working resultset */ curr_res = next_set; } } ARGLIST_CLEANUP(sorted_arglist) /* Initialize query object */ query = (wg_query *) malloc(sizeof(wg_query)); if(!query) { free_resultset(db, curr_res); show_query_error(db, "Failed to allocate memory"); return NULL; } query->qtype = WG_QTYPE_PREFETCH; query->arglist = NULL; query->argc = 0; query->column = -1; /* Copy the result. */ query->curr_page = curr_res->first_page; query->curr_pidx = 0; query->res_count = curr_res->res_count; query->mpool = curr_res->mpool; free(curr_res); /* contents were inherited, dispose of the struct */ return query; } /* ------------------ simple query functions -------------------*/ void *wg_find_record(void *db, gint fieldnr, gint cond, gint data, void* lastrecord) { gint index_id = -1; /* find index on colum */ if(cond != WG_COND_NOT_EQUAL) { index_id = wg_multi_column_to_index_id(db, &fieldnr, 1, WG_INDEX_TYPE_TTREE, NULL, 0); } if(index_id > 0) { int start_inclusive = 1, end_inclusive = 1; /* WG_ILLEGAL is interpreted as "no bound" */ gint start_bound = WG_ILLEGAL; gint end_bound = WG_ILLEGAL; gint curr_offset = 0, curr_slot = -1, end_offset = 0, end_slot = -1; void *prev = NULL; switch(cond) { case WG_COND_EQUAL: start_bound = end_bound = data; break; case WG_COND_LESSTHAN: end_bound = data; end_inclusive = 0; break; case WG_COND_GREATER: start_bound = data; start_inclusive = 0; break; case WG_COND_LTEQUAL: end_bound = data; break; case WG_COND_GTEQUAL: start_bound = data; break; default: show_query_error(db, "Invalid condition (ignoring)"); return NULL; } if(find_ttree_bounds(db, index_id, fieldnr, start_bound, end_bound, start_inclusive, end_inclusive, &curr_offset, &curr_slot, &end_offset, &end_slot)) { return NULL; } /* We have the bounds, scan to lastrecord */ while(curr_offset) { struct wg_tnode *node = (struct wg_tnode *) offsettoptr(db, curr_offset); void *rec = offsettoptr(db, node->array_of_values[curr_slot]); if(prev == lastrecord) { /* if lastrecord is NULL, first match returned */ return rec; } prev = rec; if(curr_offset==end_offset && curr_slot==end_slot) { /* Last slot reached */ break; } else { /* Some rows still left */ curr_slot += 1; /* direction implied as 1 */ if(curr_slot >= node->number_of_elements) { #ifdef CHECK if(end_offset==curr_offset) { /* This should not happen */ show_query_error(db, "Warning: end slot mismatch, possible bug"); break; } else { #endif curr_offset = TNODE_SUCCESSOR(db, node); curr_slot = 0; #ifdef CHECK } #endif } } } } else { /* no index (or cond == WG_COND_NOT_EQUAL), do a scan */ wg_query_arg arg; void *rec; if(lastrecord) { rec = wg_get_next_record(db, lastrecord); } else { rec = wg_get_first_record(db); } arg.column = fieldnr; arg.cond = cond; arg.value = data; while(rec) { if(check_arglist(db, rec, &arg, 1)) { return rec; } rec = wg_get_next_record(db, rec); } } /* No records found (this can also happen if matching records were * found but lastrecord does not match any of them or matches the * very last one). */ return NULL; } /* * Wrapper function for wg_find_record with unencoded data (null) */ void *wg_find_record_null(void *db, gint fieldnr, gint cond, char *data, void* lastrecord) { gint enc = wg_encode_query_param_null(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); return rec; } /* * Wrapper function for wg_find_record with unencoded data (record) */ void *wg_find_record_record(void *db, gint fieldnr, gint cond, void *data, void* lastrecord) { gint enc = wg_encode_query_param_record(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); return rec; } /* * Wrapper function for wg_find_record with unencoded data (char) */ void *wg_find_record_char(void *db, gint fieldnr, gint cond, char data, void* lastrecord) { gint enc = wg_encode_query_param_char(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); return rec; } /* * Wrapper function for wg_find_record with unencoded data (fixpoint) */ void *wg_find_record_fixpoint(void *db, gint fieldnr, gint cond, double data, void* lastrecord) { gint enc = wg_encode_query_param_fixpoint(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); return rec; } /* * Wrapper function for wg_find_record with unencoded data (date) */ void *wg_find_record_date(void *db, gint fieldnr, gint cond, int data, void* lastrecord) { gint enc = wg_encode_query_param_date(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); return rec; } /* * Wrapper function for wg_find_record with unencoded data (time) */ void *wg_find_record_time(void *db, gint fieldnr, gint cond, int data, void* lastrecord) { gint enc = wg_encode_query_param_time(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); return rec; } /* * Wrapper function for wg_find_record with unencoded data (var) */ void *wg_find_record_var(void *db, gint fieldnr, gint cond, gint data, void* lastrecord) { gint enc = wg_encode_query_param_var(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); return rec; } /* * Wrapper function for wg_find_record with unencoded data (int) */ void *wg_find_record_int(void *db, gint fieldnr, gint cond, int data, void* lastrecord) { gint enc = wg_encode_query_param_int(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); wg_free_query_param(db, enc); return rec; } /* * Wrapper function for wg_find_record with unencoded data (double) */ void *wg_find_record_double(void *db, gint fieldnr, gint cond, double data, void* lastrecord) { gint enc = wg_encode_query_param_double(db, data); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); wg_free_query_param(db, enc); return rec; } /* * Wrapper function for wg_find_record with unencoded data (string) */ void *wg_find_record_str(void *db, gint fieldnr, gint cond, char *data, void* lastrecord) { gint enc = wg_encode_query_param_str(db, data, NULL); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); wg_free_query_param(db, enc); return rec; } /* * Wrapper function for wg_find_record with unencoded data (xmlliteral) */ void *wg_find_record_xmlliteral(void *db, gint fieldnr, gint cond, char *data, char *xsdtype, void* lastrecord) { gint enc = wg_encode_query_param_xmlliteral(db, data, xsdtype); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); wg_free_query_param(db, enc); return rec; } /* * Wrapper function for wg_find_record with unencoded data (uri) */ void *wg_find_record_uri(void *db, gint fieldnr, gint cond, char *data, char *prefix, void* lastrecord) { gint enc = wg_encode_query_param_uri(db, data, prefix); void *rec = wg_find_record(db, fieldnr, cond, enc, lastrecord); wg_free_query_param(db, enc); return rec; } /* --------------- error handling ------------------------------*/ /** called with err msg * * may print or log an error * does not do any jumps etc */ static gint show_query_error(void* db, char* errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"query error: %s\n",errmsg); #endif return -1; } #if 0 /** called with err msg and additional int data * * may print or log an error * does not do any jumps etc */ static gint show_query_error_nr(void* db, char* errmsg, gint nr) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"query error: %s %d\n",errmsg,nr); #endif return -1; } #endif #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dbutil.h0000644000175000001440000000507212421471034012047 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbutil.h * Public headers for miscellaneous functions. */ #ifndef DEFINED_DBUTIL_H #define DEFINED_DBUTIL_H #ifdef HAVE_RAPTOR #include #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* ====== data structures ======== */ #ifdef HAVE_RAPTOR struct wg_triple_handler_params { void *db; int pref_fields; /** number of fields preceeding the triple */ int suff_fields; /** number of fields to reserve at the end */ gint (*callback) (void *, void *); /** function called after *the triple is stored */ raptor_parser *rdf_parser; /** parser object */ int count; /** return status: rows parsed */ int error; /** return status: error level */ }; #endif /* ==== Protos ==== */ /* API functions (copied in dbapi.h) */ void wg_print_db(void *db); void wg_print_record(void *db, gint* rec); void wg_snprint_value(void *db, gint enc, char *buf, int buflen); gint wg_parse_and_encode(void *db, char *buf); gint wg_parse_and_encode_param(void *db, char *buf); void wg_export_db_csv(void *db, char *filename); gint wg_import_db_csv(void *db, char *filename); /* Separate raptor API (copied in rdfapi.h) */ #ifdef HAVE_RAPTOR gint wg_import_raptor_file(void *db, gint pref_fields, gint suff_fields, gint (*callback) (void *, void *), char *filename); gint wg_import_raptor_rdfxml_file(void *db, gint pref_fields, gint suff_fields, gint (*callback) (void *, void *), char *filename); gint wg_rdfparse_default_callback(void *db, void *rec); gint wg_export_raptor_file(void *db, gint pref_fields, char *filename, char *serializer); gint wg_export_raptor_rdfxml_file(void *db, gint pref_fields, char *filename); #endif void wg_pretty_print_memsize(gint memsz, char *buf, size_t buflen); #endif /* DEFINED_DBUTIL_H */ whitedb-0.7.3/Db/dbmem.h0000644000175000001440000000523612421471034011652 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbmem.h * Public headers for database memory handling. */ #ifndef DEFINED_DBMEM_H #define DEFINED_DBMEM_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #define DEFAULT_MEMDBASE_KEY 1000 //#define DEFAULT_MEMDBASE_SIZE 1000000 // 1 meg #define DEFAULT_MEMDBASE_SIZE 10000000 // 10 meg //#define DEFAULT_MEMDBASE_SIZE 800000000 // 800 meg //#define DEFAULT_MEMDBASE_SIZE 2000000000 #define MAX_FILENAME_SIZE 100 /* ====== data structures ======== */ /* ==== Protos ==== */ void* wg_attach_database(char* dbasename, gint size); // returns a pointer to the database, NULL if failure void* wg_attach_existing_database(char* dbasename); // like wg_attach_database, but does not create a new base void* wg_attach_logged_database(char* dbasename, gint size); // like wg_attach_database, but activates journal logging on creation void* wg_attach_database_mode(char* dbasename, gint size, int mode); // like wg_attach_database, set shared segment permissions to "mode" void* wg_attach_logged_database_mode(char* dbasename, gint size, int mode); // like above, activate journal logging void* wg_attach_memsegment(char* dbasename, gint minsize, gint size, int create, int logging, int mode); // same as wg_attach_database, does not check contents int wg_detach_database(void* dbase); // detaches a database: returns 0 if OK int wg_delete_database(char* dbasename); // deletes a database: returns 0 if OK int wg_check_header_compat(db_memsegment_header *dbh); // check memory image compatibility void wg_print_code_version(void); // show libwgdb version info void wg_print_header_version(db_memsegment_header *dbh, int verbose); // show version info from header void* wg_attach_local_database(gint size); void wg_delete_local_database(void* dbase); int wg_memmode(void *db); int wg_memowner(void *db); int wg_memgroup(void *db); #endif /* DEFINED_DBMEM_H */ whitedb-0.7.3/Db/dbcompare.h0000644000175000001440000000341112257043255012522 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbcompare.h * Public headers for data comparison functions. */ #ifndef DEFINED_DBCOMPARE_H #define DEFINED_DBCOMPARE_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* For gint data type */ #include "dbdata.h" /* ==== Public macros ==== */ #define WG_EQUAL 0 #define WG_GREATER 1 #define WG_LESSTHAN -1 /* If backlinking is enabled, records can be compared by their * contents instead of just pointers. With no backlinking this * is disabled so that records' comparative values do not change * when updating their contents. */ #ifdef USE_BACKLINKING #define WG_COMPARE_REC_DEPTH 7 /** recursion depth for record comparison */ #else #define WG_COMPARE_REC_DEPTH 0 #endif /* wrapper macro for wg_compare(), if encoded values are * equal they will also decode to an equal value and so * we can avoid calling the function. */ #define WG_COMPARE(d,a,b) (a==b ? WG_EQUAL :\ wg_compare(d,a,b,WG_COMPARE_REC_DEPTH)) /* ==== Protos ==== */ gint wg_compare(void *db, gint a, gint b, int depth); #endif /* DEFINED_DBCOMPARE_H */ whitedb-0.7.3/Db/crc1.h0000644000175000001440000001134112257032275011417 00000000000000/* * zlib/libpng license * Copyright (c) 2000-2004 mypapit * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the * use of this software. * * Permission is granted to anyone to use this software for any purpose, including * commercial applications, and to alter it and redistribute it freely, subject to * the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not claim * that you wrote the original software. If you use this software in a product, an * acknowledgment in the product documentation would be appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. */ /** @file crc1.h * CRC32 calculator from minicrc project. */ /* table of CRC-32's of all single-byte values (made by makecrc.c) */ gint32 crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL }; static gint32 update_crc32(char *buf, gint n, gint32 crc) { register gint i; crc ^= 0xffffffff; for (i=0; i> 8); return crc ^= 0xffffffff; } whitedb-0.7.3/Db/dbutil.c0000644000175000001440000011006512421471034012041 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010,2011,2012,2013 * * Minor mods by Tanel Tammet. Triple handler for raptor and raptor * rdf parsing originally written by Tanel Tammet. * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbutil.c * Miscellaneous utility functions. */ /* ====== Includes =============== */ #include #include #include #include #ifdef HAVE_RAPTOR #include #endif /* ====== Private headers and defs ======== */ #ifdef __cplusplus extern "C" { #endif #include "dbdata.h" #include "dbutil.h" #include "dbquery.h" #ifdef _WIN32 #define snprintf(s, sz, f, ...) _snprintf_s(s, sz+1, sz, f, ## __VA_ARGS__) #define strncpy(d, s, sz) strncpy_s(d, sz+1, s, sz) #else /* Use error-detecting versions for other C libs */ #define atof(s) strtod(s, NULL) #define atol(s) strtol(s, NULL, 10) #endif #define CSV_FIELD_BUF 4096 /** max size of csv I/O field */ #define CSV_FIELD_SEPARATOR ',' /** field separator, comma or semicolon */ #define CSV_DECIMAL_SEPARATOR '.' /** comma or dot */ #define CSV_ENCDATA_BUF 10 /** initial storage for encoded (gint) data */ #define MAX_URI_SCHEME 10 /* ======== Data ========================= */ /** Recognized URI schemes (used when parsing input data) * when adding new schemes, check that MAX_URI_SCHEME is enough to * store the entire scheme + '\0' */ struct uri_scheme_info { char *prefix; int length; } uri_scheme_table[] = { { "urn:", 4 }, { "file:", 5 }, { "http://", 7 }, { "https://", 8 }, { "mailto:", 7 }, { NULL, 0 } }; /* ======= Private protos ================ */ static gint show_io_error(void *db, char *errmsg); static gint show_io_error_str(void *db, char *errmsg, char *str); static void snprint_record(void *db, wg_int* rec, char *buf, int buflen); static void csv_escaped_str(void *db, char *iptr, char *buf, int buflen); static void snprint_value_csv(void *db, gint enc, char *buf, int buflen); #if 0 static gint parse_and_encode_uri(void *db, char *buf); #endif static gint parse_input_type(void *db, char *buf, gint *intdata, double *doubledata, gint *datetime); static gint fread_csv(void *db, FILE *f); #ifdef HAVE_RAPTOR static gint import_raptor(void *db, gint pref_fields, gint suff_fields, gint (*callback) (void *, void *), char *filename, raptor_parser *rdf_parser); static void handle_triple(void* user_data, const raptor_statement* triple); static raptor_uri *dburi_to_raptoruri(void *db, gint enc); static gint export_raptor(void *db, gint pref_fields, char *filename, raptor_serializer *rdf_serializer); #endif /* ====== Functions ============== */ /** Print contents of database. * */ void wg_print_db(void *db) { void *rec; rec = wg_get_first_record(db); while(rec) { wg_print_record(db, (gint *) rec); printf("\n"); rec = wg_get_next_record(db,rec); } } /** Print single record * */ void wg_print_record(void *db, wg_int* rec) { wg_int len, enc; int i; char strbuf[256]; #ifdef USE_CHILD_DB void *parent; #endif if (rec==NULL) { printf("\n"); return; } #ifdef USE_CHILD_DB parent = wg_get_rec_owner(db, rec); #endif len = wg_get_record_len(db, rec); printf("["); for(i=0; i\n"); return; } if(buflen < 2) return; *buf++ = '['; buflen--; #ifdef USE_CHILD_DB parent = wg_get_rec_owner(db, rec); #endif strbuf = malloc(buflen); if(strbuf) { int i, strbuflen; gint enc; gint len = wg_get_record_len(db, rec); for(i=0; i 1) *buf++ = ']'; *buf = '\0'; } /** Print a single, encoded value * The value is written into a character buffer. */ void wg_snprint_value(void *db, gint enc, char *buf, int buflen) { gint ptrdata; int intdata, len; char *strdata, *exdata; double doubledata; char strbuf[80]; buflen--; /* snprintf adds '\0' */ switch(wg_get_encoded_type(db, enc)) { case WG_NULLTYPE: snprintf(buf, buflen, "NULL"); break; case WG_RECORDTYPE: ptrdata = (gint) wg_decode_record(db, enc); snprintf(buf, buflen, "", (int) ptrdata); len = strlen(buf); if(buflen - len > 1) snprint_record(db, (wg_int*)ptrdata, buf+len, buflen-len); break; case WG_INTTYPE: intdata = wg_decode_int(db, enc); snprintf(buf, buflen, "%d", intdata); break; case WG_DOUBLETYPE: doubledata = wg_decode_double(db, enc); snprintf(buf, buflen, "%f", doubledata); break; case WG_FIXPOINTTYPE: doubledata = wg_decode_fixpoint(db, enc); snprintf(buf, buflen, "%f", doubledata); break; case WG_STRTYPE: strdata = wg_decode_str(db, enc); snprintf(buf, buflen, "\"%s\"", strdata); break; case WG_URITYPE: strdata = wg_decode_uri(db, enc); exdata = wg_decode_uri_prefix(db, enc); if (exdata==NULL) snprintf(buf, buflen, "%s", strdata); else snprintf(buf, buflen, "%s:%s", exdata, strdata); break; case WG_XMLLITERALTYPE: strdata = wg_decode_xmlliteral(db, enc); exdata = wg_decode_xmlliteral_xsdtype(db, enc); snprintf(buf, buflen, "\"%s\"", exdata, strdata); break; case WG_CHARTYPE: intdata = wg_decode_char(db, enc); snprintf(buf, buflen, "%c", (char) intdata); break; case WG_DATETYPE: intdata = wg_decode_date(db, enc); wg_strf_iso_datetime(db,intdata,0,strbuf); strbuf[10]=0; snprintf(buf, buflen, "%s", intdata,strbuf); break; case WG_TIMETYPE: intdata = wg_decode_time(db, enc); wg_strf_iso_datetime(db,1,intdata,strbuf); snprintf(buf, buflen, "%s",intdata,strbuf+11); break; case WG_VARTYPE: intdata = wg_decode_var(db, enc); snprintf(buf, buflen, "?%d", intdata); break; case WG_ANONCONSTTYPE: strdata = wg_decode_anonconst(db, enc); snprintf(buf, buflen, "!%s",strdata); break; default: snprintf(buf, buflen, ""); break; } } /** Create CSV-formatted quoted string * */ static void csv_escaped_str(void *db, char *iptr, char *buf, int buflen) { char *optr; #ifdef CHECK if(buflen < 3) { show_io_error(db, "CSV field buffer too small"); return; } #endif optr = buf; *optr++ = '"'; buflen--; /* space for terminating quote */ while(*iptr) { /* \0 terminates */ int nextsz = 1; if(*iptr == '"') nextsz++; /* Will our string fit? */ if(((gint)optr + nextsz - (gint)buf) < buflen) { *optr++ = *iptr; if(*iptr++ == '"') *optr++ = '"'; /* quote -> double quote */ } else break; } *optr++ = '"'; /* CSV string terminator */ *optr = '\0'; /* C string terminator */ } /** Print a single, encoded value, into a CSV-friendly format * The value is written into a character buffer. */ static void snprint_value_csv(void *db, gint enc, char *buf, int buflen) { int intdata, ilen; double doubledata; char strbuf[80], *ibuf; buflen--; /* snprintf adds '\0' */ switch(wg_get_encoded_type(db, enc)) { case WG_NULLTYPE: buf[0] = '\0'; /* output an empty field */ break; case WG_RECORDTYPE: intdata = ptrtooffset(db, wg_decode_record(db, enc)); snprintf(buf, buflen, "\"\"", intdata); break; case WG_INTTYPE: intdata = wg_decode_int(db, enc); snprintf(buf, buflen, "%d", intdata); break; case WG_DOUBLETYPE: doubledata = wg_decode_double(db, enc); snprintf(buf, buflen, "%f", doubledata); break; case WG_FIXPOINTTYPE: doubledata = wg_decode_fixpoint(db, enc); snprintf(buf, buflen, "%f", doubledata); break; case WG_STRTYPE: csv_escaped_str(db, wg_decode_str(db, enc), buf, buflen); break; case WG_XMLLITERALTYPE: csv_escaped_str(db, wg_decode_xmlliteral(db, enc), buf, buflen); break; case WG_URITYPE: /* More efficient solutions are possible, but here we simply allocate * enough storage to concatenate the URI before encoding it for CSV. */ ilen = wg_decode_uri_len(db, enc); ilen += wg_decode_uri_prefix_len(db, enc); ibuf = (char *) malloc(ilen + 1); if(!ibuf) { show_io_error(db, "Failed to allocate memory"); return; } snprintf(ibuf, ilen+1, "%s%s", wg_decode_uri_prefix(db, enc), wg_decode_uri(db, enc)); csv_escaped_str(db, ibuf, buf, buflen); free(ibuf); break; case WG_CHARTYPE: intdata = wg_decode_char(db, enc); snprintf(buf, buflen, "%c", (char) intdata); break; case WG_DATETYPE: intdata = wg_decode_date(db, enc); wg_strf_iso_datetime(db,intdata,0,strbuf); strbuf[10]=0; snprintf(buf, buflen, "%s", strbuf); break; case WG_TIMETYPE: intdata = wg_decode_time(db, enc); wg_strf_iso_datetime(db,1,intdata,strbuf); snprintf(buf, buflen, "%s", strbuf+11); break; default: snprintf(buf, buflen, "\"\""); break; } } /** Try parsing an URI from a string. * Returns encoded WG_URITYPE field when successful * Returns WG_ILLEGAL on error * * XXX: this is a very naive implementation. Something more robust * is needed. * * XXX: currently unused. */ #if 0 static gint parse_and_encode_uri(void *db, char *buf) { gint encoded = WG_ILLEGAL; struct uri_scheme_info *next = uri_scheme_table; /* Try matching to a known scheme */ while(next->prefix) { if(!strncmp(buf, next->prefix, next->length)) { /* We have a matching URI scheme. * XXX: check this code for correct handling of prefix. */ int urilen = strlen(buf); char *prefix = (char *) malloc(urilen + 1); char *dataptr; if(!prefix) break; strncpy(prefix, buf, urilen); dataptr = prefix + urilen; while(--dataptr >= prefix) { switch(*dataptr) { case ':': case '/': case '#': *(dataptr+1) = '\0'; goto prefix_marked; default: break; } } prefix_marked: encoded = wg_encode_uri(db, buf+((gint)dataptr-(gint)prefix+1), prefix); free(prefix); break; } next++; } return encoded; } #endif /** Parse value from string, encode it for WhiteDB * returns WG_ILLEGAL if value could not be parsed or * encoded. * * See the comment for parse_input_type() for the supported types. * If other conversions fail, data will be encoded as string. */ gint wg_parse_and_encode(void *db, char *buf) { gint intdata = 0; double doubledata = 0; gint encoded = WG_ILLEGAL, res = 0; switch(parse_input_type(db, buf, &intdata, &doubledata, &res)) { case WG_NULLTYPE: encoded = 0; break; case WG_INTTYPE: encoded = wg_encode_int(db, intdata); break; case WG_DOUBLETYPE: encoded = wg_encode_double(db, doubledata); break; case WG_STRTYPE: encoded = wg_encode_str(db, buf, NULL); break; case WG_DATETYPE: encoded = wg_encode_date(db, res); break; case WG_TIMETYPE: encoded = wg_encode_time(db, res); break; default: break; } return encoded; } /** Parse value from string, encode it as a query parameter. * returns WG_ILLEGAL if value could not be parsed or * encoded. * * Parameters encoded like this should be freed with * wg_free_query_param() and cannot be used interchangeably * with other encoded values. */ gint wg_parse_and_encode_param(void *db, char *buf) { gint intdata = 0; double doubledata = 0; gint encoded = WG_ILLEGAL, res = 0; switch(parse_input_type(db, buf, &intdata, &doubledata, &res)) { case WG_NULLTYPE: encoded = 0; break; case WG_INTTYPE: encoded = wg_encode_query_param_int(db, intdata); break; case WG_DOUBLETYPE: encoded = wg_encode_query_param_double(db, doubledata); break; case WG_STRTYPE: encoded = wg_encode_query_param_str(db, buf, NULL); break; case WG_DATETYPE: encoded = wg_encode_query_param_date(db, res); break; case WG_TIMETYPE: encoded = wg_encode_query_param_time(db, res); break; default: break; } return encoded; } /** Detect the type of input data in string format. * * Supports following data types: * NULL - empty string * int - plain integer * double - floating point number in fixed decimal notation * date - ISO8601 date * time - ISO8601 time+fractions of second. * string - input data that does not match the above types * * Does NOT support ambiguous types: * fixpoint - floating point number in fixed decimal notation * uri - string starting with an URI prefix * char - single character * * Does NOT support types which would require a special encoding * scheme in string form: * record, XML literal, blob, anon const, variables * * Return values: * 0 - value type could not be parsed or detected * WG_NULLTYPE - NULL * WG_INTTYPE - int, *intdata contains value * WG_DOUBLETYPE - double, *doubledata contains value * WG_DATETYPE - date, *datetime contains internal representation * WG_TIMETYPE - time, *datetime contains internal representation * WG_STRTYPE - string, use entire buf * * Since leading whitespace makes type guesses fail, it invariably * causes WG_STRTYPE to be returned. */ static gint parse_input_type(void *db, char *buf, gint *intdata, double *doubledata, gint *datetime) { gint type = 0; char c = buf[0]; if(c == 0) { /* empty fields become NULL-s */ type = WG_NULLTYPE; } else if((c >= '0' && c <= '9') ||\ (c == '-' && buf[1] >= '0' && buf[1] <= '9')) { /* This could be one of int, double, date or time */ if(c != '-' && (*datetime = wg_strp_iso_date(db, buf)) >= 0) { type = WG_DATETYPE; } else if(c != '-' && (*datetime = wg_strp_iso_time(db, buf)) >= 0) { type = WG_TIMETYPE; } else { /* Examine the field contents to distinguish between float * and int, then convert using atol()/atof(). sscanf() tends to * be too optimistic about the conversion, especially under Win32. */ char numbuf[80]; char *ptr = buf, *wptr = numbuf, *decptr = NULL; int decsep = 0; while(*ptr) { if(*ptr == CSV_DECIMAL_SEPARATOR) { decsep++; decptr = wptr; } else if((*ptr < '0' || *ptr > '9') && ptr != buf) { /* Non-numeric. Mark this as an invalid number * by abusing the decimal separator count. */ decsep = 2; break; } *(wptr++) = *(ptr++); if((int) (wptr - numbuf) >= 79) break; } *wptr = '\0'; if(decsep==1) { char tmp = *decptr; *decptr = '.'; /* ignore locale, force conversion by plain atof() */ *doubledata = atof(numbuf); if(errno!=ERANGE && errno!=EINVAL) { type = WG_DOUBLETYPE; } else { errno = 0; /* Under Win32, successful calls don't do this? */ } *decptr = tmp; /* conversion might have failed, restore string */ } else if(!decsep) { *intdata = atol(numbuf); if(errno!=ERANGE && errno!=EINVAL) { type = WG_INTTYPE; } else { errno = 0; } } } } if(type == 0) { /* Default type is string */ type = WG_STRTYPE; } return type; } /** Write single record to stream in CSV format * */ void wg_fprint_record_csv(void *db, wg_int* rec, FILE *f) { wg_int len, enc; int i; char *strbuf; if(rec==NULL) { show_io_error(db, "null record pointer"); return; } strbuf = (char *) malloc(CSV_FIELD_BUF); if(strbuf==NULL) { show_io_error(db, "Failed to allocate memory"); return; } len = wg_get_record_len(db, rec); for(i=0; i= encdata_sz) { gint *tmp; encdata_sz += CSV_ENCDATA_BUF; tmp = (gint *) realloc(encdata, sizeof(gint) * encdata_sz); if(tmp==NULL) { err = -3; show_io_error(db, "Failed to allocate memory"); break; } else encdata = tmp; } /* Do the actual parsing. This also allocates database-side * storage for the new data. */ enc = wg_parse_and_encode(db, strbuf); if(enc == WG_ILLEGAL) { show_io_error_str(db, "Warning: failed to parse", strbuf); enc = 0; /* continue anyway */ } encdata[reclen++] = enc; } if(commit_record) { /* Need to save the record to database. */ int i; void *rec; commit_record = 0; if(!reclen) continue; /* Ignore empty rows */ rec = wg_create_record(db, reclen); if(!rec) { err = -2; show_io_error(db, "Failed to create record"); break; } for(i=0; i 0) err = -1; /* XXX: not clear if fatal errors can occur here */ if(!user_data.count && err > -1) err = -1; /* No rows read. File was total garbage? */ if(err > user_data.error) err = user_data.error; /* More severe database error. */ raptor_free_uri(base_uri); raptor_free_uri(uri); raptor_free_memory(uri_string); return (gint) err; } /** Triple handler for raptor * Stores the triples parsed by raptor into database */ static void handle_triple(void* user_data, const raptor_statement* triple) { void* rec; struct wg_triple_handler_params *params = \ (struct wg_triple_handler_params *) user_data; gint enc; rec=wg_create_record(params->db, params->pref_fields + 3 + params->suff_fields); if (!rec) { show_io_error(params->db, "cannot create a new record"); params->error = -2; raptor_parse_abort(params->rdf_parser); } /* Field storage order: predicate, subject, object */ enc = parse_and_encode_uri(params->db, (char*)(triple->predicate)); if(enc==WG_ILLEGAL ||\ wg_set_field(params->db, rec, params->pref_fields, enc)) { show_io_error(params->db, "failed to store field"); params->error = -2; raptor_parse_abort(params->rdf_parser); } enc = parse_and_encode_uri(params->db, (char*)(triple->subject)); if(enc==WG_ILLEGAL ||\ wg_set_field(params->db, rec, params->pref_fields+1, enc)) { show_io_error(params->db, "failed to store field"); params->error = -2; raptor_parse_abort(params->rdf_parser); } if ((triple->object_type)==RAPTOR_IDENTIFIER_TYPE_RESOURCE) { enc = parse_and_encode_uri(params->db, (char*)(triple->object)); } else if ((triple->object_type)==RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) { /* Fixed prefix urn:local: */ enc=wg_encode_uri(params->db, (char*)(triple->object), "urn:local:"); } else if ((triple->object_type)==RAPTOR_IDENTIFIER_TYPE_LITERAL) { if ((triple->object_literal_datatype)==NULL) { enc=wg_encode_str(params->db,(char*)(triple->object), (char*)(triple->object_literal_language)); } else { enc=wg_encode_xmlliteral(params->db, (char*)(triple->object), (char*)(triple->object_literal_datatype)); } } else { show_io_error(params->db, "Unknown triple object type"); /* XXX: is this fatal? Maybe we should set error and continue here */ params->error = -2; raptor_parse_abort(params->rdf_parser); } if(enc==WG_ILLEGAL ||\ wg_set_field(params->db, rec, params->pref_fields+2, enc)) { show_io_error(params->db, "failed to store field"); params->error = -2; raptor_parse_abort(params->rdf_parser); } /* After correctly storing the triple, call the designated callback */ if(params->callback) { if((*(params->callback)) (params->db, rec)) { show_io_error(params->db, "record callback failed"); params->error = -2; raptor_parse_abort(params->rdf_parser); } } params->count++; } /** WhiteDB RDF parsing callback * This callback does nothing, but is always called when RDF files * are imported using wgdb commandline tool. If import API is used from * user application, alternative callback functions can be implemented * in there. * * Callback functions are expected to return 0 on success and * <0 on errors that cause the database to go into an invalid state. */ gint wg_rdfparse_default_callback(void *db, void *rec) { return 0; } /** Export triple data to file * wrapper for export_raptor(), allows user to specify serializer type. * * raptor provides an API to enumerate serializers. This is not * utilized here. */ gint wg_export_raptor_file(void *db, gint pref_fields, char *filename, char *serializer) { raptor_serializer *rdf_serializer=NULL; gint err = 0; raptor_init(); rdf_serializer = raptor_new_serializer(serializer); if(!rdf_serializer) return -1; err = export_raptor(db, pref_fields, filename, rdf_serializer); raptor_free_serializer(rdf_serializer); raptor_finish(); return err; } /** Export triple data to file, instructing raptor to use rdfxml serializer * */ gint wg_export_raptor_rdfxml_file(void *db, gint pref_fields, char *filename) { return wg_export_raptor_file(db, pref_fields, filename, "rdfxml"); } /** Convert wgdb URI field to raptor URI * Helper function. Caller is responsible for calling raptor_free_uri() * when the returned value is no longer needed. */ static raptor_uri *dburi_to_raptoruri(void *db, gint enc) { raptor_uri *tmpuri = raptor_new_uri((unsigned char *) wg_decode_uri_prefix(db, enc)); raptor_uri *uri = raptor_new_uri_from_uri_local_name(tmpuri, (unsigned char *) wg_decode_uri(db, enc)); raptor_free_uri(tmpuri); return uri; } /** File-based raptor export function * Uses WhiteDB-specific API parameters of: * pref_fields * suff_fields * * Expects an initialized serializer as an argument. * returns 0 on success. * returns -1 on errors (no fatal errors that would corrupt * the database are expected here). */ static gint export_raptor(void *db, gint pref_fields, char *filename, raptor_serializer *rdf_serializer) { int err, minsize; raptor_statement *triple; void *rec; err = raptor_serialize_start_to_filename(rdf_serializer, filename); if(err) return -1; /* initialization failed somehow */ /* Start constructing triples and sending them to the serializer. */ triple = (raptor_statement *) malloc(sizeof(raptor_statement)); if(!triple) { show_io_error(db, "Failed to allocate memory"); return -1; } memset(triple, 0, sizeof(raptor_statement)); rec = wg_get_first_record(db); minsize = pref_fields + 3; while(rec) { if(wg_get_record_len(db, rec) >= minsize) { gint enc = wg_get_field(db, rec, pref_fields); if(wg_get_encoded_type(db, enc) == WG_URITYPE) { triple->predicate = dburi_to_raptoruri(db, enc); } else if(wg_get_encoded_type(db, enc) == WG_STRTYPE) { triple->predicate = (void *) raptor_new_uri( (unsigned char *) wg_decode_str(db, enc)); } else { show_io_error(db, "Bad field type for predicate"); err = -1; goto done; } triple->predicate_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; enc = wg_get_field(db, rec, pref_fields + 1); if(wg_get_encoded_type(db, enc) == WG_URITYPE) { triple->subject = dburi_to_raptoruri(db, enc); } else if(wg_get_encoded_type(db, enc) == WG_STRTYPE) { triple->subject = (void *) raptor_new_uri( (unsigned char *) wg_decode_str(db, enc)); } else { show_io_error(db, "Bad field type for subject"); err = -1; goto done; } triple->subject_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; enc = wg_get_field(db, rec, pref_fields + 2); triple->object_literal_language = NULL; triple->object_literal_datatype = NULL; if(wg_get_encoded_type(db, enc) == WG_URITYPE) { triple->object = dburi_to_raptoruri(db, enc); triple->object_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; } else if(wg_get_encoded_type(db, enc) == WG_XMLLITERALTYPE) { triple->object = (void *) raptor_new_uri( (unsigned char *) wg_decode_xmlliteral(db, enc)); triple->object_literal_datatype = raptor_new_uri( (unsigned char *) wg_decode_xmlliteral_xsdtype(db, enc)); triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; } else if(wg_get_encoded_type(db, enc) == WG_STRTYPE) { triple->object = (void *) wg_decode_str(db, enc); triple->object_literal_language =\ (unsigned char *) wg_decode_str_lang(db, enc); triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; } else { show_io_error(db, "Bad field type for object"); err = -1; goto done; } /* Write the triple */ raptor_serialize_statement(rdf_serializer, triple); /* Cleanup current triple */ raptor_free_uri((raptor_uri *) triple->subject); raptor_free_uri((raptor_uri *) triple->predicate); if(triple->object_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE) raptor_free_uri((raptor_uri *) triple->object); else if(triple->object_literal_datatype) raptor_free_uri((raptor_uri *) triple->object_literal_datatype); } rec = wg_get_next_record(db, rec); } done: raptor_serialize_end(rdf_serializer); free(triple); return (gint) err; } #endif /* HAVE_RAPTOR */ void wg_pretty_print_memsize(gint memsz, char *buf, size_t buflen) { if(memsz < 1000) { snprintf(buf, buflen-1, "%d bytes", (int) memsz); } else if(memsz < 1000000) { snprintf(buf, buflen-1, "%d kB", (int) (memsz/1000)); } else if(memsz < 1000000000) { snprintf(buf, buflen-1, "%d MB", (int) (memsz/1000000)); } else { snprintf(buf, buflen-1, "%d GB", (int) (memsz/1000000000)); } buf[buflen-1] = '\0'; } /* ------------ error handling ---------------- */ static gint show_io_error(void *db, char *errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"I/O error: %s.\n", errmsg); #endif return -1; } static gint show_io_error_str(void *db, char *errmsg, char *str) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"I/O error: %s: %s.\n", errmsg, str); #endif return -1; } #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dballoc.h0000644000175000001440000005406412421471034012171 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2013 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dballoc.h * Public headers for database heap allocation procedures. */ #ifndef DEFINED_DBALLOC_H #define DEFINED_DBALLOC_H /* For gint/wg_int types */ #include #ifndef _MSC_VER #include #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #define USE_DATABASE_HANDLE /* Levels of allocation used: - Memory segment allocation: gives a large contiguous area of memory (typically shared memory). Could be extended later (has to be contiguous). - Inside the contiguous memory segment: Allocate usage areas for different heaps (data records, strings, doubles, lists, etc). Each area is typically not contiguous: can consist of several subareas of different length. Areas have different object allocation principles: - fixed-length object area (e.g. list cells) allocation uses pre-calced freelists - various-length object area (e.g. data records) allocation uses ordinary allocation techniques: - objects initialised from next free / designated victim object, split as needed - short freed objects are put into freelists in size-corresponding buckets - large freed object lists contain objects of different sizes - Data object allocation: data records, strings, list cells etc. Allocated in corresponding subareas. list area: 8M is filled 16 M area 32 datarec area: 8M is filled 16 M area 32 M area Fixlen allocation: - Fixlen objects are allocated using a pre-calced singly-linked freelist. When one subarea is exhausted(freelist empty), a new subarea is taken, it is organised into a long freelist and the beginning of the freelist is stored in db_area_header.freelist. - Each freelist element is one fixlen object. The first gint of the object is an offset of the next freelist element. The list is terminated with 0. Varlen allocation follows the main ideas of the Doug Lea allocator: - the minimum size to allocate is 4 gints (MIN_VARLENOBJ_SIZE) and all objects should be aligned at least to a gint. - each varlen area contains a number of gint-size buckets for storing different doubly-linked freelists. The buckets are: - EXACTBUCKETS_NR of buckets for exact object size. Contains an offset of the first free object of this size. - VARBUCKETS_NR of buckets for variable (interval between prev and next) object size, growing exponentially. Contains an offset of the first free object in this size interval. - EXACTBUCKETS_NR+VARBUCKETS_NR+1 is a designated victim (marked as in use): offset of the preferred place to split off new objects. Initially the whole free area is made one big designated victim. - EXACTBUCKETS_NR+VARBUCKETS_NR+2 is a size of the designated victim. - a free object contains gints: - size (in bytes) with last two bits marked (i.e. not part of size!): - last bits: 00 - offset of the next element in the freelist (terminated with 0). - offset of the previous element in the freelist (can be offset of the bucket!) ... arbitrary nr of bytes ... - size (in bytes) with last two bits marked as the initial size gint. This repeats the initial size gint and is located at the very end of the memory block. - an in-use object contains gints: - size (in bytes) with mark bits and assumptions: - last 2 bits markers, not part of size: - for normal in-use objects with in-use predecessor 00 - for normal in-use objects with free predecessor 10 - for specials (dv area and start/end markers) 11 - real size taken is always 8-aligned (minimal granularity 8 bytes) - size gint may be not 8-aligned if 32-bit gint used (but still has to be 4-aligned). In this case: - if size gint is not 8-aligned, real size taken either: - if size less than MIN_VARLENOBJ_SIZE, then MIN_VARLENOBJ_SIZE - else size+4 bytes (but used size is just size, no bytes added) - usable gints following - a designated victim is marked to be in use: - the first gint has last bits 11 to differentiate from normal in-use objects (00 or 10 bits) - the second gint contains 0 to indicate that it is a dv object, and not start marker (1) or end marker (2) - all the following gints are arbitrary and contain no markup. - the first 4 gints and the last 4 gints of each subarea are marked as in-use objects, although they should be never used! The reason is to give a markup for subarea beginning and end. - last bits 10 to differentiate from normal in-use objects (00 bits) - the next gint is 1 for start marker an 2 for end marker - the following 2 gints are arbitrary and contain no markup - summary of end bits for various objects: - 00 in-use normal object with in-use previous object - 10 in-use normal object with a free previous object - 01 free object - 11 in-use special object (dv or start/end marker) */ #define MEMSEGMENT_MAGIC_MARK 1232319011 /** enables to check that we really have db pointer */ #define MEMSEGMENT_MAGIC_INIT 1916950123 /** init time magic */ #define MEMSEGMENT_VERSION ((VERSION_REV<<16)|\ (VERSION_MINOR<<8)|(VERSION_MAJOR)) /** written to dump headers for compatibilty checking */ #define SUBAREA_ARRAY_SIZE 64 /** nr of possible subareas in each area */ #define INITIAL_SUBAREA_SIZE 8192 /** size of the first created subarea (bytes) */ #define MINIMAL_SUBAREA_SIZE 8192 /** checked before subarea creation to filter out stupid requests */ #define SUBAREA_ALIGNMENT_BYTES 8 /** subarea alignment */ #define SYN_VAR_PADDING 128 /** sync variable padding in bytes */ #if (LOCK_PROTO==3) #define MAX_LOCKS 64 /** queue size (currently fixed :-() */ #endif #define EXACTBUCKETS_NR 256 /** amount of free ob buckets with exact length */ #define VARBUCKETS_NR 32 /** amount of free ob buckets with varying length */ #define CACHEBUCKETS_NR 2 /** buckets used as special caches */ #define DVBUCKET EXACTBUCKETS_NR+VARBUCKETS_NR /** cachebucket: designated victim offset */ #define DVSIZEBUCKET EXACTBUCKETS_NR+VARBUCKETS_NR+1 /** cachebucket: byte size of designated victim */ #define MIN_VARLENOBJ_SIZE (4*(gint)(sizeof(gint))) /** minimal size of variable length object */ #define SHORTSTR_SIZE 32 /** max len of short strings */ /* defaults, used when there is no user-supplied or computed value */ #define DEFAULT_STRHASH_LENGTH 10000 /** length of the strhash array (nr of array elements) */ #define DEFAULT_IDXHASH_LENGTH 10000 /** hash index hash size */ #define ANONCONST_TABLE_SIZE 200 /** length of the table containing predefined anonconst uri ptrs */ /* ====== general typedefs and macros ======= */ // integer and address fetch and store typedef ptrdiff_t gint; /** always used instead of int. Pointers are also handled as gint. */ #ifndef _MSC_VER /* MSVC on Win32 */ typedef int32_t gint32; /** 32-bit fixed size storage */ typedef int64_t gint64; /** 64-bit fixed size storage */ #else typedef __int32 gint32; /** 32-bit fixed size storage */ typedef __int64 gint64; /** 64-bit fixed size storage */ #endif #ifdef USE_DATABASE_HANDLE #define dbmemseg(x) ((void *)(((db_handle *) x)->db)) #define dbmemsegh(x) ((db_memsegment_header *)(((db_handle *) x)->db)) #define dbmemsegbytes(x) ((char *)(((db_handle *) x)->db)) #else #define dbmemseg(x) ((void *)(x)) #define dbmemsegh(x) ((db_memsegment_header *)(x)) #define dbmemsegbytes(x) ((char *)(x)) #endif #define dbfetch(db,offset) (*((gint*)(dbmemsegbytes(db)+(offset)))) /** get gint from address */ #define dbstore(db,offset,data) (*((gint*)(dbmemsegbytes(db)+(offset)))=data) /** store gint to address */ #define dbaddr(db,realptr) ((gint)(((char*)(realptr))-dbmemsegbytes(db))) /** give offset of real adress */ #define offsettoptr(db,offset) ((void*)(dbmemsegbytes(db)+(offset))) /** give real address from offset */ #define ptrtooffset(db,realptr) (dbaddr((db),(realptr))) #define dbcheckh(dbh) (dbh!=NULL && *((gint32 *) dbh)==MEMSEGMENT_MAGIC_MARK) /** check that correct db ptr */ #define dbcheck(db) dbcheckh(dbmemsegh(db)) /** check that correct db ptr */ #define dbcheckhinit(dbh) (dbh!=NULL && *((gint32 *) dbh)==MEMSEGMENT_MAGIC_INIT) #define dbcheckinit(db) dbcheckhinit(dbmemsegh(db)) /* ==== fixlen object allocation macros ==== */ #define alloc_listcell(db) wg_alloc_fixlen_object((db),&(dbmemsegh(db)->listcell_area_header)) #define alloc_shortstr(db) wg_alloc_fixlen_object((db),&(dbmemsegh(db)->shortstr_area_header)) #define alloc_word(db) wg_alloc_fixlen_object((db),&(dbmemsegh(db)->word_area_header)) #define alloc_doubleword(db) wg_alloc_fixlen_object((db),&(dbmemsegh(db)->doubleword_area_header)) /* ==== varlen object allocation special macros ==== */ #define isfreeobject(i) (((i) & 3)==1) /** end bits 01 */ #define isnormalusedobject(i) (!((i) & 1)) /** end bits either 00 or 10, i.e. last bit 0 */ #define isnormalusedobjectprevused(i) (!((i) & 3)) /** end bits 00 */ #define isnormalusedobjectprevfree(i) (((i) & 3)==2) /** end bits 10 */ #define isspecialusedobject(i) (((i) & 3) == 3) /** end bits 11 */ #define getfreeobjectsize(i) ((i) & ~3) /** mask off two lowest bits: just keep all higher */ /** small size marks always use MIN_VARLENOBJ_SIZE, * non-8-aligned size marks mean obj really takes 4 more bytes (all real used sizes are 8-aligned) */ #define getusedobjectsize(i) (((i) & ~3)<=MIN_VARLENOBJ_SIZE ? MIN_VARLENOBJ_SIZE : ((((i) & ~3)%8) ? (((i) & ~3)+4) : ((i) & ~3)) ) #define getspecialusedobjectsize(i) ((i) & ~3) /** mask off two lowest bits: just keep all higher */ #define getusedobjectwantedbytes(i) ((i) & ~3) #define getusedobjectwantedgintsnr(i) (((i) & ~3)>>((sizeof(gint)==4) ? 2 : 3)) /** divide pure size by four or eight */ #define makefreeobjectsize(i) (((i) & ~3)|1) /** set lowest bits to 01: current object is free */ #define makeusedobjectsizeprevused(i) ((i) & ~3) /** set lowest bits to 00 */ #define makeusedobjectsizeprevfree(i) (((i) & ~3)|2) /** set lowest bits to 10 */ #define makespecialusedobjectsize(i) ((i)|3) /** set lowest bits to 11 */ #define SPECIALGINT1DV 1 /** second gint of a special in use dv area */ #define SPECIALGINT1START 0 /** second gint of a special in use start marker area, should be 0 */ #define SPECIALGINT1END 0 /** second gint of a special in use end marker area, should be 0 */ // #define setpfree(i) ((i) | 2) /** set next lowest bit to 1: previous object is free ???? */ /* === data structures used in allocated areas ===== */ /** general list cell: a pair of two integers (both can be also used as pointers) */ typedef struct { gint car; /** first element */ gint cdr;} /** second element, often a pointer to the rest of the list */ gcell; #define car(cell) (((gint)((gcell*)(cell)))->car) /** get list cell first elem gint */ #define cdr(cell) (((gint)((gcell*)(cell)))->cdr) /** get list cell second elem gint */ /* index related stuff */ #define MAX_INDEX_FIELDS 10 /** maximum number of fields in one index */ #define MAX_INDEXED_FIELDNR 127 /** limits the size of field/index table */ #ifndef TTREE_CHAINED_NODES #define WG_TNODE_ARRAY_SIZE 10 #else #define WG_TNODE_ARRAY_SIZE 8 #endif /* logging related */ #define maxnumberoflogrows 10 /* external database stuff */ #define MAX_EXTDB 20 /* ====== segment/area header data structures ======== */ /* memory segment structure: ------------- db_memsegment_header - - - - - - - db_area_header - - - - db_subarea_header ... db_subarea_header - - - - - - - ... - - - - - - - db_area_header - - - - db_subarea_header ... db_subarea_header ---------------- various actual subareas ---------------- */ /** located inside db_area_header: one single memory subarea header * * alignedoffset should be always used: it may come some bytes after offset */ typedef struct _db_subarea_header { gint size; /** size of subarea */ gint offset; /** subarea exact offset from segment start: do not use for objects! */ gint alignedsize; /** subarea object alloc usable size: not necessarily to end of area */ gint alignedoffset; /** subarea start as to be used for object allocation */ } db_subarea_header; /** located inside db_memsegment_header: one single memory area header * */ typedef struct _db_area_header { gint fixedlength; /** 1 if fixed length area, 0 if variable length */ gint objlength; /** only for fixedlength: length of allocatable obs in bytes */ gint freelist; /** freelist start: if 0, then no free objects available */ gint last_subarea_index; /** last used subarea index (0,...,) */ db_subarea_header subarea_array[SUBAREA_ARRAY_SIZE]; /** array of subarea headers */ gint freebuckets[EXACTBUCKETS_NR+VARBUCKETS_NR+CACHEBUCKETS_NR]; /** array of subarea headers */ } db_area_header; /** synchronization structures in shared memory * * Note that due to the similarity we can keep the memory images * using the wpspin and rpspin protocols compatible. */ typedef struct { #if !defined(LOCK_PROTO) || (LOCK_PROTO < 3) /* rpspin, wpspin */ gint global_lock; /** db offset to cache-aligned sync variable */ gint writers; /** db offset to cache-aligned writer count */ char _storage[SYN_VAR_PADDING*3]; /** padded storage */ #else /* tfqueue */ gint tail; /** db offset to last queue node */ gint queue_lock; /** db offset to cache-aligned sync variable */ gint storage; /** db offset to queue node storage */ gint max_nodes; /** number of cells in queue node storage */ gint freelist; /** db offset to the top of the allocation stack */ #endif } syn_var_area; /** hash area header * */ typedef struct _db_hash_area_header { gint size; /** size of subarea */ gint offset; /** subarea exact offset from segment start: do not use for array! */ gint arraysize; /** subarea object alloc usable size: not necessarily to end of area */ gint arraystart; /** subarea start as to be used for object allocation */ gint arraylength; /** nr of elements in the hash array */ } db_hash_area_header; /** * T-tree specific index header fields */ struct __wg_ttree_header { gint offset_root_node; #ifdef TTREE_CHAINED_NODES gint offset_max_node; /** last node in chain */ gint offset_min_node; /** first node in chain */ #endif }; /** * Hash-specific index header fields */ struct __wg_hashidx_header { db_hash_area_header hasharea; }; /** control data for one index * */ typedef struct { gint type; gint fields; /** number of fields in index */ gint rec_field_index[MAX_INDEX_FIELDS]; /** field numbers for this index */ union { struct __wg_ttree_header t; struct __wg_hashidx_header h; } ctl; /** shared fields for different index types */ gint template_offset; /** matchrec template, 0 if full index */ } wg_index_header; /** index mask meta-info * */ #ifdef USE_INDEX_TEMPLATE typedef struct { gint fixed_columns; /** number of fixed columns in the template */ gint offset_matchrec; /** offset to the record that stores the fields */ gint refcount; /** number of indexes using this template */ } wg_index_template; #endif /** highest level index management data * contains lookup table by field number and memory management data */ typedef struct { gint number_of_indexes; /** unused, reserved */ gint index_list; /** master index list */ gint index_table[MAX_INDEXED_FIELDNR+1]; /** index lookup by column */ #ifdef USE_INDEX_TEMPLATE gint index_template_list; /** sorted list of index masks */ gint index_template_table[MAX_INDEXED_FIELDNR+1]; /** masks indexed by column */ #endif } db_index_area_header; /** Registered external databases * Offsets of data in these databases are recognized properly * by the data store/retrieve/compare functions. */ typedef struct { gint count; /** number of records */ gint offset[MAX_EXTDB]; /** offsets of external databases */ gint size[MAX_EXTDB]; /** corresponding sizes of external databases */ } extdb_area; /** logging management * */ typedef struct { gint active; /** logging mode on/off */ gint dirty; /** log file is clean/dirty */ gint serial; /** incremented when the log file is backed up */ } db_logging_area_header; /** bitmap area header * */ typedef struct { gint offset; /** actual start of bitmap as used */ gint size; /** actual used size in bytes */ } db_recptr_bitmap_header; /** anonconst area header * */ #ifdef USE_REASONER typedef struct _db_anonconst_area_header { gint anonconst_nr; gint anonconst_funs; gint anonconst_table[ANONCONST_TABLE_SIZE]; } db_anonconst_area_header; #endif /** located at the very beginning of the memory segment * */ typedef struct _db_memsegment_header { // core info about segment /****** fixed size part of the header. Do not edit this without * also editing the code that checks the header in dbmem.c */ gint32 mark; /** fixed uncommon int to check if really a segment */ gint32 version; /** db engine version to check dump file compatibility */ gint32 features; /** db engine compile-time features */ gint32 checksum; /** dump file checksum */ /* end of fixed size header ******/ gint size; /** segment size in bytes */ gint free; /** pointer to first free area in segment (aligned) */ gint initialadr; /** initial segment address, only valid for creator */ gint key; /** global shared mem key */ // areas db_area_header datarec_area_header; db_area_header longstr_area_header; db_area_header listcell_area_header; db_area_header shortstr_area_header; db_area_header word_area_header; db_area_header doubleword_area_header; // hash structures db_hash_area_header strhash_area_header; // index structures db_index_area_header index_control_area_header; db_area_header tnode_area_header; db_area_header indexhdr_area_header; db_area_header indextmpl_area_header; db_area_header indexhash_area_header; // logging structures db_logging_area_header logging; // recptr bitmap db_recptr_bitmap_header recptr_bitmap; // anonconst table #ifdef USE_REASONER db_anonconst_area_header anonconst; #endif // statistics // field/table name structures syn_var_area locks; /** currently holds a single global lock */ extdb_area extdbs; /** offset ranges of external databases */ } db_memsegment_header; #ifdef USE_DATABASE_HANDLE /** Database handle in local memory. Contains the pointer to the * shared memory area. */ typedef struct { db_memsegment_header *db; /** shared memory header */ void *logdata; /** log data structure in local memory */ } db_handle; #endif /* --------- anonconsts: special uris with attached funs ----------- */ #ifdef USE_REASONER #define ACONST_FALSE_STR "false" #define ACONST_FALSE encode_anonconst(0) #define ACONST_TRUE_STR "true" #define ACONST_TRUE encode_anonconst(1) #define ACONST_IF_STR "if" #define ACONST_IF encode_anonconst(2) #define ACONST_NOT_STR "not" #define ACONST_NOT encode_anonconst(3) #define ACONST_AND_STR "and" #define ACONST_AND encode_anonconst(4) #define ACONST_OR_STR "or" #define ACONST_OR encode_anonconst(5) #define ACONST_IMPLIES_STR "implies" #define ACONST_IMPLIES encode_anonconst(6) #define ACONST_XOR_STR "xor" #define ACONST_XOR encode_anonconst(7) #define ACONST_LESS_STR "<" #define ACONST_LESS encode_anonconst(8) #define ACONST_EQUAL_STR "=" #define ACONST_EQUAL encode_anonconst(9) #define ACONST_GREATER_STR ">" #define ACONST_GREATER encode_anonconst(10) #define ACONST_LESSOREQUAL_STR "<=" #define ACONST_LESSOREQUAL encode_anonconst(11) #define ACONST_GREATEROREQUAL_STR ">=" #define ACONST_GREATEROREQUAL encode_anonconst(12) #define ACONST_ISZERO_STR "zero" #define ACONST_ISZERO encode_anonconst(13) #define ACONST_ISEMPTYSTR_STR "strempty" #define ACONST_ISEMPTYSTR encode_anonconst(14) #define ACONST_PLUS_STR "+" #define ACONST_PLUS encode_anonconst(15) #define ACONST_MINUS_STR "!-" #define ACONST_MINUS encode_anonconst(16) #define ACONST_MULTIPLY_STR "*" #define ACONST_MULTIPLY encode_anonconst(17) #define ACONST_DIVIDE_STR "/" #define ACONST_DIVIDE encode_anonconst(18) #define ACONST_STRCONTAINS_STR "strcontains" #define ACONST_STRCONTAINS encode_anonconst(19) #define ACONST_STRCONTAINSICASE_STR "strcontainsicase" #define ACONST_STRCONTAINSICASE encode_anonconst(20) #define ACONST_SUBSTR_STR "substr" #define ACONST_SUBSTR encode_anonconst(21) #define ACONST_STRLEN_STR "strlen" #define ACONST_STRLEN encode_anonconst(22) #endif /* ==== Protos ==== */ gint wg_init_db_memsegment(void* db, gint key, gint size); // creates initial memory structures for a new db gint wg_alloc_fixlen_object(void* db, void* area_header); gint wg_alloc_gints(void* db, void* area_header, gint nr); void wg_free_listcell(void* db, gint offset); void wg_free_shortstr(void* db, gint offset); void wg_free_word(void* db, gint offset); void wg_free_doubleword(void* db, gint offset); void wg_free_tnode(void* db, gint offset); void wg_free_fixlen_object(void* db, db_area_header *hdr, gint offset); gint wg_freebuckets_index(void* db, gint size); gint wg_free_object(void* db, void* area_header, gint object) ; #if 0 void *wg_create_child_db(void* db, gint size); #endif gint wg_register_external_db(void *db, void *extdb); gint wg_create_hash(void *db, db_hash_area_header* areah, gint size); gint wg_database_freesize(void *db); gint wg_database_size(void *db); /* ------- testing ------------ */ #endif /* DEFINED_DBALLOC_H */ whitedb-0.7.3/Db/Makefile.am0000644000175000001440000000072412421471034012446 00000000000000# # - - - - main db sources - - - noinst_LTLIBRARIES = libDb.la libDb_la_SOURCES = dbmem.c dbmem.h\ dballoc.c dballoc.h dbfeatures.h\ dbdata.c dbdata.h\ dblock.c dblock.h\ dbdump.c dbdump.h crc1.h\ dblog.c dblog.h\ dbhash.c dbhash.h\ dbindex.c dbindex.h\ dbcompare.c dbcompare.h\ dbquery.c dbquery.h\ dbutil.c dbutil.h\ dbmpool.c dbmpool.h\ dbjson.c dbjson.h\ dbschema.c dbschema.h if RAPTOR AM_CFLAGS += `$(RAPTOR_CONFIG) --cflags` endif whitedb-0.7.3/Db/dbdata.c0000644000175000001440000026252312421471034012004 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2009,2010,2011,2013,2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbdata.c * Procedures for handling actual data: strings, integers, records, etc * */ /* ====== Includes =============== */ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN /* For Sleep() */ #include #endif #include #include #include #include #include #include //#include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" #include "dbdata.h" #include "dbhash.h" #include "dblog.h" #include "dbindex.h" #include "dbcompare.h" #include "dblock.h" /* ====== Private headers and defs ======== */ #ifdef _WIN32 //Thread-safe localtime_r appears not to be present on windows: emulate using win localtime, which is thread-safe. static struct tm * localtime_r (const time_t *timer, struct tm *result); #define sscanf sscanf_s // warning: needs extra buflen args for string etc params #define snprintf sprintf_s #endif /* ======= Private protos ================ */ #ifdef USE_BACKLINKING static gint remove_backlink_index_entries(void *db, gint *record, gint value, gint depth); static gint restore_backlink_index_entries(void *db, gint *record, gint value, gint depth); #endif static int isleap(unsigned yr); static unsigned months_to_days (unsigned month); static long years_to_days (unsigned yr); static long ymd_to_scalar (unsigned yr, unsigned mo, unsigned day); static void scalar_to_ymd (long scalar, unsigned *yr, unsigned *mo, unsigned *day); static gint free_field_encoffset(void* db,gint encoffset); static gint find_create_longstr(void* db, char* data, char* extrastr, gint type, gint length); #ifdef USE_CHILD_DB static void *get_ptr_owner(void *db, gint encoded); static int is_local_offset(void *db, gint offset); #endif #ifdef USE_RECPTR_BITMAP static void recptr_setbit(void *db,void *ptr); static void recptr_clearbit(void *db,void *ptr); #endif static gint show_data_error(void* db, char* errmsg); static gint show_data_error_nr(void* db, char* errmsg, gint nr); static gint show_data_error_double(void* db, char* errmsg, double nr); static gint show_data_error_str(void* db, char* errmsg, char* str); /* ====== Functions ============== */ /* ------------ full record handling ---------------- */ void* wg_create_record(void* db, wg_int length) { void *rec = wg_create_raw_record(db, length); /* Index all the created NULL fields to ensure index consistency */ if(rec) { if(wg_index_add_rec(db, rec) < -1) return NULL; /* index error */ } return rec; } /* * Creates the record and initializes the fields * to NULL, but does not update indexes. This is useful in two * scenarios: 1. fields are immediately initialized to something * else, making indexing NULLs useless 2. record will have * a RECORD_META_NOTDATA bit set, so the fields should not * be indexed at all. * * In the first case, it is required that wg_set_new_field() * is called on all the fields in the record. In the second case, * the caller is responsible for setting the meta bits, however * it is not mandatory to re-initialize all the fields. */ void* wg_create_raw_record(void* db, wg_int length) { gint offset; gint i; #ifdef CHECK if (!dbcheck(db)) { show_data_error_nr(db,"wrong database pointer given to wg_create_record with length ",length); return 0; } if(length < 0) { show_data_error_nr(db, "invalid record length:",length); return 0; } #endif #ifdef USE_DBLOG /* Log first, modify shared memory next */ if(dbmemsegh(db)->logging.active) { if(wg_log_create_record(db, length)) return 0; } #endif offset=wg_alloc_gints(db, &(dbmemsegh(db)->datarec_area_header), length+RECORD_HEADER_GINTS); if (!offset) { show_data_error_nr(db,"cannot create a record of size ",length); #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { wg_log_encval(db, 0); } #endif return 0; } /* Init header */ dbstore(db, offset+RECORD_META_POS*sizeof(gint), 0); dbstore(db, offset+RECORD_BACKLINKS_POS*sizeof(gint), 0); for(i=RECORD_HEADER_GINTS;ilogging.active) { if(wg_log_encval(db, offset)) return 0; /* journal error */ } #endif return offsettoptr(db,offset); } /** Delete record from database * returns 0 on success * returns -1 if the record is referenced by others and cannot be deleted. * returns -2 on general error * returns -3 on fatal error * * XXX: when USE_BACKLINKING is off, this function should be used * with extreme care. */ gint wg_delete_record(void* db, void *rec) { gint offset; gint* dptr; gint* dendptr; gint data; #ifdef CHECK if (!dbcheck(db)) { show_data_error(db, "wrong database pointer given to wg_delete_record"); return -2; } #endif #ifdef USE_BACKLINKING if(*((gint *) rec + RECORD_BACKLINKS_POS)) return -1; #endif #ifdef USE_DBLOG /* Log first, modify shared memory next */ if(dbmemsegh(db)->logging.active) { if(wg_log_delete_record(db, ptrtooffset(db, rec))) return -3; } #endif /* Remove data from index */ if(!is_special_record(rec)) { if(wg_index_del_rec(db, rec) < -1) return -3; /* index error */ } offset = ptrtooffset(db, rec); #if defined(CHECK) && defined(USE_CHILD_DB) /* Check if it's a local record */ if(!is_local_offset(db, offset)) { show_data_error(db, "not deleting an external record"); return -2; } #endif /* Loop over fields, freeing them */ dendptr = (gint *) (((char *) rec) + datarec_size_bytes(*((gint *)rec))); for(dptr=(gint *)rec+RECORD_HEADER_GINTS; dptrcar == offset) { gint old_offset = *next_offset; *next_offset = old->cdr; /* remove from list chain */ wg_free_listcell(db, old_offset); /* free storage */ goto recdel_backlink_removed; } next_offset = &(old->cdr); } show_data_error(db, "Corrupt backlink chain"); return -3; /* backlink error */ } recdel_backlink_removed: #endif if(isptr(data)) free_field_encoffset(db,data); } /* Free the record storage */ wg_free_object(db, &(dbmemsegh(db)->datarec_area_header), offset); return 0; } /** Get the first data record from the database * Uses header meta bits to filter out special records * (rules, system records etc) */ void* wg_get_first_record(void* db) { void *res = wg_get_first_raw_record(db); if(res && is_special_record(res)) return wg_get_next_record(db, res); /* find first data record */ return res; } /** Get the next data record from the database * Uses header meta bits to filter out special records */ void* wg_get_next_record(void* db, void* record) { void *res = record; do { res = wg_get_next_raw_record(db, res); } while(res && is_special_record(res)); return res; } /** Get the first record from the database * */ void* wg_get_first_raw_record(void* db) { db_subarea_header* arrayadr; gint firstoffset; void* res; #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_get_first_record"); return NULL; } #endif arrayadr=&((dbmemsegh(db)->datarec_area_header).subarea_array[0]); firstoffset=((arrayadr[0]).alignedoffset); // do NOT skip initial "used" marker //printf("arrayadr %x firstoffset %d \n",(uint)arrayadr,firstoffset); res=wg_get_next_raw_record(db,offsettoptr(db,firstoffset)); return res; } /** Get the next record from the database * */ void* wg_get_next_raw_record(void* db, void* record) { gint curoffset; gint head; db_subarea_header* arrayadr; gint last_subarea_index; gint i; gint found; gint subareastart; gint subareaend; gint freemarker; curoffset=ptrtooffset(db,record); //printf("curroffset %d record %x\n",curoffset,(uint)record); #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_get_first_record"); return NULL; } head=dbfetch(db,curoffset); if (isfreeobject(head)) { show_data_error(db,"wrong record pointer (free) given to wg_get_next_record"); return NULL; } #endif freemarker=0; //assume input pointer to used object head=dbfetch(db,curoffset); while(1) { // increase offset to next memory block curoffset=curoffset+(freemarker ? getfreeobjectsize(head) : getusedobjectsize(head)); head=dbfetch(db,curoffset); //printf("new curoffset %d head %d isnormaluseobject %d isfreeobject %d \n", // curoffset,head,isnormalusedobject(head),isfreeobject(head)); // check if found a normal used object if (isnormalusedobject(head)) return offsettoptr(db,curoffset); //return ptr to normal used object if (isfreeobject(head)) { freemarker=1; // loop start leads us to next object } else { // found a special object (dv or end marker) freemarker=0; if (dbfetch(db,curoffset+sizeof(gint))==SPECIALGINT1DV) { // we have reached a dv object continue; // loop start leads us to next object } else { // we have reached an end marker, have to find the next subarea // first locate subarea for this offset arrayadr=&((dbmemsegh(db)->datarec_area_header).subarea_array[0]); last_subarea_index=(dbmemsegh(db)->datarec_area_header).last_subarea_index; found=0; for(i=0;(i<=last_subarea_index)&&(i=subareastart && curoffsetlast_subarea_index || i>=SUBAREA_ARRAY_SIZE) { //printf("next used object not found: i %d curoffset %d \n",i,curoffset); return NULL; } //printf("taking next subarea i %d\n",i); curoffset=((arrayadr[i]).alignedoffset); // curoffset is now the special start marker head=dbfetch(db,curoffset); // loop start will lead us to next object from special marker } } } } /** Get the first data parent pointer from the backlink chain. * */ void *wg_get_first_parent(void* db, void *record) { #ifdef USE_BACKLINKING gint backlink_list; #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"invalid database pointer given to wg_get_first_parent"); return NULL; } #endif backlink_list = *((gint *) record + RECORD_BACKLINKS_POS); if(backlink_list) { gcell *cell = (gcell *) offsettoptr(db, backlink_list); return (void *) offsettoptr(db, cell->car); } #endif /* USE_BACKLINKING */ return NULL; /* no parents or backlinking not enabled */ } /** Get the next parent pointer from the backlink chain. * */ void *wg_get_next_parent(void* db, void* record, void *parent) { #ifdef USE_BACKLINKING gint backlink_list; #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"invalid database pointer given to wg_get_next_parent"); return NULL; } #endif backlink_list = *((gint *) record + RECORD_BACKLINKS_POS); if(backlink_list) { gcell *next = (gcell *) offsettoptr(db, backlink_list); while(next->cdr) { void *pp = (void *) offsettoptr(db, next->car); next = (gcell *) offsettoptr(db, next->cdr); if(pp == parent && next->car) { return (void *) offsettoptr(db, next->car); } } } #endif /* USE_BACKLINKING */ return NULL; /* no more parents or backlinking not enabled */ } /* ------------ backlink chain recursive functions ------------------- */ #ifdef USE_BACKLINKING /** Remove index entries in backlink chain recursively. * Needed for index maintenance when records are compared by their * contens, as change in contents also changes the value of the entire * record and thus affects it's placement in the index. * Returns 0 for success * Returns -1 in case of errors. */ static gint remove_backlink_index_entries(void *db, gint *record, gint value, gint depth) { gint col, length, err = 0; db_memsegment_header *dbh = dbmemsegh(db); if(!is_special_record(record)) { /* Find all fields in the record that match value (which is actually * a reference to a child record in encoded form) and remove it from * indexes. It will be recreated in the indexes by wg_set_field() later. */ length = getusedobjectwantedgintsnr(*record) - RECORD_HEADER_GINTS; if(length > MAX_INDEXED_FIELDNR) length = MAX_INDEXED_FIELDNR + 1; for(col=0; colindex_control_area_header.index_table[col]) { if(wg_index_del_field(db, record, col) < -1) return -1; } } } } /* If recursive depth is not exchausted, continue with the parents * of this record. */ if(depth > 0) { gint backlink_list = *(record + RECORD_BACKLINKS_POS); if(backlink_list) { gcell *next = (gcell *) offsettoptr(db, backlink_list); for(;;) { err = remove_backlink_index_entries(db, (gint *) offsettoptr(db, next->car), wg_encode_record(db, record), depth-1); if(err) return err; if(!next->cdr) break; next = (gcell *) offsettoptr(db, next->cdr); } } } return 0; } /** Add index entries in backlink chain recursively. * Called after doing remove_backling_index_entries() and updating * data in the record that originated the call. This recreates the * entries in the indexes for all the records that were affected. * Returns 0 for success * Returns -1 in case of errors. */ static gint restore_backlink_index_entries(void *db, gint *record, gint value, gint depth) { gint col, length, err = 0; db_memsegment_header *dbh = dbmemsegh(db); if(!is_special_record(record)) { /* Find all fields in the record that match value (which is actually * a reference to a child record in encoded form) and add it back to * indexes. */ length = getusedobjectwantedgintsnr(*record) - RECORD_HEADER_GINTS; if(length > MAX_INDEXED_FIELDNR) length = MAX_INDEXED_FIELDNR + 1; for(col=0; colindex_control_area_header.index_table[col]) { if(wg_index_add_field(db, record, col) < -1) return -1; } } } } /* Continue to the parents until depth==0 */ if(depth > 0) { gint backlink_list = *(record + RECORD_BACKLINKS_POS); if(backlink_list) { gcell *next = (gcell *) offsettoptr(db, backlink_list); for(;;) { err = restore_backlink_index_entries(db, (gint *) offsettoptr(db, next->car), wg_encode_record(db, record), depth-1); if(err) return err; if(!next->cdr) break; next = (gcell *) offsettoptr(db, next->cdr); } } } return 0; } #endif /* ------------ field handling: data storage and fetching ---------------- */ wg_int wg_get_record_len(void* db, void* record) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_get_record_len"); return -1; } #endif return ((gint)(getusedobjectwantedgintsnr(*((gint*)record))))-RECORD_HEADER_GINTS; } wg_int* wg_get_record_dataarray(void* db, void* record) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_get_record_dataarray"); return NULL; } #endif return (((gint*)record)+RECORD_HEADER_GINTS); } /** Update contents of one field * returns 0 if successful * returns -1 if invalid db pointer passed (by recordcheck macro) * returns -2 if invalid record passed (by recordcheck macro) * returns -3 for fatal index error * returns -4 for backlink-related error * returns -5 for invalid external data * returns -6 for journal error */ wg_int wg_set_field(void* db, void* record, wg_int fieldnr, wg_int data) { gint* fieldadr; gint fielddata; gint* strptr; #ifdef USE_BACKLINKING gint backlink_list; /** start of backlinks for this record */ gint rec_enc = WG_ILLEGAL; /** this record as encoded value. */ #endif db_memsegment_header *dbh = dbmemsegh(db); #ifdef USE_CHILD_DB void *offset_owner = dbmemseg(db); #endif #ifdef CHECK recordcheck(db,record,fieldnr,"wg_set_field"); #endif #ifdef USE_DBLOG /* Do not proceed before we've logged the operation */ if(dbh->logging.active) { if(wg_log_set_field(db,record,fieldnr,data)) return -6; /* journal error, cannot write */ } #endif /* Read the old encoded value */ fieldadr=((gint*)record)+RECORD_HEADER_GINTS+fieldnr; fielddata=*fieldadr; /* Update index(es) while the old value is still in the db */ #ifdef USE_INDEX_TEMPLATE if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ (dbh->index_control_area_header.index_table[fieldnr] ||\ dbh->index_control_area_header.index_template_table[fieldnr])) { #else if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ dbh->index_control_area_header.index_table[fieldnr]) { #endif if(wg_index_del_field(db, record, fieldnr) < -1) return -3; /* index error */ } /* If there are backlinks, go up the chain and remove the reference * to this record from all indexes (updating a field in the record * causes the value of the record to change). Note that we only go * as far as the recursive comparison depth - records higher in the * hierarchy are not affected. */ #if defined(USE_BACKLINKING) && (WG_COMPARE_REC_DEPTH > 0) backlink_list = *((gint *) record + RECORD_BACKLINKS_POS); if(backlink_list) { gint err; gcell *next = (gcell *) offsettoptr(db, backlink_list); rec_enc = wg_encode_record(db, record); for(;;) { err = remove_backlink_index_entries(db, (gint *) offsettoptr(db, next->car), rec_enc, WG_COMPARE_REC_DEPTH-1); if(err) { return -4; /* override the error code, for now. */ } if(!next->cdr) break; next = (gcell *) offsettoptr(db, next->cdr); } } #endif #ifdef USE_CHILD_DB /* Get the offset owner */ if(isptr(data)) { offset_owner = get_ptr_owner(db, data); if(!offset_owner) { show_data_error(db, "External reference not recognized"); return -5; } } #endif #ifdef USE_BACKLINKING /* Is the old field value a record pointer? If so, remove the backlink. * XXX: this can be optimized to use a custom macro instead of * wg_get_encoded_type(). */ #ifdef USE_CHILD_DB /* Only touch local records */ if(wg_get_encoded_type(db, fielddata) == WG_RECORDTYPE && offset_owner == dbmemseg(db)) { #else if(wg_get_encoded_type(db, fielddata) == WG_RECORDTYPE) { #endif gint *rec = (gint *) wg_decode_record(db, fielddata); gint *next_offset = rec + RECORD_BACKLINKS_POS; gint parent_offset = ptrtooffset(db, record); gcell *old = NULL; while(*next_offset) { old = (gcell *) offsettoptr(db, *next_offset); if(old->car == parent_offset) { gint old_offset = *next_offset; *next_offset = old->cdr; /* remove from list chain */ wg_free_listcell(db, old_offset); /* free storage */ goto setfld_backlink_removed; } next_offset = &(old->cdr); } show_data_error(db, "Corrupt backlink chain"); return -4; /* backlink error */ } setfld_backlink_removed: #endif //printf("wg_set_field adr %d offset %d\n",fieldadr,ptrtooffset(db,fieldadr)); if (isptr(fielddata)) { //printf("wg_set_field freeing old data\n"); free_field_encoffset(db,fielddata); } (*fieldadr)=data; // store data to field #ifdef USE_CHILD_DB if (islongstr(data) && offset_owner == dbmemseg(db)) { #else if (islongstr(data)) { #endif // increase data refcount for longstr-s strptr = (gint *) offsettoptr(db,decode_longstr_offset(data)); ++(*(strptr+LONGSTR_REFCOUNT_POS)); } /* Update index after new value is written */ #ifdef USE_INDEX_TEMPLATE if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ (dbh->index_control_area_header.index_table[fieldnr] ||\ dbh->index_control_area_header.index_template_table[fieldnr])) { #else if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ dbh->index_control_area_header.index_table[fieldnr]) { #endif if(wg_index_add_field(db, record, fieldnr) < -1) return -3; } #ifdef USE_BACKLINKING /* Is the new field value a record pointer? If so, add a backlink */ #ifdef USE_CHILD_DB if(wg_get_encoded_type(db, data) == WG_RECORDTYPE && offset_owner == dbmemseg(db)) { #else if(wg_get_encoded_type(db, data) == WG_RECORDTYPE) { #endif gint *rec = (gint *) wg_decode_record(db, data); gint *next_offset = rec + RECORD_BACKLINKS_POS; gint new_offset = wg_alloc_fixlen_object(db, &(dbmemsegh(db)->listcell_area_header)); gcell *new_cell = (gcell *) offsettoptr(db, new_offset); while(*next_offset) next_offset = &(((gcell *) offsettoptr(db, *next_offset))->cdr); new_cell->car = ptrtooffset(db, record); new_cell->cdr = 0; *next_offset = new_offset; } #endif #if defined(USE_BACKLINKING) && (WG_COMPARE_REC_DEPTH > 0) /* Create new entries in indexes in all referring records */ if(backlink_list) { gint err; gcell *next = (gcell *) offsettoptr(db, backlink_list); for(;;) { err = restore_backlink_index_entries(db, (gint *) offsettoptr(db, next->car), rec_enc, WG_COMPARE_REC_DEPTH-1); if(err) { return -4; } if(!next->cdr) break; next = (gcell *) offsettoptr(db, next->cdr); } } #endif return 0; } /** Write contents of one field. * * Used to initialize fields in records that have been created with * wg_create_raw_record(). * * This function ignores the previous contents of the field. The * rationale is that newly created fields do not have any meaningful * content and this allows faster writing. It is up to the programmer * to ensure that this function is not called on fields that already * contain data. * * returns 0 if successful * returns -1 if invalid db pointer passed * returns -2 if invalid record or field passed * returns -3 for fatal index error * returns -4 for backlink-related error * returns -5 for invalid external data * returns -6 for journal error */ wg_int wg_set_new_field(void* db, void* record, wg_int fieldnr, wg_int data) { gint* fieldadr; gint* strptr; #ifdef USE_BACKLINKING gint backlink_list; /** start of backlinks for this record */ #endif db_memsegment_header *dbh = dbmemsegh(db); #ifdef USE_CHILD_DB void *offset_owner = dbmemseg(db); #endif #ifdef CHECK recordcheck(db,record,fieldnr,"wg_set_field"); #endif #ifdef USE_DBLOG /* Do not proceed before we've logged the operation */ if(dbh->logging.active) { if(wg_log_set_field(db,record,fieldnr,data)) return -6; /* journal error, cannot write */ } #endif #ifdef USE_CHILD_DB /* Get the offset owner */ if(isptr(data)) { offset_owner = get_ptr_owner(db, data); if(!offset_owner) { show_data_error(db, "External reference not recognized"); return -5; } } #endif /* Write new value */ fieldadr=((gint*)record)+RECORD_HEADER_GINTS+fieldnr; #ifdef CHECK if(*fieldadr) { show_data_error(db,"wg_set_new_field called on field that contains data"); return -2; } #endif (*fieldadr)=data; #ifdef USE_CHILD_DB if (islongstr(data) && offset_owner == dbmemseg(db)) { #else if (islongstr(data)) { #endif // increase data refcount for longstr-s strptr = (gint *) offsettoptr(db,decode_longstr_offset(data)); ++(*(strptr+LONGSTR_REFCOUNT_POS)); } /* Update index after new value is written */ #ifdef USE_INDEX_TEMPLATE if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ (dbh->index_control_area_header.index_table[fieldnr] ||\ dbh->index_control_area_header.index_template_table[fieldnr])) { #else if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ dbh->index_control_area_header.index_table[fieldnr]) { #endif if(wg_index_add_field(db, record, fieldnr) < -1) return -3; } #ifdef USE_BACKLINKING /* Is the new field value a record pointer? If so, add a backlink */ #ifdef USE_CHILD_DB if(wg_get_encoded_type(db, data) == WG_RECORDTYPE && offset_owner == dbmemseg(db)) { #else if(wg_get_encoded_type(db, data) == WG_RECORDTYPE) { #endif gint *rec = (gint *) wg_decode_record(db, data); gint *next_offset = rec + RECORD_BACKLINKS_POS; gint new_offset = wg_alloc_fixlen_object(db, &(dbmemsegh(db)->listcell_area_header)); gcell *new_cell = (gcell *) offsettoptr(db, new_offset); while(*next_offset) next_offset = &(((gcell *) offsettoptr(db, *next_offset))->cdr); new_cell->car = ptrtooffset(db, record); new_cell->cdr = 0; *next_offset = new_offset; } #endif #if defined(USE_BACKLINKING) && (WG_COMPARE_REC_DEPTH > 0) /* Create new entries in indexes in all referring records. Normal * usage scenario would be that the record is also new, so that * there are no backlinks, however this is not guaranteed. */ backlink_list = *((gint *) record + RECORD_BACKLINKS_POS); if(backlink_list) { gint err; gcell *next = (gcell *) offsettoptr(db, backlink_list); gint rec_enc = wg_encode_record(db, record); for(;;) { err = restore_backlink_index_entries(db, (gint *) offsettoptr(db, next->car), rec_enc, WG_COMPARE_REC_DEPTH-1); if(err) { return -4; } if(!next->cdr) break; next = (gcell *) offsettoptr(db, next->cdr); } } #endif return 0; } wg_int wg_set_int_field(void* db, void* record, wg_int fieldnr, gint data) { gint fielddata; fielddata=wg_encode_int(db,data); //printf("wg_set_int_field data %d encoded %d\n",data,fielddata); if (fielddata==WG_ILLEGAL) return -1; return wg_set_field(db,record,fieldnr,fielddata); } wg_int wg_set_double_field(void* db, void* record, wg_int fieldnr, double data) { gint fielddata; fielddata=wg_encode_double(db,data); if (fielddata==WG_ILLEGAL) return -1; return wg_set_field(db,record,fieldnr,fielddata); } wg_int wg_set_str_field(void* db, void* record, wg_int fieldnr, char* data) { gint fielddata; fielddata=wg_encode_str(db,data,NULL); if (fielddata==WG_ILLEGAL) return -1; return wg_set_field(db,record,fieldnr,fielddata); } wg_int wg_set_rec_field(void* db, void* record, wg_int fieldnr, void* data) { gint fielddata; fielddata=wg_encode_record(db,data); if (fielddata==WG_ILLEGAL) return -1; return wg_set_field(db,record,fieldnr,fielddata); } /** Special case of updating a field value without a write-lock. * * Operates like wg_set_field but takes a previous value in a field * as an additional argument for atomicity check. * * This special case does not require a write lock: however, * you MUST still get a read-lock before the operation while * doing parallel processing, otherwise the operation * may corrupt the database: no complex write operations should * happen in parallel to this operation. * * NB! the operation may still confuse other parallel readers, changing * the value in a record they have just read. Use only if this is * known to not create problems for other processes. * * It can be only used to write an immediate value (NULL, short int, * char, date, time) to a non-indexed field containing also an * immediate field: checks whether these conditions hold. * * The operation will fail if the original value passed has been * overwritten before we manage to store a new value: this is * a guaranteed atomic check and enables correct operation of * several parallel wg_set_atomic_field operations * changing the same field. * * returns 0 if successful * returns -1 if wrong db pointer * returns -2 if wrong fieldnr * returns -10 if new value non-immediate * returns -11 if old value non-immediate * returns -12 if cannot fetch old data * returns -13 if the field has an index * returns -14 if logging is active * returns -15 if the field value has been changed from old_data * may return other field-setting error codes from wg_set_new_field * */ wg_int wg_update_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data, wg_int old_data) { gint* fieldadr; db_memsegment_header *dbh = dbmemsegh(db); gint tmp; // basic sanity check #ifdef CHECK recordcheck(db,record,fieldnr,"wg_update_atomic_field"); #endif // check whether new value and old value are direct values in a record if (!isimmediatedata(data)) return -10; if (!isimmediatedata(old_data)) return -11; // check whether there is index on the field #ifdef USE_INDEX_TEMPLATE if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ (dbh->index_control_area_header.index_table[fieldnr] ||\ dbh->index_control_area_header.index_template_table[fieldnr])) { #else if(!is_special_record(record) && fieldnr<=MAX_INDEXED_FIELDNR &&\ dbh->index_control_area_header.index_table[fieldnr]) { #endif return -13; } // check that no logging is used #ifdef USE_DBLOG if(dbh->logging.active) { return -14; } #endif // checks passed, do atomic field setting fieldadr=((gint*)record)+RECORD_HEADER_GINTS+fieldnr; tmp=wg_compare_and_swap(fieldadr, old_data, data); if (tmp) return 0; else return -15; } /** Special case of setting a field value without a write-lock. * * Calls wg_update_atomic_field iteratively until compare-and-swap succeeds. * * The restrictions and error codes from wg_update_atomic_field apply. * returns 0 if successful * returns -1...-15 with an error defined before in wg_update_atomic_field. * returns -17 if atomic assignment failed after a large number (1000) of tries */ wg_int wg_set_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data) { gint* fieldadr; gint old,r; int i; #ifdef _WIN32 int ts=1; #else struct timespec ts; #endif // basic sanity check #ifdef CHECK recordcheck(db,record,fieldnr,"wg_set_atomic_field"); #endif fieldadr=((gint*)record)+RECORD_HEADER_GINTS+fieldnr; for(i=0;;i++) { // loop until preconditions fail or addition succeeds and // the old value is not changed during compare-and-swap old=*fieldadr; r=wg_update_atomic_field(db,record,fieldnr,data,old); if (!r) return 0; if (r!=-15) return r; // -15 is field changed error // here compare-and-swap failed, try again if (i>1000) return -17; // possibly a deadlock if (i%10!=0) continue; // sleep only every tenth loop // several loops passed, sleep a bit #ifdef _WIN32 Sleep(ts); // 1000 for loops take ca 0.1 sec #else ts.tv_sec=0; ts.tv_nsec=100+i; nanosleep(&ts,NULL); // 1000 for loops take ca 60 microsec #endif } return -17; // should not reach here } /** Special case of adding to an int field without a write-lock. * * fieldnr must contain a smallint and the result of addition * must also be a smallint. * * The restrictions and error codes from wg_update_atomic_field apply. * * returns 0 if successful * returns -1...-15 with an error defined before in wg_set_atomic_field. * returns -16 if the result of the addition does not fit into a smallint * returns -17 if atomic assignment failed after a large number (1000) of tries * */ wg_int wg_add_int_atomic_field(void* db, void* record, wg_int fieldnr, int data) { gint* fieldadr; gint old,nxt,r; int i,sum; #ifdef _WIN32 int ts=1; #else struct timespec ts; #endif // basic sanity check #ifdef CHECK recordcheck(db,record,fieldnr,"wg_add_int_atomic_field"); #endif fieldadr=((gint*)record)+RECORD_HEADER_GINTS+fieldnr; for(i=0;;i++) { // loop until preconditions fail or addition succeeds and // the old value is not changed during compare-and-swap old=*fieldadr; if (!issmallint(old)) return -11; sum=wg_decode_int(db,(gint)old)+data; if (!fits_smallint(sum)) return -16; nxt=encode_smallint(sum); r=wg_update_atomic_field(db,record,fieldnr,nxt,old); if (!r) return 0; if (r!=-15) return r; // -15 is field changed error // here compare-and-swap failed, try again if (i>1000) return -17; // possibly a deadlock if (i%10!=0) continue; // sleep only every tenth loop // several loops passed, sleep a bit #ifdef _WIN32 Sleep(ts); // 1000 for loops take ca 0.1 sec #else ts.tv_sec=0; ts.tv_nsec=100+i; nanosleep(&ts,NULL); // 1000 for loops take ca 60 microsec #endif } return -17; // should not reach here } wg_int wg_get_field(void* db, void* record, wg_int fieldnr) { #ifdef CHECK if (!dbcheck(db)) { show_data_error_nr(db,"wrong database pointer given to wg_get_field",fieldnr); return WG_ILLEGAL; } if (fieldnr<0 || (getusedobjectwantedgintsnr(*((gint*)record))<=fieldnr+RECORD_HEADER_GINTS)) { show_data_error_nr(db,"wrong field number given to wg_get_field",fieldnr);\ return WG_ILLEGAL; } #endif //printf("wg_get_field adr %d offset %d\n", // (((gint*)record)+RECORD_HEADER_GINTS+fieldnr), // ptrtooffset(db,(((gint*)record)+RECORD_HEADER_GINTS+fieldnr))); return *(((gint*)record)+RECORD_HEADER_GINTS+fieldnr); } wg_int wg_get_field_type(void* db, void* record, wg_int fieldnr) { #ifdef CHECK if (!dbcheck(db)) { show_data_error_nr(db,"wrong database pointer given to wg_get_field_type",fieldnr);\ return 0; } if (fieldnr<0 || (getusedobjectwantedgintsnr(*((gint*)record))<=fieldnr+RECORD_HEADER_GINTS)) { show_data_error_nr(db,"wrong field number given to wg_get_field_type",fieldnr);\ return 0; } #endif return wg_get_encoded_type(db,*(((gint*)record)+RECORD_HEADER_GINTS+fieldnr)); } /* ------------- general operations -------------- */ wg_int wg_free_encoded(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_free_encoded"); return 0; } #endif if (isptr(data)) { gint *strptr; /* XXX: Major hack: since free_field_encoffset() decrements * the refcount, but wg_encode_str() does not (which is correct), * before, increment the refcount once before we free the * object. If the string is in use already, this will be a * no-op, otherwise it'll be successfully freed anyway. */ #ifdef USE_CHILD_DB if (islongstr(data) && is_local_offset(db, decode_longstr_offset(data))) { #else if (islongstr(data)) { #endif // increase data refcount for longstr-s strptr = (gint *) offsettoptr(db,decode_longstr_offset(data)); ++(*(strptr+LONGSTR_REFCOUNT_POS)); } return free_field_encoffset(db,data); } return 0; } /** properly removes ptr (offset) to data * * assumes fielddata is offset to allocated data * depending on type of fielddata either deallocates pointed data or * removes data back ptr or decreases refcount * * in case fielddata points to record or longstring, these * are freed only if they have no more pointers * * returns non-zero in case of error */ static gint free_field_encoffset(void* db,gint encoffset) { gint offset; #if 0 gint* dptr; gint* dendptr; gint data; gint i; #endif gint tmp; gint* objptr; gint* extrastr; // takes last three bits to decide the type // fullint is represented by two options: 001 and 101 switch(encoffset&NORMALPTRMASK) { case DATARECBITS: #if 0 /* This section of code in quarantine */ // remove from list // refcount check offset=decode_datarec_offset(encoffset); tmp=dbfetch(db,offset+sizeof(gint)*LONGSTR_REFCOUNT_POS); tmp--; if (tmp>0) { dbstore(db,offset+LONGSTR_REFCOUNT_POS,tmp); } else { // free frompointers structure // loop over fields, freeing them dptr=offsettoptr(db,offset); dendptr=(gint*)(((char*)dptr)+datarec_size_bytes(*dptr)); for(i=0,dptr=dptr+RECORD_HEADER_GINTS;dptrdatarec_area_header),offset); } #endif break; case LONGSTRBITS: offset=decode_longstr_offset(encoffset); #ifdef USE_CHILD_DB if(!is_local_offset(db, offset)) break; /* Non-local reference, ignore it */ #endif // refcount check tmp=dbfetch(db,offset+sizeof(gint)*LONGSTR_REFCOUNT_POS); tmp--; if (tmp>0) { dbstore(db,offset+sizeof(gint)*LONGSTR_REFCOUNT_POS,tmp); } else { objptr = (gint *) offsettoptr(db,offset); extrastr=(gint*)(((char*)(objptr))+(sizeof(gint)*LONGSTR_EXTRASTR_POS)); tmp=*extrastr; // remove from hash wg_remove_from_strhash(db,encoffset); // remove extrastr if (tmp!=0) free_field_encoffset(db,tmp); *extrastr=0; // really free object from area wg_free_object(db,&(dbmemsegh(db)->longstr_area_header),offset); } break; case SHORTSTRBITS: #ifdef USE_CHILD_DB offset = decode_shortstr_offset(encoffset); if(!is_local_offset(db, offset)) break; /* Non-local reference, ignore it */ wg_free_shortstr(db, offset); #else wg_free_shortstr(db,decode_shortstr_offset(encoffset)); #endif break; case FULLDOUBLEBITS: #ifdef USE_CHILD_DB offset = decode_fulldouble_offset(encoffset); if(!is_local_offset(db, offset)) break; /* Non-local reference, ignore it */ wg_free_doubleword(db, offset); #else wg_free_doubleword(db,decode_fulldouble_offset(encoffset)); #endif break; case FULLINTBITSV0: #ifdef USE_CHILD_DB offset = decode_fullint_offset(encoffset); if(!is_local_offset(db, offset)) break; /* Non-local reference, ignore it */ wg_free_word(db, offset); #else wg_free_word(db,decode_fullint_offset(encoffset)); #endif break; case FULLINTBITSV1: #ifdef USE_CHILD_DB offset = decode_fullint_offset(encoffset); if(!is_local_offset(db, offset)) break; /* Non-local reference, ignore it */ wg_free_word(db, offset); #else wg_free_word(db,decode_fullint_offset(encoffset)); #endif break; } return 0; } /* ------------- data encoding and decoding ------------ */ /** determines the type of encoded data * * returns a zero-or-bigger macro integer value from wg_db_api.h beginning: * * #define WG_NULLTYPE 1 * #define WG_RECORDTYPE 2 * #define WG_INTTYPE 3 * #define WG_DOUBLETYPE 4 * #define WG_STRTYPE 5 * ... etc ... * * returns a negative number -1 in case of error * */ wg_int wg_get_encoded_type(void* db, wg_int data) { gint fieldoffset; gint tmp; #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_get_encoded_type"); return 0; } #endif if (!data) return WG_NULLTYPE; if (((data)&NONPTRBITS)==NONPTRBITS) { // data is one of the non-pointer types if (isvar(data)) return (gint)WG_VARTYPE; if (issmallint(data)) return (gint)WG_INTTYPE; switch(data&LASTBYTEMASK) { case CHARBITS: return WG_CHARTYPE; case FIXPOINTBITS: return WG_FIXPOINTTYPE; case DATEBITS: return WG_DATETYPE; case TIMEBITS: return WG_TIMETYPE; case TINYSTRBITS: return WG_STRTYPE; case VARBITS: return WG_VARTYPE; case ANONCONSTBITS: return WG_ANONCONSTTYPE; default: return -1; } } // here we know data must be of ptr type // takes last three bits to decide the type // fullint is represented by two options: 001 and 101 //printf("cp0\n"); switch(data&NORMALPTRMASK) { case DATARECBITS: return (gint)WG_RECORDTYPE; case LONGSTRBITS: //printf("cp1\n"); fieldoffset=decode_longstr_offset(data)+LONGSTR_META_POS*sizeof(gint); //printf("fieldoffset %d\n",fieldoffset); tmp=dbfetch(db,fieldoffset); //printf("str meta %d lendiff %d subtype %d\n", // tmp,(tmp&LONGSTR_META_LENDIFMASK)>>LONGSTR_META_LENDIFSHFT,tmp&LONGSTR_META_TYPEMASK); return tmp&LONGSTR_META_TYPEMASK; // WG_STRTYPE, WG_URITYPE, WG_XMLLITERALTYPE case SHORTSTRBITS: return (gint)WG_STRTYPE; case FULLDOUBLEBITS: return (gint)WG_DOUBLETYPE; case FULLINTBITSV0: return (gint)WG_INTTYPE; case FULLINTBITSV1: return (gint)WG_INTTYPE; default: return -1; } return 0; } char* wg_get_type_name(void* db, wg_int type) { switch (type) { case WG_NULLTYPE: return "null"; case WG_RECORDTYPE: return "record"; case WG_INTTYPE: return "int"; case WG_DOUBLETYPE: return "double"; case WG_STRTYPE: return "string"; case WG_XMLLITERALTYPE: return "xmlliteral"; case WG_URITYPE: return "uri"; case WG_BLOBTYPE: return "blob"; case WG_CHARTYPE: return "char"; case WG_FIXPOINTTYPE: return "fixpoint"; case WG_DATETYPE: return "date"; case WG_TIMETYPE: return "time"; case WG_ANONCONSTTYPE: return "anonconstant"; case WG_VARTYPE: return "var"; default: return "unknown"; } } wg_int wg_encode_null(void* db, char* data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_null"); return WG_ILLEGAL; } if (data!=NULL) { show_data_error(db,"data given to wg_encode_null is not NULL"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Skip logging values that do not cause storage allocation. if(dbh->logging.active) { if(wg_log_encode(db, WG_NULLTYPE, NULL, 0, NULL, 0)) return WG_ILLEGAL; } */ #endif return (gint)0; } char* wg_decode_null(void* db,wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_null"); return NULL; } if (data!=(gint)0) { show_data_error(db,"data given to wg_decode_null is not an encoded NULL"); return NULL; } #endif return NULL; } wg_int wg_encode_int(void* db, wg_int data) { gint offset; #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_int"); return WG_ILLEGAL; } #endif if (fits_smallint(data)) { return encode_smallint(data); } else { #ifdef USE_DBLOG /* Log before allocating. Note this call is skipped when * we have a small int. */ if(dbmemsegh(db)->logging.active) { if(wg_log_encode(db, WG_INTTYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } #endif offset=alloc_word(db); if (!offset) { show_data_error_nr(db,"cannot store an integer in wg_set_int_field: ",data); #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { wg_log_encval(db, WG_ILLEGAL); } #endif return WG_ILLEGAL; } dbstore(db,offset,data); #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { if(wg_log_encval(db, encode_fullint_offset(offset))) return WG_ILLEGAL; /* journal error */ } #endif return encode_fullint_offset(offset); } } wg_int wg_decode_int(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_int"); return 0; } #endif if (issmallint(data)) return decode_smallint(data); if (isfullint(data)) return dbfetch(db,decode_fullint_offset(data)); show_data_error_nr(db,"data given to wg_decode_int is not an encoded int: ",data); return 0; } wg_int wg_encode_char(void* db, char data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_char"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Skip logging values that do not cause storage allocation. if(dbh->logging.active) { if(wg_log_encode(db, WG_CHARTYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } */ #endif return (wg_int)(encode_char((wg_int)data)); } char wg_decode_char(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_char"); return 0; } #endif return (char)(decode_char(data)); } wg_int wg_encode_double(void* db, double data) { gint offset; #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_double"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Log before allocating. */ if(dbmemsegh(db)->logging.active) { if(wg_log_encode(db, WG_DOUBLETYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } #endif if (0) { // possible future case for tiny floats } else { offset=alloc_doubleword(db); if (!offset) { show_data_error_double(db,"cannot store a double in wg_set_double_field: ",data); #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { wg_log_encval(db, WG_ILLEGAL); } #endif return WG_ILLEGAL; } *((double*)(offsettoptr(db,offset)))=data; #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { if(wg_log_encval(db, encode_fulldouble_offset(offset))) return WG_ILLEGAL; /* journal error */ } #endif return encode_fulldouble_offset(offset); } } double wg_decode_double(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_double"); return 0; } #endif if (isfulldouble(data)) return *((double*)(offsettoptr(db,decode_fulldouble_offset(data)))); show_data_error_nr(db,"data given to wg_decode_double is not an encoded double: ",data); return 0; } wg_int wg_encode_fixpoint(void* db, double data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_fixpoint"); return WG_ILLEGAL; } if (!fits_fixpoint(data)) { show_data_error(db,"argument given to wg_encode_fixpoint too big or too small"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Skip logging values that do not cause storage allocation. if(dbh->logging.active) { if(wg_log_encode(db, WG_FIXPOINTTYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } */ #endif return encode_fixpoint(data); } double wg_decode_fixpoint(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_double"); return 0; } #endif if (isfixpoint(data)) return decode_fixpoint(data); show_data_error_nr(db,"data given to wg_decode_fixpoint is not an encoded fixpoint: ",data); return 0; } wg_int wg_encode_date(void* db, int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_date"); return WG_ILLEGAL; } if (!fits_date(data)) { show_data_error(db,"argument given to wg_encode_date too big or too small"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Skip logging values that do not cause storage allocation. if(dbh->logging.active) { if(wg_log_encode(db, WG_DATETYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } */ #endif return encode_date(data); } int wg_decode_date(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_date"); return 0; } #endif if (isdate(data)) return decode_date(data); show_data_error_nr(db,"data given to wg_decode_date is not an encoded date: ",data); return 0; } wg_int wg_encode_time(void* db, int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_time"); return WG_ILLEGAL; } if (!fits_time(data)) { show_data_error(db,"argument given to wg_encode_time too big or too small"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Skip logging values that do not cause storage allocation. if(dbh->logging.active) { if(wg_log_encode(db, WG_TIMETYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } */ #endif return encode_time(data); } int wg_decode_time(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_time"); return 0; } #endif if (istime(data)) return decode_time(data); show_data_error_nr(db,"data given to wg_decode_time is not an encoded time: ",data); return 0; } int wg_current_utcdate(void* db) { time_t ts; int epochadd=719163; // y 1970 m 1 d 1 ts=time(NULL); // secs since Epoch 1970 return (int)(ts/(24*60*60))+epochadd; } int wg_current_localdate(void* db) { time_t esecs; int res; struct tm ctime; esecs=time(NULL); // secs since Epoch 1970tstruct.time; localtime_r(&esecs,&ctime); res=ymd_to_scalar(ctime.tm_year+1900,ctime.tm_mon+1,ctime.tm_mday); return res; } int wg_current_utctime(void* db) { struct timeb tstruct; int esecs; int days; int secs; int milli; int secsday=24*60*60; ftime(&tstruct); esecs=(int)(tstruct.time); milli=tstruct.millitm; days=esecs/secsday; secs=esecs-(days*secsday); return (secs*100)+(milli/10); } int wg_current_localtime(void* db) { struct timeb tstruct; time_t esecs; int secs; int milli; struct tm ctime; ftime(&tstruct); esecs=tstruct.time; milli=tstruct.millitm; localtime_r(&esecs,&ctime); secs=ctime.tm_hour*60*60+ctime.tm_min*60+ctime.tm_sec; return (secs*100)+(milli/10); } int wg_strf_iso_datetime(void* db, int date, int time, char* buf) { unsigned yr, mo, day, hr, min, sec, spart; int t=time; int c; hr=t/(60*60*100); t=t-(hr*(60*60*100)); min=t/(60*100); t=t-(min*(60*100)); sec=t/100; t=t-(sec*(100)); spart=t; scalar_to_ymd(date,&yr,&mo,&day); c=snprintf(buf,24,"%04d-%02d-%02dT%02d:%02d:%02d.%02d",yr,mo,day,hr,min,sec,spart); return(c); } int wg_strp_iso_date(void* db, char* inbuf) { int sres; int yr=0; int mo=0; int day=0; int res; sres=sscanf(inbuf,"%4d-%2d-%2d",&yr,&mo,&day); if (sres<3 || yr<0 || mo<1 || mo>12 || day<1 || day>31) return -1; res=ymd_to_scalar(yr,mo,day); return res; } int wg_strp_iso_time(void* db, char* inbuf) { int sres; int hr=0; int min=0; int sec=0; int prt=0; sres=sscanf(inbuf,"%2d:%2d:%2d.%2d",&hr,&min,&sec,&prt); if (sres<3 || hr<0 || hr>24 || min<0 || min>60 || sec<0 || sec>60 || prt<0 || prt>99) return -1; return hr*(60*60*100)+min*(60*100)+sec*100+prt; } int wg_ymd_to_date(void* db, int yr, int mo, int day) { if (yr<0 || mo<1 || mo>12 || day<1 || day>31) return -1; return ymd_to_scalar(yr,mo,day); } int wg_hms_to_time(void* db, int hr, int min, int sec, int prt) { if (hr<0 || hr>24 || min<0 || min>60 || sec<0 || sec>60 || prt<0 || prt>99) return -1; return hr*(60*60*100)+min*(60*100)+sec*100+prt; } void wg_date_to_ymd(void* db, int date, int *yr, int *mo, int *day) { unsigned int y, m, d; scalar_to_ymd(date, &y, &m, &d); *yr=y; *mo=m; *day=d; } void wg_time_to_hms(void* db, int time, int *hr, int *min, int *sec, int *prt) { int t=time; *hr=t/(60*60*100); t=t-(*hr * (60*60*100)); *min=t/(60*100); t=t-(*min * (60*100)); *sec=t/100; t=t-(*sec * (100)); *prt=t; } // record wg_int wg_encode_record(void* db, void* data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_char"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Skip logging values that do not cause storage allocation. if(dbh->logging.active) { if(wg_log_encode(db, WG_RECORDTYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } */ #endif return (wg_int)(encode_datarec_offset(ptrtooffset(db,data))); } void* wg_decode_record(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_char"); return 0; } #endif return (void*)(offsettoptr(db,decode_datarec_offset(data))); } /* ============================================ Separate string, xmlliteral, uri, blob funs call universal funs defined later ============================================== */ /* string */ wg_int wg_encode_str(void* db, char* str, char* lang) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_str"); return WG_ILLEGAL; } if (str==NULL) { show_data_error(db,"NULL string ptr given to wg_encode_str"); return WG_ILLEGAL; } #endif /* Logging handled inside wg_encode_unistr() */ return wg_encode_unistr(db,str,lang,WG_STRTYPE); } char* wg_decode_str(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_str"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_str is 0, not an encoded string"); return NULL; } #endif return wg_decode_unistr(db,data,WG_STRTYPE); } wg_int wg_decode_str_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_str_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_str_len is 0, not an encoded string"); return -1; } #endif return wg_decode_unistr_len(db,data,WG_STRTYPE); } wg_int wg_decode_str_copy(void* db, wg_int data, char* strbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_str_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_str_copy is 0, not an encoded string"); return -1; } if (strbuf==NULL) { show_data_error(db,"buffer given to wg_decode_str_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_str_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_copy(db,data,strbuf,buflen,WG_STRTYPE); } char* wg_decode_str_lang(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_str"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_str_lang is 0, not an encoded string"); return NULL; } #endif return wg_decode_unistr_lang(db,data,WG_STRTYPE); } wg_int wg_decode_str_lang_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_str_lang_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_str_lang_len is 0, not an encoded string"); return -1; } #endif return wg_decode_unistr_lang_len(db,data,WG_STRTYPE); } wg_int wg_decode_str_lang_copy(void* db, wg_int data, char* langbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_str_lang_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_str_lang_copy is 0, not an encoded string"); return -1; } if (langbuf==NULL) { show_data_error(db,"buffer given to wg_decode_str_lang_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_str_lang_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_lang_copy(db,data,langbuf,buflen,WG_STRTYPE); } /* xmlliteral */ wg_int wg_encode_xmlliteral(void* db, char* str, char* xsdtype) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_xmlliteral"); return WG_ILLEGAL; } if (str==NULL) { show_data_error(db,"NULL string ptr given to wg_encode_xmlliteral"); return WG_ILLEGAL; } if (xsdtype==NULL) { show_data_error(db,"NULL xsdtype ptr given to wg_encode_xmlliteral"); return WG_ILLEGAL; } #endif /* Logging handled inside wg_encode_unistr() */ return wg_encode_unistr(db,str,xsdtype,WG_XMLLITERALTYPE); } char* wg_decode_xmlliteral(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_xmlliteral"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_xmlliteral is 0, not an encoded xmlliteral"); return NULL; } #endif return wg_decode_unistr(db,data,WG_XMLLITERALTYPE); } wg_int wg_decode_xmlliteral_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_xmlliteral_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_xmlliteral_len is 0, not an encoded xmlliteral"); return -1; } #endif return wg_decode_unistr_len(db,data,WG_XMLLITERALTYPE); } wg_int wg_decode_xmlliteral_copy(void* db, wg_int data, char* strbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_xmlliteral_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_xmlliteral_copy is 0, not an encoded xmlliteral"); return -1; } if (strbuf==NULL) { show_data_error(db,"buffer given to wg_decode_xmlliteral_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_xmlliteral_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_copy(db,data,strbuf,buflen,WG_XMLLITERALTYPE); } char* wg_decode_xmlliteral_xsdtype(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_xmlliteral"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_xmlliteral_xsdtype is 0, not an encoded xmlliteral"); return NULL; } #endif return wg_decode_unistr_lang(db,data,WG_XMLLITERALTYPE); } wg_int wg_decode_xmlliteral_xsdtype_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_xmlliteral_xsdtype_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_xmlliteral_lang_xsdtype is 0, not an encoded xmlliteral"); return -1; } #endif return wg_decode_unistr_lang_len(db,data,WG_XMLLITERALTYPE); } wg_int wg_decode_xmlliteral_xsdtype_copy(void* db, wg_int data, char* langbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_xmlliteral_xsdtype_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_xmlliteral_xsdtype_copy is 0, not an encoded xmlliteral"); return -1; } if (langbuf==NULL) { show_data_error(db,"buffer given to wg_decode_xmlliteral_xsdtype_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_xmlliteral_xsdtype_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_lang_copy(db,data,langbuf,buflen,WG_XMLLITERALTYPE); } /* uri */ wg_int wg_encode_uri(void* db, char* str, char* prefix) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_uri"); return WG_ILLEGAL; } if (str==NULL) { show_data_error(db,"NULL string ptr given to wg_encode_uri"); return WG_ILLEGAL; } #endif /* Logging handled inside wg_encode_unistr() */ return wg_encode_unistr(db,str,prefix,WG_URITYPE); } char* wg_decode_uri(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_uri"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_uri is 0, not an encoded string"); return NULL; } #endif return wg_decode_unistr(db,data,WG_URITYPE); } wg_int wg_decode_uri_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_uri_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_uri_len is 0, not an encoded string"); return -1; } #endif return wg_decode_unistr_len(db,data,WG_URITYPE); } wg_int wg_decode_uri_copy(void* db, wg_int data, char* strbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_uri_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_uri_copy is 0, not an encoded string"); return -1; } if (strbuf==NULL) { show_data_error(db,"buffer given to wg_decode_uri_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_uri_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_copy(db,data,strbuf,buflen,WG_URITYPE); } char* wg_decode_uri_prefix(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_uri_prefix"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_uri_prefix is 0, not an encoded uri"); return NULL; } #endif return wg_decode_unistr_lang(db,data,WG_URITYPE); } wg_int wg_decode_uri_prefix_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_uri_prefix_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_uri_prefix_len is 0, not an encoded string"); return -1; } #endif return wg_decode_unistr_lang_len(db,data,WG_URITYPE); } wg_int wg_decode_uri_prefix_copy(void* db, wg_int data, char* langbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_uri_prefix_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_uri_prefix_copy is 0, not an encoded string"); return -1; } if (langbuf==NULL) { show_data_error(db,"buffer given to wg_decode_uri_prefix_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_uri_prefix_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_lang_copy(db,data,langbuf,buflen,WG_URITYPE); } /* blob */ wg_int wg_encode_blob(void* db, char* str, char* type, wg_int len) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_blob"); return WG_ILLEGAL; } if (str==NULL) { show_data_error(db,"NULL string ptr given to wg_encode_blob"); return WG_ILLEGAL; } #endif return wg_encode_uniblob(db,str,type,WG_BLOBTYPE,len); } char* wg_decode_blob(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_blob"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_blob is 0, not an encoded string"); return NULL; } #endif return wg_decode_unistr(db,data,WG_BLOBTYPE); } wg_int wg_decode_blob_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_blob_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_blob_len is 0, not an encoded string"); return -1; } #endif return wg_decode_unistr_len(db,data,WG_BLOBTYPE)+1; } wg_int wg_decode_blob_copy(void* db, wg_int data, char* strbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_blob_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_blob_copy is 0, not an encoded string"); return -1; } if (strbuf==NULL) { show_data_error(db,"buffer given to wg_decode_blob_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_blob_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_copy(db,data,strbuf,buflen,WG_BLOBTYPE); } char* wg_decode_blob_type(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_blob_type"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_blob_type is 0, not an encoded blob"); return NULL; } #endif return wg_decode_unistr_lang(db,data,WG_BLOBTYPE); } wg_int wg_decode_blob_type_len(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_blob_type_len"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_blob_type_len is 0, not an encoded string"); return -1; } #endif return wg_decode_unistr_lang_len(db,data,WG_BLOBTYPE); } wg_int wg_decode_blob_type_copy(void* db, wg_int data, char* langbuf, wg_int buflen) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_blob_type_copy"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_blob_type_copy is 0, not an encoded string"); return -1; } if (langbuf==NULL) { show_data_error(db,"buffer given to wg_decode_blob_type_copy is 0, not a valid buffer pointer"); return -1; } if (buflen<1) { show_data_error(db,"buffer len given to wg_decode_blob_type_copy is 0 or less"); return -1; } #endif return wg_decode_unistr_lang_copy(db,data,langbuf,buflen,WG_BLOBTYPE); } /* anonconst */ wg_int wg_encode_anonconst(void* db, char* str) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_anonconst"); return WG_ILLEGAL; } if (str==NULL) { show_data_error(db,"NULL string ptr given to wg_encode_anonconst"); return WG_ILLEGAL; } #endif //return wg_encode_unistr(db,str,NULL,WG_ANONCONSTTYPE); /* Logging handled inside wg_encode_unistr() */ return wg_encode_unistr(db,str,NULL,WG_URITYPE); } char* wg_decode_anonconst(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_anonconst"); return NULL; } if (!data) { show_data_error(db,"data given to wg_decode_anonconst is 0, not an encoded anonconst"); return NULL; } #endif //return wg_decode_unistr(db,data,WG_ANONCONSTTYPE); return wg_decode_unistr(db,data,WG_URITYPE); } /* var */ wg_int wg_encode_var(void* db, wg_int varnr) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_encode_var"); return WG_ILLEGAL; } if (!fits_var(varnr)) { show_data_error(db,"int given to wg_encode_var too big/small"); return WG_ILLEGAL; } #endif #ifdef USE_DBLOG /* Skip logging values that do not cause storage allocation. if(dbh->logging.active) { if(wg_log_encode(db, WG_VARTYPE, &data, 0, NULL, 0)) return WG_ILLEGAL; } */ #endif return encode_var(varnr); } wg_int wg_decode_var(void* db, wg_int data) { #ifdef CHECK if (!dbcheck(db)) { show_data_error(db,"wrong database pointer given to wg_decode_var"); return -1; } if (!data) { show_data_error(db,"data given to wg_decode_var is 0, not an encoded var"); return -1; } #endif return decode_var(data); } /* ============================================ Universal funs for string, xmlliteral, uri, blob ============================================== */ gint wg_encode_unistr(void* db, char* str, char* lang, gint type) { gint offset; gint len; #ifdef USETINYSTR gint res; #endif char* dptr; char* sptr; char* dendptr; len=(gint)(strlen(str)); #ifdef USE_DBLOG /* Log before allocating. */ if(dbmemsegh(db)->logging.active) { gint extlen = 0; if(lang) extlen = strlen(lang); if(wg_log_encode(db, type, str, len, lang, extlen)) return WG_ILLEGAL; } #endif #ifdef USETINYSTR /* XXX: add tinystr support to logging */ #ifdef USE_DBLOG #error USE_DBLOG and USETINYSTR are incompatible #endif if (lang==NULL && type==WG_STRTYPE && len<(sizeof(gint)-1)) { res=TINYSTRBITS; // first zero the field and set last byte to mask if (LITTLEENDIAN) { dptr=((char*)(&res))+1; // type bits stored in lowest addressed byte } else { dptr=((char*)(&res)); // type bits stored in highest addressed byte } memcpy(dptr,str,len+1); return res; } #endif if (lang==NULL && type==WG_STRTYPE && lenlogging.active) { wg_log_encval(db, WG_ILLEGAL); } #endif return WG_ILLEGAL; } // loop over bytes, storing them starting from offset dptr = (char *) offsettoptr(db,offset); dendptr=dptr+SHORTSTR_SIZE; // //strcpy(dptr,sptr); //memset(dptr+len,0,SHORTSTR_SIZE-len); // for(sptr=str; (*dptr=*sptr)!=0; sptr++, dptr++) {}; // copy string for(dptr++; dptrlogging.active) { if(wg_log_encval(db, encode_shortstr_offset(offset))) return WG_ILLEGAL; /* journal error */ } #endif return encode_shortstr_offset(offset); //dbstore(db,ptrtoffset(record)+RECORD_HEADER_GINTS+fieldnr,encode_shortstr_offset(offset)); } else { offset=find_create_longstr(db,str,lang,type,len+1); if (!offset) { show_data_error_nr(db,"cannot create a string of size ",len); #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { wg_log_encval(db, WG_ILLEGAL); } #endif return WG_ILLEGAL; } #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { if(wg_log_encval(db, encode_longstr_offset(offset))) return WG_ILLEGAL; /* journal error */ } #endif return encode_longstr_offset(offset); } } gint wg_encode_uniblob(void* db, char* str, char* lang, gint type, gint len) { gint offset; if (0) { } else { offset=find_create_longstr(db,str,lang,type,len); if (!offset) { show_data_error_nr(db,"cannot create a blob of size ",len); return WG_ILLEGAL; } return encode_longstr_offset(offset); } } static gint find_create_longstr(void* db, char* data, char* extrastr, gint type, gint length) { db_memsegment_header* dbh = dbmemsegh(db); gint offset; size_t i; gint tmp; gint lengints; gint lenrest; char* lstrptr; gint old=0; int hash; gint hasharrel; gint res; if (0) { } else { // find hash, check if exists and use if found hash=wg_hash_typedstr(db,data,extrastr,type,length); //hasharrel=((gint*)(offsettoptr(db,((db->strhash_area_header).arraystart))))[hash]; hasharrel=dbfetch(db,((dbh->strhash_area_header).arraystart)+(sizeof(gint)*hash)); //printf("hash %d((dbh->strhash_area_header).arraystart)+(sizeof(gint)*hash) %d hasharrel %d\n", // hash,((dbh->strhash_area_header).arraystart)+(sizeof(gint)*hash), hasharrel); if (hasharrel) old=wg_find_strhash_bucket(db,data,extrastr,type,length,hasharrel); //printf("old %d \n",old); if (old) { //printf("str found in hash\n"); return old; } //printf("str not found in hash\n"); //printf("hasharrel 1 %d \n",hasharrel); // equal string not found in hash // allocate a new string lengints=length/sizeof(gint); // 7/4=1, 8/4=2, 9/4=2, lenrest=length%sizeof(gint); // 7%4=3, 8%4=0, 9%4=1, if (lenrest) lengints++; offset=wg_alloc_gints(db, &(dbmemsegh(db)->longstr_area_header), lengints+LONGSTR_HEADER_GINTS); if (!offset) { //show_data_error_nr(db,"cannot create a data string/blob of size ",length); return 0; } lstrptr=(char*)(offsettoptr(db,offset)); // store string contents memcpy(lstrptr+(LONGSTR_HEADER_GINTS*sizeof(gint)),data,length); //zero the rest for(i=0;lenrest && istrhash_area_header).arraystart)+(sizeof(gint)*hash),res); //printf("hasharrel 2 %d \n",hasharrel); dbstore(db,offset+LONGSTR_HASHCHAIN_POS*sizeof(gint),hasharrel); // store old hash array el // return result return res; } } char* wg_decode_unistr(void* db, gint data, gint type) { gint* objptr; char* dataptr; #ifdef USETINYSTR if (type==WG_STRTYPE && istinystr(data)) { if (LITTLEENDIAN) { dataptr=((char*)(&data))+1; // type bits stored in lowest addressed byte } else { dataptr=((char*)(&data)); // type bits stored in highest addressed byte } return dataptr; } #endif if (isshortstr(data)) { dataptr=(char*)(offsettoptr(db,decode_shortstr_offset(data))); return dataptr; } if (islongstr(data)) { objptr = (gint *) offsettoptr(db,decode_longstr_offset(data)); dataptr=((char*)(objptr))+(LONGSTR_HEADER_GINTS*sizeof(gint)); return dataptr; } show_data_error(db,"data given to wg_decode_unistr is not an encoded string"); return NULL; } char* wg_decode_unistr_lang(void* db, gint data, gint type) { gint* objptr; gint* fldptr; gint fldval; char* res; #ifdef USETINYSTR if (type==WG_STRTYPE && istinystr(data)) { return NULL; } #endif if (type==WG_STRTYPE && isshortstr(data)) { return NULL; } if (islongstr(data)) { objptr = (gint *) offsettoptr(db,decode_longstr_offset(data)); fldptr=((gint*)objptr)+LONGSTR_EXTRASTR_POS; fldval=*fldptr; if (fldval==0) return NULL; res=wg_decode_unistr(db,fldval,type); return res; } show_data_error(db,"data given to wg_decode_unistr_lang is not an encoded string"); return NULL; } /** * return length of the main string, not including terminating 0 * * */ gint wg_decode_unistr_len(void* db, gint data, gint type) { char* dataptr; gint* objptr; gint objsize; gint strsize; #ifdef USETINYSTR if (type==WG_STRTYPE && istinystr(data)) { if (LITTLEENDIAN) { dataptr=((char*)(&data))+1; // type bits stored in lowest addressed byte } else { dataptr=((char*)(&data)); // type bits stored in highest addressed byte } strsize=strlen(dataptr); return strsize; } #endif if (isshortstr(data)) { dataptr=(char*)(offsettoptr(db,decode_shortstr_offset(data))); strsize=strlen(dataptr); return strsize; } if (islongstr(data)) { objptr = (gint *) offsettoptr(db,decode_longstr_offset(data)); objsize=getusedobjectsize(*objptr); dataptr=((char*)(objptr))+(LONGSTR_HEADER_GINTS*sizeof(gint)); //printf("dataptr to read from %d str '%s' of len %d\n",dataptr,dataptr,strlen(dataptr)); strsize=objsize-(((*(objptr+LONGSTR_META_POS))&LONGSTR_META_LENDIFMASK)>>LONGSTR_META_LENDIFSHFT); return strsize-1; } show_data_error(db,"data given to wg_decode_unistr_len is not an encoded string"); return 0; } /** * copy string, return length of a copied string, not including terminating 0 * * return -1 in case of error * */ gint wg_decode_unistr_copy(void* db, gint data, char* strbuf, gint buflen, gint type) { gint i; gint* objptr; char* dataptr; gint objsize; gint strsize; #ifdef USETINYSTR if (type==WG_STRTYPE && istinystr(data)) { if (LITTLEENDIAN) { dataptr=((char*)(&data))+1; // type bits stored in lowest addressed byte } else { dataptr=((char*)(&data)); // type bits stored in highest addressed byte } strsize=strlen(dataptr)+1; if (strsize>=sizeof(gint)) { show_data_error_nr(db,"wrong data stored as tinystr, impossible length:",strsize); return 0; } if (buflen=buflen) { show_data_error_nr(db,"insufficient buffer length given to wg_decode_unistr_copy:",buflen); return -1; } *strbuf=*dataptr; } *strbuf=0; return i-1; } if (islongstr(data)) { objptr = (gint *) offsettoptr(db,decode_longstr_offset(data)); objsize=getusedobjectsize(*objptr); dataptr=((char*)(objptr))+(LONGSTR_HEADER_GINTS*sizeof(gint)); //printf("dataptr to read from %d str '%s' of len %d\n",dataptr,dataptr,strlen(dataptr)); strsize=objsize-(((*(objptr+LONGSTR_META_POS))&LONGSTR_META_LENDIFMASK)>>LONGSTR_META_LENDIFSHFT); //printf("objsize %d metaptr %d meta %d lendiff %d strsize %d \n", // objsize,((gint*)objptr+LONGSTR_META_POS),*((gint*)objptr+LONGSTR_META_POS), // (((*(objptr+LONGSTR_META_POS))&LONGSTR_META_LENDIFMASK)>>LONGSTR_META_LENDIFSHFT),strsize); if(buflen=buflen) { show_data_error_nr(db,"insufficient buffer length given to wg_decode_unistr_lang_copy:",buflen); return -1; } memcpy(strbuf,langptr,len+1); return len; } /* ----------- calendar and time functions ------------------- */ /* Scalar date routines used are written and given to public domain by Ray Gardner. */ static int isleap(unsigned yr) { return yr % 400 == 0 || (yr % 4 == 0 && yr % 100 != 0); } static unsigned months_to_days (unsigned month) { return (month * 3057 - 3007) / 100; } static long years_to_days (unsigned yr) { return yr * 365L + yr / 4 - yr / 100 + yr / 400; } static long ymd_to_scalar (unsigned yr, unsigned mo, unsigned day) { long scalar; scalar = day + months_to_days(mo); if ( mo > 2 ) /* adjust if past February */ scalar -= isleap(yr) ? 1 : 2; yr--; scalar += years_to_days(yr); return scalar; } static void scalar_to_ymd (long scalar, unsigned *yr, unsigned *mo, unsigned *day) { unsigned n; /* compute inverse of years_to_days() */ for ( n = (unsigned)((scalar * 400L) / 146097L); years_to_days(n) < scalar;) n++; /* 146097 == years_to_days(400) */ *yr = n; n = (unsigned)(scalar - years_to_days(n-1)); if ( n > 59 ) { /* adjust if past February */ n += 2; if (isleap(*yr)) n -= n > 62 ? 1 : 2; } *mo = (n * 100 + 3007) / 3057; /* inverse of months_to_days() */ *day = n - months_to_days(*mo); } /* Thread-safe localtime_r appears not to be present on windows: emulate using win localtime_s, which is thread-safe */ #ifdef _WIN32 static struct tm * localtime_r (const time_t *timer, struct tm *result) { struct tm local_result; int res; res = localtime_s (&local_result,timer); if (!res) return NULL; //if (local_result == NULL || result == NULL) return NULL; memcpy (result, &local_result, sizeof (result)); return result; } #endif /* ------ value offset translation ---- */ /* Translate externally encoded value in relation to current base address * * Data argument is a value encoded in the database extdb. Returned value is * translated so that it can be used in WhiteDB API functions with the * database db. */ gint wg_encode_external_data(void *db, void *extdb, gint encoded) { #ifdef USE_CHILD_DB return wg_translate_hdroffset(db, dbmemseg(extdb), encoded); #else show_data_error(db, "child databases support is not enabled."); return WG_ILLEGAL; #endif } #ifdef USE_CHILD_DB gint wg_translate_hdroffset(void *db, void *exthdr, gint encoded) { gint extoff = ptrtooffset(db, exthdr); /* relative offset of external db */ /* Only pointer-type values need translating */ if(isptr(encoded)) { switch(encoded&NORMALPTRMASK) { case DATARECBITS: return encode_datarec_offset( decode_datarec_offset(encoded) + extoff); case LONGSTRBITS: return encode_longstr_offset( decode_longstr_offset(encoded) + extoff); case SHORTSTRBITS: return encode_shortstr_offset( decode_shortstr_offset(encoded) + extoff); case FULLDOUBLEBITS: return encode_fulldouble_offset( decode_fulldouble_offset(encoded) + extoff); case FULLINTBITSV0: case FULLINTBITSV1: return encode_fullint_offset( decode_fullint_offset(encoded) + extoff); default: /* XXX: it's not entirely correct to fail silently here, but * we can only end up here if new pointer types are added without * updating this function. */ break; } } return encoded; } /** Return base address that an encoded value is "native" to. * * The external database must be registered first for the offset * to be recognized. Returns NULL if none of the registered * databases match. */ static void *get_ptr_owner(void *db, gint encoded) { gint offset = 0; if(isptr(encoded)) { switch(encoded&NORMALPTRMASK) { case DATARECBITS: offset = decode_datarec_offset(encoded); case LONGSTRBITS: offset = decode_longstr_offset(encoded); case SHORTSTRBITS: offset = decode_shortstr_offset(encoded); case FULLDOUBLEBITS: offset = decode_fulldouble_offset(encoded); case FULLINTBITSV0: case FULLINTBITSV1: offset = decode_fullint_offset(encoded); default: break; } } else { return dbmemseg(db); /* immediate values default to "Local" */ } if(!offset) return NULL; /* data values do not point at memsegment header * start anyway. */ if(offset > 0 && offset < dbmemsegh(db)->size) { return dbmemseg(db); /* "Local" record */ } else { int i; db_memsegment_header* dbh = dbmemsegh(db); for(i=0; iextdbs.count; i++) { if(offset > dbh->extdbs.offset[i] && \ offset < dbh->extdbs.offset[i] + dbh->extdbs.size[i]) { return (void *) (dbmemsegbytes(db) + dbh->extdbs.offset[i]); } } return NULL; } } /** Check if an offset is "native" to the current database. * * Returns 1 if the offset is local, 0 otherwise. */ static int is_local_offset(void *db, gint offset) { if(offset > 0 && offset < dbmemsegh(db)->size) { return 1; /* "Local" data */ } return 0; } #endif /** Return base address that the record belongs to. * * Takes pointer values as arguments. * The external database must be registered first for the offset * to be recognized. Returns NULL if none of the registered * databases match. * XXX: needed to compile the lib under windows even * if child databases are disabled. */ void *wg_get_rec_owner(void *db, void *rec) { int i; db_memsegment_header* dbh = dbmemsegh(db); if((gint) rec > (gint) dbmemseg(db)) { void *eodb = (void *) (dbmemsegbytes(db) + dbh->size); if((gint) rec < (gint) eodb) return dbmemseg(db); /* "Local" record */ } for(i=0; iextdbs.count; i++) { void *base = (void *) (dbmemsegbytes(db) + dbh->extdbs.offset[i]); void *eodb = (void *) (((char *) base) + dbh->extdbs.size[i]); if((gint) rec > (gint) base && (gint) rec < (gint) eodb) { return base; } } show_data_error(db, "invalid pointer in wg_get_rec_base_offset"); return NULL; } /* ----------- record pointer bitmap operations -------- */ /* We assume records are aligned at minimum each 8 bytes. Each possible record offset is assigned one bit in a bitmap. Consider offsets: 0,8,16,24,32,40,48,56 | 64,72,80,88,... addr: byte 0 | byte 1 ... shft: 0 1 2 3 4 5 6 7 | 0 1 2 3 ... */ /** Check both that db and record pointer ptr are correct. Uses the record pointer bitmap. */ #ifdef USE_RECPTR_BITMAP /* currently disabled, as nothing is updating * the bitmap. Re-enable as needed. */ gint wg_recptr_check(void *db,void *ptr) { gint addr; int shft; unsigned char byte; db_memsegment_header* dbh = dbmemsegh(db); gint offset=ptrtooffset(db,ptr); if (!dbcheckh(dbh)) return -1; // not a correct db if (offset<=0 || offset>=dbh->size) return -2; // ptr out of area if (offset%8) return -3; // ptr not correctly aligned addr=offset/64; // divide by alignment shft=(offset%64)/8; // bit position in byte if (!(dbh->recptr_bitmap.offset)) return -4; // bitmap not allocated byte=*((char*)(offsettoptr(db,dbh->recptr_bitmap.offset+addr))); if (byte & (1<=dbh->size) return -1; // out of area //if (offset%8) return -2; // not correctly aligned addr=offset/64; // divide by alignment shft=(offset%64)/8; // bit position in byte byteptr=(char*)(offsettoptr(db,dbh->recptr_bitmap.offset+addr)); byte=*byteptr; *byteptr=byte | (1<=dbh->size) return -1; // out of area //if (offset%8) return -2; // not correctly aligned addr=offset/64; // divide by alignment shft=(offset%64)/8; // bit position in byte byteptr=(char*)(offsettoptr(db,dbh->recptr_bitmap.offset+addr)); byte=*byteptr; *byteptr=byte ^ (1<. * */ /** @file dbhash.c * Hash operations for strings and other datatypes. * * */ /* ====== Includes =============== */ #include #include #include #include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dbhash.h" #include "dbdata.h" #include "dbmpool.h" /* ====== Private headers and defs ======== */ /* Bucket capacity > 1 reduces the impact of collisions */ #define GINTHASH_BUCKETCAP 7 /* Level 24 hash consumes approx 640MB with bucket capacity 3 on 32-bit * architecture and about twice as much on 64-bit systems. With bucket * size increased to 7 (which is more space efficient due to imperfect * hash distribution) we can reduce the level by 1 for the same space * requirements. */ #define GINTHASH_MAXLEVEL 23 /* rehash keys (useful for lowering the impact of bad distribution) */ #define GINTHASH_SCRAMBLE(v) (rehash_gint(v)) /*#define GINTHASH_SCRAMBLE(v) (v)*/ typedef struct { gint level; /* local level */ gint fill; /* slots filled / next slot index */ gint key[GINTHASH_BUCKETCAP + 1]; /* includes one overflow slot */ gint value[GINTHASH_BUCKETCAP + 1]; } ginthash_bucket; /* Dynamic local memory hashtable for gint key/value pairs. Resize * is handled using the extendible hashing algorithm. * Note: we don't use 0-level hash, so buckets[0] is unused. */ typedef struct { gint level; /* global level */ ginthash_bucket **directory; /* bucket pointers, contiguous memory */ void *mpool; /* dbmpool storage */ } ext_ginthash; /* Static local memory hash table for existence tests (double hashing) */ typedef struct { size_t dhash_size; gint *keys; } dhash_table; #ifdef HAVE_64BIT_GINT #define FNV_offset_basis ((wg_uint) 14695981039346656037ULL) #define FNV_prime ((wg_uint) 1099511628211ULL) #else #define FNV_offset_basis ((wg_uint) 2166136261UL) #define FNV_prime ((wg_uint) 16777619UL) #endif /* ======= Private protos ================ */ // static gint show_consistency_error(void* db, char* errmsg); static gint show_consistency_error_nr(void* db, char* errmsg, gint nr) ; // static gint show_consistency_error_double(void* db, char* errmsg, double nr); // static gint show_consistency_error_str(void* db, char* errmsg, char* str); static gint show_hash_error(void* db, char* errmsg); static gint show_ginthash_error(void *db, char* errmsg); static wg_uint hash_bytes(void *db, char *data, gint length, gint hashsz); static gint find_idxhash_bucket(void *db, char *data, gint length, gint *chainoffset); static gint rehash_gint(gint val); static gint grow_ginthash(void *db, ext_ginthash *tbl); static ginthash_bucket *ginthash_newbucket(void *db, ext_ginthash *tbl); static ginthash_bucket *ginthash_splitbucket(void *db, ext_ginthash *tbl, ginthash_bucket *bucket); static gint add_to_bucket(ginthash_bucket *bucket, gint key, gint value); static gint remove_from_bucket(ginthash_bucket *bucket, int idx); /* ====== Functions ============== */ /* ------------- strhash operations ------------------- */ /* Hash function for two-part strings and blobs. * * Based on sdbm. * */ int wg_hash_typedstr(void* db, char* data, char* extrastr, gint type, gint length) { char* endp; unsigned long hash = 0; int c; //printf("in wg_hash_typedstr %s %s %d %d \n",data,extrastr,type,length); if (data!=NULL) { for(endp=data+length; datastrhash_area_header).arraylength); } /* Find longstr from strhash bucket chain * * */ gint wg_find_strhash_bucket(void* db, char* data, char* extrastr, gint type, gint size, gint hashchain) { //printf("wg_find_strhash_bucket called %s %s type %d size %d hashchain %d\n",data,extrastr,type,size,hashchain); for(;hashchain!=0; hashchain=dbfetch(db,decode_longstr_offset(hashchain)+LONGSTR_HASHCHAIN_POS*sizeof(gint))) { if (wg_right_strhash_bucket(db,hashchain,data,extrastr,type,size)) { // found equal longstr, return it //printf("wg_find_strhash_bucket found hashchain %d\n",hashchain); return hashchain; } } return 0; } /* Check whether longstr hash bucket matches given new str * * */ int wg_right_strhash_bucket (void* db, gint longstr, char* cstr, char* cextrastr, gint ctype, gint cstrsize) { char* str; char* extrastr; int strsize; gint type; //printf("wg_right_strhash_bucket called with %s %s type %d size %d\n", // cstr,cextrastr,ctype,cstrsize); type=wg_get_encoded_type(db,longstr); if (type!=ctype) return 0; strsize=wg_decode_str_len(db,longstr)+1; if (strsize!=cstrsize) return 0; str=wg_decode_str(db,longstr); if ((cstr==NULL && str!=NULL) || (cstr!=NULL && str==NULL)) return 0; if ((cstr!=NULL) && (memcmp(str,cstr,cstrsize))) return 0; extrastr=wg_decode_str_lang(db,longstr); if ((cextrastr==NULL && extrastr!=NULL) || (cextrastr!=NULL && extrastr==NULL)) return 0; if ((cextrastr!=NULL) && (strcmp(extrastr,cextrastr))) return 0; return 1; } /* Remove longstr from strhash * * Internal langstr etc are not removed by this op. * */ gint wg_remove_from_strhash(void* db, gint longstr) { db_memsegment_header* dbh = dbmemsegh(db); gint type; gint* extrastrptr; char* extrastr; char* data; gint length; gint hash; gint chainoffset; gint hashchain; gint nextchain; gint offset; gint* objptr; gint fldval; gint objsize; gint strsize; gint* typeptr; //printf("wg_remove_from_strhash called on %d\n",longstr); //wg_debug_print_value(db,longstr); //printf("\n\n"); offset=decode_longstr_offset(longstr); objptr=(gint*) offsettoptr(db,offset); // get string data elements //type=objptr=offsettoptr(db,decode_longstr_offset(data)); extrastrptr=(gint *) (((char*)(objptr))+(LONGSTR_EXTRASTR_POS*sizeof(gint))); fldval=*extrastrptr; if (fldval==0) extrastr=NULL; else extrastr=wg_decode_str(db,fldval); data=((char*)(objptr))+(LONGSTR_HEADER_GINTS*sizeof(gint)); objsize=getusedobjectsize(*objptr); strsize=objsize-(((*(objptr+LONGSTR_META_POS))&LONGSTR_META_LENDIFMASK)>>LONGSTR_META_LENDIFSHFT); length=strsize; typeptr=(gint*)(((char*)(objptr))+(+LONGSTR_META_POS*sizeof(gint))); type=(*typeptr)&LONGSTR_META_TYPEMASK; //type=wg_get_encoded_type(db,longstr); // get hash of data elements and find the location in hashtable/chains hash=wg_hash_typedstr(db,data,extrastr,type,length); chainoffset=((dbh->strhash_area_header).arraystart)+(sizeof(gint)*hash); hashchain=dbfetch(db,chainoffset); while(hashchain!=0) { if (hashchain==longstr) { nextchain=dbfetch(db,decode_longstr_offset(hashchain)+(LONGSTR_HASHCHAIN_POS*sizeof(gint))); dbstore(db,chainoffset,nextchain); return 0; } chainoffset=decode_longstr_offset(hashchain)+(LONGSTR_HASHCHAIN_POS*sizeof(gint)); hashchain=dbfetch(db,chainoffset); } show_consistency_error_nr(db,"string not found in hash during deletion, offset",offset); return -1; } /* -------------- hash index support ------------------ */ #define CONCAT_FOR_HASHING(d, b, e, l, bb, en) \ if(e) { \ gint xl = wg_decode_xmlliteral_xsdtype_len(d, en); \ bb = malloc(xl + l + 1); \ if(!bb) \ return 0; \ memcpy(bb, e, xl); \ bb[xl] = '\0'; \ memcpy(bb + xl + 1, b, l); \ b = bb; \ l += xl + 1; \ } /* * Return an encoded value as a decoded byte array. * It should be freed afterwards. * returns the number of bytes in the array. * returns 0 if the decode failed. * * NOTE: to differentiate between identical byte strings * the value is prefixed with a type identifier. * TODO: For values with varying length that can contain * '\0' bytes, add length to the prefix. */ gint wg_decode_for_hashing(void *db, gint enc, char **decbytes) { gint len; gint type; gint ptrdata; int intdata; double doubledata; char *bytedata; char *exdata, *buf = NULL, *outbuf; type = wg_get_encoded_type(db, enc); switch(type) { case WG_NULLTYPE: len = sizeof(gint); ptrdata = 0; bytedata = (char *) &ptrdata; break; case WG_RECORDTYPE: len = sizeof(gint); ptrdata = enc; bytedata = (char *) &ptrdata; break; case WG_INTTYPE: len = sizeof(int); intdata = wg_decode_int(db, enc); bytedata = (char *) &intdata; break; case WG_DOUBLETYPE: len = sizeof(double); doubledata = wg_decode_double(db, enc); bytedata = (char *) &doubledata; break; case WG_FIXPOINTTYPE: len = sizeof(double); doubledata = wg_decode_fixpoint(db, enc); bytedata = (char *) &doubledata; break; case WG_STRTYPE: len = wg_decode_str_len(db, enc); bytedata = wg_decode_str(db, enc); break; case WG_URITYPE: len = wg_decode_uri_len(db, enc); bytedata = wg_decode_uri(db, enc); exdata = wg_decode_uri_prefix(db, enc); CONCAT_FOR_HASHING(db, bytedata, exdata, len, buf, enc) break; case WG_XMLLITERALTYPE: len = wg_decode_xmlliteral_len(db, enc); bytedata = wg_decode_xmlliteral(db, enc); exdata = wg_decode_xmlliteral_xsdtype(db, enc); CONCAT_FOR_HASHING(db, bytedata, exdata, len, buf, enc) break; case WG_CHARTYPE: len = sizeof(int); intdata = wg_decode_char(db, enc); bytedata = (char *) &intdata; break; case WG_DATETYPE: len = sizeof(int); intdata = wg_decode_date(db, enc); bytedata = (char *) &intdata; break; case WG_TIMETYPE: len = sizeof(int); intdata = wg_decode_time(db, enc); bytedata = (char *) &intdata; break; case WG_VARTYPE: len = sizeof(int); intdata = wg_decode_var(db, enc); bytedata = (char *) &intdata; break; case WG_ANONCONSTTYPE: /* Ignore anonconst */ default: return 0; } /* Form the hashable buffer. It is not 0-terminated */ outbuf = malloc(len + 1); if(outbuf) { outbuf[0] = (char) type; memcpy(outbuf + 1, bytedata, len++); *decbytes = outbuf; } else { /* Indicate failure */ len = 0; } if(buf) free(buf); return len; } /* * Calculate a hash for a byte buffer. Truncates the hash to given size. */ static wg_uint hash_bytes(void *db, char *data, gint length, gint hashsz) { char* endp; wg_uint hash = 0; if (data!=NULL) { for(endp=data+length; dataarraylength); head_offset = (ha->arraystart)+(sizeof(gint) * hash); head = dbfetch(db, head_offset); /* Traverse the hash chain to check if there is a matching * hash string already */ bucket = find_idxhash_bucket(db, data, length, &head_offset); if(!bucket) { size_t i; gint lengints, lenrest; char* dptr; /* Make a new bucket */ lengints = length / sizeof(gint); lenrest = length % sizeof(gint); if(lenrest) lengints++; bucket = wg_alloc_gints(db, &(dbh->indexhash_area_header), lengints + HASHIDX_HEADER_SIZE); if(!bucket) { return -1; } /* Copy the byte data */ dptr = (char *) (offsettoptr(db, bucket + HASHIDX_HEADER_SIZE*sizeof(gint))); memcpy(dptr, data, length); for(i=0;lenrest && iarraystart)+(sizeof(gint) * hash)), bucket); dbstore(db, bucket + HASHIDX_HASHCHAIN_POS*sizeof(gint), head); } /* Add the record offset to the list. */ rec_head = dbfetch(db, bucket + HASHIDX_RECLIST_POS*sizeof(gint)); rec_offset = wg_alloc_fixlen_object(db, &(dbh->listcell_area_header)); rec_cell = (gcell *) offsettoptr(db, rec_offset); rec_cell->car = offset; rec_cell->cdr = rec_head; dbstore(db, bucket + HASHIDX_RECLIST_POS*sizeof(gint), rec_offset); return 0; } /* * Remove an offset from the index hash. * * Returns 0 on success * Returns -1 on error. */ gint wg_idxhash_remove(void* db, db_hash_area_header *ha, char* data, gint length, gint offset) { wg_uint hash; gint bucket_offset, bucket; gint *next_offset, *reclist_offset; hash = hash_bytes(db, data, length, ha->arraylength); bucket_offset = (ha->arraystart)+(sizeof(gint) * hash); /* points to head */ /* Find the correct bucket. */ bucket = find_idxhash_bucket(db, data, length, &bucket_offset); if(!bucket) { return show_hash_error(db, "wg_idxhash_remove: Hash value not found."); } /* Remove the record offset from the list. */ reclist_offset = offsettoptr(db, bucket + HASHIDX_RECLIST_POS*sizeof(gint)); next_offset = reclist_offset; while(*next_offset) { gcell *rec_cell = (gcell *) offsettoptr(db, *next_offset); if(rec_cell->car == offset) { gint rec_offset = *next_offset; *next_offset = rec_cell->cdr; /* remove from list chain */ wg_free_listcell(db, rec_offset); /* free storage */ goto is_bucket_empty; } next_offset = &(rec_cell->cdr); } return show_hash_error(db, "wg_idxhash_remove: Offset not found"); is_bucket_empty: if(!(*reclist_offset)) { gint nextchain = dbfetch(db, bucket + HASHIDX_HASHCHAIN_POS*sizeof(gint)); dbstore(db, bucket_offset, nextchain); wg_free_object(db, &(dbmemsegh(db)->indexhash_area_header), bucket); } return 0; } /* * Retrieve the list of matching offsets from the hash. * * Returns the offset to head of the linked list. * Returns 0 if value was not found. */ gint wg_idxhash_find(void* db, db_hash_area_header *ha, char* data, gint length) { wg_uint hash; gint head_offset, bucket; hash = hash_bytes(db, data, length, ha->arraylength); head_offset = (ha->arraystart)+(sizeof(gint) * hash); /* points to head */ /* Find the correct bucket. */ bucket = find_idxhash_bucket(db, data, length, &head_offset); if(!bucket) return 0; return dbfetch(db, bucket + HASHIDX_RECLIST_POS*sizeof(gint)); } /* ------- local-memory extendible gint hash ---------- */ /* * Dynamically growing gint hash. * * Implemented in local memory for temporary usage (database memory is not well * suited as it is not resizable). Uses the extendible hashing algorithm * proposed by Fagin et al '79 as this allows the use of simple, easily * disposable data structures. */ /** Initialize the hash table. * The initial hash level is 1. * returns NULL on failure. */ void *wg_ginthash_init(void *db) { ext_ginthash *tbl = malloc(sizeof(ext_ginthash)); if(!tbl) { show_ginthash_error(db, "Failed to allocate table."); return NULL; } memset(tbl, 0, sizeof(ext_ginthash)); if(grow_ginthash(db, tbl)) { /* initial level is set to 1 */ free(tbl); return NULL; } return tbl; } /** Add a key/value pair to the hash table. * tbl should be created with wg_ginthash_init() * Returns 0 on success * Returns -1 on failure */ gint wg_ginthash_addkey(void *db, void *tbl, gint key, gint val) { size_t dirsize = 1<<((ext_ginthash *)tbl)->level; size_t hash = GINTHASH_SCRAMBLE(key) & (dirsize - 1); ginthash_bucket *bucket = ((ext_ginthash *)tbl)->directory[hash]; /*static gint keys = 0;*/ /* printf("add: %d hash %d items %d\n", key, hash, ++keys); */ if(!bucket) { /* allocate a new bucket, store value, we're done */ bucket = ginthash_newbucket(db, (ext_ginthash *) tbl); if(!bucket) return -1; bucket->level = ((ext_ginthash *) tbl)->level; add_to_bucket(bucket, key, val); /* Always fits, no check needed */ ((ext_ginthash *)tbl)->directory[hash] = bucket; } else { add_to_bucket(bucket, key, val); while(bucket->fill > GINTHASH_BUCKETCAP) { ginthash_bucket *newb; /* Overflow, bucket split needed. */ if(!(newb = ginthash_splitbucket(db, (ext_ginthash *)tbl, bucket))) return -1; /* Did everything flow to the new bucket, causing another overflow? */ if(newb->fill > GINTHASH_BUCKETCAP) { bucket = newb; /* Keep splitting */ } } } return 0; } /** Fetch a value from the hash table. * If the value is not found, returns -1 (val is unmodified). * Otherwise returns 0; contents of val is replaced with the * value from the hash table. */ gint wg_ginthash_getkey(void *db, void *tbl, gint key, gint *val) { size_t dirsize = 1<<((ext_ginthash *)tbl)->level; size_t hash = GINTHASH_SCRAMBLE(key) & (dirsize - 1); ginthash_bucket *bucket = ((ext_ginthash *)tbl)->directory[hash]; if(bucket) { int i; for(i=0; ifill; i++) { if(bucket->key[i] == key) { *val = bucket->value[i]; return 0; } } } return -1; } /** Release all memory allocated for the hash table. * */ void wg_ginthash_free(void *db, void *tbl) { if(tbl) { if(((ext_ginthash *) tbl)->directory) free(((ext_ginthash *) tbl)->directory); if(((ext_ginthash *) tbl)->mpool) wg_free_mpool(db, ((ext_ginthash *) tbl)->mpool); free(tbl); } } /** Scramble a gint value * This is useful when dealing with aligned offsets, that are * multiples of 4, 8 or larger values and thus waste the majority * of the directory space when used directly. * Uses FNV-1a. */ static gint rehash_gint(gint val) { int i; wg_uint hash = FNV_offset_basis; for(i=0; ilevel + 1; if(newlevel >= GINTHASH_MAXLEVEL) return show_ginthash_error(db, "Maximum level exceeded."); if((tmp = realloc((void *) tbl->directory, (1<directory = (ginthash_bucket **) tmp; if(tbl->level) { size_t i; size_t dirsize = 1<level; /* duplicate the existing pointers. */ for(i=0; idirectory[dirsize + i] = tbl->directory[i]; } else { /* Initialize the memory pool (2 buckets) */ if((tmp = wg_create_mpool(db, 2*sizeof(ginthash_bucket)))) { tbl->mpool = tmp; /* initial directory is empty */ memset(tbl->directory, 0, 2*sizeof(ginthash_bucket *)); } else { return show_ginthash_error(db, "Failed to allocate bucket pool."); } } } else { return show_ginthash_error(db, "Failed to reallocate directory."); } tbl->level = newlevel; return 0; } /** Allocate a new bucket. * */ static ginthash_bucket *ginthash_newbucket(void *db, ext_ginthash *tbl) { ginthash_bucket *bucket = (ginthash_bucket *) \ wg_alloc_mpool(db, tbl->mpool, sizeof(ginthash_bucket)); if(bucket) { /* bucket->level = tbl->level; */ bucket->fill = 0; } return bucket; } /** Split a bucket. * Returns the newly created bucket on success * Returns NULL on failure (likely cause being out of memory) */ static ginthash_bucket *ginthash_splitbucket(void *db, ext_ginthash *tbl, ginthash_bucket *bucket) { gint msbmask, lowbits; int i; ginthash_bucket *newbucket; if(bucket->level == tbl->level) { /* can't split at this level anymore, extend directory */ /*printf("grow: curr level %d\n", tbl->level);*/ if(grow_ginthash(db, (ext_ginthash *) tbl)) return NULL; } /* Hash values for the new level (0+lowbits, msb+lowbits) */ msbmask = (1<<(bucket->level++)); lowbits = GINTHASH_SCRAMBLE(bucket->key[0]) & (msbmask - 1); /* Create a bucket to split into */ newbucket = ginthash_newbucket(db, tbl); if(!newbucket) return NULL; newbucket->level = bucket->level; /* Split the entries based on the most significant * bit for the local level hash (the ones with msb set are relocated) */ for(i=bucket->fill-1; i>=0; i--) { gint k_i = bucket->key[i]; if(GINTHASH_SCRAMBLE(k_i) & msbmask) { add_to_bucket(newbucket, k_i, remove_from_bucket(bucket, i)); /* printf("reassign: %d hash %d --> %d\n", k_i, lowbits, msbmask | lowbits); */ } } /* Update the directory */ if(bucket->level == tbl->level) { /* There are just two pointers pointing to bucket, * we can compute the location of the one that has the index * with msb set. The other one's contents do not need to be * modified. */ tbl->directory[msbmask | lowbits] = newbucket; } else { /* The pointers that need to be updated have indexes * of xxx1yyyy where 1 is the msb in the index of the new * bucket, yyyy is the hash value of the bucket masked * by the previous level and xxx are all combinations of * bits that still remain masked by the local level after * the split. The pointers xxx0yyyy will remain pointing * to the old bucket. */ size_t msbbuckets = 1<<(tbl->level - bucket->level), j; for(j=0; jlevel) | msbmask | lowbits; /* XXX: paranoia check, remove in production */ if(tbl->directory[k] != bucket) return NULL; tbl->directory[k] = newbucket; } } return newbucket; } /** Add a key/value pair to bucket. * Returns bucket fill. */ static gint add_to_bucket(ginthash_bucket *bucket, gint key, gint value) { #ifdef CHECK if(bucket->fill > GINTHASH_BUCKETCAP) { /* Should never happen */ return bucket->fill + 1; } else { #endif bucket->key[bucket->fill] = key; bucket->value[bucket->fill] = value; return ++(bucket->fill); #ifdef CHECK } #endif } /** Remove an indexed value from bucket. * Returns the value. */ static gint remove_from_bucket(ginthash_bucket *bucket, int idx) { int i; gint val = bucket->value[idx]; for(i=idx; i=bucket->fill are always undefined * and shouldn't be accessed directly. */ bucket->key[i] = bucket->key[i+1]; bucket->value[i] = bucket->value[i+1]; } bucket->fill--; return val; } /* ------- set membership hash (double hashing) --------- */ /* * Compute a suitable hash table size for the known number of * entries. Returns 0 if the size is not supported. * Max hash table size is 63GB (~2G entries on 64-bit), this can * be extended by adding more primes. * Size is chosen so that the table load would be < 0.5 */ static size_t dhash_size(size_t entries) { /* List of primes lifted from stlport * (http://sourceforge.net/projects/stlport/) */ size_t primes[] = { 389UL, 769UL, 1543UL, 3079UL, 6151UL, 12289UL, 24593UL, 49157UL, 98317UL, 196613UL, 393241UL, 786433UL, 1572869UL, 3145739UL, 6291469UL, 12582917UL, 25165843UL, 50331653UL, 100663319UL, 201326611UL, 402653189UL, 805306457UL, 1610612741UL, 3221225473UL, 4294967291UL }; size_t const p_count = 20; size_t wantsize = entries<<1, i; if(entries > 2147483645UL) { return 0; /* give up here for now */ } for(i=0; i wantsize) { break; } } return primes[i]; } #define DHASH_H1(k, sz) ((k) % (sz)) #define DHASH_H2(k, sz) (1 + ((k) % ((sz)-1))) #define DHASH_PROBE(h1, h2, i, sz) (((h1) + (i)*(h2)) % sz) /* * Find a slot matching the key. * Always returns a slot. Interpreting the results: * *b == 0 --> key not present in table, slot may be used to store it * *b == key --> key found * otherwise --> hash table full */ static gint *dhash_lookup(dhash_table *tbl, gint key) { gint h = rehash_gint(key); size_t sz = tbl->dhash_size; size_t h1 = DHASH_H1(h, sz), h2; size_t i; gint *bb = tbl->keys, *b = bb + h1; if(*b == key || *b == 0) return b; h2 = DHASH_H2(h, sz); for(i=1; idhash_size = dhash_size(entries); tbl->keys = calloc(tbl->dhash_size, sizeof(gint)); /* set to 0x0 */ if(!tbl->keys || !tbl->dhash_size) { free(tbl); tbl = NULL; } } return (void *) tbl; } /* * Free the structure created by wg_dhash_init() */ void wg_dhash_free(void *db, void *tbl) { if(tbl) { if(((dhash_table *) tbl)->keys) free(((dhash_table *) tbl)->keys); free(tbl); } } /* * Add an entry to the hash table. * returns 0 on success (including when they key is already present). * returns -1 on failure. */ gint wg_dhash_addkey(void *db, void *tbl, gint key) { gint *b = dhash_lookup((dhash_table *) tbl, key); if(*b == 0) { *b = key; /* key not present, free slot found, add the key */ } else if (*b != key) { return -1; /* key not present and no free slot */ } return 0; } /* * Find a key in the hash table. * Returns 1 if key is present. * Returns 0 if key is not present. */ gint wg_dhash_haskey(void *db, void *tbl, gint key) { gint *b = dhash_lookup((dhash_table *) tbl, key); return (*b == key); } /* ------------- error handling ------------------- */ /* static gint show_consistency_error(void* db, char* errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg consistency error: %s\n",errmsg); #endif return -1; } */ static gint show_consistency_error_nr(void* db, char* errmsg, gint nr) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg consistency error: %s %d\n", errmsg, (int) nr); return -1; #endif } /* static gint show_consistency_error_double(void* db, char* errmsg, double nr) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg consistency error: %s %f\n",errmsg,nr); #endif return -1; } static gint show_consistency_error_str(void* db, char* errmsg, char* str) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg consistency error: %s %s\n",errmsg,str); #endif return -1; } */ static gint show_hash_error(void* db, char* errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg hash error: %s\n",errmsg); #endif return -1; } static gint show_ginthash_error(void *db, char* errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg gint hash error: %s\n", errmsg); #endif return -1; } /* #include "pstdint.h" // Replace with if appropriate #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) #define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif uint32_t SuperFastHash (const char * data, int len) { uint32_t hash = len, tmp; int rem; if (len <= 0 || data == NULL) return 0; rem = len & 3; len >>= 2; // Main loop for (;len > 0; len--) { hash += get16bits (data); tmp = (get16bits (data+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; data += 2*sizeof (uint16_t); hash += hash >> 11; } // Handle end cases switch (rem) { case 3: hash += get16bits (data); hash ^= hash << 16; hash ^= data[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (data); hash ^= hash << 11; hash += hash >> 17; break; case 1: hash += *data; hash ^= hash << 10; hash += hash >> 1; } // Force "avalanching" of final 127 bits hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } */ #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dbjson.h0000644000175000001440000000242412421471034012041 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2013, 2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbjson.h * Public headers for JSON I/O. */ #ifndef DEFINED_DBJSON_H #define DEFINED_DBJSON_H /* ====== data structures ======== */ /* ==== Protos ==== */ gint wg_parse_json_file(void *db, char *filename); gint wg_check_json(void *db, char *buf); gint wg_parse_json_document(void *db, char *buf, void **document); gint wg_parse_json_fragment(void *db, char *buf, void **document); gint wg_parse_json_param(void *db, char *buf, void **document); void wg_print_json_document(void *db, void *cb, void *cb_ctx, void *document); #endif /* DEFINED_DBJSON_H */ whitedb-0.7.3/Db/dbmpool.h0000644000175000001440000000364212257043255012230 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbmpool.h * Public headers for memory pool utilities. */ #ifndef DEFINED_DBMPOOL_H #define DEFINED_DBMPOOL_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* ====== data structures ======== */ /* ==== Protos ==== */ void* wg_create_mpool(void* db, int bytes); // call this to init pool with initial size bytes void* wg_alloc_mpool(void* db, void* mpool, int bytes); // call each time you want to "malloc": // automatically extends pool if no space left void wg_free_mpool(void* db, void* mpool); // remove the whole pool int wg_ispair(void* db, void* ptr); void* wg_mkpair(void* db, void* mpool, void* x, void* y); void* wg_first(void* db, void* ptr); void* wg_rest(void* db, void *ptr); int wg_listtreecount(void* db, void *ptr); int wg_isatom(void* db, void* ptr); void* wg_mkatom(void* db, void* mpool, int type, char* str1, char* str2); int wg_atomtype(void* db, void* ptr); char* wg_atomstr1(void* db, void* ptr); char* wg_atomstr2(void* db, void* ptr); void wg_mpool_print(void* db, void* ptr); #endif /* DEFINED_DBMPOOL_H */ whitedb-0.7.3/Db/Makefile.in0000644000175000001440000004517512426224004012466 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # - - - - main db sources - - - VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @RAPTOR_TRUE@am__append_1 = `$(RAPTOR_CONFIG) --cflags` subdir = Db DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libDb_la_LIBADD = am_libDb_la_OBJECTS = dbmem.lo dballoc.lo dbdata.lo dblock.lo \ dbdump.lo dblog.lo dbhash.lo dbindex.lo dbcompare.lo \ dbquery.lo dbutil.lo dbmpool.lo dbjson.lo dbschema.lo libDb_la_OBJECTS = $(am_libDb_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libDb_la_SOURCES) DIST_SOURCES = $(libDb_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ $(am__append_1) AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PRTDIAG = @PRTDIAG@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_INCLUDES = @PYTHON_INCLUDES@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RAPTOR_CONFIG = @RAPTOR_CONFIG@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libDb.la libDb_la_SOURCES = dbmem.c dbmem.h\ dballoc.c dballoc.h dbfeatures.h\ dbdata.c dbdata.h\ dblock.c dblock.h\ dbdump.c dbdump.h crc1.h\ dblog.c dblog.h\ dbhash.c dbhash.h\ dbindex.c dbindex.h\ dbcompare.c dbcompare.h\ dbquery.c dbquery.h\ dbutil.c dbutil.h\ dbmpool.c dbmpool.h\ dbjson.c dbjson.h\ dbschema.c dbschema.h all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Db/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Db/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libDb.la: $(libDb_la_OBJECTS) $(libDb_la_DEPENDENCIES) $(EXTRA_libDb_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libDb_la_OBJECTS) $(libDb_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dballoc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbcompare.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbdata.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbdump.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbhash.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbindex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbjson.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dblock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dblog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbmem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbmpool.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbquery.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbschema.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbutil.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: whitedb-0.7.3/Db/dblock.h0000644000175000001440000001132612421471034012021 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2009, 2013, 2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dblock.h * Public headers for concurrent access routines. */ #ifndef DEFINED_DBLOCK_H #define DEFINED_DBLOCK_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* ==== Public macros ==== */ /* XXX: move to configure.in / config-xxx.h */ #define USE_LOCK_TIMEOUT 1 #define DEFAULT_LOCK_TIMEOUT 2000 /* in ms */ /* Lock protocol */ #define RPSPIN 1 #define WPSPIN 2 #define TFQUEUE 3 /* ====== data structures ======== */ #if (LOCK_PROTO==TFQUEUE) /* Queue nodes are stored locally in allocated cells. * The size of this structure can never exceed SYN_VAR_PADDING * defined in dballoc.h. */ typedef struct { /* XXX: do we need separate links for stack? Or even, does * it break correctness? */ gint next_cell; /* freelist chain (db offset) */ gint class; /* LOCKQ_READ, LOCKQ_WRITE */ volatile gint waiting; /* sync variable */ volatile gint next; /* queue chain (db offset) */ volatile gint prev; /* queue chain */ } lock_queue_node; #endif /* ==== Protos ==== */ /* API functions (copied in dbapi.h) */ gint wg_start_write(void * dbase); /* start write transaction */ gint wg_end_write(void * dbase, gint lock); /* end write transaction */ gint wg_start_read(void * dbase); /* start read transaction */ gint wg_end_read(void * dbase, gint lock); /* end read transaction */ /* WhiteDB internal functions */ gint wg_compare_and_swap(volatile gint *ptr, gint oldv, gint newv); gint wg_init_locks(void * db); /* (re-) initialize locking subsystem */ #if (LOCK_PROTO==RPSPIN) #ifdef USE_LOCK_TIMEOUT gint db_rpspin_wlock(void * dbase, gint timeout); #define db_wlock(d, t) db_rpspin_wlock(d, t) #else gint db_rpspin_wlock(void * dbase); /* get DB level X lock */ #define db_wlock(d, t) db_rpspin_wlock(d) #endif gint db_rpspin_wulock(void * dbase); /* release DB level X lock */ #define db_wulock(d, l) db_rpspin_wulock(d) #ifdef USE_LOCK_TIMEOUT gint db_rpspin_rlock(void * dbase, gint timeout); #define db_rlock(d, t) db_rpspin_rlock(d, t) #else gint db_rpspin_rlock(void * dbase); /* get DB level S lock */ #define db_rlock(d, t) db_rpspin_rlock(d) #endif gint db_rpspin_rulock(void * dbase); /* release DB level S lock */ #define db_rulock(d, l) db_rpspin_rulock(d) #elif (LOCK_PROTO==WPSPIN) #ifdef USE_LOCK_TIMEOUT gint db_wpspin_wlock(void * dbase, gint timeout); #define db_wlock(d, t) db_wpspin_wlock(d, t) #else gint db_wpspin_wlock(void * dbase); /* get DB level X lock */ #define db_wlock(d, t) db_wpspin_wlock(d) #endif gint db_wpspin_wulock(void * dbase); /* release DB level X lock */ #define db_wulock(d, l) db_wpspin_wulock(d) #ifdef USE_LOCK_TIMEOUT gint db_wpspin_rlock(void * dbase, gint timeout); #define db_rlock(d, t) db_wpspin_rlock(d, t) #else gint db_wpspin_rlock(void * dbase); /* get DB level S lock */ #define db_rlock(d, t) db_wpspin_rlock(d) #endif gint db_wpspin_rulock(void * dbase); /* release DB level S lock */ #define db_rulock(d, l) db_wpspin_rulock(d) #elif (LOCK_PROTO==TFQUEUE) #ifdef USE_LOCK_TIMEOUT gint db_tfqueue_wlock(void * dbase, gint timeout); #define db_wlock(d, t) db_tfqueue_wlock(d, t) #else gint db_tfqueue_wlock(void * dbase); /* get DB level X lock */ #define db_wlock(d, t) db_tfqueue_wlock(d) #endif gint db_tfqueue_wulock(void * dbase, gint lock); /* release DB level X lock */ #define db_wulock(d, l) db_tfqueue_wulock(d, l) #ifdef USE_LOCK_TIMEOUT gint db_tfqueue_rlock(void * dbase, gint timeout); #define db_rlock(d, t) db_tfqueue_rlock(d, t) #else gint db_tfqueue_rlock(void * dbase); /* get DB level S lock */ #define db_rlock(d, t) db_tfqueue_rlock(d) #endif gint db_tfqueue_rulock(void * dbase, gint lock); /* release DB level S lock */ #define db_rulock(d, l) db_tfqueue_rulock(d, l) #else /* undefined or invalid value, disable locking */ #define db_wlock(d, t) (1) #define db_wulock(d, l) (1) #define db_rlock(d, t) (1) #define db_rulock(d, l) (1) #endif /* LOCK_PROTO */ #endif /* DEFINED_DBLOCK_H */ whitedb-0.7.3/Db/rdfapi.h0000644000175000001440000000257412257043255012044 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file rdfapi.h * * RDF parsing API for WhiteDB, depends on libraptor. * */ #ifndef DEFINED_RDFAPI_H #define DEFINED_RDFAPI_H wg_int wg_import_raptor_file(void *db, wg_int pref_fields, wg_int suff_fields, wg_int (*callback) (void *, void *), char *filename); wg_int wg_import_raptor_rdfxml_file(void *db, wg_int pref_fields, wg_int suff_fields, wg_int (*callback) (void *, void *), char *filename); wg_int wg_rdfparse_default_callback(void *db, void *rec); wg_int wg_export_raptor_file(void *db, wg_int pref_fields, char *filename, char *serializer); wg_int wg_export_raptor_rdfxml_file(void *db, wg_int pref_fields, char *filename); #endif /* DEFINED_RDFAPI_H */ whitedb-0.7.3/Db/dbmpool.c0000644000175000001440000003174412414766502012231 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbmpool.c * Allocating data using a temporary memory pool. * */ /* ====== Includes =============== */ #include #include #include #include #ifdef _WIN32 #include #else #include #include #endif #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" #include "dbmem.h" #include "dbapi.h" /* ====== Private headers and defs ======== */ #define NROF_SUBAREAS 100 // size of subarea array #define MIN_FIRST_SUBAREA_SIZE 1024 // first free area minimum: if less asked, this given #define ALIGNMENT_BYTES 4 // every val returned by wg_alloc_mpool is aligned to this #define TYPEMASK 1 // memory pool convenience objects type mask for address #define PAIRBITS 0 // memory pool convenience objects type bit for pairs (lists) #define ATOMBITS 1 // memory pool convenience objects type bit for atoms (strings etc) /** located inside mpool_header: one single memory subarea header * * */ typedef struct _wg_mpoolsubarea_header { int size; /** size of subarea in bytes */ void* area_start; /** pointer to the first byte of the subarea */ void* area_end; /** pointer to the first byte after the subarea */ } mpool_subarea_header; /** memory pool management data * stored in the beginning of the first segment of mempool * */ typedef struct { void* freeptr; /** pointer to the next free location in the pool */ int cur_subarea; /** index of the currently used subarea in the subarea_table (starts with 0) */ int nrof_subareas; /** full nr of rows in the subarea table */ mpool_subarea_header subarea_table[NROF_SUBAREAS]; /** subarea information (mpool_subarea_header) table */ } mpool_header; /* ======= Private protos ================ */ static int extend_mpool(void* db, void* mpool, int minbytes); static int show_mpool_error(void* db, char* errmsg); static int show_mpool_error_nr(void* db, char* errmsg, int nr); static void wg_mpool_print_aux(void* db, void* ptr, int depth, int pflag); /* ====== Functions for mpool creating/extending/allocating/destroying ============== */ /** create and initialise a new memory pool * * initial pool has at least origbytes of free space * mpool is extended automatically later when space used up * returns void* pointer to mpool if OK, NULL if failure * * does a single malloc (latex extensions do further mallocs) */ void* wg_create_mpool(void* db, int origbytes) { int bytes; void* mpool; mpool_header* mpoolh; int puresize; void* nextptr; int i; if (origbytesfreeptr)=nextptr; (mpoolh->cur_subarea)=0; ((mpoolh->subarea_table)[0]).size=puresize; ((mpoolh->subarea_table)[0]).area_start=mpool; ((mpoolh->subarea_table)[0]).area_end=(void*)(((char*)mpool)+bytes); return mpool; } /** extend an existing memory pool * * called automatically when mpool space used up * does one malloc for a new subarea * */ static int extend_mpool(void* db, void* mpool, int minbytes) { int cursize; int bytes; void* subarea; mpool_header* mpoolh; int i; void* nextptr; mpoolh=(mpool_header*)mpool; cursize=((mpoolh->subarea_table)[(mpoolh->cur_subarea)]).size; bytes=cursize; for(i=0;i<100;i++) { bytes=bytes*2; if (bytes>=(minbytes+ALIGNMENT_BYTES)) break; } subarea=malloc(bytes); if (subarea==NULL) { show_mpool_error_nr(db, " cannot extend mpool to size: ",minbytes); return -1; } (mpoolh->freeptr)=subarea; (mpoolh->cur_subarea)++; ((mpoolh->subarea_table)[mpoolh->cur_subarea]).size=bytes; nextptr=subarea; // set correct alignment for nextptr i=((size_t)nextptr)%ALIGNMENT_BYTES; if (i!=0) nextptr=((char*)nextptr)+(ALIGNMENT_BYTES-i); // aligment now ok (mpoolh->freeptr)=nextptr; ((mpoolh->subarea_table)[mpoolh->cur_subarea]).area_start=subarea; ((mpoolh->subarea_table)[mpoolh->cur_subarea]).area_end=(void*)(((char*)subarea)+bytes); return 0; } /** free the whole memory pool * * frees all the malloced subareas and initial mpool * */ void wg_free_mpool(void* db, void* mpool) { int i; mpool_header* mpoolh; mpoolh=(mpool_header*)mpool; i=mpoolh->cur_subarea; for(;i>0;i--) { free(((mpoolh->subarea_table)[i]).area_start); } free(mpool); } /** allocate bytes from a memory pool: analogous to malloc * * mpool is extended automatically if not enough free space present * returns void* pointer to a memory block if OK, NULL if failure * */ void* wg_alloc_mpool(void* db, void* mpool, int bytes) { void* curptr; void* nextptr; mpool_header* mpoolh; void* curend; int tmp; int i; if (bytes<=0) { show_mpool_error_nr(db, " trying to allocate too little from mpool: ",bytes); return NULL; } if (mpool==NULL) { show_mpool_error(db," mpool passed to wg_alloc_mpool is NULL "); return NULL; } mpoolh=(mpool_header*)mpool; nextptr=(void*)(((char*)(mpoolh->freeptr))+bytes); curend=((mpoolh->subarea_table)[(mpoolh->cur_subarea)]).area_end; if (nextptr>curend) { tmp=extend_mpool(db,mpool,bytes); if (tmp!=0) { show_mpool_error_nr(db," cannot extend mpool size by: ",bytes); return NULL; } nextptr=((char*)(mpoolh->freeptr))+bytes; } curptr=mpoolh->freeptr; // set correct alignment for nextptr i=((size_t)nextptr)%ALIGNMENT_BYTES; if (i!=0) nextptr=((char*)nextptr)+(ALIGNMENT_BYTES-i); // alignment now ok mpoolh->freeptr=nextptr; return curptr; } /* ====== Convenience functions for using data allocated from mpool ================= */ /* Core object types are pairs and atoms plus 0 (NULL). Lists are formed by pairs of gints. Each pair starts at address with two last bits 0. The first element of the pair points to the contents of the cell, the second to rest. Atoms may contain strings, ints etc etc. Each atom starts at address with last bit 1. The first byte of the atom indicates its type. The following bytes are content, always encoded as a 0-terminated string or TWO consequent 0-terminated strings. The atom type byte contains dbapi.h values: STRING, CONVERSION TO BE DETERMINED LATER: 0 #define WG_NULLTYPE 1 #define WG_RECORDTYPE 2 #define WG_INTTYPE 3 #define WG_DOUBLETYPE 4 #define WG_STRTYPE 5 #define WG_XMLLITERALTYPE 6 #define WG_URITYPE 7 #define WG_BLOBTYPE 8 #define WG_CHARTYPE 9 #define WG_FIXPOINTTYPE 10 #define WG_DATETYPE 11 #define WG_TIMETYPE 12 #define WG_ANONCONSTTYPE 13 #define WG_VARTYPE 14 #define WG_ILLEGAL 0xff Atom types 5-8 (strings, xmlliterals, uris, blobs) contain TWO consequent strings, first the main, terminating 0, then the second (lang, namespace etc) and the terminating 0. Two terminating 0-s after the first indicates the missing second string (NULL). Other types are simply terminated by two 0-s. */ // ------------- pairs ---------------- int wg_ispair(void* db, void* ptr) { return (ptr!=NULL && ((((gint)ptr)&TYPEMASK)==PAIRBITS)); } void* wg_mkpair(void* db, void* mpool, void* x, void* y) { void* ptr; ptr=wg_alloc_mpool(db,mpool,sizeof(gint)*2); if (ptr==NULL) { show_mpool_error(db,"cannot create a pair in mpool"); return NULL; } *((gint*)ptr)=(gint)x; *((gint*)ptr+1)=(gint)y; return ptr; } void* wg_first(void* db, void* ptr) { return (void*)(*((gint*)ptr)); } void* wg_rest(void* db, void *ptr) { return (void*)(*((gint*)ptr+1)); } int wg_listtreecount(void* db, void *ptr) { if (wg_ispair(db,ptr)) return wg_listtreecount(db,wg_first(db,ptr)) + wg_listtreecount(db,wg_rest(db,ptr)); else return 1; } // ------------ atoms ------------------ int wg_isatom(void* db, void* ptr) { return (ptr!=NULL && ((((gint)ptr)&TYPEMASK)==ATOMBITS)); } void* wg_mkatom(void* db, void* mpool, int type, char* str1, char* str2) { char* ptr; char* curptr; int size=2; if (str1!=NULL) size=size+strlen(str1); size++; if (str2!=NULL) size=size+strlen(str2); size++; ptr=(char*)(wg_alloc_mpool(db,mpool,size)); if (ptr==NULL) { show_mpool_error(db,"cannot create an atom in mpool"); return NULL; } ptr++; // shift one pos right to set address last byte 1 curptr=ptr; *curptr=(char)type; curptr++; if (str1!=NULL) { while((*curptr++ = *str1++)); } else { *curptr=(char)0; curptr++; } if (str2!=NULL) { while((*curptr++ = *str2++)); } else { *curptr=(char)0; curptr++; } return ptr; } int wg_atomtype(void* db, void* ptr) { if (ptr==NULL) return 0; else return (gint)*((char*)ptr); } char* wg_atomstr1(void* db, void* ptr) { if (ptr==NULL) return NULL; if (*(((char*)ptr)+1)==(char)0) return NULL; else return ((char*)ptr)+1; } char* wg_atomstr2(void* db, void* ptr) { if (ptr==NULL) return NULL; ptr=(char*)ptr+strlen((char*)ptr)+1; if (*(((char*)ptr)+1)==(char)0) return NULL; else return ((char*)ptr); } // ------------ printing ------------------ void wg_mpool_print(void* db, void* ptr) { wg_mpool_print_aux(db,ptr,0,1); } static void wg_mpool_print_aux(void* db, void* ptr, int depth, int pflag) { int type; char* p; int count; int ppflag=0; int i; void *curptr; if (ptr==NULL) { printf("()"); } else if (wg_isatom(db,ptr)) { type=wg_atomtype(db,ptr); switch (type) { case 0: printf("_:"); break; case WG_NULLTYPE: printf("n:"); break; case WG_RECORDTYPE: printf("r:"); break; case WG_INTTYPE: printf("i:"); break; case WG_DOUBLETYPE: printf("d:"); break; case WG_STRTYPE: printf("s:"); break; case WG_XMLLITERALTYPE: printf("x:"); break; case WG_URITYPE: printf("u:"); break; case WG_BLOBTYPE: printf("b:"); break; case WG_CHARTYPE: printf("c:"); break; case WG_FIXPOINTTYPE: printf("f:"); break; case WG_DATETYPE: printf("date:"); break; case WG_TIMETYPE: printf("time:"); break; case WG_ANONCONSTTYPE: printf("a:"); break; case WG_VARTYPE: printf("?:"); break; default: printf("!:"); } p=wg_atomstr1(db,ptr); if (p!=NULL) { if (strchr(p,' ')!=NULL || strchr(p,'\n')!=NULL || strchr(p,'\t')!=NULL) { printf("\"%s\"",p); } else { printf("%s",p); } } else { printf("\"\""); } p=wg_atomstr2(db,ptr); if (p!=NULL) { if (strchr(p,' ')!=NULL || strchr(p,'\n')!=NULL || strchr(p,'\t')!=NULL) { printf("^^\"%s\"",p); } else { printf("^^%s",p); } } } else { if (pflag && wg_listtreecount(db,ptr)>10) ppflag=1; printf ("("); for(curptr=ptr, count=0;curptr!=NULL && !wg_isatom(db,curptr);curptr=wg_rest(db,curptr), count++) { if (count>0) { if (ppflag) { printf("\n"); for(i=0;i. * */ /** @file dbschema.h * Public headers for the strucured data functions. */ #ifndef DEFINED_DBSCHEMA_H #define DEFINED_DBSCHEMA_H /* ==== Public macros ==== */ #define WG_SCHEMA_TRIPLE_SIZE 3 #define WG_SCHEMA_TRIPLE_OFFSET 0 #define WG_SCHEMA_KEY_OFFSET (WG_SCHEMA_TRIPLE_OFFSET + 1) #define WG_SCHEMA_VALUE_OFFSET (WG_SCHEMA_TRIPLE_OFFSET + 2) /* ====== data structures ======== */ /* ==== Protos ==== */ void *wg_create_triple(void *db, gint subj, gint prop, gint ob, gint isparam); #define wg_create_kvpair(db, key, val, ip) \ wg_create_triple(db, 0, key, val, ip) void *wg_create_array(void *db, gint size, gint isdocument, gint isparam); void *wg_create_object(void *db, gint size, gint isdocument, gint isparam); void *wg_find_document(void *db, void *rec); gint wg_delete_document(void *db, void *document); #endif /* DEFINED_DBSCHEMA_H */ whitedb-0.7.3/Db/dbfeatures.h0000644000175000001440000000411012257043255012707 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbfeatures.h * Constructs bit vector of libwgdb compile-time features */ #ifndef DEFINED_DBFEATURES_H #define DEFINED_DBFEATURES_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* Used to check for individual features */ #define FEATURE_BITS_64BIT 0x1 #define FEATURE_BITS_QUEUED_LOCKS 0x2 #define FEATURE_BITS_TTREE_CHAINED 0x4 #define FEATURE_BITS_BACKLINK 0x8 #define FEATURE_BITS_CHILD_DB 0x10 #define FEATURE_BITS_INDEX_TMPL 0x20 /* Construct the bit vector */ #ifdef HAVE_64BIT_GINT #define FEATURE_BITS_01 FEATURE_BITS_64BIT #else #define FEATURE_BITS_01 0x0 #endif #if (LOCK_PROTO==3) #define FEATURE_BITS_02 FEATURE_BITS_QUEUED_LOCKS #else #define FEATURE_BITS_02 0x0 #endif #ifdef TTREE_CHAINED_NODES #define FEATURE_BITS_03 FEATURE_BITS_TTREE_CHAINED #else #define FEATURE_BITS_03 0x0 #endif #ifdef USE_BACKLINKING #define FEATURE_BITS_04 FEATURE_BITS_BACKLINK #else #define FEATURE_BITS_04 0x0 #endif #ifdef USE_CHILD_DB #define FEATURE_BITS_05 FEATURE_BITS_CHILD_DB #else #define FEATURE_BITS_05 0x0 #endif #ifdef USE_INDEX_TEMPLATE #define FEATURE_BITS_06 FEATURE_BITS_INDEX_TMPL #else #define FEATURE_BITS_06 0x0 #endif #define MEMSEGMENT_FEATURES (FEATURE_BITS_01 |\ FEATURE_BITS_02 |\ FEATURE_BITS_03 |\ FEATURE_BITS_04 |\ FEATURE_BITS_05 |\ FEATURE_BITS_06) #endif /* DEFINED_DBFEATURES_H */ whitedb-0.7.3/Db/indexapi.h0000644000175000001440000000337212257043255012375 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2011 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file indexapi.h * * Index management API for WhiteDB. * * wg_int type is defined in dbapi.h */ #ifndef DEFINED_INDEXAPI_H #define DEFINED_INDEXAPI_H /* Public macros */ #define WG_INDEX_TYPE_TTREE 50 #define WG_INDEX_TYPE_TTREE_JSON 51 #define WG_INDEX_TYPE_HASH 60 #define WG_INDEX_TYPE_HASH_JSON 61 /* Public protos */ wg_int wg_create_index(void *db, wg_int column, wg_int type, wg_int *matchrec, wg_int reclen); wg_int wg_create_multi_index(void *db, wg_int *columns, wg_int col_count, wg_int type, wg_int *matchrec, wg_int reclen); wg_int wg_drop_index(void *db, wg_int index_id); wg_int wg_column_to_index_id(void *db, wg_int column, wg_int type, wg_int *matchrec, wg_int reclen); wg_int wg_multi_column_to_index_id(void *db, wg_int *columns, wg_int col_count, wg_int type, wg_int *matchrec, wg_int reclen); wg_int wg_get_index_type(void *db, wg_int index_id); void * wg_get_index_template(void *db, wg_int index_id, wg_int *reclen); void * wg_get_all_indexes(void *db, wg_int *count); #endif /* DEFINED_INDEXAPI_H */ whitedb-0.7.3/Db/dbschema.c0000644000175000001440000001573412421471034012333 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2013, 2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbschema.c * WhiteDB (semi-)structured data representation */ /* ====== Includes =============== */ #include /* ====== Private headers and defs ======== */ #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dbdata.h" #include "dbcompare.h" #include "dbindex.h" #include "dbschema.h" #include "dblog.h" /* ======== Data ========================= */ /* ======= Private protos ================ */ #ifdef USE_BACKLINKING static void *find_document_recursive(void *db, gint *rec, int depth); #endif static gint delete_record_recursive(void *db, void *rec, int depth); static gint show_schema_error(void *db, char *errmsg); /* ====== Functions ============== */ /* * Create a data triple (subj, prop, ob) * May also be called to create key-value pairs with (NULL, key, value) * if isparam is non-0, the data is not indexed. * returns the new record * returns NULL on error. */ void *wg_create_triple(void *db, gint subj, gint prop, gint ob, gint isparam) { void *rec = wg_create_raw_record(db, WG_SCHEMA_TRIPLE_SIZE); gint *meta; if(rec) { meta = ((gint *) rec + RECORD_META_POS); if(isparam) { *meta |= (RECORD_META_NOTDATA|RECORD_META_MATCH); } else if(wg_index_add_rec(db, rec) < -1) { return NULL; /* index error */ } if(wg_set_field(db, rec, WG_SCHEMA_TRIPLE_OFFSET, subj)) return NULL; if(wg_set_field(db, rec, WG_SCHEMA_TRIPLE_OFFSET + 1, prop)) return NULL; if(wg_set_field(db, rec, WG_SCHEMA_TRIPLE_OFFSET + 2, ob)) return NULL; } return rec; } /* * Create an empty (JSON) array of given size. * if isparam is non-0, the data is not indexed (incl. when updating later) * if isdocument is non-0, the record represents a top-level document * returns the new record * returns NULL on error. */ void *wg_create_array(void *db, gint size, gint isdocument, gint isparam) { void *rec = wg_create_raw_record(db, size); gint *metap, meta; if(rec) { metap = ((gint *) rec + RECORD_META_POS); meta = *metap; /* Temp variable used for write-ahead logging */ meta |= RECORD_META_ARRAY; if(isdocument) meta |= RECORD_META_DOC; if(isparam) meta |= (RECORD_META_NOTDATA|RECORD_META_MATCH); #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { if(wg_log_set_meta(db, rec, meta)) return NULL; } #endif *metap = meta; if(!isparam) { if(wg_index_add_rec(db, rec) < -1) { return NULL; /* index error */ } } } return rec; } /* * Create an empty (JSON) object of given size. * if isparam is non-0, the data is not indexed (incl. when updating later) * if isdocument is non-0, the record represents a top-level document * returns the new record * returns NULL on error. */ void *wg_create_object(void *db, gint size, gint isdocument, gint isparam) { void *rec = wg_create_raw_record(db, size); gint *metap, meta; if(rec) { metap = ((gint *) rec + RECORD_META_POS); meta = *metap; meta |= RECORD_META_OBJECT; if(isdocument) meta |= RECORD_META_DOC; if(isparam) meta |= (RECORD_META_NOTDATA|RECORD_META_MATCH); #ifdef USE_DBLOG if(dbmemsegh(db)->logging.active) { if(wg_log_set_meta(db, rec, meta)) return NULL; } #endif *metap = meta; if(!isparam) { if(wg_index_add_rec(db, rec) < -1) { return NULL; /* index error */ } } } return rec; } /* * Find a top-level document that the record belongs to. * returns the document pointer on success * returns NULL if the document was not found. */ void *wg_find_document(void *db, void *rec) { #ifndef USE_BACKLINKING show_schema_error(db, "Backlinks are required to find complete documents"); return NULL; #else return find_document_recursive(db, (gint *) rec, WG_COMPARE_REC_DEPTH-1); #endif } #ifdef USE_BACKLINKING /* * Find a document recursively. * iterates through the backlink chain and checks each parent recursively. * Returns the pointer to the (first) found document. * Returns NULL if nothing found. * XXX: if a document links to the contents of another document, it * can "hijack" it in the search results this way. The priority * depends on the position(s) in the backlink chain, as this is a depth-first * search. */ static void *find_document_recursive(void *db, gint *rec, int depth) { if(is_schema_document(rec)) return rec; if(depth > 0) { gint backlink_list = *(rec + RECORD_BACKLINKS_POS); if(backlink_list) { gcell *next = (gcell *) offsettoptr(db, backlink_list); for(;;) { void *res = find_document_recursive(db, (gint *) offsettoptr(db, next->car), depth-1); if(res) return res; /* Something was found recursively */ if(!next->cdr) break; next = (gcell *) offsettoptr(db, next->cdr); } } } return NULL; /* Depth exhausted or nothing found. */ } #endif /* * Delete a top-level document * returns 0 on success * returns -1 on error */ gint wg_delete_document(void *db, void *document) { #ifdef CHECK if(!is_schema_document(document)) { return show_schema_error(db, "wg_delete_document: not a document"); } #endif #ifndef USE_BACKLINKING return delete_record_recursive(db, document, 99); #else return delete_record_recursive(db, document, WG_COMPARE_REC_DEPTH); #endif } /* * Delete a record and all the records it points to. * This is safe to call on JSON documents. */ static gint delete_record_recursive(void *db, void *rec, int depth) { gint i, reclen; if(depth <= 0) { return show_schema_error(db, "deleting record: recursion too deep"); } reclen = wg_get_record_len(db, rec); for(i=0; i. * */ /** @file dbindex.c * Implementation of T-tree index */ /* ====== Includes =============== */ #include #include #include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dbdata.h" #include "dbindex.h" #include "dbcompare.h" #include "dbhash.h" /* ====== Private defs =========== */ #define LL_CASE 0 #define LR_CASE 1 #define RL_CASE 2 #define RR_CASE 3 #ifndef max #define max(a,b) (a>b ? a : b) #endif #define HASHIDX_OP_STORE 1 #define HASHIDX_OP_REMOVE 2 #define HASHIDX_OP_FIND 3 /* ======= Private protos ================ */ #ifndef TTREE_SINGLE_COMPARE static gint db_find_bounding_tnode(void *db, gint rootoffset, gint key, gint *result, struct wg_tnode *rb_node); #endif static int db_which_branch_causes_overweight(void *db, struct wg_tnode *root); static int db_rotate_ttree(void *db, gint index_id, struct wg_tnode *root, int overw); static gint ttree_add_row(void *db, gint index_id, void *rec); static gint ttree_remove_row(void *db, gint index_id, void * rec); static gint create_ttree_index(void *db, gint index_id); static gint drop_ttree_index(void *db, gint column); static gint insert_into_list(void *db, gint *head, gint value); static void delete_from_list(void *db, gint *head); #ifdef USE_INDEX_TEMPLATE static gint add_index_template(void *db, gint *matchrec, gint reclen); static gint find_index_template(void *db, gint *matchrec, gint reclen); static gint remove_index_template(void *db, gint template_offset); #endif static gint hash_add_row(void *db, gint index_id, void *rec); static gint hash_remove_row(void *db, gint index_id, void *rec); static gint hash_recurse(void *db, wg_index_header *hdr, char *prefix, gint prefixlen, gint *values, gint count, void *rec, gint op, gint expand); static gint hash_extend_prefix(void *db, wg_index_header *hdr, char *prefix, gint prefixlen, gint nextval, gint *values, gint count, void *rec, gint op, gint expand); static gint create_hash_index(void *db, gint index_id); static gint drop_hash_index(void *db, gint index_id); static gint sort_columns(gint *sorted_cols, gint *columns, gint col_count); static gint show_index_error(void* db, char* errmsg); static gint show_index_error_nr(void* db, char* errmsg, gint nr); /* ====== Functions ============== */ /* * Index implementation: * - T-Tree, as described by Lehman & Carey '86 * This includes search with a single compare per node, enabled by * defining TTREE_SINGLE_COMPARE * * - improvements loosely based on T* tree (Kim & Choi '96) * Nodes have predecessor and successor pointers. This is turned * on by defining TTREE_CHAINED_NODES. Other alterations described in * the original T* tree paper were not implemented. * * - hash index (allows multi-column indexes) (not done yet) * * Index metainfo: * data about indexes in system is stored in dbh->index_control_area_header * * index_table[] - 0 - 0 - v - 0 - 0 - v - 0 * | | * index hdr A <--- list elem list elem ---> index hdr B * ^ 0 v * | | * ----------------------- list elem * 0 * * index_table is a fixed size array that contains offsets to index * lists by database field (column) number. Index lists themselves contain * offsets to index headers. This arrangement is used so that one * index can be referred to from several fields (index headers are * unique, index list elements are not). * * In the above example, A is a (hash) index on columns 2 and 5, while B * is an index on column 5. * * Note: offset to index header struct is also used as an index id. */ /* ------------------- T-tree private functions ------------- */ #ifndef TTREE_SINGLE_COMPARE /** * returns bounding node offset or if no really bounding node exists, then the closest node */ static gint db_find_bounding_tnode(void *db, gint rootoffset, gint key, gint *result, struct wg_tnode *rb_node) { struct wg_tnode * node = (struct wg_tnode *)offsettoptr(db,rootoffset); /* Original tree search algorithm: compares both bounds of * the node to determine immediately if the value falls between them. */ if(WG_COMPARE(db, key, node->current_min) == WG_LESSTHAN) { /* if(key < node->current_max) */ if(node->left_child_offset != 0) return db_find_bounding_tnode(db, node->left_child_offset, key, result, NULL); else { *result = DEAD_END_LEFT_NOT_BOUNDING; return rootoffset; } } else if(WG_COMPARE(db, key, node->current_max) != WG_GREATER) { *result = REALLY_BOUNDING_NODE; return rootoffset; } else { /* if(key > node->current_max) */ if(node->right_child_offset != 0) return db_find_bounding_tnode(db, node->right_child_offset, key, result, NULL); else{ *result = DEAD_END_RIGHT_NOT_BOUNDING; return rootoffset; } } } #else /* "rightmost" node search is the improved tree search described in * the original T-tree paper. */ #define db_find_bounding_tnode wg_search_ttree_rightmost #endif /** * returns the description of imbalance - 4 cases possible * LL - left child of the left child is overweight * LR - right child of the left child is overweight * etc */ static int db_which_branch_causes_overweight(void *db, struct wg_tnode *root){ struct wg_tnode *child; if(root->left_subtree_height > root->right_subtree_height){ child = (struct wg_tnode *)offsettoptr(db,root->left_child_offset); if(child->left_subtree_height >= child->right_subtree_height)return LL_CASE; else return LR_CASE; }else{ child = (struct wg_tnode *)offsettoptr(db,root->right_child_offset); if(child->left_subtree_height > child->right_subtree_height)return RL_CASE; else return RR_CASE; } } static int db_rotate_ttree(void *db, gint index_id, struct wg_tnode *root, int overw){ gint grandparent = root->parent_offset; gint initialrootoffset = ptrtooffset(db,root); struct wg_tnode *r = NULL; struct wg_tnode *g = (struct wg_tnode *)offsettoptr(db,grandparent); wg_index_header *hdr = (wg_index_header *)offsettoptr(db,index_id); gint column = hdr->rec_field_index[0]; /* always one column for T-tree */ if(overw == LL_CASE){ /* A B * B C D A * D E -> N E C * N */ //printf("LL_CASE\n"); //save some stuff into variables for later use gint offset_left_child = root->left_child_offset; gint offset_right_grandchild = ((struct wg_tnode *)offsettoptr(db,offset_left_child))->right_child_offset; gint right_grandchild_height = ((struct wg_tnode *)offsettoptr(db,offset_left_child))->right_subtree_height; //first switch: E goes to A's left child root->left_child_offset = offset_right_grandchild; root->left_subtree_height = right_grandchild_height; if(offset_right_grandchild != 0){ ((struct wg_tnode *)offsettoptr(db,offset_right_grandchild))->parent_offset = ptrtooffset(db,root); } //second switch: A goes to B's right child ((struct wg_tnode *)offsettoptr(db,offset_left_child)) -> right_child_offset = ptrtooffset(db,root); ((struct wg_tnode *)offsettoptr(db,offset_left_child)) -> right_subtree_height = max(root->left_subtree_height,root->right_subtree_height)+1; root->parent_offset = offset_left_child; //for later grandparent fix r = (struct wg_tnode *)offsettoptr(db,offset_left_child); }else if(overw == RR_CASE){ /* A C * B C A E * D E -> B D N * N */ //printf("RR_CASE\n"); //save some stuff into variables for later use gint offset_right_child = root->right_child_offset; gint offset_left_grandchild = ((struct wg_tnode *)offsettoptr(db,offset_right_child))->left_child_offset; gint left_grandchild_height = ((struct wg_tnode *)offsettoptr(db,offset_right_child))->left_subtree_height; //first switch: D goes to A's right child root->right_child_offset = offset_left_grandchild; root->right_subtree_height = left_grandchild_height; if(offset_left_grandchild != 0){ ((struct wg_tnode *)offsettoptr(db,offset_left_grandchild))->parent_offset = ptrtooffset(db,root); } //second switch: A goes to C's left child ((struct wg_tnode *)offsettoptr(db,offset_right_child)) -> left_child_offset = ptrtooffset(db,root); ((struct wg_tnode *)offsettoptr(db,offset_right_child)) -> left_subtree_height = max(root->right_subtree_height,root->left_subtree_height)+1; root->parent_offset = offset_right_child; //for later grandparent fix r = (struct wg_tnode *)offsettoptr(db,offset_right_child); }else if(overw == LR_CASE){ /* A E * B C B A * D E -> D F G C * F G N * N */ struct wg_tnode *bb, *ee; //save some stuff into variables for later use gint offset_left_child = root->left_child_offset; gint offset_right_grandchild = ((struct wg_tnode *)offsettoptr(db,offset_left_child))->right_child_offset; //first swtich: G goes to A's left child ee = (struct wg_tnode *)offsettoptr(db,offset_right_grandchild); root -> left_child_offset = ee -> right_child_offset; root -> left_subtree_height = ee -> right_subtree_height; if(ee -> right_child_offset != 0){ ((struct wg_tnode *)offsettoptr(db,ee->right_child_offset))->parent_offset = ptrtooffset(db, root); } //second switch: F goes to B's right child bb = (struct wg_tnode *)offsettoptr(db,offset_left_child); bb -> right_child_offset = ee -> left_child_offset; bb -> right_subtree_height = ee -> left_subtree_height; if(ee -> left_child_offset != 0){ ((struct wg_tnode *)offsettoptr(db,ee->left_child_offset))->parent_offset = offset_left_child; } //third switch: B goes to E's left child /* The Lehman/Carey "special" LR rotation - instead of creating * an internal node with one element, the values of what will become the * left child will be moved over to the parent, thus ensuring the internal * node is adequately filled. This is only allowed if E is a leaf. */ if(ee->number_of_elements == 1 && !ee->right_child_offset &&\ !ee->left_child_offset && bb->number_of_elements == WG_TNODE_ARRAY_SIZE){ int i; /* Create space for elements from B */ ee->array_of_values[bb->number_of_elements - 1] = ee->array_of_values[0]; /* All the values moved are smaller than in E */ for(i=1; inumber_of_elements; i++) ee->array_of_values[i-1] = bb->array_of_values[i]; ee->number_of_elements = bb->number_of_elements; /* Examine the new leftmost element to find current_min */ ee->current_min = wg_get_field(db, (void *)offsettoptr(db, ee->array_of_values[0]), column); bb -> number_of_elements = 1; bb -> current_max = bb -> current_min; } //then switch the nodes ee -> left_child_offset = offset_left_child; ee -> left_subtree_height = max(bb->right_subtree_height,bb->left_subtree_height)+1; bb -> parent_offset = offset_right_grandchild; //fourth switch: A goes to E's right child ee -> right_child_offset = ptrtooffset(db, root); ee -> right_subtree_height = max(root->right_subtree_height,root->left_subtree_height)+1; root -> parent_offset = offset_right_grandchild; //for later grandparent fix r = ee; }else if(overw == RL_CASE){ /* A E * C B A B * E D -> C G F D * G F N * N */ struct wg_tnode *bb, *ee; //save some stuff into variables for later use gint offset_right_child = root->right_child_offset; gint offset_left_grandchild = ((struct wg_tnode *)offsettoptr(db,offset_right_child))->left_child_offset; //first swtich: G goes to A's left child ee = (struct wg_tnode *)offsettoptr(db,offset_left_grandchild); root -> right_child_offset = ee -> left_child_offset; root -> right_subtree_height = ee -> left_subtree_height; if(ee -> left_child_offset != 0){ ((struct wg_tnode *)offsettoptr(db,ee->left_child_offset))->parent_offset = ptrtooffset(db, root); } //second switch: F goes to B's right child bb = (struct wg_tnode *)offsettoptr(db,offset_right_child); bb -> left_child_offset = ee -> right_child_offset; bb -> left_subtree_height = ee -> right_subtree_height; if(ee -> right_child_offset != 0){ ((struct wg_tnode *)offsettoptr(db,ee->right_child_offset))->parent_offset = offset_right_child; } //third switch: B goes to E's right child /* "special" RL rotation - see comments for LR_CASE */ if(ee->number_of_elements == 1 && !ee->right_child_offset &&\ !ee->left_child_offset && bb->number_of_elements == WG_TNODE_ARRAY_SIZE){ int i; /* All the values moved are larger than in E */ for(i=1; inumber_of_elements; i++) ee->array_of_values[i] = bb->array_of_values[i-1]; ee->number_of_elements = bb->number_of_elements; /* Examine the new rightmost element to find current_max */ ee->current_max = wg_get_field(db, (void *)offsettoptr(db, ee->array_of_values[ee->number_of_elements - 1]), column); /* Remaining B node array element should sit in slot 0 */ bb->array_of_values[0] = \ bb->array_of_values[bb->number_of_elements - 1]; bb -> number_of_elements = 1; bb -> current_min = bb -> current_max; } ee -> right_child_offset = offset_right_child; ee -> right_subtree_height = max(bb->right_subtree_height,bb->left_subtree_height)+1; bb -> parent_offset = offset_left_grandchild; //fourth switch: A goes to E's right child ee -> left_child_offset = ptrtooffset(db, root); ee -> left_subtree_height = max(root->right_subtree_height,root->left_subtree_height)+1; root -> parent_offset = offset_left_grandchild; //for later grandparent fix r = ee; } else { /* catch an error case (can't really happen) */ show_index_error(db, "tree rotate called with invalid argument, "\ "index may have become corrupt"); return -1; } //fix grandparent - regardless of current 'overweight' case if(grandparent == 0){//'grandparent' is index header data r->parent_offset = 0; //TODO more error check here TTREE_ROOT_NODE(hdr) = ptrtooffset(db,r); }else{//grandparent is usual node //printf("change grandparent node\n"); r -> parent_offset = grandparent; if(g->left_child_offset == initialrootoffset){//new subtree must replace the left child of grandparent g->left_child_offset = ptrtooffset(db,r); g->left_subtree_height = max(r->left_subtree_height,r->right_subtree_height)+1; }else{ g->right_child_offset = ptrtooffset(db,r); g->right_subtree_height = max(r->left_subtree_height,r->right_subtree_height)+1; } } return 0; } /** inserts pointer to data row into index tree structure * * returns: * 0 - on success * -1 - if error */ static gint ttree_add_row(void *db, gint index_id, void *rec) { gint rootoffset, column; gint newvalue, boundtype, bnodeoffset, newoffset; struct wg_tnode *node; wg_index_header *hdr = (wg_index_header *)offsettoptr(db,index_id); db_memsegment_header* dbh = dbmemsegh(db); rootoffset = TTREE_ROOT_NODE(hdr); #ifdef CHECK if(rootoffset == 0){ #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"index at offset %d does not exist\n", (int) index_id); #endif return -1; } #endif column = hdr->rec_field_index[0]; /* always one column for T-tree */ //extract real value from the row (rec) newvalue = wg_get_field(db, rec, column); //find bounding node for the value bnodeoffset = db_find_bounding_tnode(db, rootoffset, newvalue, &boundtype, NULL); node = (struct wg_tnode *)offsettoptr(db,bnodeoffset); newoffset = 0;//save here the offset of newly created tnode - 0 if no node added into the tree //if bounding node exists - follow one algorithm, else the other if(boundtype == REALLY_BOUNDING_NODE){ //check if the node has room for a new entry if(node->number_of_elements < WG_TNODE_ARRAY_SIZE){ int i, j; gint cr; /* add array entry and update control data. We keep the * array sorted, smallest values left. */ for(i=0; inumber_of_elements; i++) { /* The node is small enough for naive scans to be * "good enough" inside the node. Note that we * branch into re-sort loop as early as possible * with >= operator (> would be algorithmically correct too) * since here the compare is more expensive than the slot * copying. */ cr = WG_COMPARE(db, wg_get_field(db, (void *)offsettoptr(db,node->array_of_values[i]), column), newvalue); if(cr != WG_LESSTHAN) { /* value >= newvalue */ /* Push remaining values to the right */ for(j=node->number_of_elements; j>i; j--) node->array_of_values[j] = node->array_of_values[j-1]; break; } } /* i is either number_of_elements or a vacated slot * in the array now. */ node->array_of_values[i] = ptrtooffset(db,rec); node->number_of_elements++; /* Update min. Due to the >= comparison max is preserved * in this case. Note that we are overwriting values that * WG_COMPARE() may deem equal. This is intentional, because other * parts of T-tree algorithm rely on encoded values of min/max fields * to be in sync with the leftmost/rightmost slots. */ if(i==0) { node->current_min = newvalue; } } else{ //still, insert the value here, but move minimum out of this node //get the minimum element from this node int i, j; gint cr, minvalue, minvaluerowoffset; minvalue = node->current_min; minvaluerowoffset = node->array_of_values[0]; /* Now scan for the matching slot. However, since * we already know the 0 slot will be re-filled, we * do this scan (and sort) in reverse order, compared to the case * where array had some space left. */ for(i=WG_TNODE_ARRAY_SIZE-1; i>0; i--) { cr = WG_COMPARE(db, wg_get_field(db, (void *)offsettoptr(db,node->array_of_values[i]), column), newvalue); if(cr != WG_GREATER) { /* value <= newvalue */ /* Push remaining values to the left */ for(j=0; jarray_of_values[j] = node->array_of_values[j+1]; break; } } /* i is either 0 or a freshly vacated slot */ node->array_of_values[i] = ptrtooffset(db,rec); /* Update minimum. Thanks to the sorted array, we know for a fact * that the minimum sits in slot 0. */ if(i==0) { node->current_min = newvalue; } else { node->current_min = wg_get_field(db, (void *)offsettoptr(db,node->array_of_values[0]), column); /* The scan for the free slot starts from the right and * tries to exit as fast as possible. So it's possible that * the rightmost slot was changed. */ if(i == WG_TNODE_ARRAY_SIZE-1) { node->current_max = newvalue; } } //proceed to the node that holds greatest lower bound - must be leaf (can be the initial bounding node) if(node->left_child_offset != 0){ #ifndef TTREE_CHAINED_NODES gint greatestlb = wg_ttree_find_glb_node(db,node->left_child_offset); #else gint greatestlb = node->pred_offset; #endif node = (struct wg_tnode *)offsettoptr(db, greatestlb); } //if the greatest lower bound node has room, insert value //otherwise make the new node as right child and put the value there if(node->number_of_elements < WG_TNODE_ARRAY_SIZE){ //add array entry and update control data node->array_of_values[node->number_of_elements] = minvaluerowoffset;//save offset, use first free slot node->number_of_elements++; node->current_max = minvalue; }else{ //create, initialize and save first value struct wg_tnode *leaf; gint newnode = wg_alloc_fixlen_object(db, &dbh->tnode_area_header); if(newnode == 0)return -1; leaf =(struct wg_tnode *)offsettoptr(db,newnode); leaf->parent_offset = ptrtooffset(db,node); leaf->left_subtree_height = 0; leaf->right_subtree_height = 0; leaf->current_max = minvalue; leaf->current_min = minvalue; leaf->number_of_elements = 1; leaf->left_child_offset = 0; leaf->right_child_offset = 0; leaf->array_of_values[0] = minvaluerowoffset; /* If the original, full node did not have a left child, then * there also wasn't a separate GLB node, so we are adding one now * as the left child. Otherwise, the new node is added as the right * child to the current GLB node. */ if(bnodeoffset == ptrtooffset(db,node)) { node->left_child_offset = newnode; #ifdef TTREE_CHAINED_NODES /* Create successor / predecessor relationship */ leaf->succ_offset = ptrtooffset(db, node); leaf->pred_offset = node->pred_offset; if(node->pred_offset) { struct wg_tnode *pred = \ (struct wg_tnode *) offsettoptr(db, node->pred_offset); pred->succ_offset = newnode; } else { TTREE_MIN_NODE(hdr) = newnode; } node->pred_offset = newnode; #endif } else { #ifdef TTREE_CHAINED_NODES struct wg_tnode *succ; #endif node->right_child_offset = newnode; #ifdef TTREE_CHAINED_NODES /* Insert the new node in the sequential chain between * the original node and the GLB node found */ leaf->succ_offset = node->succ_offset; leaf->pred_offset = ptrtooffset(db, node); #ifdef CHECK if(!node->succ_offset) { show_index_error(db, "GLB with no successor, panic"); return -1; } else { #endif succ = (struct wg_tnode *) offsettoptr(db, leaf->succ_offset); succ->pred_offset = newnode; #ifdef CHECK } #endif node->succ_offset = newnode; #endif /* TTREE_CHAINED_NODES */ } newoffset = newnode; } } }//the bounding node existed - first algorithm else{// bounding node does not exist //try to insert the new value to that node - becoming new min or max //if the node has room for a new entry if(node->number_of_elements < WG_TNODE_ARRAY_SIZE){ int i; /* add entry, keeping the array sorted (see also notes for the * bounding node case. The difference this time is that we already * know if this value is becoming the new min or max). */ if(boundtype == DEAD_END_LEFT_NOT_BOUNDING) { /* our new value is the new min, push everything right */ for(i=node->number_of_elements; i>0; i--) node->array_of_values[i] = node->array_of_values[i-1]; node->array_of_values[0] = ptrtooffset(db,rec); node->current_min = newvalue; } else { /* DEAD_END_RIGHT_NOT_BOUNDING */ /* even simpler case, new value is added to the right */ node->array_of_values[node->number_of_elements] = ptrtooffset(db,rec); node->current_max = newvalue; } node->number_of_elements++; /* XXX: not clear if the empty node can occur here. Until this * is checked, we'll be paranoid and overwrite both min and max. */ if(node->number_of_elements==1) { node->current_max = newvalue; node->current_min = newvalue; } }else{ //make a new node and put data there struct wg_tnode *leaf; gint newnode = wg_alloc_fixlen_object(db, &dbh->tnode_area_header); if(newnode == 0)return -1; leaf =(struct wg_tnode *)offsettoptr(db,newnode); leaf->parent_offset = ptrtooffset(db,node); leaf->left_subtree_height = 0; leaf->right_subtree_height = 0; leaf->current_max = newvalue; leaf->current_min = newvalue; leaf->number_of_elements = 1; leaf->left_child_offset = 0; leaf->right_child_offset = 0; leaf->array_of_values[0] = ptrtooffset(db,rec); newoffset = newnode; //set new node as left or right leaf if(boundtype == DEAD_END_LEFT_NOT_BOUNDING){ node->left_child_offset = newnode; #ifdef TTREE_CHAINED_NODES /* Set the new node as predecessor of the parent */ leaf->succ_offset = ptrtooffset(db, node); leaf->pred_offset = node->pred_offset; if(node->pred_offset) { /* Notify old predecessor that the node following * it changed */ struct wg_tnode *pred = \ (struct wg_tnode *) offsettoptr(db, node->pred_offset); pred->succ_offset = newnode; } else { TTREE_MIN_NODE(hdr) = newnode; } node->pred_offset = newnode; #endif }else if(boundtype == DEAD_END_RIGHT_NOT_BOUNDING){ node->right_child_offset = newnode; #ifdef TTREE_CHAINED_NODES /* Set the new node as successor of the parent */ leaf->succ_offset = node->succ_offset; leaf->pred_offset = ptrtooffset(db, node); if(node->succ_offset) { /* Notify old successor that the node preceding * it changed */ struct wg_tnode *succ = \ (struct wg_tnode *) offsettoptr(db, node->succ_offset); succ->pred_offset = newnode; } else { TTREE_MAX_NODE(hdr) = newnode; } node->succ_offset = newnode; #endif } } }//no bounding node found - algorithm 2 //if new node was added to tree - must update child height data in nodes from leaf to root //or until find a node with imbalance //then determine the bad balance case: LL, LR, RR or RL and execute proper rotation if(newoffset){ struct wg_tnode *child = (struct wg_tnode *)offsettoptr(db,newoffset); struct wg_tnode *parent; int left = 0; while(child->parent_offset != 0){//this is not a root int balance; parent = (struct wg_tnode *)offsettoptr(db,child->parent_offset); //determine which child the child is, left or right one if(parent->left_child_offset == ptrtooffset(db,child)) left = 1; else left = 0; //increment parent left or right subtree height if(left)parent->left_subtree_height++; else parent->right_subtree_height++; //check balance balance = parent->left_subtree_height - parent->right_subtree_height; if(balance == 0) { /* As a result of adding a new node somewhere below, left * and right subtrees of the node we're checking became * of EQUAL height. This means that changes in subtree heights * do not propagate any further (the max depth in this node * dit NOT change). */ break; } if(balance > 1 || balance < -1){//must rebalance //the current parent is root for balancing operation //determine the branch that causes overweight int overw = db_which_branch_causes_overweight(db,parent); //fix balance db_rotate_ttree(db,index_id,parent,overw); break;//while loop because balance does not change in the next levels }else{//just proceed to the parent node child = parent; } } } return 0; } /** removes pointer to data row from index tree structure * * returns: * 0 - on success * -1 - if error, index doesnt exist * -2 - if error, no bounding node for key * -3 - if error, boundig node exists, value not * -4 - if error, tree not in balance */ static gint ttree_remove_row(void *db, gint index_id, void * rec) { int i, found; gint key, rootoffset, column, boundtype, bnodeoffset; gint rowoffset; struct wg_tnode *node, *parent; wg_index_header *hdr = (wg_index_header *)offsettoptr(db,index_id); rootoffset = TTREE_ROOT_NODE(hdr); #ifdef CHECK if(rootoffset == 0){ #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"index at offset %d does not exist\n", (int) index_id); #endif return -1; } #endif column = hdr->rec_field_index[0]; /* always one column for T-tree */ key = wg_get_field(db, rec, column); rowoffset = ptrtooffset(db, rec); /* find bounding node for the value. Since non-unique values * are allowed, we will find the leftmost node and scan * right from there (we *need* the exact row offset). */ bnodeoffset = wg_search_ttree_leftmost(db, rootoffset, key, &boundtype, NULL); node = (struct wg_tnode *)offsettoptr(db,bnodeoffset); //if bounding node does not exist - error if(boundtype != REALLY_BOUNDING_NODE) return -2; /* find the record inside the node. This is an expensive loop if there * are many repeated values, so unnecessary deleting should be avoided * on higher level. */ found = -1; for(;;) { for(i=0;inumber_of_elements;i++){ if(node->array_of_values[i] == rowoffset) { found = i; goto found_row; } } bnodeoffset = TNODE_SUCCESSOR(db, node); if(!bnodeoffset) break; /* no more successors */ node = (struct wg_tnode *)offsettoptr(db,bnodeoffset); if(WG_COMPARE(db, node->current_min, key) == WG_GREATER) break; /* successor is not a bounding node */ } found_row: if(found == -1) return -3; //delete the key and rearrange other elements node->number_of_elements--; if(found < node->number_of_elements) { /* not the last element */ /* slide the elements to the right of the found value * one step to the left */ for(i=found; inumber_of_elements; i++) node->array_of_values[i] = node->array_of_values[i+1]; } /* Update min/max */ if(found==node->number_of_elements && node->number_of_elements != 0) { /* Rightmost element was removed, so new max should be updated to * the new rightmost value */ node->current_max = wg_get_field(db, (void *)offsettoptr(db, node->array_of_values[node->number_of_elements - 1]), column); } else if(found==0 && node->number_of_elements != 0) { /* current_min removed, update to new leftmost value */ node->current_min = wg_get_field(db, (void *)offsettoptr(db, node->array_of_values[0]), column); } //check underflow and take some actions if needed if(node->number_of_elements < 5){//TODO use macro //if the node is internal node - borrow its gratest lower bound from the node where it is if(node->left_child_offset != 0 && node->right_child_offset != 0){//internal node #ifndef TTREE_CHAINED_NODES gint greatestlb = wg_ttree_find_glb_node(db,node->left_child_offset); #else gint greatestlb = node->pred_offset; #endif struct wg_tnode *glbnode = (struct wg_tnode *)offsettoptr(db, greatestlb); /* Make space for a new min value */ for(i=node->number_of_elements; i>0; i--) node->array_of_values[i] = node->array_of_values[i-1]; /* take the glb value (always the rightmost in the array) and * insert it in our node */ node -> array_of_values[0] = \ glbnode->array_of_values[glbnode->number_of_elements-1]; node -> number_of_elements++; node -> current_min = glbnode -> current_max; if(node->number_of_elements == 1) /* we just got our first element */ node->current_max = glbnode -> current_max; glbnode -> number_of_elements--; //reset new max for glbnode if(glbnode->number_of_elements != 0) { glbnode->current_max = wg_get_field(db, (void *)offsettoptr(db, glbnode->array_of_values[glbnode->number_of_elements - 1]), column); } node = glbnode; } } //now variable node points to the node which really lost an element //this is definitely leaf or half-leaf //if the node is empty - free it and rebalanc the tree parent = NULL; //delete the empty leaf if(node->left_child_offset == 0 && node->right_child_offset == 0 && node->number_of_elements == 0){ if(node->parent_offset != 0){ parent = (struct wg_tnode *)offsettoptr(db, node->parent_offset); //was it left or right child if(parent->left_child_offset == ptrtooffset(db,node)){ parent->left_child_offset=0; parent->left_subtree_height=0; }else{ parent->right_child_offset=0; parent->right_subtree_height=0; } } #ifdef TTREE_CHAINED_NODES /* Remove the node from sequential chain */ if(node->succ_offset) { struct wg_tnode *succ = \ (struct wg_tnode *) offsettoptr(db, node->succ_offset); succ->pred_offset = node->pred_offset; } else { TTREE_MAX_NODE(hdr) = node->pred_offset; } if(node->pred_offset) { struct wg_tnode *pred = \ (struct wg_tnode *) offsettoptr(db, node->pred_offset); pred->succ_offset = node->succ_offset; } else { TTREE_MIN_NODE(hdr) = node->succ_offset; } #endif /* Free the node, unless it's the root node */ if(node != offsettoptr(db, TTREE_ROOT_NODE(hdr))) { wg_free_tnode(db, ptrtooffset(db,node)); } else { /* Set empty state of root node */ node->current_max = WG_ILLEGAL; node->current_min = WG_ILLEGAL; #ifdef TTREE_CHAINED_NODES TTREE_MAX_NODE(hdr) = TTREE_ROOT_NODE(hdr); TTREE_MIN_NODE(hdr) = TTREE_ROOT_NODE(hdr); #endif } //rebalance if needed } //or if the node was a half-leaf, see if it can be merged with its leaf if((node->left_child_offset == 0 && node->right_child_offset != 0) || (node->left_child_offset != 0 && node->right_child_offset == 0)){ int elements = node->number_of_elements; int left; struct wg_tnode *child; if(node->left_child_offset != 0){ child = (struct wg_tnode *)offsettoptr(db, node->left_child_offset); left = 1;//true }else{ child = (struct wg_tnode *)offsettoptr(db, node->right_child_offset); left = 0;//false } elements += child->number_of_elements; if(!(child->left_subtree_height == 0 && child->right_subtree_height == 0)){ show_index_error(db, "index tree is not balanced, deleting algorithm doesn't work"); return -4; } //if possible move all elements from child to node and free child if(elements <= WG_TNODE_ARRAY_SIZE){ int i = node->number_of_elements; int j; node->number_of_elements = elements; if(left){ /* Left child elements are all smaller than in current node */ for(j=i-1; j>=0; j--){ node->array_of_values[j + child->number_of_elements] = \ node->array_of_values[j]; } for(j=0;jnumber_of_elements;j++){ node->array_of_values[j]=child->array_of_values[j]; } node->left_subtree_height=0; node->left_child_offset=0; node->current_min=child->current_min; if(!i) node->current_max=child->current_max; /* parent was empty */ }else{ /* Right child elements are all larger than in current node */ for(j=0;jnumber_of_elements;j++){ node->array_of_values[i+j]=child->array_of_values[j]; } node->right_subtree_height=0; node->right_child_offset=0; node->current_max=child->current_max; if(!i) node->current_min=child->current_min; /* parent was empty */ } #ifdef TTREE_CHAINED_NODES /* Remove the child from sequential chain */ if(child->succ_offset) { struct wg_tnode *succ = \ (struct wg_tnode *) offsettoptr(db, child->succ_offset); succ->pred_offset = child->pred_offset; } else { TTREE_MAX_NODE(hdr) = child->pred_offset; } if(child->pred_offset) { struct wg_tnode *pred = \ (struct wg_tnode *) offsettoptr(db, child->pred_offset); pred->succ_offset = child->succ_offset; } else { TTREE_MIN_NODE(hdr) = child->succ_offset; } #endif wg_free_tnode(db, ptrtooffset(db, child)); if(node->parent_offset) { parent = (struct wg_tnode *)offsettoptr(db, node->parent_offset); if(parent->left_child_offset==ptrtooffset(db,node)){ parent->left_subtree_height=1; }else{ parent->right_subtree_height=1; } } } } //check balance and update subtree height data //stop when find a node where subtree heights dont change if(parent != NULL){ int balance, height; for(;;) { balance = parent->left_subtree_height - parent->right_subtree_height; if(balance > 1 || balance < -1){//must rebalance //the current parent is root for balancing operation //rotarion fixes subtree heights in grandparent //determine the branch that causes overweight int overw = db_which_branch_causes_overweight(db,parent); //fix balance db_rotate_ttree(db,index_id,parent,overw); } else if(parent->parent_offset) { struct wg_tnode *gp; //manually set grandparent subtree heights height = max(parent->left_subtree_height,parent->right_subtree_height); gp = (struct wg_tnode *)offsettoptr(db, parent->parent_offset); if(gp->left_child_offset==ptrtooffset(db,parent)){ gp->left_subtree_height=1+height; }else{ gp->right_subtree_height=1+height; } } if(!parent->parent_offset) break; /* root node reached */ parent = (struct wg_tnode *)offsettoptr(db, parent->parent_offset); } } return 0; } /* ------------------- T-tree public functions ---------------- */ /** * returns offset to data row: * -1 - error, index does not exist * 0 - if key NOT found * other integer - if key found (= offset to data row) * XXX: with duplicate values, which one is returned is somewhat * undetermined, so this function is mainly for early development/testing */ gint wg_search_ttree_index(void *db, gint index_id, gint key){ int i; gint rootoffset, bnodetype, bnodeoffset; gint rowoffset, column; struct wg_tnode * node; wg_index_header *hdr = (wg_index_header *)offsettoptr(db,index_id); rootoffset = TTREE_ROOT_NODE(hdr); #ifdef CHECK /* XXX: This is a rather weak check but might catch some errors */ if(rootoffset == 0){ #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"index at offset %d does not exist\n", (int) index_id); #endif return -1; } #endif /* Find the leftmost bounding node */ bnodeoffset = wg_search_ttree_leftmost(db, rootoffset, key, &bnodetype, NULL); node = (struct wg_tnode *)offsettoptr(db,bnodeoffset); if(bnodetype != REALLY_BOUNDING_NODE) return 0; column = hdr->rec_field_index[0]; /* always one column for T-tree */ /* find the record inside the node. */ for(;;) { for(i=0;inumber_of_elements;i++){ rowoffset = node->array_of_values[i]; if(WG_COMPARE(db, wg_get_field(db, (void *)offsettoptr(db,rowoffset), column), key) == WG_EQUAL) { return rowoffset; } } /* Normally we cannot end up here. We'll keep the code in case * implementation of wg_compare() changes in the future. */ bnodeoffset = TNODE_SUCCESSOR(db, node); if(!bnodeoffset) break; /* no more successors */ node = (struct wg_tnode *)offsettoptr(db,bnodeoffset); if(WG_COMPARE(db, node->current_min, key) == WG_GREATER) break; /* successor is not a bounding node */ } return 0; } /* * The following pairs of functions implement tree traversal. Only * wg_ttree_find_glb_node() is used for the upkeep of T-tree (insert, delete, * re-balance), the rest are required for sequential scan and range queries * when the tree is implemented without predecessor and successor pointers. */ #ifndef TTREE_CHAINED_NODES /** find greatest lower bound node * returns offset of the (half-) leaf node with greatest lower bound * goes only right - so: must call on the left child of the internal * which we are looking the GLB node for. */ gint wg_ttree_find_glb_node(void *db, gint nodeoffset) { struct wg_tnode * node = (struct wg_tnode *)offsettoptr(db,nodeoffset); if(node->right_child_offset != 0) return wg_ttree_find_glb_node(db, node->right_child_offset); else return nodeoffset; } /** find least upper bound node * returns offset of the (half-) leaf node with least upper bound * Call with the right child of an internal node as argument. */ gint wg_ttree_find_lub_node(void *db, gint nodeoffset) { struct wg_tnode * node = (struct wg_tnode *)offsettoptr(db,nodeoffset); if(node->left_child_offset != 0) return wg_ttree_find_lub_node(db, node->left_child_offset); else return nodeoffset; } /** find predecessor of a leaf. * Returns offset of the internal node which holds the value * immediately preceeding the current_min of the leaf. * If the search hit root (the leaf could be the leftmost one in * the tree) the function returns 0. * This is the reverse of finding the LUB node. */ gint wg_ttree_find_leaf_predecessor(void *db, gint nodeoffset) { struct wg_tnode *node, *parent; node = (struct wg_tnode *)offsettoptr(db,nodeoffset); if(node->parent_offset) { parent = (struct wg_tnode *) offsettoptr(db, node->parent_offset); /* If the current node was left child of the parent, the immediate * parent has larger values, so we need to climb to the next * level with our search. */ if(parent->left_child_offset == nodeoffset) return wg_ttree_find_leaf_predecessor(db, node->parent_offset); } return node->parent_offset; } /** find successor of a leaf. * Returns offset of the internal node which holds the value * immediately succeeding the current_max of the leaf. * Returns 0 if there is no successor. * This is the reverse of finding the GLB node. */ gint wg_ttree_find_leaf_successor(void *db, gint nodeoffset) { struct wg_tnode *node, *parent; node = (struct wg_tnode *)offsettoptr(db,nodeoffset); if(node->parent_offset) { parent = (struct wg_tnode *) offsettoptr(db, node->parent_offset); if(parent->right_child_offset == nodeoffset) return wg_ttree_find_leaf_successor(db, node->parent_offset); } return node->parent_offset; } #endif /* TTREE_CHAINED_NODES */ /* * Functions to support range queries (and fetching multiple * duplicate values) using T-tree index. Since the nodes can be * traversed sequentially, the simplest way to implement queries that * have result sets is to find leftmost (or rightmost) value that * meets the query conditions and scan right (or left) from there. */ /** Find rightmost node containing given value * returns NULL if node was not found */ gint wg_search_ttree_rightmost(void *db, gint rootoffset, gint key, gint *result, struct wg_tnode *rb_node) { struct wg_tnode * node; #ifdef TTREE_SINGLE_COMPARE node = (struct wg_tnode *)offsettoptr(db,rootoffset); /* Improved(?) tree search algorithm with a single compare per node. * only lower bound is examined, if the value is larger the right subtree * is selected immediately. If the search ends in a dead end, the node where * the right branch was taken is examined again. */ if(WG_COMPARE(db, key, node->current_min) == WG_LESSTHAN) { /* key < node->current_min */ if(node->left_child_offset != 0) { return wg_search_ttree_rightmost(db, node->left_child_offset, key, result, rb_node); } else if (rb_node) { /* Dead end, but we still have an unexamined node left */ if(WG_COMPARE(db, key, rb_node->current_max) != WG_GREATER) { /* key<=rb_node->current_max */ *result = REALLY_BOUNDING_NODE; return ptrtooffset(db, rb_node); } } /* No left child, no rb_node or it's right bound was not interesting */ *result = DEAD_END_LEFT_NOT_BOUNDING; return rootoffset; } else { if(node->right_child_offset != 0) { /* Here we jump the gun and branch to right, ignoring the * current_max of the node (therefore avoiding one expensive * compare operation). */ return wg_search_ttree_rightmost(db, node->right_child_offset, key, result, node); } else if(WG_COMPARE(db, key, node->current_max) != WG_GREATER) { /* key<=node->current_max */ *result = REALLY_BOUNDING_NODE; return rootoffset; } /* key is neither left of or inside this node and * there is no right child */ *result = DEAD_END_RIGHT_NOT_BOUNDING; return rootoffset; } #else gint bnodeoffset; bnodeoffset = db_find_bounding_tnode(db, rootoffset, key, result, NULL); if(*result != REALLY_BOUNDING_NODE) return bnodeoffset; /* There is at least one node with the key we're interested in, * now make sure we have the rightmost */ node = offsettoptr(db, bnodeoffset); while(WG_COMPARE(db, node->current_max, key) == WG_EQUAL) { gint nextoffset = TNODE_SUCCESSOR(db, node); if(nextoffset) { struct wg_tnode *next = offsettoptr(db, nextoffset); if(WG_COMPARE(db, next->current_min, key) == WG_GREATER) /* next->current_min > key */ break; /* overshot */ node = next; } else break; /* last node in chain */ } return ptrtooffset(db, node); #endif } /** Find leftmost node containing given value * returns NULL if node was not found */ gint wg_search_ttree_leftmost(void *db, gint rootoffset, gint key, gint *result, struct wg_tnode *lb_node) { struct wg_tnode * node; #ifdef TTREE_SINGLE_COMPARE node = (struct wg_tnode *)offsettoptr(db,rootoffset); /* Rightmost bound search mirrored */ if(WG_COMPARE(db, key, node->current_max) == WG_GREATER) { /* key > node->current_max */ if(node->right_child_offset != 0) { return wg_search_ttree_leftmost(db, node->right_child_offset, key, result, lb_node); } else if (lb_node) { /* Dead end, but we still have an unexamined node left */ if(WG_COMPARE(db, key, lb_node->current_min) != WG_LESSTHAN) { /* key>=lb_node->current_min */ *result = REALLY_BOUNDING_NODE; return ptrtooffset(db, lb_node); } } *result = DEAD_END_RIGHT_NOT_BOUNDING; return rootoffset; } else { if(node->left_child_offset != 0) { return wg_search_ttree_leftmost(db, node->left_child_offset, key, result, node); } else if(WG_COMPARE(db, key, node->current_min) != WG_LESSTHAN) { /* key>=node->current_min */ *result = REALLY_BOUNDING_NODE; return rootoffset; } *result = DEAD_END_LEFT_NOT_BOUNDING; return rootoffset; } #else gint bnodeoffset; bnodeoffset = db_find_bounding_tnode(db, rootoffset, key, result, NULL); if(*result != REALLY_BOUNDING_NODE) return bnodeoffset; /* One (we don't know which) bounding node found, traverse the * tree to the leftmost. */ node = offsettoptr(db, bnodeoffset); while(WG_COMPARE(db, node->current_min, key) == WG_EQUAL) { gint prevoffset = TNODE_PREDECESSOR(db, node); if(prevoffset) { struct wg_tnode *prev = offsettoptr(db, prevoffset); if(WG_COMPARE(db, prev->current_max, key) == WG_LESSTHAN) /* prev->current_max < key */ break; /* overshot */ node = prev; } else break; /* first node in chain */ } return ptrtooffset(db, node); #endif } /** Find first occurrence of a value in a T-tree node * returns the number of the slot. If the value itself * is missing, the location of the first value that * exceeds it is returned. */ gint wg_search_tnode_first(void *db, gint nodeoffset, gint key, gint column) { gint i, encoded; struct wg_tnode *node = (struct wg_tnode *) offsettoptr(db, nodeoffset); for(i=0; inumber_of_elements; i++) { /* Naive scan is ok for small values of WG_TNODE_ARRAY_SIZE. */ encoded = wg_get_field(db, (void *)offsettoptr(db,node->array_of_values[i]), column); if(WG_COMPARE(db, encoded, key) != WG_LESSTHAN) /* encoded >= key */ return i; } return -1; } /** Find last occurrence of a value in a T-tree node * returns the number of the slot. If the value itself * is missing, the location of the first value that * is smaller (when scanning from right to left) is returned. */ gint wg_search_tnode_last(void *db, gint nodeoffset, gint key, gint column) { gint i, encoded; struct wg_tnode *node = (struct wg_tnode *) offsettoptr(db, nodeoffset); for(i=node->number_of_elements -1; i>=0; i--) { encoded = wg_get_field(db, (void *)offsettoptr(db,node->array_of_values[i]), column); if(WG_COMPARE(db, encoded, key) != WG_GREATER) /* encoded <= key */ return i; } return -1; } /** Create T-tree index on a column * returns: * 0 - on success * -1 - error (failed to create the index) */ static gint create_ttree_index(void *db, gint index_id){ gint node; unsigned int rowsprocessed; struct wg_tnode *nodest; void *rec; db_memsegment_header* dbh = dbmemsegh(db); wg_index_header *hdr = (wg_index_header *) offsettoptr(db, index_id); gint column = hdr->rec_field_index[0]; /* allocate (+ init) root node for new index tree and save * the offset into index_array */ node = wg_alloc_fixlen_object(db, &dbh->tnode_area_header); nodest =(struct wg_tnode *)offsettoptr(db,node); nodest->parent_offset = 0; nodest->left_subtree_height = 0; nodest->right_subtree_height = 0; nodest->current_max = WG_ILLEGAL; nodest->current_min = WG_ILLEGAL; nodest->number_of_elements = 0; nodest->left_child_offset = 0; nodest->right_child_offset = 0; #ifdef TTREE_CHAINED_NODES nodest->succ_offset = 0; nodest->pred_offset = 0; #endif TTREE_ROOT_NODE(hdr) = node; #ifdef TTREE_CHAINED_NODES TTREE_MIN_NODE(hdr) = node; TTREE_MAX_NODE(hdr) = node; #endif //scan all the data - make entry for every suitable row rec = wg_get_first_record(db); rowsprocessed = 0; while(rec != NULL) { if(column >= wg_get_record_len(db, rec)) { rec=wg_get_next_record(db,rec); continue; } if(MATCH_TEMPLATE(db, hdr, rec)) { ttree_add_row(db, index_id, rec); rowsprocessed++; } rec=wg_get_next_record(db,rec); } #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"new index created on rec field %d into slot %d and %d data rows inserted\n", (int) column, (int) index_id, rowsprocessed); #endif return 0; } /** Drop T-tree index by id * Frees the memory in the T-node area * returns: * 0 - on success * -1 - error */ static gint drop_ttree_index(void *db, gint index_id){ struct wg_tnode *node; wg_index_header *hdr; hdr = (wg_index_header *) offsettoptr(db, index_id); /* Free the T-node memory. This is trivial for chained nodes, since * once we've found a successor for a node it can be deleted and * forgotten about. For plain T-tree this does not work since tree * traversal often runs down and up parent-child chains, which means * that some parents cannot be deleted before their children. */ node = NULL; #ifdef TTREE_CHAINED_NODES if(TTREE_MIN_NODE(hdr)) node = (struct wg_tnode *) offsettoptr(db, TTREE_MIN_NODE(hdr)); else if(TTREE_ROOT_NODE(hdr)) /* normally this does not happen */ node = (struct wg_tnode *) offsettoptr(db, TTREE_ROOT_NODE(hdr)); while(node) { gint deleteme = ptrtooffset(db, node); if(node->succ_offset) node = (struct wg_tnode *) offsettoptr(db, node->succ_offset); else node = NULL; wg_free_tnode(db, deleteme); } #else /* XXX: not implemented */ show_index_error(db, "Warning: T-node memory cannot be deallocated"); #endif return 0; } /* -------------- Hash index private functions ------------- */ /** inserts pointer to data row into index tree structure * returns: * 0 - on success * -1 - if error */ static gint hash_add_row(void *db, gint index_id, void *rec) { wg_index_header *hdr = (wg_index_header *)offsettoptr(db,index_id); gint i; gint values[MAX_INDEX_FIELDS]; for(i=0; ifields; i++) { values[i] = wg_get_field(db, rec, hdr->rec_field_index[i]); } return hash_recurse(db, hdr, NULL, 0, values, hdr->fields, rec, HASHIDX_OP_STORE, (hdr->type == WG_INDEX_TYPE_HASH_JSON)); } /** Remove all entries connected to a row from hash index * returns: * 0 - on success * -1 - if error */ static gint hash_remove_row(void *db, gint index_id, void *rec) { wg_index_header *hdr = (wg_index_header *)offsettoptr(db,index_id); gint i; gint values[MAX_INDEX_FIELDS]; for(i=0; ifields; i++) { values[i] = wg_get_field(db, rec, hdr->rec_field_index[i]); } return hash_recurse(db, hdr, NULL, 0, values, hdr->fields, rec, HASHIDX_OP_REMOVE, (hdr->type == WG_INDEX_TYPE_HASH_JSON)); } /** * Construct a byte array for hashing recursively. * Hash it when it is complete. * * If we have a JSON index *and* we're acting on an indexable row, * all arrays are expanded. This does not happen if we're called * by updating a value *in* an array. * * returns: * 0 - on success * -1 - on error */ static gint hash_recurse(void *db, wg_index_header *hdr, char *prefix, gint prefixlen, gint *values, gint count, void *rec, gint op, gint expand) { if(count) { gint nextvalue = values[0]; if(expand) { /* In case of a JSON/array index, check the value */ if(wg_get_encoded_type(db, nextvalue) == WG_RECORDTYPE) { void *valrec = wg_decode_record(db, nextvalue); if(is_schema_array(valrec)) { /* expand the array */ gint i, reclen, retv = 0; reclen = wg_get_record_len(db, valrec); for(i=0; itype; gint firstcol = hdr->rec_field_index[0]; gint i; /* Initialize the hash table (0 - use default size) */ if(wg_create_hash(db, HASHIDX_ARRAYP(hdr), 0)) return -1; /* Add existing records */ rec = wg_get_first_record(db); rowsprocessed = 0; while(rec != NULL) { if(firstcol >= wg_get_record_len(db, rec)) { rec=wg_get_next_record(db,rec); continue; } if(MATCH_TEMPLATE(db, hdr, rec)) { if(type == WG_INDEX_TYPE_HASH_JSON) { /* Ignore array and object records. Their data is indexed * from the rows that point to them. */ if(is_plain_record(rec)) { hash_add_row(db, index_id, rec); rowsprocessed++; } } else { /* Add all rows normally */ hash_add_row(db, index_id, rec); rowsprocessed++; } } rec=wg_get_next_record(db,rec); } #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"new hash index created on ("); #endif for(i=0; ifields; i++) { #ifdef WG_NO_ERRPRINT #else #ifdef _WIN32 fprintf(stderr,"%s%Id", (i ? "," : ""), hdr->rec_field_index[i]); #else fprintf(stderr,"%s%td", (i ? "," : ""), hdr->rec_field_index[i]); #endif #endif } #ifdef WG_NO_ERRPRINT #else fprintf(stderr,") into slot %d and %d data rows inserted\n", (int) index_id, rowsprocessed); #endif return 0; } /** Drop a hash index by id * returns: * 0 - on success * -1 - error * * XXX: implement this. Needs some method of de-allocating or reusing * the main hash table (list cells/varlen storage can be freed piece by * piece if necessary). */ static gint drop_hash_index(void *db, gint index_id){ show_index_error(db, "Cannot drop hash index: not implemented"); return -1; } /* -------------- Hash index public functions -------------- */ /** * Search the hash index for given values. * * returns offset to data row: * -1 - error * 0 - if key NOT found * >0 - offset to the linked list that contains the row offsets */ gint wg_search_hash(void *db, gint index_id, gint *values, gint count) { wg_index_header *hdr = (wg_index_header *) offsettoptr(db, index_id); #ifdef CHECK gint type = wg_get_index_type(db, index_id); /* also validates the id */ if(type < 0) return type; if(type != WG_INDEX_TYPE_HASH && type != WG_INDEX_TYPE_HASH_JSON) return show_index_error(db, "wg_search_hash: Not a hash index"); if(hdr->fields != count) { show_index_error(db, "Number of indexed fields does not match"); return -1; } #endif return hash_recurse(db, hdr, NULL, 0, values, count, NULL, HASHIDX_OP_FIND, 0); } /* ----------------- Index template functions -------------- */ /** Insert into list * * helper function to insert list elements. Takes address of * a variable containing an offset to the first element (that * offset may be 0 for empty lists or when appending). */ static gint insert_into_list(void *db, gint *head, gint value) { db_memsegment_header* dbh = dbmemsegh(db); gint old = *head; *head = wg_alloc_fixlen_object(db, &dbh->listcell_area_header); if(*head) { gcell *listelem = (gcell *) offsettoptr(db, *head); listelem->car = value; listelem->cdr = old; } return *head; } /** Delete from list * * helper function to delete list elements. Deletes the current * element. */ static void delete_from_list(void *db, gint *head) { db_memsegment_header* dbh = dbmemsegh(db); gcell *listelem = (gcell *) offsettoptr(db, *head); *head = listelem->cdr; /* Free the vacated list element */ wg_free_fixlen_object(db, &dbh->listcell_area_header, ptrtooffset(db, listelem)); } #ifdef USE_INDEX_TEMPLATE /** Add index template * * Takes a gint array that represents an template for records * that are inserted into an index. Creates a database record * from that array and links the record into an ordered list. * * Returns offset to the created match record, if successful * Returns 0 on error. */ static gint add_index_template(void *db, gint *matchrec, gint reclen) { gint *ilist, *meta; void *rec; db_memsegment_header* dbh = dbmemsegh(db); wg_index_template *tmpl; gint fixed_columns = 0, template_offset = 0, last_fixed = 0; int i; /* Find the number of fixed columns in the template */ for(i=0; iindex_control_area_header.index_template_list; while(*ilist) { gcell *ilistelem = (gcell *) offsettoptr(db, *ilist); if(!ilistelem->car) { show_index_error(db, "Invalid header in index tempate list"); return 0; } tmpl = (wg_index_template *) offsettoptr(db, ilistelem->car); if(tmpl->fixed_columns == fixed_columns) { rec = offsettoptr(db, tmpl->offset_matchrec); if(reclen != wg_get_record_len(db, rec)) goto nextelem; /* match not possible */ for(i=0; icar; } else if(tmpl->fixed_columns < fixed_columns) { /* No matching record found. New template should be inserted * ahead of current element. */ break; } nextelem: ilist = &ilistelem->cdr; } /* Create the new match record */ rec = wg_create_raw_record(db, reclen); if(!rec) return 0; for(i=0; iindextmpl_area_header); tmpl = (wg_index_template *) offsettoptr(db, template_offset); tmpl->offset_matchrec = ptrtooffset(db, rec); tmpl->fixed_columns = fixed_columns; /* Insert it into the template list */ if(!insert_into_list(db, ilist, template_offset)) return 0; return template_offset; } /** Find index template * * Takes a gint array that represents an template for records * that are inserted into an index. Checks if a matching template * exists in a database. This function is used for finding an * index. * * Returns the template offset on success. * Returns 0 on error. */ static gint find_index_template(void *db, gint *matchrec, gint reclen) { gint *ilist; void *rec; db_memsegment_header* dbh = dbmemsegh(db); wg_index_template *tmpl; gint fixed_columns = 0, last_fixed = 0; int i; /* Get some statistics about the match record and validate it */ for(i=0; iindex_control_area_header.index_template_list; while(*ilist) { gcell *ilistelem = (gcell *) offsettoptr(db, *ilist); if(!ilistelem->car) { show_index_error(db, "Invalid header in index tempate list"); return 0; } tmpl = (wg_index_template *) offsettoptr(db, ilistelem->car); if(tmpl->fixed_columns == fixed_columns) { rec = offsettoptr(db, tmpl->offset_matchrec); if(reclen != wg_get_record_len(db, rec)) goto nextelem; /* match not possible */ for(i=0; icar; } else if(tmpl->fixed_columns < fixed_columns) { /* No matching record found. New template should be inserted * ahead of current element. */ break; } nextelem: ilist = &ilistelem->cdr; } return 0; } /** Remove index template * * Caller should make sure that the template is no longer * referenced by any indexes before calling this. */ static gint remove_index_template(void *db, gint template_offset) { gint *ilist; void *rec; db_memsegment_header* dbh = dbmemsegh(db); wg_index_template *tmpl; tmpl = (wg_index_template *) offsettoptr(db, template_offset); /* Delete the database record */ rec = offsettoptr(db, tmpl->offset_matchrec); wg_delete_record(db, rec); /* Remove from template list */ ilist = &dbh->index_control_area_header.index_template_list; while(*ilist) { gcell *ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car == template_offset) { delete_from_list(db, ilist); break; } ilist = &ilistelem->cdr; } /* Free the template */ wg_free_fixlen_object(db, &dbh->indextmpl_area_header, template_offset); return 0; } /** Check if a record matches a template * * Returns 1 if they match * Otherwise, returns 0 */ gint wg_match_template(void *db, wg_index_template *tmpl, void *rec) { void *matchrec; gint reclen, mreclen; int i; #ifdef CHECK /* Paranoia */ if(!tmpl->offset_matchrec) { show_index_error(db, "Invalid match record template"); return 0; } #endif matchrec = offsettoptr(db, tmpl->offset_matchrec); mreclen = wg_get_record_len(db, matchrec); reclen = wg_get_record_len(db, rec); if(mreclen > reclen) { /* Match records always end in a fixed column, so * this is guaranteed to be a mismatch */ return 0; } else if(mreclen < reclen) { /* Fields outside the template always match */ reclen = mreclen; } for(i=0; i prev) lowest = columns[j]; } if(lowest == MAX_INDEXED_FIELDNR + 1) break; sorted_cols[i++] = lowest; prev = lowest; }; return i; } /** Create an index. * * Single-column backward compatibility wrapper. */ gint wg_create_index(void *db, gint column, gint type, gint *matchrec, gint reclen) { return wg_create_multi_index(db, &column, 1, type, matchrec, reclen); } /** Create an index. * * Arguments - * type - WG_INDEX_TYPE_TTREE - single-column T-tree index * WG_INDEX_TYPE_TTREE_JSON - T-tree for JSON schema * WG_INDEX_TYPE_HASH - multi-column hash index * WG_INDEX_TYPE_HASH_JSON - hash index with JSON features * * columns - array of column numbers * col_count - size of the column number array * * matchrec - array of gints * reclen - size of matchrec * If matchrec is NULL, regular index will be created. Otherwise, * only database records that match the template defined by * matchrec are inserted in this index. */ gint wg_create_multi_index(void *db, gint *columns, gint col_count, gint type, gint *matchrec, gint reclen) { gint index_id, template_offset = 0, i; wg_index_header *hdr; #ifdef USE_INDEX_TEMPLATE wg_index_template *tmpl = NULL; gint fixed_columns = 0; #endif gint *ilist[MAX_INDEX_FIELDS]; gint sorted_cols[MAX_INDEX_FIELDS]; db_memsegment_header* dbh = dbmemsegh(db); /* Check the arguments */ #ifdef CHECK if (!dbcheck(db)) { show_index_error(db, "Invalid database pointer in wg_create_multi_index"); return -1; } if(!columns) { show_index_error(db, "columns list is a NULL pointer"); return -1; } #endif #ifdef USE_CHILD_DB /* Workaround to handle external refs/ttree issue */ if(dbh->extdbs.count > 0) { return show_index_error(db, "Database has external data, "\ "indexes disabled."); } #endif /* Column count validation */ if(col_count < 1) { show_index_error(db, "need at least one indexed column"); return -1; } else if(col_count > MAX_INDEX_FIELDS) { show_index_error_nr(db, "Max allowed indexed fields", MAX_INDEX_FIELDS); return -1; } else if(col_count > 1 &&\ (type == WG_INDEX_TYPE_TTREE || type == WG_INDEX_TYPE_TTREE_JSON)) { show_index_error(db, "Cannot create a T-tree index on multiple columns"); return -1; } if(sort_columns(sorted_cols, columns, col_count) < col_count) { show_index_error(db, "Duplicate columns not allowed"); return -1; } for(i=0; i MAX_INDEXED_FIELDNR) { show_index_error_nr(db, "Max allowed column number", MAX_INDEXED_FIELDNR); return -1; } } #ifdef USE_INDEX_TEMPLATE /* Handle the template */ if(matchrec) { if(!reclen) { show_index_error(db, "Zero-length match record not allowed"); return -1; } if(reclen > MAX_INDEXED_FIELDNR+1) { show_index_error_nr(db, "Match record too long, max", MAX_INDEXED_FIELDNR+1); return -1; } /* Sanity check */ for(i=0; ifixed_columns; } #endif /* Scan to the end of index chain for each column. If templates are used, * new indexes are inserted in between list elements to maintain * the chains sorted by number of fixed columns. */ for(i=0; iindex_control_area_header.index_table[column]; while(*(ilist[i])) { gcell *ilistelem = (gcell *) offsettoptr(db, *(ilist[i])); if(!ilistelem->car) { show_index_error(db, "Invalid header in index list"); return -1; } hdr = (wg_index_header *) offsettoptr(db, ilistelem->car); /* If this is the first column, check for a matching index. * Note that this is simplified by having the column lists sorted. */ if(!i && hdr->type==type && template_offset==hdr->template_offset &&\ hdr->fields==col_count) { gint j, match = 1; /* Compare the field lists */ for(j=0; jrec_field_index[j] != sorted_cols[j]) { match = 0; break; } } if(match) { show_index_error(db, "Identical index already exists on the column"); return -1; } } #ifdef USE_INDEX_TEMPLATE if(hdr->template_offset) { wg_index_template *t = \ (wg_index_template *) offsettoptr(db, hdr->template_offset); if(t->fixed_columns < fixed_columns) break; /* new template is more promising, insert here */ } else if(fixed_columns) { /* Current list element does not have a template, so * the new one should be inserted before it. */ break; } #endif ilist[i] = &ilistelem->cdr; } } /* Add new index header */ index_id = wg_alloc_fixlen_object(db, &dbh->indexhdr_area_header); for(i=0; itype = type; hdr->fields = col_count; for(i=0; i < col_count; i++) { hdr->rec_field_index[i] = sorted_cols[i]; } hdr->template_offset = template_offset; /* create the actual index */ switch(hdr->type) { case WG_INDEX_TYPE_TTREE: create_ttree_index(db, index_id); break; case WG_INDEX_TYPE_HASH: case WG_INDEX_TYPE_HASH_JSON: if(create_hash_index(db, index_id)) return -1; break; case WG_INDEX_TYPE_TTREE_JSON: /* Return an error, until proper implementation exists */ default: show_index_error(db, "Invalid index type"); return -1; } /* Add to master list */ if(!insert_into_list(db, &dbh->index_control_area_header.index_list ,index_id)) return -1; #ifdef USE_INDEX_TEMPLATE if(hdr->template_offset) { int i; /* Update the template index */ for(i=0; iindex_control_area_header.index_template_table[i]), index_id)) return 0; } } } #endif /* increase index counter */ dbh->index_control_area_header.number_of_indexes++; #ifdef USE_INDEX_TEMPLATE if(tmpl) tmpl->refcount++; #endif return 0; } /** Drop index by index id * * returns: * 0 - on success * -1 - error */ gint wg_drop_index(void *db, gint index_id){ int i; wg_index_header *hdr = NULL; gint *ilist; gcell *ilistelem; db_memsegment_header* dbh = dbmemsegh(db); /* Locate the header */ ilist = &dbh->index_control_area_header.index_list; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car == index_id) { hdr = (wg_index_header *) offsettoptr(db, index_id); /* Delete current element */ delete_from_list(db, ilist); break; } ilist = &ilistelem->cdr; } if(!hdr) { show_index_error_nr(db, "Invalid index for delete", index_id); return -1; } /* Remove the index from index table */ for(i=0; ifields; i++) { int column = hdr->rec_field_index[i]; ilist = &dbh->index_control_area_header.index_table[column]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car == index_id) { delete_from_list(db, ilist); break; } ilist = &ilistelem->cdr; } } #ifdef USE_INDEX_TEMPLATE if(hdr->template_offset) { wg_index_template *tmpl = \ (wg_index_template *) offsettoptr(db, hdr->template_offset); void *matchrec = offsettoptr(db, tmpl->offset_matchrec); gint reclen = wg_get_record_len(db, matchrec); /* Remove from template index */ for(i=0; iindex_control_area_header.index_template_table[i]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car == index_id) { delete_from_list(db, ilist); break; } ilist = &ilistelem->cdr; } } } } #endif /* Drop the index */ switch(hdr->type) { case WG_INDEX_TYPE_TTREE: case WG_INDEX_TYPE_TTREE_JSON: if(drop_ttree_index(db, index_id)) return -1; break; case WG_INDEX_TYPE_HASH: case WG_INDEX_TYPE_HASH_JSON: if(drop_hash_index(db, index_id)) return -1; break; default: show_index_error(db, "Invalid index type"); return -1; } #ifdef USE_INDEX_TEMPLATE if(hdr->template_offset) { wg_index_template *tmpl = \ (wg_index_template *) offsettoptr(db, hdr->template_offset); if(!(--(tmpl->refcount))) remove_index_template(db, hdr->template_offset); } #endif /* Now free the header */ wg_free_fixlen_object(db, &dbh->indexhdr_area_header, index_id); /* decrement index counter */ dbh->index_control_area_header.number_of_indexes--; return 0; } /** Find index id (index header) by column. * * Single-column backward compatibility wrapper. */ gint wg_column_to_index_id(void *db, gint column, gint type, gint *matchrec, gint reclen) { return wg_multi_column_to_index_id(db, &column, 1, type, matchrec, reclen); } /** Find index id (index header) by column(s) * Supports all types of indexes, calling program should examine the * header of returned index to decide how to proceed. Alternatively, * if type is not 0 then only indexes of the given type are * returned. * * If matchrec is NULL, "full" index is returned. Otherwise * the function attempts to locate a matching template. * * returns: * -1 if no index found * offset > 0 if index found - index id */ gint wg_multi_column_to_index_id(void *db, gint *columns, gint col_count, gint type, gint *matchrec, gint reclen) { int i; gint template_offset = 0; db_memsegment_header* dbh = dbmemsegh(db); gint *ilist; gcell *ilistelem; gint sorted_cols[MAX_INDEX_FIELDS]; #ifdef USE_INDEX_TEMPLATE /* Validate the match record and find the template */ if(matchrec) { if(!reclen) { show_index_error(db, "Zero-length match record not allowed"); return -1; } if(reclen > MAX_INDEXED_FIELDNR+1) { show_index_error_nr(db, "Match record too long, max", MAX_INDEXED_FIELDNR+1); return -1; } template_offset = find_index_template(db, matchrec, reclen); if(!template_offset) { /* No matching template */ return -1; } } #endif /* Column count validation */ if(col_count < 1) { show_index_error(db, "need at least one indexed column"); return -1; } else if(col_count > MAX_INDEX_FIELDS) { show_index_error_nr(db, "Max allowed indexed fields", MAX_INDEX_FIELDS); return -1; } if(col_count > 1) { if(sort_columns(sorted_cols, columns, col_count) < col_count) { show_index_error(db, "Duplicate columns not allowed"); return -1; } } else { sorted_cols[0] = columns[0]; } for(i=0; i MAX_INDEXED_FIELDNR) { show_index_error_nr(db, "Max allowed column number", MAX_INDEXED_FIELDNR); return -1; } } /* Find all indexes on the first column */ ilist = &dbh->index_control_area_header.index_table[sorted_cols[0]]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); #ifndef USE_INDEX_TEMPLATE if(!type || type==hdr->type) { #else if((!type || type==hdr->type) &&\ hdr->template_offset == template_offset) { #endif if(hdr->fields == col_count) { for(i=0; irec_field_index[i]!=sorted_cols[i]) goto nextindex; } return ilistelem->car; /* index id */ } } } nextindex: ilist = &ilistelem->cdr; } return -1; } /** Return index type by index id * * returns: * -1 if no index found * type >= 0 if index found */ gint wg_get_index_type(void *db, gint index_id) { wg_index_header *hdr = NULL; gint *ilist; gcell *ilistelem; db_memsegment_header* dbh = dbmemsegh(db); /* Locate the header */ ilist = &dbh->index_control_area_header.index_list; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car == index_id) { hdr = (wg_index_header *) offsettoptr(db, index_id); break; } ilist = &ilistelem->cdr; } if(!hdr) { show_index_error_nr(db, "Invalid index_id", index_id); return -1; } return hdr->type; } /** Return index template by index id * * Returns a pointer to the gint array used for the index template. * reclen is set to the length of the array. The pointer may not * be freed and it's contents should be accessed read-only. * * If the index is not found or has no template, NULL is returned. * In that case contents of *reclen are unmodified. */ void * wg_get_index_template(void *db, gint index_id, gint *reclen) { #ifdef USE_INDEX_TEMPLATE wg_index_header *hdr = NULL; gint *ilist; gcell *ilistelem; db_memsegment_header* dbh = dbmemsegh(db); wg_index_template *tmpl = NULL; void *matchrec; /* Locate the header */ ilist = &dbh->index_control_area_header.index_list; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car == index_id) { hdr = (wg_index_header *) offsettoptr(db, index_id); break; } ilist = &ilistelem->cdr; } if(!hdr) { show_index_error_nr(db, "Invalid index_id", index_id); return NULL; } if(!hdr->template_offset) { return NULL; } tmpl = (wg_index_template *) offsettoptr(db, hdr->template_offset); #ifdef CHECK if(!tmpl->offset_matchrec) { show_index_error(db, "Invalid match record template"); return NULL; } #endif matchrec = offsettoptr(db, tmpl->offset_matchrec); *reclen = wg_get_record_len(db, matchrec); return wg_get_record_dataarray(db, matchrec); #else return NULL; #endif } /** Return all indexes in database. * * Returns a pointer to a NEW allocated array of index id-s. * count is initialized to the number of indexes in the array. * * Returns NULL if there are no indexes. */ void * wg_get_all_indexes(void *db, gint *count) { int column; db_memsegment_header* dbh = dbmemsegh(db); gint *ilist; gint *res; *count = 0; if(!dbh->index_control_area_header.number_of_indexes) { return NULL; } res = (gint *) malloc(dbh->index_control_area_header.number_of_indexes *\ sizeof(gint)); if(!res) { show_index_error(db, "Memory allocation failed"); return NULL; } for(column=0; column<=MAX_INDEXED_FIELDNR; column++) { ilist = &dbh->index_control_area_header.index_table[column]; while(*ilist) { gcell *ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { res[(*count)++] = ilistelem->car; } ilist = &ilistelem->cdr; } } if(*count != dbh->index_control_area_header.number_of_indexes) { show_index_error(db, "Index control area is corrupted"); free(res); return NULL; } return res; } #define INDEX_ADD_ROW(d, h, i, r) \ switch(h->type) { \ case WG_INDEX_TYPE_TTREE: \ if(ttree_add_row(d, i, r)) \ return -2; \ break; \ case WG_INDEX_TYPE_TTREE_JSON: \ if(is_plain_record(r)) { \ if(ttree_add_row(d, i, r)) \ return -2; \ } \ break; \ case WG_INDEX_TYPE_HASH: \ if(hash_add_row(d, i, r)) \ return -2; \ break; \ case WG_INDEX_TYPE_HASH_JSON: \ if(is_plain_record(r)) { \ if(hash_add_row(d, i, r)) \ return -2; \ } \ break; \ default: \ show_index_error(db, "unknown index type, ignoring"); \ break; \ } #define INDEX_REMOVE_ROW(d, h, i, r) \ switch(h->type) { \ case WG_INDEX_TYPE_TTREE: \ if(ttree_remove_row(d, i, r) < -2) \ return -2; \ break; \ case WG_INDEX_TYPE_TTREE_JSON: \ if(is_plain_record(r)) { \ if(ttree_remove_row(d, i, r) < -2) \ return -2; \ } \ break; \ case WG_INDEX_TYPE_HASH: \ if(hash_remove_row(d, i, r) < -2) \ return -2; \ break; \ case WG_INDEX_TYPE_HASH_JSON: \ if(is_plain_record(r)) { \ if(hash_remove_row(d, i, r) < -2) \ return -2; \ } \ break; \ default: \ show_index_error(db, "unknown index type, ignoring"); \ break; \ } /** Add data of one field to all indexes * Loops over indexes in one field and inserts the data into * each one of them. * returns 0 for success * returns -1 for invalid arguments * returns -2 for error (insert failed, index is no longer consistent) */ gint wg_index_add_field(void *db, void *rec, gint column) { gint *ilist; gcell *ilistelem; db_memsegment_header* dbh = dbmemsegh(db); gint reclen = wg_get_record_len(db, rec); #ifdef CHECK /* XXX: if used from wg_set_field() only, this is redundant */ if(column > MAX_INDEXED_FIELDNR || column >= reclen) return -1; if(is_special_record(rec)) return -1; #endif #if 0 /* XXX: if used from wg_set_field() only, this is redundant */ if(!dbh->index_control_area_header.index_table[column]) return -1; #endif ilist = &dbh->index_control_area_header.index_table[column]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); if(reclen > hdr->rec_field_index[hdr->fields - 1]) { if(MATCH_TEMPLATE(db, hdr, rec)) { INDEX_ADD_ROW(db, hdr, ilistelem->car, rec) } } } ilist = &ilistelem->cdr; } #ifdef USE_INDEX_TEMPLATE /* Other candidates are indexes that have match * records. The current record may have become compatible * with their template. */ ilist = &dbh->index_control_area_header.index_template_table[column]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); if(reclen > hdr->rec_field_index[hdr->fields - 1]) { if(MATCH_TEMPLATE(db, hdr, rec)) { INDEX_ADD_ROW(db, hdr, ilistelem->car, rec) } } } ilist = &ilistelem->cdr; } #endif return 0; } /** Add data of one record to all indexes * Convinience function to add an entire record into * all indexes in the database. * returns 0 on success, -2 on error * (-1 is skipped to have consistent error codes for add/del functions) */ gint wg_index_add_rec(void *db, void *rec) { gint i; db_memsegment_header* dbh = dbmemsegh(db); gint reclen = wg_get_record_len(db, rec); #ifdef CHECK if(is_special_record(rec)) return -1; #endif if(reclen > MAX_INDEXED_FIELDNR) reclen = MAX_INDEXED_FIELDNR + 1; for(i=0;iindex_control_area_header.index_table[i]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); if(hdr->rec_field_index[hdr->fields - 1] == i) { /* Only add the record if we're at the last column * of the index. This way we ensure that a.) a record * is entered once into a multi-column index and b.) the * record is long enough so that it qualifies for the * multi-column index. * For a single-column index, the indexed column is * also the last column, therefore the above is valid, * altough the check is unnecessary. */ if(MATCH_TEMPLATE(db, hdr, rec)) { INDEX_ADD_ROW(db, hdr, ilistelem->car, rec) } } } ilist = &ilistelem->cdr; } #ifdef USE_INDEX_TEMPLATE ilist = &dbh->index_control_area_header.index_template_table[i]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); wg_index_template *tmpl = \ (wg_index_template *) offsettoptr(db, hdr->template_offset); void *matchrec; gint mreclen; int j, firstmatch = -1; /* Here the check for a match is slightly more complicated. * If there is a match *but* the current column is not the * first fixed one in the template, the match has * already occurred earlier. */ matchrec = offsettoptr(db, tmpl->offset_matchrec); mreclen = wg_get_record_len(db, matchrec); if(mreclen > reclen) { goto nexttmpl1; } for(j=0; j hdr->rec_field_index[hdr->fields - 1]) { /* The record matches AND this is the first time we * see this index. Update it. */ INDEX_ADD_ROW(db, hdr, ilistelem->car, rec) } } nexttmpl1: ilist = &ilistelem->cdr; } #endif } return 0; } /** Delete data of one field from all indexes * Loops over indexes in one column and removes the references * to the record from all of them. * returns 0 for success * returns -1 for invalid arguments * returns -2 for error (delete failed, possible index corruption) */ gint wg_index_del_field(void *db, void *rec, gint column) { gint *ilist; gcell *ilistelem; db_memsegment_header* dbh = dbmemsegh(db); gint reclen = wg_get_record_len(db, rec); #ifdef CHECK /* XXX: if used from wg_set_field() only, this is redundant */ if(column > MAX_INDEXED_FIELDNR || column >= reclen) return -1; if(is_special_record(rec)) return -1; #endif #if 0 /* XXX: if used from wg_set_field() only, this is redundant */ if(!dbh->index_control_area_header.index_table[column]) return -1; #endif /* Find all indexes on the column */ ilist = &dbh->index_control_area_header.index_table[column]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); if(reclen > hdr->rec_field_index[hdr->fields - 1]) { if(MATCH_TEMPLATE(db, hdr, rec)) { INDEX_REMOVE_ROW(db, hdr, ilistelem->car, rec) } } } ilist = &ilistelem->cdr; } #ifdef USE_INDEX_TEMPLATE /* Find all indexes on the column */ ilist = &dbh->index_control_area_header.index_template_table[column]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); if(reclen > hdr->rec_field_index[hdr->fields - 1]) { if(MATCH_TEMPLATE(db, hdr, rec)) { INDEX_REMOVE_ROW(db, hdr, ilistelem->car, rec) } } } ilist = &ilistelem->cdr; } #endif return 0; } /* Delete data of one record from all indexes * Should be called from wg_delete_record() * returns 0 for success * returns -2 for error (delete failed, index presumably corrupt) */ gint wg_index_del_rec(void *db, void *rec) { gint i; db_memsegment_header* dbh = dbmemsegh(db); gint reclen = wg_get_record_len(db, rec); #ifdef CHECK if(is_special_record(rec)) return -1; #endif if(reclen > MAX_INDEXED_FIELDNR) reclen = MAX_INDEXED_FIELDNR + 1; for(i=0;iindex_control_area_header.index_table[i]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); if(hdr->rec_field_index[hdr->fields - 1] == i) { /* Only update once per index. See also comment for * wg_index_add_rec function. */ if(MATCH_TEMPLATE(db, hdr, rec)) { INDEX_REMOVE_ROW(db, hdr, ilistelem->car, rec) } } } ilist = &ilistelem->cdr; } #ifdef USE_INDEX_TEMPLATE ilist = &dbh->index_control_area_header.index_template_table[i]; while(*ilist) { ilistelem = (gcell *) offsettoptr(db, *ilist); if(ilistelem->car) { wg_index_header *hdr = \ (wg_index_header *) offsettoptr(db, ilistelem->car); wg_index_template *tmpl = \ (wg_index_template *) offsettoptr(db, hdr->template_offset); void *matchrec; gint mreclen; int j, firstmatch = -1; /* Similar check as in wg_index_add_rec() */ matchrec = offsettoptr(db, tmpl->offset_matchrec); mreclen = wg_get_record_len(db, matchrec); if(mreclen > reclen) { goto nexttmpl2; /* no match */ } for(j=0; j hdr->rec_field_index[hdr->fields - 1]) { /* The record matches AND this is the first time we * see this index. Update it. */ INDEX_REMOVE_ROW(db, hdr, ilistelem->car, rec) } } nexttmpl2: ilist = &ilistelem->cdr; } #endif } return 0; } /* --------------- error handling ------------------------------*/ /** called with err msg * * may print or log an error * does not do any jumps etc */ static gint show_index_error(void* db, char* errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"index error: %s\n",errmsg); #endif return -1; } /** called with err msg and additional int data * * may print or log an error * does not do any jumps etc */ static gint show_index_error_nr(void* db, char* errmsg, gint nr) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"index error: %s %d\n", errmsg, (int) nr); #endif return -1; } #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dbquery.h0000644000175000001440000001227412414767446012262 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2010,2011,2013 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbcompare.h * Public headers for WhiteDB query engine. */ #ifndef DEFINED_DBQUERY_H #define DEFINED_DBQUERY_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dbdata.h" #include "dbindex.h" /* ==== Public macros ==== */ #define WG_COND_EQUAL 0x0001 /** = */ #define WG_COND_NOT_EQUAL 0x0002 /** != */ #define WG_COND_LESSTHAN 0x0004 /** < */ #define WG_COND_GREATER 0x0008 /** > */ #define WG_COND_LTEQUAL 0x0010 /** <= */ #define WG_COND_GTEQUAL 0x0020 /** >= */ #define WG_QTYPE_TTREE 0x01 #define WG_QTYPE_HASH 0x02 #define WG_QTYPE_SCAN 0x04 #define WG_QTYPE_PREFETCH 0x80 /* ====== data structures ======== */ /** Query argument list object */ typedef struct { gint column; /** column (field) number this argument applies to */ gint cond; /** condition (equal, less than, etc) */ gint value; /** encoded value */ } wg_query_arg; typedef struct { gint key; /** encoded key */ gint value; /** encoded value */ } wg_json_query_arg; /** Query object */ typedef struct { gint qtype; /** Query type (T-tree, hash, full scan, prefetch) */ /* Argument list based query is the only one supported at the moment. */ wg_query_arg *arglist; /** check each row in result set against these */ gint argc; /** number of elements in arglist */ gint column; /** index on this column used */ /* Fields for T-tree query (XXX: some may be re-usable for * other types as well) */ gint curr_offset; gint end_offset; gint curr_slot; gint end_slot; gint direction; /* Fields for full scan */ gint curr_record; /** offset of the current record */ /* Fields for prefetch */ void *mpool; /** storage for row offsets */ void *curr_page; /** current page of results */ gint curr_pidx; /** current index on page */ wg_uint res_count; /** number of rows in results */ } wg_query; /* ==== Protos ==== */ wg_query *wg_make_query(void *db, void *matchrec, gint reclen, wg_query_arg *arglist, gint argc); #define wg_make_prefetch_query wg_make_query wg_query *wg_make_query_rc(void *db, void *matchrec, gint reclen, wg_query_arg *arglist, gint argc, wg_uint rowlimit); wg_query *wg_make_json_query(void *db, wg_json_query_arg *arglist, gint argc); void *wg_fetch(void *db, wg_query *query); void wg_free_query(void *db, wg_query *query); gint wg_encode_query_param_null(void *db, char *data); gint wg_encode_query_param_record(void *db, void *data); gint wg_encode_query_param_char(void *db, char data); gint wg_encode_query_param_fixpoint(void *db, double data); gint wg_encode_query_param_date(void *db, int data); gint wg_encode_query_param_time(void *db, int data); gint wg_encode_query_param_var(void *db, gint data); gint wg_encode_query_param_int(void *db, gint data); gint wg_encode_query_param_double(void *db, double data); gint wg_encode_query_param_str(void *db, char *data, char *lang); gint wg_encode_query_param_xmlliteral(void *db, char *data, char *xsdtype); gint wg_encode_query_param_uri(void *db, char *data, char *prefix); gint wg_free_query_param(void* db, gint data); void *wg_find_record(void *db, gint fieldnr, gint cond, gint data, void* lastrecord); void *wg_find_record_null(void *db, gint fieldnr, gint cond, char *data, void* lastrecord); void *wg_find_record_record(void *db, gint fieldnr, gint cond, void *data, void* lastrecord); void *wg_find_record_char(void *db, gint fieldnr, gint cond, char data, void* lastrecord); void *wg_find_record_fixpoint(void *db, gint fieldnr, gint cond, double data, void* lastrecord); void *wg_find_record_date(void *db, gint fieldnr, gint cond, int data, void* lastrecord); void *wg_find_record_time(void *db, gint fieldnr, gint cond, int data, void* lastrecord); void *wg_find_record_var(void *db, gint fieldnr, gint cond, gint data, void* lastrecord); void *wg_find_record_int(void *db, gint fieldnr, gint cond, int data, void* lastrecord); void *wg_find_record_double(void *db, gint fieldnr, gint cond, double data, void* lastrecord); void *wg_find_record_str(void *db, gint fieldnr, gint cond, char *data, void* lastrecord); void *wg_find_record_xmlliteral(void *db, gint fieldnr, gint cond, char *data, char *xsdtype, void* lastrecord); void *wg_find_record_uri(void *db, gint fieldnr, gint cond, char *data, char *prefix, void* lastrecord); #endif /* DEFINED_DBQUERY_H */ whitedb-0.7.3/Db/dballoc.c0000644000175000001440000014757112421471034012172 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2013 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dballoc.c * Database initialisation and common allocation/deallocation procedures: * areas, subareas, objects, strings etc. * */ /* ====== Includes =============== */ #include #include #include #include #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" #include "dbfeatures.h" #include "dblock.h" #include "dbindex.h" /* don't output 'segment does not have enough space' messages */ #define SUPPRESS_LOWLEVEL_ERR 1 /* ====== Private headers and defs ======== */ /* ======= Private protos ================ */ static gint init_db_subarea(void* db, void* area_header, gint index, gint size); static gint alloc_db_segmentchunk(void* db, gint size); // allocates a next chunk from db memory segment static gint init_syn_vars(void* db); static gint init_extdb(void* db); static gint init_db_index_area_header(void* db); static gint init_logging(void* db); static gint init_strhash_area(void* db, db_hash_area_header* areah); static gint init_hash_subarea(void* db, db_hash_area_header* areah, gint arraylength); static gint init_db_recptr_bitmap(void* db); #ifdef USE_REASONER static gint init_anonconst_table(void* db); static gint intern_anonconst(void* db, char* str, gint enr); #endif static gint make_subarea_freelist(void* db, void* area_header, gint arrayindex); static gint init_area_buckets(void* db, void* area_header); static gint init_subarea_freespace(void* db, void* area_header, gint arrayindex); static gint extend_fixedlen_area(void* db, void* area_header); static gint split_free(void* db, void* area_header, gint nr, gint* freebuckets, gint i); static gint extend_varlen_area(void* db, void* area_header, gint minbytes); static gint show_dballoc_error_nr(void* db, char* errmsg, gint nr); static gint show_dballoc_error(void* db, char* errmsg); /* ====== Functions ============== */ /* -------- segment header initialisation ---------- */ /** starts and completes memsegment initialisation * * should be called after new memsegment is allocated */ gint wg_init_db_memsegment(void* db, gint key, gint size) { db_memsegment_header* dbh = dbmemsegh(db); gint tmp; gint free; gint i; // set main global values for db dbh->mark=(gint32) MEMSEGMENT_MAGIC_INIT; dbh->version=(gint32) MEMSEGMENT_VERSION; dbh->features=(gint32) MEMSEGMENT_FEATURES; dbh->checksum=0; dbh->size=size; dbh->initialadr=(gint)dbh; /* XXX: this assumes pointer size. Currently harmless * because initialadr isn't used much. */ dbh->key=key; /* might be 0 if local memory used */ #ifdef CHECK if(((gint) dbh)%SUBAREA_ALIGNMENT_BYTES) show_dballoc_error(dbh,"db base pointer has bad alignment (ignoring)"); #endif // set correct alignment for free free=sizeof(db_memsegment_header); // set correct alignment for free i=SUBAREA_ALIGNMENT_BYTES-(free%SUBAREA_ALIGNMENT_BYTES); if (i==SUBAREA_ALIGNMENT_BYTES) i=0; dbh->free=free+i; // allocate and initialise subareas //datarec tmp=init_db_subarea(db,&(dbh->datarec_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create datarec area"); return -1; } (dbh->datarec_area_header).fixedlength=0; tmp=init_area_buckets(db,&(dbh->datarec_area_header)); // fill buckets with 0-s if (tmp) { show_dballoc_error(db," cannot initialize datarec area buckets"); return -1; } tmp=init_subarea_freespace(db,&(dbh->datarec_area_header),0); // mark and store free space in subarea 0 if (tmp) { show_dballoc_error(db," cannot initialize datarec subarea 0"); return -1; } //longstr tmp=init_db_subarea(db,&(dbh->longstr_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create longstr area"); return -1; } (dbh->longstr_area_header).fixedlength=0; tmp=init_area_buckets(db,&(dbh->longstr_area_header)); // fill buckets with 0-s if (tmp) { show_dballoc_error(db," cannot initialize longstr area buckets"); return -1; } tmp=init_subarea_freespace(db,&(dbh->longstr_area_header),0); // mark and store free space in subarea 0 if (tmp) { show_dballoc_error(db," cannot initialize longstr subarea 0"); return -1; } //listcell tmp=init_db_subarea(db,&(dbh->listcell_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create listcell area"); return -1; } (dbh->listcell_area_header).fixedlength=1; (dbh->listcell_area_header).objlength=sizeof(gcell); tmp=make_subarea_freelist(db,&(dbh->listcell_area_header),0); // freelist into subarray 0 if (tmp) { show_dballoc_error(db," cannot initialize listcell area"); return -1; } //shortstr tmp=init_db_subarea(db,&(dbh->shortstr_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create short string area"); return -1; } (dbh->shortstr_area_header).fixedlength=1; (dbh->shortstr_area_header).objlength=SHORTSTR_SIZE; tmp=make_subarea_freelist(db,&(dbh->shortstr_area_header),0); // freelist into subarray 0 if (tmp) { show_dballoc_error(db," cannot initialize shortstr area"); return -1; } //word tmp=init_db_subarea(db,&(dbh->word_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create word area"); return -1; } (dbh->word_area_header).fixedlength=1; (dbh->word_area_header).objlength=sizeof(gint); tmp=make_subarea_freelist(db,&(dbh->word_area_header),0); // freelist into subarray 0 if (tmp) { show_dballoc_error(db," cannot initialize word area"); return -1; } //doubleword tmp=init_db_subarea(db,&(dbh->doubleword_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create doubleword area"); return -1; } (dbh->doubleword_area_header).fixedlength=1; (dbh->doubleword_area_header).objlength=2*sizeof(gint); tmp=make_subarea_freelist(db,&(dbh->doubleword_area_header),0); // freelist into subarray 0 if (tmp) { show_dballoc_error(db," cannot initialize doubleword area"); return -1; } /* index structures also user fixlen object storage: * tnode area - contains index nodes * index header area - contains index headers * index template area - contains template headers * index hash area - varlen storage for hash buckets * index lookup data takes up relatively little space so we allocate * the smallest chunk allowed for the headers. */ tmp=init_db_subarea(db,&(dbh->tnode_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create tnode area"); return -1; } (dbh->tnode_area_header).fixedlength=1; (dbh->tnode_area_header).objlength=sizeof(struct wg_tnode); tmp=make_subarea_freelist(db,&(dbh->tnode_area_header),0); if (tmp) { show_dballoc_error(db," cannot initialize tnode area"); return -1; } tmp=init_db_subarea(db,&(dbh->indexhdr_area_header),0,MINIMAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create index header area"); return -1; } (dbh->indexhdr_area_header).fixedlength=1; (dbh->indexhdr_area_header).objlength=sizeof(wg_index_header); tmp=make_subarea_freelist(db,&(dbh->indexhdr_area_header),0); if (tmp) { show_dballoc_error(db," cannot initialize index header area"); return -1; } #ifdef USE_INDEX_TEMPLATE tmp=init_db_subarea(db,&(dbh->indextmpl_area_header),0,MINIMAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create index header area"); return -1; } (dbh->indextmpl_area_header).fixedlength=1; (dbh->indextmpl_area_header).objlength=sizeof(wg_index_template); tmp=make_subarea_freelist(db,&(dbh->indextmpl_area_header),0); if (tmp) { show_dballoc_error(db," cannot initialize index header area"); return -1; } #endif tmp=init_db_subarea(db,&(dbh->indexhash_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create indexhash area"); return -1; } (dbh->indexhash_area_header).fixedlength=0; tmp=init_area_buckets(db,&(dbh->indexhash_area_header)); // fill buckets with 0-s if (tmp) { show_dballoc_error(db," cannot initialize indexhash area buckets"); return -1; } tmp=init_subarea_freespace(db,&(dbh->indexhash_area_header),0); if (tmp) { show_dballoc_error(db," cannot initialize indexhash subarea 0"); return -1; } /* initialize other structures */ /* initialize strhash array area */ tmp=init_strhash_area(db,&(dbh->strhash_area_header)); if (tmp) { show_dballoc_error(db," cannot create strhash array area"); return -1; } /* initialize synchronization */ tmp=init_syn_vars(db); if (tmp) { show_dballoc_error(db," cannot initialize synchronization area"); return -1; } /* initialize external database register */ tmp=init_extdb(db); if (tmp) { show_dballoc_error(db," cannot initialize external db register"); return -1; } /* initialize index structures */ tmp=init_db_index_area_header(db); if (tmp) { show_dballoc_error(db," cannot initialize index header area"); return -1; } /* initialize bitmap for record pointers: really allocated only if USE_RECPTR_BITMAP defined */ tmp=init_db_recptr_bitmap(db); if (tmp) { show_dballoc_error(db," cannot initialize record pointer bitmap"); return -1; } #ifdef USE_REASONER /* initialize anonconst table */ tmp=init_anonconst_table(db); if (tmp) { show_dballoc_error(db," cannot initialize anonconst table"); return -1; } #endif /* initialize logging structures */ tmp=init_logging(db); /* tmp=init_db_subarea(db,&(dbh->logging_area_header),0,INITIAL_SUBAREA_SIZE); if (tmp) { show_dballoc_error(db," cannot create logging area"); return -1; } (dbh->logging_area_header).fixedlength=0; tmp=init_area_buckets(db,&(dbh->logging_area_header)); // fill buckets with 0-s if (tmp) { show_dballoc_error(db," cannot initialize logging area buckets"); return -1; }*/ /* Database is initialized, mark it as valid */ dbh->mark=(gint32) MEMSEGMENT_MAGIC_MARK; return 0; } /** initializes a subarea. subarea is used for actual data obs allocation * * returns 0 if ok, negative otherwise; * * called - several times - first by wg_init_db_memsegment, then as old subareas * get filled up */ static gint init_db_subarea(void* db, void* area_header, gint index, gint size) { db_area_header* areah; gint segmentchunk; gint i; gint asize; //printf("init_db_subarea called with size %d \n",size); if (sizesubarea_array)[index]).size=size; ((areah->subarea_array)[index]).offset=segmentchunk; // set correct alignment for alignedoffset i=SUBAREA_ALIGNMENT_BYTES-(segmentchunk%SUBAREA_ALIGNMENT_BYTES); if (i==SUBAREA_ALIGNMENT_BYTES) i=0; ((areah->subarea_array)[index]).alignedoffset=segmentchunk+i; // set correct alignment for alignedsize asize=(size-i); i=asize-(asize%MIN_VARLENOBJ_SIZE); ((areah->subarea_array)[index]).alignedsize=i; // set last index and freelist areah->last_subarea_index=index; areah->freelist=0; return 0; } /** allocates a new segment chunk from the segment * * returns offset if successful, 0 if no more space available * if 0 returned, no allocation performed: can try with a smaller value * used for allocating all subareas * * Alignment is guaranteed to SUBAREA_ALIGNMENT_BYTES */ static gint alloc_db_segmentchunk(void* db, gint size) { db_memsegment_header* dbh = dbmemsegh(db); gint lastfree; gint nextfree; gint i; lastfree=dbh->free; nextfree=lastfree+size; if (nextfree<0) { show_dballoc_error_nr(db,"trying to allocate next segment exceeds positive int limit",size); return 0; } // set correct alignment for nextfree i=SUBAREA_ALIGNMENT_BYTES-(nextfree%SUBAREA_ALIGNMENT_BYTES); if (i==SUBAREA_ALIGNMENT_BYTES) i=0; nextfree=nextfree+i; if (nextfree>=(dbh->size)) { #ifndef SUPPRESS_LOWLEVEL_ERR show_dballoc_error_nr(db,"segment does not have enough space for the required chunk of size",size); #endif return 0; } dbh->free=nextfree; return lastfree; } /** initializes sync variable storage * * returns 0 if ok, negative otherwise; * Note that a basic spinlock area is initialized even if locking * is disabled, this is done for better memory image compatibility. */ static gint init_syn_vars(void* db) { db_memsegment_header* dbh = dbmemsegh(db); gint i; #if !defined(LOCK_PROTO) || (LOCK_PROTO < 3) /* rpspin, wpspin */ /* calculate aligned pointer */ i = ((gint) (dbh->locks._storage) + SYN_VAR_PADDING - 1) & -SYN_VAR_PADDING; dbh->locks.global_lock = dbaddr(db, (void *) i); dbh->locks.writers = dbaddr(db, (void *) (i + SYN_VAR_PADDING)); #else i = alloc_db_segmentchunk(db, SYN_VAR_PADDING * (MAX_LOCKS+2)); if(!i) return -1; /* re-align (SYN_VAR_PADDING <> SUBAREA_ALIGNMENT_BYTES) */ i = (i + SYN_VAR_PADDING - 1) & -SYN_VAR_PADDING; dbh->locks.queue_lock = i; dbh->locks.storage = i + SYN_VAR_PADDING; dbh->locks.max_nodes = MAX_LOCKS; dbh->locks.freelist = dbh->locks.storage; /* dummy, wg_init_locks() will overwrite this */ #endif /* allocating space was successful, set the initial state */ return wg_init_locks(db); } /** initializes external database register * * returns 0 if ok, negative otherwise; */ static gint init_extdb(void* db) { db_memsegment_header* dbh = dbmemsegh(db); int i; dbh->extdbs.count = 0; for(i=0; iextdbs.offset[i] = 0; dbh->extdbs.size[i] = 0; } return 0; } /** initializes main index area * Currently this function only sets up an empty index table. The rest * of the index storage is initialized by wg_init_db_memsegment(). * returns 0 if ok */ static gint init_db_index_area_header(void* db) { db_memsegment_header* dbh = dbmemsegh(db); dbh->index_control_area_header.number_of_indexes=0; memset(dbh->index_control_area_header.index_table, 0, (MAX_INDEXED_FIELDNR+1)*sizeof(gint)); dbh->index_control_area_header.index_list=0; #ifdef USE_INDEX_TEMPLATE dbh->index_control_area_header.index_template_list=0; memset(dbh->index_control_area_header.index_template_table, 0, (MAX_INDEXED_FIELDNR+1)*sizeof(gint)); #endif return 0; } /** initializes logging area * */ static gint init_logging(void* db) { db_memsegment_header* dbh = dbmemsegh(db); dbh->logging.active = 0; dbh->logging.dirty = 0; dbh->logging.serial = 1; /* non-zero, so that zero value in db handle * indicates uninitialized state. */ return 0; } /** initializes strhash area * */ static gint init_strhash_area(void* db, db_hash_area_header* areah) { db_memsegment_header* dbh = dbmemsegh(db); gint arraylength; if(STRHASH_SIZE > 0.01 && STRHASH_SIZE < 50) { arraylength = (gint) ((dbh->size+1) * (STRHASH_SIZE/100.0)) / sizeof(gint); } else { arraylength = DEFAULT_STRHASH_LENGTH; } return init_hash_subarea(db, areah, arraylength); } /** initializes hash area * */ static gint init_hash_subarea(void* db, db_hash_area_header* areah, gint arraylength) { gint segmentchunk; gint i; gint asize; gint j; //printf("init_hash_subarea called with arraylength %d \n",arraylength); asize=((arraylength+1)*sizeof(gint))+(2*SUBAREA_ALIGNMENT_BYTES); // 2* just to be safe //printf("asize: %d \n",asize); //if (asize<100) return -1; // errcase to filter out stupid requests segmentchunk=alloc_db_segmentchunk(db,asize); //printf("segmentchunk: %d \n",segmentchunk); if (!segmentchunk) return -2; // errcase areah->offset=segmentchunk; areah->size=asize; areah->arraylength=arraylength; // set correct alignment for arraystart i=SUBAREA_ALIGNMENT_BYTES-(segmentchunk%SUBAREA_ALIGNMENT_BYTES); if (i==SUBAREA_ALIGNMENT_BYTES) i=0; areah->arraystart=segmentchunk+i; i=areah->arraystart; for(j=0;jsize)/64)+16; segmentchunk=alloc_db_segmentchunk(db,asize); if (!segmentchunk) return -2; // errcase dbh->recptr_bitmap.offset=segmentchunk; dbh->recptr_bitmap.size=asize; memset(offsettoptr(db,segmentchunk),0,asize); return 0; #else dbh->recptr_bitmap.offset=0; dbh->recptr_bitmap.size=0; return 0; #endif } #ifdef USE_REASONER /** initializes anonymous constants (special uris with attached funs) * */ static gint init_anonconst_table(void* db) { int i; db_memsegment_header* dbh = dbmemsegh(db); dbh->anonconst.anonconst_nr=0; dbh->anonconst.anonconst_funs=0; // clearing is not really necessary for(i=0;ianonconst.anonconst_table)[i]=0; } if (intern_anonconst(db,ACONST_TRUE_STR,ACONST_TRUE)) return 1; if (intern_anonconst(db,ACONST_FALSE_STR,ACONST_FALSE)) return 1; if (intern_anonconst(db,ACONST_IF_STR,ACONST_IF)) return 1; if (intern_anonconst(db,ACONST_NOT_STR,ACONST_NOT)) return 1; if (intern_anonconst(db,ACONST_AND_STR,ACONST_AND)) return 1; if (intern_anonconst(db,ACONST_OR_STR,ACONST_OR)) return 1; if (intern_anonconst(db,ACONST_IMPLIES_STR,ACONST_IMPLIES)) return 1; if (intern_anonconst(db,ACONST_XOR_STR,ACONST_XOR)) return 1; if (intern_anonconst(db,ACONST_LESS_STR,ACONST_LESS)) return 1; if (intern_anonconst(db,ACONST_EQUAL_STR,ACONST_EQUAL)) return 1; if (intern_anonconst(db,ACONST_GREATER_STR,ACONST_GREATER)) return 1; if (intern_anonconst(db,ACONST_LESSOREQUAL_STR,ACONST_LESSOREQUAL)) return 1; if (intern_anonconst(db,ACONST_GREATEROREQUAL_STR,ACONST_GREATEROREQUAL)) return 1; if (intern_anonconst(db,ACONST_ISZERO_STR,ACONST_ISZERO)) return 1; if (intern_anonconst(db,ACONST_ISEMPTYSTR_STR,ACONST_ISEMPTYSTR)) return 1; if (intern_anonconst(db,ACONST_PLUS_STR,ACONST_PLUS)) return 1; if (intern_anonconst(db,ACONST_MINUS_STR,ACONST_MINUS)) return 1; if (intern_anonconst(db,ACONST_MULTIPLY_STR,ACONST_MULTIPLY)) return 1; if (intern_anonconst(db,ACONST_DIVIDE_STR,ACONST_DIVIDE)) return 1; if (intern_anonconst(db,ACONST_STRCONTAINS_STR,ACONST_STRCONTAINS)) return 1; if (intern_anonconst(db,ACONST_STRCONTAINSICASE_STR,ACONST_STRCONTAINSICASE)) return 1; if (intern_anonconst(db,ACONST_SUBSTR_STR,ACONST_SUBSTR)) return 1; if (intern_anonconst(db,ACONST_STRLEN_STR,ACONST_STRLEN)) return 1; ++(dbh->anonconst.anonconst_nr); // max used slot + 1 dbh->anonconst.anonconst_funs=dbh->anonconst.anonconst_nr; return 0; } /** internalizes new anonymous constants: used in init * */ static gint intern_anonconst(void* db, char* str, gint enr) { db_memsegment_header* dbh = dbmemsegh(db); gint nr; gint uri; nr=decode_anonconst(enr); if (nr<0 || nr>=ANONCONST_TABLE_SIZE) { show_dballoc_error_nr(db,"inside intern_anonconst: nr given out of range: ", nr); return 1; } uri=wg_encode_unistr(db,str,NULL,WG_URITYPE); if (uri==WG_ILLEGAL) { show_dballoc_error_nr(db,"inside intern_anonconst: cannot create an uri of size ",strlen(str)); return 1; } (dbh->anonconst.anonconst_table)[nr]=uri; if (dbh->anonconst.anonconst_nranonconst.anonconst_nr)=nr; return 0; } #endif /* -------- freelists creation ---------- */ /** create freelist for an area * * used for initialising (sub)areas used for fixed-size allocation * * returns 0 if ok * * speed stats: * * 10000 * creation of 100000 elems (1 000 000 000 or 1G ops) takes 1.2 sec on penryn * 1000 * creation of 1000000 elems (1 000 000 000 or 1G ops) takes 3.4 sec on penryn * */ static gint make_subarea_freelist(void* db, void* area_header, gint arrayindex) { db_area_header* areah; gint objlength; gint max; gint size; gint offset; gint i; // general area info areah=(db_area_header*)area_header; objlength=areah->objlength; //subarea info size=((areah->subarea_array)[arrayindex]).alignedsize; offset=((areah->subarea_array)[arrayindex]).alignedoffset; // create freelist max=(offset+size)-(2*objlength); for(i=offset;i<=max;i=i+objlength) { dbstore(db,i,i+objlength); } dbstore(db,i,0); (areah->freelist)=offset; // //printf("(areah->freelist) %d \n",(areah->freelist)); return 0; } /* -------- buckets creation ---------- */ /** fill bucket data for an area * * used for initialising areas used for variable-size allocation * * returns 0 if ok, not 0 if error * */ gint init_area_buckets(void* db, void* area_header) { db_area_header* areah; gint* freebuckets; gint i; // general area info areah=(db_area_header*)area_header; freebuckets=areah->freebuckets; // empty all buckets for(i=0;ifreebuckets; //subarea info size=((areah->subarea_array)[arrayindex]).alignedsize; offset=((areah->subarea_array)[arrayindex]).alignedoffset; // if the previous area exists, store current victim to freelist if (arrayindex>0) { dv=freebuckets[DVBUCKET]; dvsize=freebuckets[DVSIZEBUCKET]; if (dv!=0 && dvsize>=MIN_VARLENOBJ_SIZE) { dbstore(db,dv,makefreeobjectsize(dvsize)); // store new size with freebit to the second half of object dbstore(db,dv+dvsize-sizeof(gint),makefreeobjectsize(dvsize)); dvindex=wg_freebuckets_index(db,dvsize); freelist=freebuckets[dvindex]; if (freelist!=0) dbstore(db,freelist+2*sizeof(gint),dv); // update prev ptr dbstore(db,dv+sizeof(gint),freelist); // store previous freelist dbstore(db,dv+2*sizeof(gint),dbaddr(db,&freebuckets[dvindex])); // store ptr to previous freebuckets[dvindex]=dv; // store offset to correct bucket //printf("in init_subarea_freespace: \n PUSHED DV WITH SIZE %d TO FREELIST TO BUCKET %d:\n", // dvsize,dvindex); //show_bucket_freeobjects(db,freebuckets[dvindex]); } } // create two minimal in-use objects never to be freed: marking beginning // and end of free area via in-use bits in size // beginning of free area dbstore(db,offset,makespecialusedobjectsize(MIN_VARLENOBJ_SIZE)); // lowest bit 0 means in use dbstore(db,offset+sizeof(gint),SPECIALGINT1START); // next ptr dbstore(db,offset+2*sizeof(gint),0); // prev ptr dbstore(db,offset+MIN_VARLENOBJ_SIZE-sizeof(gint),MIN_VARLENOBJ_SIZE); // len to end as well // end of free area endmarkobj=offset+size-MIN_VARLENOBJ_SIZE; dbstore(db,endmarkobj,makespecialusedobjectsize(MIN_VARLENOBJ_SIZE)); // lowest bit 0 means in use dbstore(db,endmarkobj+sizeof(gint),SPECIALGINT1END); // next ptr dbstore(db,endmarkobj+2*sizeof(gint),0); // prev ptr dbstore(db,endmarkobj+MIN_VARLENOBJ_SIZE-sizeof(gint),MIN_VARLENOBJ_SIZE); // len to end as well // calc where real free area starts and what is the size freeoffset=offset+MIN_VARLENOBJ_SIZE; freesize=size-2*MIN_VARLENOBJ_SIZE; // put whole free area into one free object // store the single free object as a designated victim dbstore(db,freeoffset,makespecialusedobjectsize(freesize)); // length without free bits: victim not marked free dbstore(db,freeoffset+sizeof(gint),SPECIALGINT1DV); // marks that it is a dv kind of special object freebuckets[DVBUCKET]=freeoffset; freebuckets[DVSIZEBUCKET]=freesize; // alternative: store the single free object to correct bucket /* dbstore(db,freeoffset,setcfree(freesize)); // size with free bits stored to beginning of object dbstore(db,freeoffset+sizeof(gint),0); // empty ptr to remaining obs stored after size i=freebuckets_index(db,freesize); if (i<0) { show_dballoc_error_nr(db,"initialising free object failed for ob size ",freesize); return -1; } dbstore(db,freeoffset+2*sizeof(gint),dbaddr(db,&freebuckets[i])); // ptr to previous stored freebuckets[i]=freeoffset; */ return 0; } /* -------- fixed length object allocation and freeing ---------- */ /** allocate a new fixed-len object * * return offset if ok, 0 if allocation fails */ gint wg_alloc_fixlen_object(void* db, void* area_header) { db_area_header* areah; gint freelist; areah=(db_area_header*)area_header; freelist=areah->freelist; if (!freelist) { if(!extend_fixedlen_area(db,areah)) { show_dballoc_error_nr(db,"cannot extend fixed length object area for size ",areah->objlength); return 0; } freelist=areah->freelist; if (!freelist) { show_dballoc_error_nr(db,"no free fixed length objects available for size ",areah->objlength); return 0; } else { areah->freelist=dbfetch(db,freelist); return freelist; } } else { areah->freelist=dbfetch(db,freelist); return freelist; } } /** create and initialise a new subarea for fixed-len obs area * * returns allocated size if ok, 0 if failure * used when the area has no more free space * */ static gint extend_fixedlen_area(void* db, void* area_header) { gint i; gint tmp; gint size, newsize; db_area_header* areah; areah=(db_area_header*)area_header; i=areah->last_subarea_index; if (i+1>=SUBAREA_ARRAY_SIZE) { show_dballoc_error_nr(db, " no more subarea array elements available for fixedlen of size: ",areah->objlength); return 0; // no more subarea array elements available } size=((areah->subarea_array)[i]).size; // last allocated subarea size // make tmp power-of-two times larger newsize=size<<1; //printf("fixlen OLD SUBAREA SIZE WAS %d NEW SUBAREA SIZE SHOULD BE %d\n",size,newsize); while(newsize >= MINIMAL_SUBAREA_SIZE) { if(!init_db_subarea(db,areah,i+1,newsize)) { goto done; } /* fall back to smaller size */ newsize>>=1; //printf("REQUIRED SPACE FAILED, TRYING %d\n",newsize); } show_dballoc_error_nr(db," cannot extend datarec area with a new subarea of size: ",newsize<<1); return 0; done: // here we have successfully allocated a new subarea tmp=make_subarea_freelist(db,areah,i+1); // fill with a freelist, store ptrs if (tmp) { show_dballoc_error(db," cannot initialize new subarea"); return 0; } return newsize; } /** free an existing listcell * * the object is added to the freelist * */ void wg_free_listcell(void* db, gint offset) { dbstore(db,offset,(dbmemsegh(db)->listcell_area_header).freelist); (dbmemsegh(db)->listcell_area_header).freelist=offset; } /** free an existing shortstr object * * the object is added to the freelist * */ void wg_free_shortstr(void* db, gint offset) { dbstore(db,offset,(dbmemsegh(db)->shortstr_area_header).freelist); (dbmemsegh(db)->shortstr_area_header).freelist=offset; } /** free an existing word-len object * * the object is added to the freelist * */ void wg_free_word(void* db, gint offset) { dbstore(db,offset,(dbmemsegh(db)->word_area_header).freelist); (dbmemsegh(db)->word_area_header).freelist=offset; } /** free an existing doubleword object * * the object is added to the freelist * */ void wg_free_doubleword(void* db, gint offset) { dbstore(db,offset,(dbmemsegh(db)->doubleword_area_header).freelist); //bug fixed here (dbmemsegh(db)->doubleword_area_header).freelist=offset; } /** free an existing tnode object * * the object is added to the freelist * */ void wg_free_tnode(void* db, gint offset) { dbstore(db,offset,(dbmemsegh(db)->tnode_area_header).freelist); (dbmemsegh(db)->tnode_area_header).freelist=offset; } /** free generic fixlen object * * the object is added to the freelist * */ void wg_free_fixlen_object(void* db, db_area_header *hdr, gint offset) { dbstore(db,offset,hdr->freelist); hdr->freelist=offset; } /* -------- variable length object allocation and freeing ---------- */ /** allocate a new object of given length * * returns correct offset if ok, 0 in case of error * */ gint wg_alloc_gints(void* db, void* area_header, gint nr) { gint wantedbytes; // actually wanted size in bytes, stored in object header gint usedbytes; // amount of bytes used: either wantedbytes or bytes+4 (obj must be 8 aligned) gint* freebuckets; gint res, nextobject; gint nextel; gint i; gint j; gint tmp; gint size; db_area_header* areah; areah=(db_area_header*)area_header; wantedbytes=nr*sizeof(gint); // object sizes are stored in bytes if (wantedbytes<0) return 0; // cannot allocate negative or zero sizes if (wantedbytes<=MIN_VARLENOBJ_SIZE) usedbytes=MIN_VARLENOBJ_SIZE; /* XXX: modifying the next line breaks encode_query_param_unistr(). * Rewrite this using macros to reduce the chance of accidental breakage */ else if (wantedbytes%8) usedbytes=wantedbytes+4; else usedbytes=wantedbytes; //printf("wg_alloc_gints called with nr %d and wantedbytes %d and usedbytes %d\n",nr,wantedbytes,usedbytes); // first find if suitable length free object is available freebuckets=areah->freebuckets; if (usedbytes=usedbytes+MIN_VARLENOBJ_SIZE) { // found one somewhat larger: now split and store the rest res=freebuckets[i]; tmp=split_free(db,areah,usedbytes,freebuckets,i); if (tmp<0) return 0; // error case // prev elem cannot be free (no consecutive free elems) dbstore(db,res,makeusedobjectsizeprevused(wantedbytes)); // store wanted size to the returned object return res; } } // next try to use the cached designated victim for creating objects off beginning // designated victim is not marked free by header and is not present in any freelist size=freebuckets[DVSIZEBUCKET]; if (usedbytes<=size && freebuckets[DVBUCKET]!=0) { res=freebuckets[DVBUCKET]; if (usedbytes==size) { // found a designated victim of exactly right size, dv is used up and disappears freebuckets[DVBUCKET]=0; freebuckets[DVSIZEBUCKET]=0; // prev elem of dv cannot be free dbstore(db,res,makeusedobjectsizeprevused(wantedbytes)); // store wanted size to the returned object return res; } else if (usedbytes+MIN_VARLENOBJ_SIZE<=size) { // found a designated victim somewhat larger: take the first part and keep the rest as dv dbstore(db,res+usedbytes,makespecialusedobjectsize(size-usedbytes)); // store smaller size to victim, turn off free bits dbstore(db,res+usedbytes+sizeof(gint),SPECIALGINT1DV); // marks that it is a dv kind of special object freebuckets[DVBUCKET]=res+usedbytes; // point to rest of victim freebuckets[DVSIZEBUCKET]=size-usedbytes; // rest of victim becomes shorter // prev elem of dv cannot be free dbstore(db,res,makeusedobjectsizeprevused(wantedbytes)); // store wanted size to the returned object return res; } } // next try to find first free object in exact-length buckets (shorter first) for(i=usedbytes+1;i=usedbytes+MIN_VARLENOBJ_SIZE) { // found one somewhat larger: now split and store the rest res=freebuckets[i]; tmp=split_free(db,areah,usedbytes,freebuckets,i); if (tmp<0) return 0; // error case // prev elem cannot be free (no consecutive free elems) dbstore(db,res,makeusedobjectsizeprevused(wantedbytes)); // store wanted size to the returned object return res; } } // next try to find first free object in var-length buckets (shorter first) for(i=wg_freebuckets_index(db,usedbytes);i=usedbytes+MIN_VARLENOBJ_SIZE) { // found one somewhat larger: now split and store the rest res=freebuckets[i]; //printf("db %d,nr %d,freebuckets %d,i %d\n",db,(int)nr,(int)freebuckets,(int)i); tmp=split_free(db,areah,usedbytes,freebuckets,i); if (tmp<0) return 0; // error case // prev elem cannot be free (no consecutive free elems) dbstore(db,res,makeusedobjectsizeprevused(wantedbytes)); // store wanted size to the returned object return res; } } } // down here we have found no suitable dv or free object to use for allocation // try to get a new memory area //printf("ABOUT TO CREATE A NEW SUBAREA\n"); tmp=extend_varlen_area(db,areah,usedbytes); if (!tmp) { show_dballoc_error(db," cannot initialize new varlen subarea"); return 0; } // here we have successfully allocated a new subarea // call self recursively: this call will use the new free area tmp=wg_alloc_gints(db,areah,nr); //show_db_memsegment_header(db); return tmp; } /** create and initialise a new subarea for var-len obs area * * returns allocated size if ok, 0 if failure * used when the area has no more free space * * bytes indicates the minimal required amount: * could be extended much more, but not less than bytes * */ static gint extend_varlen_area(void* db, void* area_header, gint minbytes) { gint i; gint tmp; gint size, minsize, newsize; db_area_header* areah; areah=(db_area_header*)area_header; i=areah->last_subarea_index; if (i+1>=SUBAREA_ARRAY_SIZE) { show_dballoc_error_nr(db," no more subarea array elements available for datarec: ",i); return 0; // no more subarea array elements available } size=((areah->subarea_array)[i]).size; // last allocated subarea size minsize=minbytes+SUBAREA_ALIGNMENT_BYTES+2*(MIN_VARLENOBJ_SIZE); // minimum allowed #ifdef CHECK if(minsize<0) { /* sanity check */ show_dballoc_error_nr(db, "invalid number of bytes requested: ", minbytes); return 0; } #endif if(minsize=0 && newsize= minsize) { if(!init_db_subarea(db,areah,i+1,newsize)) { goto done; } /* fall back to smaller size */ newsize>>=1; //printf("REQUIRED SPACE FAILED, TRYING %d\n",newsize); } show_dballoc_error_nr(db," cannot extend datarec area with a new subarea of size: ",newsize<<1); return 0; done: // here we have successfully allocated a new subarea tmp=init_subarea_freespace(db,areah,i+1); // mark beg and end, store new victim if (tmp) { show_dballoc_error(db," cannot initialize new subarea"); return 0; } return newsize; } /** splits a free object into a smaller new object and the remainder, stores remainder to right list * * returns 0 if ok, negative nr in case of error * we assume we always split the first elem in a bucket freelist * we also assume the remainder is >=MIN_VARLENOBJ_SIZE * */ static gint split_free(void* db, void* area_header, gint nr, gint* freebuckets, gint i) { gint object; gint oldsize; gint oldnextptr; gint splitsize; gint splitobject; gint splitindex; gint freelist; gint dv; gint dvsize; gint dvindex; object=freebuckets[i]; // object offset oldsize=dbfetch(db,object); // first gint at offset if (!isfreeobject(oldsize)) return -1; // not really a free object! oldsize=getfreeobjectsize(oldsize); // remove free bits, get real size // observe object is first obj in freelist, hence no free obj at prevptr oldnextptr=dbfetch(db,object+sizeof(gint)); // second gint at offset // store new size at offset (beginning of object) and mark as used with used prev // observe that a free object cannot follow another free object, hence we know prev is used dbstore(db,object,makeusedobjectsizeprevused(nr)); freebuckets[i]=oldnextptr; // store ptr to next elem into bucket ptr splitsize=oldsize-nr; // remaining size splitobject=object+nr; // offset of the part left // we may store the splitobject as a designated victim instead of a suitable freelist // but currently this is disallowed and the underlying code is not really finished: // marking of next used object prev-free/prev-used is missing // instead of this code we rely on using a newly freed object as dv is larger than dv dvsize=freebuckets[DVSIZEBUCKET]; if (0) { // (splitsize>dvsize) { // store splitobj as a new designated victim, but first store current victim to freelist, if possible dv=freebuckets[DVBUCKET]; if (dv!=0) { if (dvsizefreebuckets; // first try to merge with the previous free object, if so marked if (isnormalusedobjectprevfree(objecthead)) { //printf("**** about to merge object %d on free with prev %d !\n",object,prevobject); // use the size of the previous (free) object stored at the end of the previous object prevobjectsize=getfreeobjectsize(dbfetch(db,(object-sizeof(gint)))); prevobject=object-prevobjectsize; prevobjecthead=dbfetch(db,prevobject); if (!isfreeobject(prevobjecthead) || !getfreeobjectsize(prevobject)==prevobjectsize) { show_dballoc_error(db,"wg_free_object notices corruption: previous object is not ok free object"); return -4; // corruption noticed } // remove prev object from its freelist // first, get necessary information prevnextptr=dbfetch(db,prevobject+sizeof(gint)); prevprevptr=dbfetch(db,prevobject+2*sizeof(gint)); previndex=wg_freebuckets_index(db,prevobjectsize); freelist=freebuckets[previndex]; // second, really remove prev object from freelist if (freelist==prevobject) { // prev object pointed to directly from bucket freebuckets[previndex]=prevnextptr; // modify prev prev if (prevnextptr!=0) dbstore(db,prevnextptr+2*sizeof(gint),prevprevptr); // modify prev next } else { // prev object pointed to from another object, not directly bucket // next of prev of prev will point to next of next dbstore(db,prevprevptr+sizeof(gint),prevnextptr); // prev of next of prev will prev-point to prev of prev if (prevnextptr!=0) dbstore(db,prevnextptr+2*sizeof(gint),prevprevptr); } // now treat the prev object as the current object to be freed! object=prevobject; size=size+prevobjectsize; } else if ((freebuckets[DVBUCKET]+freebuckets[DVSIZEBUCKET])==object) { // should merge with a previous dv object=freebuckets[DVBUCKET]; size=size+freebuckets[DVSIZEBUCKET]; // increase size to cover dv as well // modify dv size information in area header: dv will extend to freed object freebuckets[DVSIZEBUCKET]=size; // store dv size and marker to dv head dbstore(db,object,makespecialusedobjectsize(size)); dbstore(db,object+sizeof(gint),SPECIALGINT1DV); return 0; // do not store anything to freebuckets!! } // next, try to merge with the next object: either free object or dv // also, if next object is normally used instead, mark it as following the free object nextobject=object+size; nextobjecthead=dbfetch(db,nextobject); if (isfreeobject(nextobjecthead)) { // should merge with a following free object //printf("**** about to merge object %d on free with next %d !\n",object,nextobject); size=size+getfreeobjectsize(nextobjecthead); // increase size to cover next object as well // remove next object from its freelist // first, get necessary information nextnextptr=dbfetch(db,nextobject+sizeof(gint)); nextprevptr=dbfetch(db,nextobject+2*sizeof(gint)); nextindex=wg_freebuckets_index(db,getfreeobjectsize(nextobjecthead)); freelist=freebuckets[nextindex]; // second, really remove next object from freelist if (freelist==nextobject) { // next object pointed to directly from bucket freebuckets[nextindex]=nextnextptr; // modify next prev if (nextnextptr!=0) dbstore(db,nextnextptr+2*sizeof(gint),nextprevptr); // modify next next } else { // next object pointed to from another object, not directly bucket // prev of next will point to next of next dbstore(db,nextprevptr+sizeof(gint),nextnextptr); // next of next will prev-point to prev of next if (nextnextptr!=0) dbstore(db,nextnextptr+2*sizeof(gint),nextprevptr); } } else if (isspecialusedobject(nextobjecthead) && nextobject==freebuckets[DVBUCKET]) { // should merge with a following dv size=size+freebuckets[DVSIZEBUCKET]; // increase size to cover next object as well // modify dv information in area header freebuckets[DVBUCKET]=object; freebuckets[DVSIZEBUCKET]=size; // store dv size and marker to dv head dbstore(db,object,makespecialusedobjectsize(size)); dbstore(db,object+sizeof(gint),SPECIALGINT1DV); return 0; // do not store anything to freebuckets!! } else if (isnormalusedobject(nextobjecthead)) { // mark the next used object as following a free object dbstore(db,nextobject,makeusedobjectsizeprevfree(dbfetch(db,nextobject))); } // we do no special actions in case next object is end marker // maybe the newly freed object is larger than the designated victim? // if yes, use the newly freed object as a new designated victim // and afterwards put the old dv to freelist if (size>freebuckets[DVSIZEBUCKET]) { dv=freebuckets[DVBUCKET]; dvsize=freebuckets[DVSIZEBUCKET]; freebuckets[DVBUCKET]=object; freebuckets[DVSIZEBUCKET]=size; dbstore(db,object,makespecialusedobjectsize(size)); dbstore(db,object+sizeof(gint),SPECIALGINT1DV); // set the next used object mark to prev-used! nextobject=object+size; tmp=dbfetch(db,nextobject); if (isnormalusedobject(tmp)) dbstore(db,nextobject,makeusedobjectsizeprevused(tmp)); // dv handling if (dv==0) return 0; // if no dv actually, then nothing to put to freelist // set the object point to dv to make it put into freelist after // but first mark the next object after dv as following free nextobject=dv+dvsize; tmp=dbfetch(db,nextobject); if (isnormalusedobject(tmp)) dbstore(db,nextobject,makeusedobjectsizeprevfree(tmp)); // let the old dv be handled as object to be put to freelist after object=dv; size=dvsize; } // store freed (or freed and merged) object to the correct bucket, // except for dv-merge cases above (returns earlier) i=wg_freebuckets_index(db,size); bucketfreelist=freebuckets[i]; if (bucketfreelist!=0) dbstore(db,bucketfreelist+2*sizeof(gint),object); // update prev ptr dbstore(db,object,makefreeobjectsize(size)); // store size and freebit dbstore(db,object+size-sizeof(gint),makefreeobjectsize(size)); // store size and freebit dbstore(db,object+sizeof(gint),bucketfreelist); // store previous freelist dbstore(db,object+2*sizeof(gint),dbaddr(db,&freebuckets[i])); // store prev ptr freebuckets[i]=object; return 0; } /* Tanel Tammet http://www.epl.ee/?i=112121212 Kuiv tn 9, Tallinn, Estonia +3725524876 len | refcount | xsd:type | namespace | contents .... | header: 4*4=16 bytes 128 bytes */ /***************** Child database functions ******************/ /* Register external database offset * * Stores offset and size of an external database. This allows * recognizing external pointers/offsets and computing their * base offset. * * Once external data is stored to the database, the memory * image can no longer be saved/restored. */ gint wg_register_external_db(void *db, void *extdb) { #ifdef USE_CHILD_DB db_memsegment_header* dbh = dbmemsegh(db); #ifdef CHECK if(dbh->key != 0) { show_dballoc_error(db, "external references not allowed in a shared memory db"); return -1; } #endif if(dbh->index_control_area_header.number_of_indexes > 0) { return show_dballoc_error(db, "Database has indexes, external references not allowed"); } if(dbh->extdbs.count >= MAX_EXTDB) { show_dballoc_error(db, "cannot register external database"); } else { dbh->extdbs.offset[dbh->extdbs.count] = ptrtooffset(db, dbmemsegh(extdb)); dbh->extdbs.size[dbh->extdbs.count++] = \ dbmemsegh(extdb)->size; } return 0; #else show_dballoc_error(db, "child database support is not enabled"); return -1; #endif } /******************** Hash index support *********************/ /* * Initialize a new hash table for an index. */ gint wg_create_hash(void *db, db_hash_area_header* areah, gint size) { if(size <= 0) size = DEFAULT_IDXHASH_LENGTH; if(init_hash_subarea(db, areah, size)) { return show_dballoc_error(db," cannot create strhash array area"); } return 0; } /********** Helper functions for accessing the header ********/ /* * Return free space in segment (in bytes) * Also tries to predict whether it is possible to allocate more * space in the segment. */ gint wg_database_freesize(void *db) { db_memsegment_header* dbh = dbmemsegh(db); gint freesize = dbh->size - dbh->free; return (freesize < MINIMAL_SUBAREA_SIZE ? 0 : freesize); } /* * Return total segment size (in bytes) */ gint wg_database_size(void *db) { db_memsegment_header* dbh = dbmemsegh(db); return dbh->size; } /* --------------- error handling ------------------------------*/ /** called with err msg when an allocation error occurs * * may print or log an error * does not do any jumps etc */ static gint show_dballoc_error(void* db, char* errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"db memory allocation error: %s\n",errmsg); #endif return -1; } /** called with err msg and err nr when an allocation error occurs * * may print or log an error * does not do any jumps etc */ static gint show_dballoc_error_nr(void* db, char* errmsg, gint nr) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"db memory allocation error: %s %d\n", errmsg, (int) nr); #endif return -1; } #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dbdump.h0000644000175000001440000000257212257043255012050 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Andri Rebane 2009 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbdump.h * Public headers for memory dumping to the disk. */ #ifndef DEFINED_DBDUMP_H #define DEFINED_DBDUMP_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif /* ====== data structures ======== */ /* ==== Protos ==== */ gint wg_dump(void * db,char fileName[]); /* dump shared memory database to the disk */ gint wg_dump_internal(void * db,char fileName[], int locking); /* handle the dump */ gint wg_import_dump(void * db,char fileName[]); /* import database from the disk */ gint wg_check_dump(void *db, char fileName[], gint *mixsize, gint *maxsize); /* check the dump file and get the db size */ #endif /* DEFINED_DBDUMP_H */ whitedb-0.7.3/Db/dbmem.c0000644000175000001440000005551712421471034011654 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2013,2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbmem.c * Allocating/detaching system memory: shared memory and allocated ordinary memory * */ /* ====== Includes =============== */ #include #include #include #include #ifdef _WIN32 #include #else #include #include #include #endif #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" #include "dbfeatures.h" #include "dbmem.h" #include "dblog.h" /* ====== Private headers and defs ======== */ /* ======= Private protos ================ */ static int normalize_perms(int mode); static void* link_shared_memory(int key, int *errcode); static void* create_shared_memory(int key, gint size, int mode); static int free_shared_memory(int key); static int detach_shared_memory(void* shmptr); #ifdef USE_DATABASE_HANDLE static void *init_dbhandle(void); static void free_dbhandle(void *dbhandle); #endif #ifndef _WIN32 static int memory_stats(void *db, struct shmid_ds *buf); #endif static gint show_memory_error(char *errmsg); #ifdef _WIN32 static gint show_memory_error_nr(char* errmsg, int nr); #endif /* ====== Functions ============== */ /* ----------- dbase creation and deletion api funs ------------------ */ /* Check the header for compatibility. * XXX: this is not required for a fresh database. */ #define CHECK_SEGMENT(shmx) \ if(shmx && dbmemsegh(shmx)) { \ int err; \ if((err = wg_check_header_compat(dbmemsegh(shmx)))) { \ if(err < -1) { \ show_memory_error("Existing segment header is incompatible"); \ wg_print_code_version(); \ wg_print_header_version(dbmemsegh(shmx), 1); \ } \ return NULL; \ } \ } /** returns a pointer to the database, NULL if failure * * In case database with dbasename exists, the returned pointer * points to the existing database. * * If there exists no database with dbasename, a new database * is created in shared memory with size in bytes * * If size is not 0 and the database exists, the size of the * existing segment is required to be >= requested size, * otherwise the operation fails. * */ void* wg_attach_database(char* dbasename, gint size){ void* shm = wg_attach_memsegment(dbasename, size, size, 1, 0, 0); CHECK_SEGMENT(shm) return shm; } /** returns a pointer to the existing database, NULL if * there is no database with dbasename. * */ void* wg_attach_existing_database(char* dbasename){ void* shm = wg_attach_memsegment(dbasename, 0, 0, 0, 0, 0); CHECK_SEGMENT(shm) return shm; } /** returns a pointer to the database, NULL if failure * * Starts journal logging in the database. */ void* wg_attach_logged_database(char* dbasename, gint size){ void* shm = wg_attach_memsegment(dbasename, size, size, 1, 1, 0); CHECK_SEGMENT(shm) return shm; } /** returns a pointer to the database, NULL if failure * * Creates the database with given permission mode. * Otherwise performs like wg_attach_database(). */ void* wg_attach_database_mode(char* dbasename, gint size, int mode){ void* shm = wg_attach_memsegment(dbasename, size, size, 1, 0, mode); CHECK_SEGMENT(shm) return shm; } /** returns a pointer to the database, NULL if failure * * Creates the database with given permission mode. * Otherwise performs like wg_attach_logged_database(). */ void* wg_attach_logged_database_mode(char* dbasename, gint size, int mode){ void* shm = wg_attach_memsegment(dbasename, size, size, 1, 1, mode); CHECK_SEGMENT(shm) return shm; } /** Normalize the mode for permissions. * */ static int normalize_perms(int mode) { /* Normalize the mode */ mode &= 0666; /* kill the high bits and execute bits */ mode |= 0600; /* owner can always read and write */ /* group and others are either read-write or nothing */ if((mode & 0060) != 0060) mode &= 0606; if((mode & 0006) != 0006) mode &= 0660; return mode; } /** Attach to shared memory segment. * Normally called internally by wg_attach_database() * May be called directly if the version compatibility of the * memory image is not relevant (such as, when importing a dump * file). */ void* wg_attach_memsegment(char* dbasename, gint minsize, gint size, int create, int logging, int mode){ #ifdef USE_DATABASE_HANDLE void *dbhandle; #endif void* shm; int err; int key=0; #ifdef USE_DBLOG int omode; #endif #ifdef USE_DATABASE_HANDLE dbhandle = init_dbhandle(); if(!dbhandle) return NULL; #endif // default args handling if (dbasename!=NULL) key=strtol(dbasename,NULL,10); if (key<=0 || key==INT_MIN || key==INT_MAX) key=DEFAULT_MEMDBASE_KEY; if (minsize<0) minsize=0; if (sizesize < minsize) { show_memory_error("Existing segment is too small"); #ifdef USE_DATABASE_HANDLE free_dbhandle(dbhandle); #endif return NULL; } } #ifdef USE_DATABASE_HANDLE #ifdef USE_DBLOG if(logging) { /* If logging was requested and we're not initializing a new * segment, we should fail here if the existing database is * not actively logging. */ if(!((db_memsegment_header *) shm)->logging.active) { show_memory_error("Existing memory segment has no journal"); free_dbhandle(dbhandle); return NULL; } } #endif ((db_handle *) dbhandle)->db = shm; #ifdef USE_DBLOG /* Always set the umask for the logfile */ omode = wg_memmode(dbhandle); if(omode == -1) { show_memory_error("Failed to get the access mode of the segment"); free_dbhandle(dbhandle); return NULL; } wg_log_umask(dbhandle, ~omode); #endif #endif #ifdef _WIN32 } else if (!create) { #else } else if (!create || err == EACCES) { #endif /* linking to already existing block failed do not create a new base */ #ifdef USE_DATABASE_HANDLE free_dbhandle(dbhandle); #endif return NULL; } else { /* linking to already existing block failed */ /* create a new block if createnew_flag set * * When creating a new base, we have to select the size for the * memory segment. There are three possible scenarios: * - no size was requested. Use the default size. * - specific size was requested. Use it. * - a size and a minimum size were provided. First try the size * given, if that fails fall back to minimum size. */ if(!size) size = DEFAULT_MEMDBASE_SIZE; mode = normalize_perms(mode); shm = create_shared_memory(key, size, mode); if(!shm && minsize && minsizedb = shm; err=wg_init_db_memsegment(dbhandle, key, size); #ifdef USE_DBLOG wg_log_umask(dbhandle, ~mode); if(!err && logging) { err = wg_start_logging(dbhandle); } #endif #else err=wg_init_db_memsegment(shm,key,size); #endif if(err) { show_memory_error("Database initialization failed"); free_shared_memory(key); #ifdef USE_DATABASE_HANDLE free_dbhandle(dbhandle); #endif return NULL; } } } #ifdef USE_DATABASE_HANDLE return dbhandle; #else return shm; #endif } /** Detach database * * returns 0 if OK */ int wg_detach_database(void* dbase) { int err = detach_shared_memory(dbmemseg(dbase)); #ifdef USE_DATABASE_HANDLE if(!err) { free_dbhandle(dbase); } #endif return err; } /** Delete a database * * returns 0 if OK */ int wg_delete_database(char* dbasename) { int key=0; // default args handling if (dbasename!=NULL) key=strtol(dbasename,NULL,10); if (key<=0 || key==INT_MIN || key==INT_MAX) key=DEFAULT_MEMDBASE_KEY; return free_shared_memory(key); } /* --------- local memory db creation and deleting ---------- */ /** Create a database in local memory * returns a pointer to the database, NULL if failure. */ void* wg_attach_local_database(gint size) { void* shm; #ifdef USE_DATABASE_HANDLE void *dbhandle = init_dbhandle(); if(!dbhandle) return NULL; #endif if (size<=0) size=DEFAULT_MEMDBASE_SIZE; shm = (void *) malloc(size); if (shm==NULL) { show_memory_error("malloc failed"); return NULL; } else { /* key=0 - no shared memory associated */ #ifdef USE_DATABASE_HANDLE ((db_handle *) dbhandle)->db = shm; if(wg_init_db_memsegment(dbhandle, 0, size)) { #else if(wg_init_db_memsegment(shm, 0, size)) { #endif show_memory_error("Database initialization failed"); free(shm); #ifdef USE_DATABASE_HANDLE free_dbhandle(dbhandle); #endif return NULL; } } #ifdef USE_DATABASE_HANDLE return dbhandle; #else return shm; #endif } /** Free a database in local memory * frees the allocated memory. */ void wg_delete_local_database(void* dbase) { if(dbase) { void *localmem = dbmemseg(dbase); if(localmem) free(localmem); #ifdef USE_DATABASE_HANDLE free_dbhandle(dbase); #endif } } /* -------------------- database handle management -------------------- */ #ifdef USE_DATABASE_HANDLE static void *init_dbhandle() { void *dbhandle = malloc(sizeof(db_handle)); if(!dbhandle) { show_memory_error("Failed to allocate the db handle"); return NULL; } else { memset(dbhandle, 0, sizeof(db_handle)); } #ifdef USE_DBLOG if(wg_init_handle_logdata(dbhandle)) { free(dbhandle); return NULL; } #endif return dbhandle; } static void free_dbhandle(void *dbhandle) { #ifdef USE_DBLOG wg_cleanup_handle_logdata(dbhandle); #endif free(dbhandle); } #endif /* ----------------- memory image/dump compatibility ------------------ */ /** Check compatibility of memory image (or dump file) header * * Note: unlike API functions, this functions works directly on * the (db_memsegment_header *) pointer. * * returns 0 if header is compatible with current executable * returns -1 if header is not recognizable * returns -2 if header has wrong endianness * returns -3 if header version does not match * returns -4 if compile-time features do not match */ int wg_check_header_compat(db_memsegment_header *dbh) { /* * Check: * - magic marker (including endianness) * - version */ if(!dbcheckh(dbh)) { gint32 magic = MEMSEGMENT_MAGIC_MARK; char *magic_bytes = (char *) &magic; char *header_bytes = (char *) dbh; if(magic_bytes[0]==header_bytes[3] && magic_bytes[1]==header_bytes[2] &&\ magic_bytes[2]==header_bytes[1] && magic_bytes[3]==header_bytes[0]) { return -2; /* wrong endianness */ } else { return -1; /* unknown marker (not a valid header) */ } } if(dbh->version!=MEMSEGMENT_VERSION) { return -3; } if(dbh->features!=MEMSEGMENT_FEATURES) { return -4; } return 0; } void wg_print_code_version(void) { int i = 1; char *i_bytes = (char *) &i; printf("\nlibwgdb version: %d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_REV); printf("byte order: %s endian\n", (i_bytes[0]==1 ? "little" : "big")); printf("compile-time features:\n"\ " 64-bit encoded data: %s\n"\ " queued locks: %s\n"\ " chained nodes in T-tree: %s\n"\ " record backlinking: %s\n"\ " child databases: %s\n"\ " index templates: %s\n", (MEMSEGMENT_FEATURES & FEATURE_BITS_64BIT ? "yes" : "no"), (MEMSEGMENT_FEATURES & FEATURE_BITS_QUEUED_LOCKS ? "yes" : "no"), (MEMSEGMENT_FEATURES & FEATURE_BITS_TTREE_CHAINED ? "yes" : "no"), (MEMSEGMENT_FEATURES & FEATURE_BITS_BACKLINK ? "yes" : "no"), (MEMSEGMENT_FEATURES & FEATURE_BITS_CHILD_DB ? "yes" : "no"), (MEMSEGMENT_FEATURES & FEATURE_BITS_INDEX_TMPL ? "yes" : "no")); } void wg_print_header_version(db_memsegment_header *dbh, int verbose) { gint32 version, features; gint32 magic = MEMSEGMENT_MAGIC_MARK; char *magic_bytes = (char *) &magic; char *header_bytes = (char *) dbh; char magic_lsb = (char) (MEMSEGMENT_MAGIC_MARK & 0xff); /* Header might be incompatible, but to display version and feature * information, we still need to read it somehow, even if * it has wrong endianness. */ if(magic_bytes[0]==header_bytes[3] && magic_bytes[1]==header_bytes[2] &&\ magic_bytes[2]==header_bytes[1] && magic_bytes[3]==header_bytes[0]) { char *f1 = (char *) &(dbh->version); char *t1 = (char *) &version; char *f2 = (char *) &(dbh->features); char *t2 = (char *) &features; int i; for(i=0; i<4; i++) { t1[i] = f1[3-i]; t2[i] = f2[3-i]; } } else { version = dbh->version; features = dbh->features; } if(verbose) { printf("\nheader version: %d.%d.%d\n", (version & 0xff), ((version>>8) & 0xff), ((version>>16) & 0xff)); printf("byte order: %s endian\n", (header_bytes[0]==magic_lsb ? "little" : "big")); printf("compile-time features:\n"\ " 64-bit encoded data: %s\n"\ " queued locks: %s\n"\ " chained nodes in T-tree: %s\n"\ " record backlinking: %s\n"\ " child databases: %s\n"\ " index templates: %s\n", (features & FEATURE_BITS_64BIT ? "yes" : "no"), (features & FEATURE_BITS_QUEUED_LOCKS ? "yes" : "no"), (features & FEATURE_BITS_TTREE_CHAINED ? "yes" : "no"), (features & FEATURE_BITS_BACKLINK ? "yes" : "no"), (features & FEATURE_BITS_CHILD_DB ? "yes" : "no"), (features & FEATURE_BITS_INDEX_TMPL ? "yes" : "no")); } else { printf("%d.%d.%d%s\n", (version & 0xff), ((version>>8) & 0xff), ((version>>16) & 0xff), (features & FEATURE_BITS_64BIT ? " (64-bit)" : "")); } } /* -------------------- memory image stats --------------------------- */ #ifndef _WIN32 /** Get the shared memory stats structure. * Returns 0 on success. * Returns -1 if the database is local. * Returns -2 on error. */ static int memory_stats(void *db, struct shmid_ds *buf) { db_memsegment_header* dbh = dbmemsegh(db); if(dbh->key) { int shmid = shmget((key_t) dbh->key, 0, 0); if(shmid < 0) { show_memory_error("memory_stats(): failed to get shmid"); return -2; } else { int err; memset(buf, 0, sizeof(struct shmid_ds)); err = shmctl(shmid, IPC_STAT, buf); if(err) { show_memory_error("memory_stats(): failed to stat shared memory"); return -2; } return 0; } } return -1; } #endif /** Return the mode bits of the shared memory permissions. * Defaults to 0600 in cases where this does not apply directly. */ int wg_memmode(void *db) { int mode = 0600; /* default for local memory and Win32 */ #ifndef _WIN32 struct shmid_ds buf; int err = memory_stats(db, &buf); if(!err) { mode = (int) buf.shm_perm.mode; } else if(err < -1) { return -1; } #endif return mode; } /** Return the uid of the owner of the segment. * returns -1 on error. */ int wg_memowner(void *db) { #ifdef _WIN32 int uid = 0; #else int uid = getuid(); /* default for local memory */ struct shmid_ds buf; int err = memory_stats(db, &buf); if(!err) { uid = (int) buf.shm_perm.uid; } else if(err < -1) { return -1; } #endif return uid; } /** Return the gid of the owner of the segment. * returns -1 on error. */ int wg_memgroup(void *db) { #ifdef _WIN32 int gid = 0; #else int gid = getgid(); /* default for local memory */ struct shmid_ds buf; int err = memory_stats(db, &buf); if(!err) { gid = (int) buf.shm_perm.gid; } else if(err < -1) { return -1; } #endif return gid; } /* --------------- dbase create/delete ops not in api ----------------- */ static void* link_shared_memory(int key, int *errcode) { void *shm; #ifdef _WIN32 char fname[MAX_FILENAME_SIZE]; HANDLE hmapfile; sprintf_s(fname,MAX_FILENAME_SIZE-1,"%d",key); hmapfile = OpenFileMapping( FILE_MAP_ALL_ACCESS, // read/write access FALSE, // do not inherit the name fname); // name of mapping object errno = 0; *errcode = 0; if (hmapfile == NULL) { /* this is an expected error, message in most cases not wanted */ return NULL; } shm = (void*) MapViewOfFile(hmapfile, // handle to map object FILE_MAP_ALL_ACCESS, // read/write permission 0, 0, 0); // size of mapping if (shm == NULL) { show_memory_error_nr("Could not map view of file", (int) GetLastError()); CloseHandle(hmapfile); return NULL; } return shm; #else int shmid; /* return value from shmget() */ errno = 0; *errcode = 0; // Link to existing segment shmid=shmget((key_t)key, 0, 0); if (shmid < 0) { return NULL; } // Attach the segment to our data space shm=shmat(shmid,NULL,0); if (shm==(char *) -1) { *errcode = errno; if(*errcode == EACCES) { show_memory_error("cannot attach to shared memory (No permission)"); return NULL; } else { show_memory_error("attaching shared memory segment failed"); return NULL; } } return (void*) shm; #endif } static void* create_shared_memory(int key, gint size, int mode) { void *shm; #ifdef _WIN32 char fname[MAX_FILENAME_SIZE]; HANDLE hmapfile; sprintf_s(fname,MAX_FILENAME_SIZE-1,"%d",key); /* XXX: need to interpret the mode value here. * Right now the shared segment is created using the * default permissions, in the local namespace. */ hmapfile = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file NULL, // default security PAGE_READWRITE, // read/write access 0, // max. object size size, // buffer size fname); // name of mapping object errno = 0; if (hmapfile == NULL) { show_memory_error_nr("Could not create file mapping object", (int) GetLastError()); return NULL; } shm = (void*) MapViewOfFile(hmapfile, // handle to map object FILE_MAP_ALL_ACCESS, // read/write permission 0, 0, 0); if (shm == NULL) { show_memory_error_nr("Could not map view of file", (int) GetLastError()); CloseHandle(hmapfile); return NULL; } return shm; #else int shmflg; /* shmflg to be passed to shmget() */ int shmid; /* return value from shmget() */ // Create the segment shmflg=IPC_CREAT | IPC_EXCL | mode; shmid=shmget((key_t)key,size,shmflg); if (shmid < 0) { switch(errno) { case EEXIST: show_memory_error("creating shared memory segment: "\ "Race condition detected when initializing"); break; case EINVAL: show_memory_error("creating shared memory segment: "\ "Specified segment size too large or too small"); break; case ENOMEM: show_memory_error("creating shared memory segment: "\ "Not enough physical memory"); break; default: /* Generic error */ show_memory_error("creating shared memory segment failed"); break; } return NULL; } // Attach the segment to our data space shm=shmat(shmid,NULL,0); if (shm==(char *) -1) { show_memory_error("attaching shared memory segment failed"); return NULL; } return (void*) shm; #endif } static int free_shared_memory(int key) { #ifdef _WIN32 return 0; #else int shmflg; /* shmflg to be passed to shmget() */ int shmid; /* return value from shmget() */ int tmp; errno = 0; // Link to existing segment shmflg=0666; shmid=shmget((key_t)key, 0, shmflg); if (shmid < 0) { switch(errno) { case EACCES: show_memory_error("linking to shared memory segment (for freeing): "\ "Access denied"); break; case ENOENT: show_memory_error("linking to shared memory segment (for freeing): "\ "Segment does not exist"); break; default: show_memory_error("linking to shared memory segment (for freeing) failed"); break; } return -1; } // Free the segment tmp=shmctl(shmid, IPC_RMID, NULL); if (tmp==-1) { switch(errno) { case EPERM: show_memory_error("freeing shared memory segment: "\ "Permission denied"); break; default: show_memory_error("freeing shared memory segment failed"); break; } return -2; } return 0; #endif } static int detach_shared_memory(void* shmptr) { #ifdef _WIN32 return 0; #else int tmp; // detach the segment tmp=shmdt(shmptr); if (tmp==-1) { show_memory_error("detaching shared memory segment failed"); return -2; } return 0; #endif } /* ------------ error handling ---------------- */ /** Handle memory error * since these errors mostly indicate a fatal error related to database * memory allocation, the db pointer is not very useful here and is * omitted. */ static gint show_memory_error(char *errmsg) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"wg memory error: %s.\n", errmsg); #endif return -1; } #ifdef _WIN32 static gint show_memory_error_nr(char* errmsg, int nr) { #ifdef WG_NO_ERRPRINT #else fprintf(stderr,"db memory allocation error: %s %d\n", errmsg, nr); #endif return -1; } #endif #ifdef __cplusplus } #endif whitedb-0.7.3/Db/dblog.h0000644000175000001440000000451412421471034011653 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Andri Rebane 2009 * Copyright (c) Priit Järv 2013,2014 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dblog.h * Public headers for the recovery journal. */ #ifndef DEFINED_DBLOG_H #define DEFINED_DBLOG_H #ifndef _WIN32 #define WG_JOURNAL_FILENAME DBLOG_DIR "/wgdb.journal" #else #define WG_JOURNAL_FILENAME DBLOG_DIR "\\wgdb_journal" #endif #define WG_JOURNAL_FN_BUFSIZE (sizeof(WG_JOURNAL_FILENAME) + 20) #define WG_JOURNAL_MAX_BACKUPS 10 #define WG_JOURNAL_MAGIC "wgdb" #define WG_JOURNAL_MAGIC_BYTES 4 #define WG_JOURNAL_ENTRY_ENC ((unsigned char) 0) /* top bits clear |= type */ #define WG_JOURNAL_ENTRY_CRE ((unsigned char) 0x40) #define WG_JOURNAL_ENTRY_DEL ((unsigned char) 0x80) #define WG_JOURNAL_ENTRY_SET ((unsigned char) 0xc0) #define WG_JOURNAL_ENTRY_META ((unsigned char) 0x20) #define WG_JOURNAL_ENTRY_CMDMASK (0xe0) #define WG_JOURNAL_ENTRY_TYPEMASK (0x1f) /* ====== data structures ======== */ typedef struct { FILE *f; int fd; gint serial; int umask; } db_handle_logdata; /* ==== Protos ==== */ gint wg_init_handle_logdata(void *db); void wg_cleanup_handle_logdata(void *db); int wg_log_umask(void *db, int cmask); void wg_journal_filename(void *db, char *buf, size_t buflen); gint wg_start_logging(void *db); gint wg_stop_logging(void *db); gint wg_replay_log(void *db, char *filename); gint wg_log_create_record(void *db, gint length); gint wg_log_delete_record(void *db, gint enc); gint wg_log_encval(void *db, gint enc); gint wg_log_encode(void *db, gint type, void *data, gint length, void *extdata, gint extlength); gint wg_log_set_field(void *db, void *rec, gint col, gint data); gint wg_log_set_meta(void *db, void *rec, gint meta); #endif /* DEFINED_DBLOG_H */ whitedb-0.7.3/Db/dbhash.h0000644000175000001440000000452012421471034012012 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Tanel Tammet 2004,2005,2006,2007,2008,2009 * Copyright (c) Priit Järv 2013,2014 * * Contact: tanel.tammet@gmail.com * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file dbhash.h * Public headers for hash-related procedures. */ #ifndef DEFINED_DBHASH_H #define DEFINED_DBHASH_H #ifdef _WIN32 #include "../config-w32.h" #else #include "../config.h" #endif #include "dballoc.h" /* ==== Public macros ==== */ #define HASHIDX_META_POS 1 #define HASHIDX_RECLIST_POS 2 #define HASHIDX_HASHCHAIN_POS 3 #define HASHIDX_HEADER_SIZE 4 /* ==== Protos ==== */ int wg_hash_typedstr(void* db, char* data, char* extrastr, gint type, gint length); gint wg_find_strhash_bucket(void* db, char* data, char* extrastr, gint type, gint size, gint hashchain); int wg_right_strhash_bucket (void* db, gint longstr, char* cstr, char* cextrastr, gint ctype, gint cstrsize); gint wg_remove_from_strhash(void* db, gint longstr); gint wg_decode_for_hashing(void *db, gint enc, char **decbytes); gint wg_idxhash_store(void* db, db_hash_area_header *ha, char* data, gint length, gint offset); gint wg_idxhash_remove(void* db, db_hash_area_header *ha, char* data, gint length, gint offset); gint wg_idxhash_find(void* db, db_hash_area_header *ha, char* data, gint length); void *wg_ginthash_init(void *db); gint wg_ginthash_addkey(void *db, void *tbl, gint key, gint val); gint wg_ginthash_getkey(void *db, void *tbl, gint key, gint *val); void wg_ginthash_free(void *db, void *tbl); void *wg_dhash_init(void *db, size_t entries); void wg_dhash_free(void *db, void *tbl); gint wg_dhash_addkey(void *db, void *tbl, gint key); gint wg_dhash_haskey(void *db, void *tbl, gint key); #endif /* DEFINED_DBHASH_H */ whitedb-0.7.3/compile.bat0000644000175000001440000000177612421471034012215 00000000000000@rem current version does not build reasoner: added later @rem build DLL. @rem unlike gcc build, it is necessary to have all functions declared in @rem wgdb.def file. Make sure it's up to date (should list same functions as @rem Db/dbapi.h) cl /Ox /W3 /MT /Fewgdb /LD Db\dbmem.c Db\dballoc.c Db\dbdata.c Db\dblock.c DB\dbdump.c Db\dblog.c Db\dbhash.c Db\dbindex.c Db\dbcompare.c Db\dbquery.c Db\dbutil.c Db\dbmpool.c Db\dbjson.c Db\dbschema.c json\yajl_all.c /link /def:wgdb.def /incremental:no /MANIFEST:NO @rem Link executables against wgdb.dll @rem cl /Ox /W3 Main\stresstest.c wgdb.lib cl /Ox /W3 Main\wgdb.c wgdb.lib @rem cl /Ox /W3 Main\indextool.c wgdb.lib @rem Example of building without the DLL @rem the test module depends on many symbols not part of the API cl /Ox /W3 Main\selftest.c Db\dbmem.c Db\dballoc.c Db\dbdata.c Db\dblock.c Test\dbtest.c DB\dbdump.c Db\dblog.c Db\dbhash.c Db\dbindex.c Db\dbcompare.c Db\dbquery.c Db\dbutil.c Db\dbmpool.c Db\dbjson.c Db\dbschema.c json\yajl_all.c whitedb-0.7.3/depcomp0000755000175000001440000005570312153415437011460 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2012-10-18.11; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: whitedb-0.7.3/INSTALL0000644000175000001440000000006312232205232011105 00000000000000See Doc/Install.txt for installation instructions. whitedb-0.7.3/COPYING0000644000175000001440000010451312146112207011117 00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . whitedb-0.7.3/ChangeLog0000644000175000001440000000012412232205232011624 00000000000000ChangeLog ========= Nothing here: see https://github.com/priitj/whitedb for historywhitedb-0.7.3/Python/0000755000175000001440000000000012426224011011417 500000000000000whitedb-0.7.3/Python/whitedb.py0000644000175000001440000003360312235660271013356 00000000000000#!/usr/bin/env python # -*- coding: latin-1 -*- # # Copyright (c) Priit Järv 2009, 2010, 2013 # # This file is part of WhiteDB # # WhiteDB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # WhiteDB is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with WhiteDB. If not, see . """@file whitedb.py High level Python API for WhiteDB database """ # This module is implemented loosely following the guidelines # in Python DBI spec (http://www.python.org/dev/peps/pep-0249/). # Due to the wgdb feature set being much slimmer than typical # SQL databases, it does not make sense to follow DBI fully, # but where there are overlaps in functionality, similar # naming and object structure should be generally used. import wgdb ### Error classes (by DBI recommendation) ### # class DatabaseError(wgdb.error): """Base class for database errors""" pass class ProgrammingError(DatabaseError): """Exception class to indicate invalid database usage""" pass class DataError(DatabaseError): """Exception class to indicate invalid data passed to the db adapter""" pass class InternalError(DatabaseError): """Exception class to indicate invalid internal state of the module""" pass ############## DBI classes: ############### # class Connection(object): """The Connection class acts as a container for wgdb.Database and provides all connection-related and record accessing functions.""" def __init__(self, shmname=None, shmsize=0, local=0): if local: self._db = wgdb.attach_database(size=shmsize, local=local) elif shmname: self._db = wgdb.attach_database(shmname, shmsize) else: self._db = wgdb.attach_database(size=shmsize) self.shmname = shmname self.locking = 1 self._lock_id = None def close(self): """Close the connection.""" if self._db: wgdb.detach_database(self._db) self._db = None def cursor(self): """Return a DBI-style database cursor""" if self._db is None: raise InternalError("Connection is closed.") return Cursor(self) # Locking support # def set_locking(self, mode): """Set locking mode (1=on, 0=off)""" self.locking = mode def start_write(self): """Start writing transaction""" if self._lock_id: raise ProgrammingError("Transaction already started.") self._lock_id = wgdb.start_write(self._db) def end_write(self): """Finish writing transaction""" if not self._lock_id: raise ProgrammingError("No current transaction.") wgdb.end_write(self._db, self._lock_id) self._lock_id = None def start_read(self): """Start reading transaction""" if self._lock_id: raise ProgrammingError("Transaction already started.") self._lock_id = wgdb.start_read(self._db) def end_read(self): """Finish reading transaction""" if not self._lock_id: raise ProgrammingError("No current transaction.") wgdb.end_read(self._db, self._lock_id) self._lock_id = None def commit(self): """Commit the transaction (no-op)""" pass def rollback(self): """Roll back the transaction (no-op)""" pass # Record operations. Wrap wgdb.Record object into Record class. # def _new_record(self, rec): """Create a Record instance from wgdb record object (internal)""" r = Record(self, rec) if self.locking: self.start_read() try: r.size = wgdb.get_record_len(self._db, rec) finally: if self.locking: self.end_read() return r def first_record(self): """Get first record from database.""" if self.locking: self.start_read() try: r = wgdb.get_first_record(self._db) except wgdb.error: r = None finally: if self.locking: self.end_read() if not r: return None return self._new_record(r) def next_record(self, rec): """Get next record from database.""" if self.locking: self.start_read() try: r = wgdb.get_next_record(self._db, rec.get__rec()) except wgdb.error: r = None finally: if self.locking: self.end_read() if not r: return None return self._new_record(r) def create_record(self, size): """Create new record with given size.""" if size <= 0: raise DataError("Invalid record size") if self.locking: self.start_write() try: r = wgdb.create_record(self._db, size) finally: if self.locking: self.end_write() return self._new_record(r) def delete_record(self, rec): """Delete record.""" if self.locking: self.start_write() try: r = wgdb.delete_record(self._db, rec.get__rec()) finally: if self.locking: self.end_write() rec.set__rec(None) # prevent future usage def atomic_create_record(self, fields): """Create a record and set field contents atomically.""" if not fields: raise DataError("Cannot create an empty record") l = len(fields) tupletype = type(()) if self.locking: self.start_write() try: r = wgdb.create_raw_record(self._db, l) for i in range(l): if type(fields[i]) == tupletype: data = fields[i][0] extarg = fields[i][1:] else: data = fields[i] extarg = () if isinstance(data, Record): data = data.get__rec() fargs = (self._db, r, i, data) + extarg wgdb.set_new_field(*fargs) finally: if self.locking: self.end_write() return self._new_record(r) def atomic_update_record(self, rec, fields): """Set the contents of the entire record atomically.""" # fields should be a sequence l = len(fields) sz = rec.get_size() r = rec.get__rec() tupletype = type(()) if self.locking: self.start_write() try: for i in range(l): if type(fields[i]) == tupletype: data = fields[i][0] extarg = fields[i][1:] else: data = fields[i] extarg = () if isinstance(data, Record): data = data.get__rec() fargs = (self._db, r, i, data) + extarg wgdb.set_field(*fargs) if l < sz: # fill the remainder: for i in range(l, sz): wgdb.set_field(self._db, r, i, None) finally: if self.locking: self.end_write() # alias for atomic_create_record() def insert(self, fields): """Insert a record into database""" return self.atomic_create_record(fields) # Field operations. Expect Record instances as argument # def get_field(self, rec, fieldnr): """Return data field contents""" if self.locking: self.start_read() try: data = wgdb.get_field(self._db, rec.get__rec(), fieldnr) finally: if self.locking: self.end_read() if wgdb.is_record(data): return self._new_record(data) else: return data def set_field(self, rec, fieldnr, data, *arg, **kwarg): """Set data field contents""" if isinstance(data, Record): data = data.get__rec() if self.locking: self.start_write() try: r = wgdb.set_field(self._db, rec.get__rec(), fieldnr, data, *arg, **kwarg) finally: if self.locking: self.end_write() return r # Query operations # def make_query(self, matchrec=None, *arg, **kwarg): """Create a query object.""" if isinstance(matchrec, Record): matchrec = matchrec.get__rec() if self.locking: self.start_write() # write lock for parameter encoding try: query = wgdb.make_query(self._db, matchrec, *arg, **kwarg) finally: if self.locking: self.end_write() return query def fetch(self, query): """Get next record from query result set.""" if self.locking: self.start_read() try: r = wgdb.fetch(self._db, query) except wgdb.error: r = None finally: if self.locking: self.end_read() if not r: return None return self._new_record(r) def free_query(self, cur): """Free query belonging to a cursor.""" if not self._db: # plausible enough to warrant special handling raise ProgrammingError("Database closed before freeing query "\ "(Hint: use Cursor.close() before Connection.close())") if self.locking: self.start_write() # may write shared memory try: r = wgdb.free_query(self._db, cur.get__query()) finally: if self.locking: self.end_write() cur.set__query(None) # prevent future usage class Cursor(object): """Cursor object. Supports wgdb-style queries based on match records or argument lists. Does not currently support SQL.""" def __init__(self, conn): self._query = None self._conn = conn self.rowcount = -1 def get__query(self): """Return low level query object""" return self._query def set__query(self, query): """Overwrite low level query object""" self._query = query def fetchone(self): """Fetch the next record from the result set""" if not self._query: raise ProgrammingError("No results to fetch.") return self._conn.fetch(self._query) def fetchall(self): """Fetch all (remaining) records from the result set""" result = [] while 1: r = self.fetchone() if not r: break result.append(r) return result # includes sql parameter for future extension. Current # wgdb queries should use arglist and matchrec keyword parameters. def execute(self, sql="", matchrec=None, arglist=None): """Execute a database query""" self._query = self._conn.make_query(matchrec=matchrec, arglist=arglist) if self._query.res_count is not None: self.rowcount = self._query.res_count # using cursors to insert data does not make sense # in WhiteDB context, since there is no relation at all # between the current cursor state and new records. # This functionality will be moved to Connection object. def insert(self, fields): """Insert a record into database --DEPRECATED--""" return self._conn.atomic_create_record(fields) def close(self): """Close the cursor""" if self._query: self._conn.free_query(self) ############## Additional classes: ############### # class Record(object): """Record data representation. Allows field-level and record-level manipulation of data. Supports iterator and (partial) sequence protocol.""" def __init__(self, conn, rec): self._rec = rec self._conn = conn self.size = 0 def get__rec(self): """Return low level record object""" return self._rec def set__rec(self, rec): """Overwrite low level record object""" self._rec = rec def get_size(self): """Return record size""" return self.size def get_field(self, fieldnr): """Return data field contents""" if fieldnr < 0 or fieldnr >= self.size: raise DataError("Field number out of bounds.") return self._conn.get_field(self, fieldnr) def set_field(self, fieldnr, data, *arg, **kwarg): """Set data field contents with optional encoding""" if fieldnr < 0 or fieldnr >= self.size: raise DataError("Field number out of bounds.") return self._conn.set_field(self, fieldnr, data, *arg, **kwarg) def update(self, fields): """Set the contents of the entire record""" self._conn.atomic_update_record(self, fields) def delete(self): """Delete the record from database""" self._conn.delete_record(self) # iterator protocol def __iter__(self): for fieldnr in range(self.size): yield self.get_field(fieldnr) # sequence protocol def __getitem__(self, index): return self.get_field(index) def __setitem__(self, index, data, *arg, **kwarg): # XXX: should we allow this? # Could be counter-intuitive for users. return self.set_field(index, data, *arg, **kwarg) def __len__(self): return self.size ############## DBI API functions: ############### # def connect(shmname=None, shmsize=0, local=0): """Attaches to (or creates) a database. Returns a database object""" return Connection(shmname, shmsize, local) whitedb-0.7.3/Python/compile.sh0000755000175000001440000000120512426116005013327 00000000000000#!/bin/sh [ -z "$CC" ] && CC="cc" if [ -z "$(which $CC 2>/dev/null)" ]; then echo "Error: No compiler found" exit 1 fi export PYDIR=/usr/include/python2.7 # run unite.sh if needed if [ ! -f ../whitedb.c ]; then cd ..; ./unite.sh; cd "$OLDPWD" fi $CC -O3 -Wall -fPIC -shared -I.. -I../Db -I${PYDIR} -o wgdb.so wgdbmodule.c ../whitedb.c #$CC -O3 -Wall -fPIC -shared -I../Db -I${PYDIR} -o wgdb.so wgdbmodule.c ../Db/dbmem.c ../Db/dballoc.c ../Db/dbdata.c ../Db/dblock.c ../Db/dbindex.c ../Db/dblog.c ../Db/dbhash.c ../Db/dbcompare.c ../Db/dbquery.c ../Db/dbutil.c ../Db/dbmpool.c ../Db/dbjson.c ../Db/dbschema.c ../json/yajl_all.c whitedb-0.7.3/Python/Makefile.am0000644000175000001440000000112312232205232013367 00000000000000# $Id: $ # $Source: $ # # Compile Python extension module # ---- options ---- # ---- targets ---- python_PYTHON = whitedb.py WGandalf.py pyexec_LTLIBRARIES = wgdb.la # ---- path variables ---- dbdir=../Db # ---- extra dependencies, flags, etc ----- LIBDEPS = -lm # dependency from libm round() should be removed if RAPTOR LIBDEPS += `$(RAPTOR_CONFIG) --libs` endif AM_CPPFLAGS = $(PYTHON_INCLUDES) -I $(dbdir) wgdb_la_LDFLAGS = -module -avoid-version $(LIBDEPS) # ----- all sources for the created programs ----- wgdb_la_SOURCES = wgdbmodule.c wgdb_la_LIBADD = ../Main/libwgdb.la whitedb-0.7.3/Python/Makefile.in0000644000175000001440000005442212426224004013415 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: $ # $Source: $ # # Compile Python extension module # ---- options ---- # ---- targets ---- VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @RAPTOR_TRUE@am__append_1 = `$(RAPTOR_CONFIG) --libs` subdir = Python DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(python_PYTHON) \ $(top_srcdir)/py-compile ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pyexecdir)" "$(DESTDIR)$(pythondir)" LTLIBRARIES = $(pyexec_LTLIBRARIES) wgdb_la_DEPENDENCIES = ../Main/libwgdb.la am_wgdb_la_OBJECTS = wgdbmodule.lo wgdb_la_OBJECTS = $(am_wgdb_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = wgdb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(wgdb_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(wgdb_la_SOURCES) DIST_SOURCES = $(wgdb_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile) am__pep3147_tweak = \ sed -e 's|\.py$$||' -e 's|[^/]*$$|__pycache__/&.*.py|' py_compile = $(top_srcdir)/py-compile am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON = @BISON@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PRTDIAG = @PRTDIAG@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON = @PYTHON@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_INCLUDES = @PYTHON_INCLUDES@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RAPTOR_CONFIG = @RAPTOR_CONFIG@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ python_PYTHON = whitedb.py WGandalf.py pyexec_LTLIBRARIES = wgdb.la # ---- path variables ---- dbdir = ../Db # ---- extra dependencies, flags, etc ----- LIBDEPS = -lm $(am__append_1) AM_CPPFLAGS = $(PYTHON_INCLUDES) -I $(dbdir) wgdb_la_LDFLAGS = -module -avoid-version $(LIBDEPS) # ----- all sources for the created programs ----- wgdb_la_SOURCES = wgdbmodule.c wgdb_la_LIBADD = ../Main/libwgdb.la all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Python/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Python/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pyexecLTLIBRARIES: $(pyexec_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pyexec_LTLIBRARIES)'; test -n "$(pyexecdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pyexecdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pyexecdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pyexecdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pyexecdir)"; \ } uninstall-pyexecLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pyexec_LTLIBRARIES)'; test -n "$(pyexecdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pyexecdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pyexecdir)/$$f"; \ done clean-pyexecLTLIBRARIES: -test -z "$(pyexec_LTLIBRARIES)" || rm -f $(pyexec_LTLIBRARIES) @list='$(pyexec_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } wgdb.la: $(wgdb_la_OBJECTS) $(wgdb_la_DEPENDENCIES) $(EXTRA_wgdb_la_DEPENDENCIES) $(AM_V_CCLD)$(wgdb_la_LINK) -rpath $(pyexecdir) $(wgdb_la_OBJECTS) $(wgdb_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wgdbmodule.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-pythonPYTHON: $(python_PYTHON) @$(NORMAL_INSTALL) @list='$(python_PYTHON)'; dlist=; list2=; test -n "$(pythondir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pythondir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pythondir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \ if test -f $$b$$p; then \ $(am__strip_dir) \ dlist="$$dlist $$f"; \ list2="$$list2 $$b$$p"; \ else :; fi; \ done; \ for file in $$list2; do echo $$file; done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pythondir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pythondir)" || exit $$?; \ done || exit $$?; \ if test -n "$$dlist"; then \ $(am__py_compile) --destdir "$(DESTDIR)" \ --basedir "$(pythondir)" $$dlist; \ else :; fi uninstall-pythonPYTHON: @$(NORMAL_UNINSTALL) @list='$(python_PYTHON)'; test -n "$(pythondir)" || list=; \ py_files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ test -n "$$py_files" || exit 0; \ dir='$(DESTDIR)$(pythondir)'; \ pyc_files=`echo "$$py_files" | sed 's|$$|c|'`; \ pyo_files=`echo "$$py_files" | sed 's|$$|o|'`; \ py_files_pep3147=`echo "$$py_files" | $(am__pep3147_tweak)`; \ echo "$$py_files_pep3147";\ pyc_files_pep3147=`echo "$$py_files_pep3147" | sed 's|$$|c|'`; \ pyo_files_pep3147=`echo "$$py_files_pep3147" | sed 's|$$|o|'`; \ st=0; \ for files in \ "$$py_files" \ "$$pyc_files" \ "$$pyo_files" \ "$$pyc_files_pep3147" \ "$$pyo_files_pep3147" \ ; do \ $(am__uninstall_files_from_dir) || st=$$?; \ done; \ exit $$st ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pyexecdir)" "$(DESTDIR)$(pythondir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pyexecLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-pythonPYTHON install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pyexecLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pyexecLTLIBRARIES uninstall-pythonPYTHON .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pyexecLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-pyexecLTLIBRARIES \ install-pythonPYTHON install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am \ uninstall-pyexecLTLIBRARIES uninstall-pythonPYTHON # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: whitedb-0.7.3/Python/WGandalf.py0000644000175000001440000000167612146112207013410 00000000000000#!/usr/bin/env python # -*- coding: latin-1 -*- # # Copyright (c) Priit Järv 2013 # # This file is part of WhiteDB # # WhiteDB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # WhiteDB is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with WhiteDB. If not, see . """@file WGandalf.py Backwards compatibility wrapper for WhiteDB database Python API """ from warnings import warn warn("WGandalf module is deprecated, use whitedb instead", DeprecationWarning) from whitedb import * whitedb-0.7.3/Python/compile.bat0000755000175000001440000000170012421471034013464 00000000000000@rem Check that this matches your Python path set PYDIR=c:\Python25 @rem When compiling for Python 3, replace /export:initwgdb @rem with /export:PyInit_wgdb @cl /Ox /W3 /MT /I..\Db /I%PYDIR%\include wgdbmodule.c ..\Db\dbmem.c ..\Db\dballoc.c ..\Db\dbdata.c ..\Db\dblock.c ..\DB\dbdump.c ..\Db\dblog.c ..\Db\dbhash.c ..\Db\dbindex.c ..\Db\dbcompare.c ..\Db\dbquery.c ..\Db\dbutil.c ..\Db\dbmpool.c ..\Db\dbjson.c ..\Db\dbschema.c ..\json\yajl_all.c /link /dll /incremental:no /MANIFEST:NO /LIBPATH:%PYDIR%\libs /export:initwgdb /out:wgdb.pyd @rem Currently this script produced a statically linked DLL for ease of @rem testing and debugging. If dynamic linking is needed: @rem 1. replace /MT with /MD @rem 2. remove /manifest:no or just the "NO" part @rem 3. uncomment the following: @rem mt -manifest wgdb.pyd.manifest -outputresource:wgdb.pyd;2 @rem You may also need to: @rem 4. distribute msvcrxx.dll from the compiler suite with the lib whitedb-0.7.3/Python/wgdbmodule.c0000644000175000001440000016015012421471034013643 00000000000000/* * $Id: $ * $Version: $ * * Copyright (c) Priit Järv 2009, 2010, 2013 * * This file is part of WhiteDB * * WhiteDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WhiteDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WhiteDB. If not, see . * */ /** @file wgdbmodule.c * Python extension module for accessing WhiteDB database * */ /* ====== Includes =============== */ #include #include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #endif #include "dbapi.h" /* ====== Private headers and defs ======== */ #if PY_VERSION_HEX >= 0x03000000 #define PYTHON3 #define ENCODEERR "surrogateescape" /* handling of charset mismatches */ #if PY_VERSION_HEX >= 0x03030000 #define HAVE_LOCALEENC /* locale dependent string encode function exists */ #endif #endif struct module_state { PyObject *wgdb_error; }; typedef struct { PyObject_HEAD void *db; int local; } wg_database; typedef struct { PyObject_HEAD void *rec; } wg_record; typedef struct { PyObject_HEAD wg_query *query; wg_database *db; wg_query_arg *arglist; int argc; void *matchrec; int reclen; } wg_query_ob; /* append _ob to avoid name clash with dbapi.h */ /* ======= Private protos ================ */ static PyObject *wgdb_attach_database(PyObject *self, PyObject *args, PyObject *kwds); static PyObject *wgdb_attach_existing_database(PyObject *self, PyObject *args); static PyObject *wgdb_delete_database(PyObject *self, PyObject *args); static PyObject *wgdb_detach_database(PyObject *self, PyObject *args); static PyObject *wgdb_create_record(PyObject *self, PyObject *args); static PyObject *wgdb_create_raw_record(PyObject *self, PyObject *args); static PyObject *wgdb_get_first_record(PyObject *self, PyObject *args); static PyObject *wgdb_get_next_record(PyObject *self, PyObject *args); static PyObject *wgdb_get_record_len(PyObject *self, PyObject *args); static PyObject *wgdb_is_record(PyObject *self, PyObject *args); static PyObject *wgdb_delete_record(PyObject *self, PyObject *args); static wg_int pytype_to_wgtype(PyObject *data, wg_int ftype); static wg_int encode_pyobject_null(wg_database *db); static wg_int encode_pyobject_record(wg_database *db, PyObject *data); static wg_int encode_pyobject_int(wg_database *db, PyObject *data, int param); static wg_int encode_pyobject_double(wg_database *db, PyObject *data, int param); static wg_int encode_pyobject_str(wg_database *db, PyObject *data, char *ext_str, int param); static wg_int encode_pyobject_uri(wg_database *db, PyObject *data, char *ext_str, int param); static wg_int encode_pyobject_xmlliteral(wg_database *db, PyObject *data, char *ext_str, int param); static wg_int encode_pyobject_char(wg_database *db, PyObject *data, int param); static wg_int encode_pyobject_fixpoint(wg_database *db, PyObject *data, int param); static wg_int encode_pyobject_date(wg_database *db, PyObject *data, int param); static wg_int encode_pyobject_time(wg_database *db, PyObject *data, int param); static wg_int encode_pyobject_var(wg_database *db, PyObject *data, int param); static wg_int encode_pyobject(wg_database *db, PyObject *data, wg_int ftype, char *ext_str, int param); static wg_int encode_pyobject_ext(PyObject *self, wg_database *db, PyObject *obj, int param); static PyObject *wgdb_set_field(PyObject *self, PyObject *args, PyObject *kwds); static PyObject *wgdb_set_new_field(PyObject *self, PyObject *args, PyObject *kwds); static PyObject *wgdb_get_field(PyObject *self, PyObject *args); static PyObject *wgdb_start_write(PyObject *self, PyObject *args); static PyObject *wgdb_end_write(PyObject *self, PyObject *args); static PyObject *wgdb_start_read(PyObject *self, PyObject *args); static PyObject *wgdb_end_read(PyObject *self, PyObject *args); static int parse_query_params(PyObject *self, PyObject *args, PyObject *kwds, wg_query_ob *query); static PyObject * wgdb_make_query(PyObject *self, PyObject *args, PyObject *kwds); static PyObject * wgdb_fetch(PyObject *self, PyObject *args); static PyObject * wgdb_free_query(PyObject *self, PyObject *args); static void free_query(wg_query_ob *obj); static void wg_database_dealloc(wg_database *obj); static void wg_query_dealloc(wg_query_ob *obj); static PyObject *wg_database_repr(wg_database *obj); static PyObject *wg_record_repr(wg_record *obj); static PyObject *wg_query_repr(wg_query_ob *obj); static PyObject *wg_query_get_res_count(wg_query_ob *obj, void *closure); static int wg_query_set_res_count(wg_query_ob *obj, PyObject *value, void *closure); static void wgdb_error_setstring(PyObject *self, char *err); /* ============= Private vars ============ */ /** Module state, contains the exception object */ #ifndef PYTHON3 static struct module_state _state; #endif /** Database object type */ static PyTypeObject wg_database_type = { #ifndef PYTHON3 PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ #else PyVarObject_HEAD_INIT(NULL, 0) #endif "wgdb.Database", /*tp_name*/ sizeof(wg_database), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) wg_database_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc) wg_database_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ (reprfunc) wg_database_repr, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ "WhiteDB database object", /* tp_doc */ }; /** Record object type */ static PyTypeObject wg_record_type = { #ifndef PYTHON3 PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ #else PyVarObject_HEAD_INIT(NULL, 0) #endif "wgdb.Record", /*tp_name*/ sizeof(wg_record), /*tp_basicsize*/ 0, /*tp_itemsize*/ 0, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc) wg_record_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ (reprfunc) wg_record_repr, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ "WhiteDB record object", /* tp_doc */ }; /** Data accessor functions for the Query type */ static PyGetSetDef wg_query_getset[] = { {"res_count", /* attribyte name */ (getter) wg_query_get_res_count, (setter) wg_query_set_res_count, "Number of rows in the result set", /* doc */ NULL}, /* closure, not used here */ {NULL} }; /** Query object type */ static PyTypeObject wg_query_type = { #ifndef PYTHON3 PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ #else PyVarObject_HEAD_INIT(NULL, 0) #endif "wgdb.Query", /*tp_name*/ sizeof(wg_query_ob), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) wg_query_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc) wg_query_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ (reprfunc) wg_query_repr, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ "WhiteDB query object", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ wg_query_getset, /* tp_getset */ }; /** Method table */ static PyMethodDef wgdb_methods[] = { {"attach_database", (PyCFunction) wgdb_attach_database, METH_VARARGS | METH_KEYWORDS, "Connect to a shared memory database. If the database with the "\ "given name does not exist, it is created."}, {"attach_existing_database", (PyCFunction) wgdb_attach_existing_database, METH_VARARGS, "Connect to a shared memory database. Fails if the database with the "\ "given name does not exist."}, {"delete_database", wgdb_delete_database, METH_VARARGS, "Delete a shared memory database."}, {"detach_database", wgdb_detach_database, METH_VARARGS, "Detach from shared memory database."}, {"create_record", wgdb_create_record, METH_VARARGS, "Create a record with given length."}, {"create_raw_record", wgdb_create_raw_record, METH_VARARGS, "Create a record without indexing the fields."}, {"get_first_record", wgdb_get_first_record, METH_VARARGS, "Fetch first record from database."}, {"get_next_record", wgdb_get_next_record, METH_VARARGS, "Fetch next record from database."}, {"get_record_len", wgdb_get_record_len, METH_VARARGS, "Get record length (number of fields)."}, {"is_record", wgdb_is_record, METH_VARARGS, "Determine if object is a WhiteDB record."}, {"delete_record", wgdb_delete_record, METH_VARARGS, "Delete a record."}, {"set_field", (PyCFunction) wgdb_set_field, METH_VARARGS | METH_KEYWORDS, "Set field value."}, {"set_new_field", (PyCFunction) wgdb_set_new_field, METH_VARARGS | METH_KEYWORDS, "Set field value (assumes no previous content)."}, {"get_field", wgdb_get_field, METH_VARARGS, "Get field data decoded to corresponding Python type."}, {"start_write", wgdb_start_write, METH_VARARGS, "Start writing transaction."}, {"end_write", wgdb_end_write, METH_VARARGS, "Finish writing transaction."}, {"start_read", wgdb_start_read, METH_VARARGS, "Start reading transaction."}, {"end_read", wgdb_end_read, METH_VARARGS, "Finish reading transaction."}, {"make_query", (PyCFunction) wgdb_make_query, METH_VARARGS | METH_KEYWORDS, "Create a query object."}, {"fetch", wgdb_fetch, METH_VARARGS, "Fetch next record from a query."}, {"free_query", wgdb_free_query, METH_VARARGS, "Unallocates the memory (local and shared) used by the query."}, {NULL, NULL, 0, NULL} /* terminator */ }; #ifdef PYTHON3 static struct PyModuleDef wgdb_def = { PyModuleDef_HEAD_INIT, "wgdb", /* name of module */ "WhiteDB database adapter", /* module documentation, may be NULL */ sizeof(struct module_state), /* size of per-interpreter state */ wgdb_methods }; #endif /* ============== Functions ============== */ /* Wrapped wgdb API * uses wg_database_type object to store the database pointer * when making calls from python. This type is not available * generally (using non-restricted values for the pointer * would cause segfaults), only by calling wgdb_attach_database(). */ /* Functions for attaching and deleting */ /** Attach to memory database. * Python wrapper to wg_attach_database() and wg_attach_local_database() */ static PyObject * wgdb_attach_database(PyObject *self, PyObject *args, PyObject *kwds) { wg_database *db; char *shmname = NULL; wg_int sz = 0; wg_int local = 0; static char *kwlist[] = {"shmname", "size", "local", NULL}; if(!PyArg_ParseTupleAndKeywords(args, kwds, "|snn", kwlist, &shmname, &sz, &local)) return NULL; db = (wg_database *) wg_database_type.tp_alloc(&wg_database_type, 0); if(!db) return NULL; /* Now try to actually connect. Note that this may create * a new database if none is found with a matching name. In case of * a local database, a new one is allocated every time. */ if(!local) db->db = (void *) wg_attach_database(shmname, sz); else db->db = (void *) wg_attach_local_database(sz); if(!db->db) { wgdb_error_setstring(self, "Failed to attach to database."); wg_database_type.tp_free(db); return NULL; } db->local = local; /* Py_INCREF(db);*/ /* XXX: not needed? if we increment here, the object is never freed, even if it's unused */ return (PyObject *) db; } /** Attach to memory database. * Python wrapper to wg_attach_existing_database() */ static PyObject *wgdb_attach_existing_database(PyObject *self, PyObject *args) { wg_database *db; char *shmname = NULL; if(!PyArg_ParseTuple(args, "|s", &shmname)) return NULL; db = (wg_database *) wg_database_type.tp_alloc(&wg_database_type, 0); if(!db) return NULL; /* Try to attach to an existing database. Fails if a database * with a matching name is not found. Only applies to shared * memory databases. */ db->db = (void *) wg_attach_existing_database(shmname); if(!db->db) { wgdb_error_setstring(self, "Failed to attach to database."); wg_database_type.tp_free(db); return NULL; } db->local = 0; /* Py_INCREF(db);*/ /* XXX: not needed? if we increment here, the object is never freed, even if it's unused */ return (PyObject *) db; } /** Delete memory database. * Python wrapper to wg_delete_database() */ static PyObject * wgdb_delete_database(PyObject *self, PyObject *args) { char *shmname = NULL; int err = 0; if(!PyArg_ParseTuple(args, "|s", &shmname)) return NULL; err = wg_delete_database(shmname); if(err) { wgdb_error_setstring(self, "Failed to delete the database."); return NULL; } Py_INCREF(Py_None); return Py_None; } /** Detach from memory database. * Python wrapper to wg_detach_database() * Detaching is generally SysV-specific (so under Win32 this * is currently a no-op). * In case of a local database, wg_delete_local_database() is * called instead. */ static PyObject * wgdb_detach_database(PyObject *self, PyObject *args) { PyObject *db = NULL; if(!PyArg_ParseTuple(args, "O!", &wg_database_type, &db)) return NULL; /* Only try detaching if we have a valid pointer. */ if(((wg_database *) db)->db) { if(((wg_database *) db)->local) { /* Local database should be deleted instead */ wg_delete_local_database(((wg_database *) db)->db); } else if(wg_detach_database(((wg_database *) db)->db) < 0) { wgdb_error_setstring(self, "Failed to detach from database."); return NULL; } ((wg_database *) db)->db = NULL; /* mark as detached */ } Py_INCREF(Py_None); return Py_None; } /* Functions to manipulate records. The record is also * represented as a custom type to avoid dealing with word * size issues on different platforms. So the type is essentially * a container for the record pointer. */ /** Create a record with given length. * Python wrapper to wg_create_record() */ static PyObject * wgdb_create_record(PyObject *self, PyObject *args) { PyObject *db = NULL; wg_int length = 0; wg_record *rec; if(!PyArg_ParseTuple(args, "O!n", &wg_database_type, &db, &length)) return NULL; /* Build a new record object */ rec = (wg_record *) wg_record_type.tp_alloc(&wg_record_type, 0); if(!rec) return NULL; rec->rec = wg_create_record(((wg_database *) db)->db, length); if(!rec->rec) { wgdb_error_setstring(self, "Failed to create a record."); wg_record_type.tp_free(rec); return NULL; } /* Py_INCREF(rec);*/ /* XXX: not needed? */ return (PyObject *) rec; } /** Create a record without indexing the fields. * Python wrapper to wg_create_raw_record() */ static PyObject * wgdb_create_raw_record(PyObject *self, PyObject *args) { PyObject *db = NULL; wg_int length = 0; wg_record *rec; if(!PyArg_ParseTuple(args, "O!n", &wg_database_type, &db, &length)) return NULL; /* Build a new record object */ rec = (wg_record *) wg_record_type.tp_alloc(&wg_record_type, 0); if(!rec) return NULL; rec->rec = wg_create_raw_record(((wg_database *) db)->db, length); if(!rec->rec) { wgdb_error_setstring(self, "Failed to create a record."); wg_record_type.tp_free(rec); return NULL; } return (PyObject *) rec; } /** Fetch first record from database. * Python wrapper to wg_get_first_record() */ static PyObject * wgdb_get_first_record(PyObject *self, PyObject *args) { PyObject *db = NULL; wg_record *rec; if(!PyArg_ParseTuple(args, "O!", &wg_database_type, &db)) return NULL; /* Build a new record object */ rec = (wg_record *) wg_record_type.tp_alloc(&wg_record_type, 0); if(!rec) return NULL; rec->rec = wg_get_first_record(((wg_database *) db)->db); if(!rec->rec) { wgdb_error_setstring(self, "Failed to fetch a record."); wg_record_type.tp_free(rec); return NULL; } Py_INCREF(rec); return (PyObject *) rec; } /** Fetch next record from database. * Python wrapper to wg_get_next_record() */ static PyObject * wgdb_get_next_record(PyObject *self, PyObject *args) { PyObject *db = NULL, *prev = NULL; wg_record *rec; if(!PyArg_ParseTuple(args, "O!O!", &wg_database_type, &db, &wg_record_type, &prev)) return NULL; /* Build a new record object */ rec = (wg_record *) wg_record_type.tp_alloc(&wg_record_type, 0); if(!rec) return NULL; rec->rec = wg_get_next_record(((wg_database *) db)->db, ((wg_record *) prev)->rec); if(!rec->rec) { wgdb_error_setstring(self, "Failed to fetch a record."); wg_record_type.tp_free(rec); return NULL; } Py_INCREF(rec); return (PyObject *) rec; } /** Get record length (number of fields). * Python wrapper to wg_get_record_len() */ static PyObject * wgdb_get_record_len(PyObject *self, PyObject *args) { PyObject *db = NULL, *rec = NULL; wg_int len = 0; if(!PyArg_ParseTuple(args, "O!O!", &wg_database_type, &db, &wg_record_type, &rec)) return NULL; len = wg_get_record_len(((wg_database *) db)->db, ((wg_record *) rec)->rec); if(len < 0) { wgdb_error_setstring(self, "Failed to get the record length."); return NULL; } return Py_BuildValue("i", (int) len); } /** Determine, if object is a record * Instead of exposing the record type directly as wgdb.Record, * we provide this function. The reason is that we do not want * these objects to be instantiated from Python, as such instances * would have no valid record pointer to the memory database. */ static PyObject * wgdb_is_record(PyObject *self, PyObject *args) { PyObject *ob = NULL; if(!PyArg_ParseTuple(args, "O", &ob)) return NULL; if(PyObject_TypeCheck(ob, &wg_record_type)) return Py_BuildValue("i", 1); else return Py_BuildValue("i", 0); } /** Delete record. * Python wrapper to wg_delete_record() */ static PyObject * wgdb_delete_record(PyObject *self, PyObject *args) { PyObject *db = NULL, *rec = NULL; wg_int err = 0; if(!PyArg_ParseTuple(args, "O!O!", &wg_database_type, &db, &wg_record_type, &rec)) return NULL; err = wg_delete_record(((wg_database *) db)->db, ((wg_record *) rec)->rec); if(err == -1) { wgdb_error_setstring(self, "Record has references."); return NULL; } else if(err < -1) { wgdb_error_setstring(self, "Failed to delete record."); return NULL; } Py_INCREF(Py_None); return Py_None; } /* Functions to manipulate field contents. * * Storing data: the Python object is first converted to an appropriate * C data. Then wg_encode_*() is used to convert it to WhiteDB encoded * field data (possibly storing the actual data in the database, if the * object itself is hashed or does not fit in a field). The encoded data * is then stored with wg_set_field() or wg_set_new_field() as appropriate. * * Reading data: encoded field data is read using wg_get_field() and * examined to determine the type. If the type is recognized, the data * is converted to appropriate C data using wg_decode_*() family of * functions and finally to a Python object. */ /** Determine matching wgdb type of a Python object. * ftype argument is a type hint in some cases where there's * ambiguity due to multiple matching wgdb types. * * returns -1 if the type is known, but the type hint is invalid. * returns -2 if type is not recognized */ static wg_int pytype_to_wgtype(PyObject *data, wg_int ftype) { if(data==Py_None) { if(!ftype) return WG_NULLTYPE; else if(ftype!=WG_NULLTYPE) return -1; } #ifndef PYTHON3 else if(PyInt_Check(data)) { #else else if(PyLong_Check(data)) { #endif if(!ftype) return WG_INTTYPE; else if(ftype!=WG_INTTYPE && ftype!=WG_VARTYPE) return -1; } else if(PyFloat_Check(data)) { if(!ftype) return WG_DOUBLETYPE; else if(ftype!=WG_DOUBLETYPE && ftype!=WG_FIXPOINTTYPE) return -1; } #ifndef PYTHON3 else if(PyString_Check(data)) { #else else if(PyUnicode_Check(data)) { #endif if(!ftype) return WG_STRTYPE; else if(ftype!=WG_STRTYPE && ftype!=WG_CHARTYPE &&\ ftype!=WG_URITYPE && ftype!=WG_XMLLITERALTYPE) return -1; } else if(PyObject_TypeCheck(data, &wg_record_type)) { if(!ftype) return WG_RECORDTYPE; else if(ftype!=WG_RECORDTYPE) return -1; } else if(PyDate_Check(data)) { if(!ftype) return WG_DATETYPE; else if(ftype!=WG_DATETYPE) return -1; } else if(PyTime_Check(data)) { if(!ftype) return WG_TIMETYPE; else if(ftype!=WG_TIMETYPE) return -1; } else /* Nothing matched */ return -2; /* User-selected type was suitable */ return ftype; } /** Encode an atomic value of type WG_NULLTYPE * Always succeeds. */ static wg_int encode_pyobject_null(wg_database *db) { return wg_encode_null(db->db, 0); } /** Encode an atomic value of type WG_RECORDTYPE * returns WG_ILLEGAL on failure */ static wg_int encode_pyobject_record(wg_database *db, PyObject *data) { return wg_encode_record(db->db, ((wg_record *) data)->rec); } /** Encode an atomic value of type WG_INTTYPE * returns WG_ILLEGAL on failure * if param is 1, the storage will be allocated in local memory (intended * for encoding query parameters without write locking) */ static wg_int encode_pyobject_int(wg_database *db, PyObject *data, int param) { wg_int intdata; #ifndef PYTHON3 intdata = (wg_int) PyInt_AsLong(data); #else intdata = (wg_int) PyLong_AsLong(data); #endif if(!param) { return wg_encode_int(db->db, intdata); } else { return wg_encode_query_param_int(db->db, intdata); } } /** Encode an atomic value of type WG_DOUBLETYPE * returns WG_ILLEGAL on failure * if param is 1, the storage will be allocated in local memory (intended * for encoding query parameters without write locking) */ static wg_int encode_pyobject_double(wg_database *db, PyObject *data, int param) { if(!param) { return wg_encode_double(db->db, (double) PyFloat_AsDouble(data)); } else { return wg_encode_query_param_double(db->db, (double) PyFloat_AsDouble(data)); } } /** Encode an atomic value of type WG_STRTYPE * returns WG_ILLEGAL on failure * if param is 1, the storage will be allocated in local memory (intended * for encoding query parameters without write locking) */ static wg_int encode_pyobject_str(wg_database *db, PyObject *data, char *ext_str, int param) { char *s; #ifndef PYTHON3 s = PyString_AsString(data); #elif defined(HAVE_LOCALEENC) s = PyBytes_AsString(PyUnicode_EncodeLocale(data, ENCODEERR)); #else s = PyBytes_AsString(PyUnicode_AsEncodedString(data, NULL, ENCODEERR)); #endif /* wg_encode_str is not guaranteed to check for NULL pointer */ if(s) { if(!param) { return wg_encode_str(db->db, s, ext_str); } else { return wg_encode_query_param_str(db->db, s, ext_str); } } else { return WG_ILLEGAL; } } /** Encode an atomic value of type WG_URITYPE * returns WG_ILLEGAL on failure * if param is 1, the storage will be allocated in local memory (intended * for encoding query parameters without write locking) */ static wg_int encode_pyobject_uri(wg_database *db, PyObject *data, char *ext_str, int param) { char *s; #ifndef PYTHON3 s = PyString_AsString(data); #elif defined(HAVE_LOCALEENC) s = PyBytes_AsString(PyUnicode_EncodeLocale(data, ENCODEERR)); #else s = PyBytes_AsString(PyUnicode_AsEncodedString(data, NULL, ENCODEERR)); #endif /* wg_encode_str is not guaranteed to check for NULL pointer */ if(s) { if(!param) { return wg_encode_uri(db->db, s, ext_str); } else { return wg_encode_query_param_uri(db->db, s, ext_str); } } else { return WG_ILLEGAL; } } /** Encode an atomic value of type WG_XMLLITERALTYPE * returns WG_ILLEGAL on failure * if param is 1, the storage will be allocated in local memory (intended * for encoding query parameters without write locking) */ static wg_int encode_pyobject_xmlliteral(wg_database *db, PyObject *data, char *ext_str, int param) { char *s; #ifndef PYTHON3 s = PyString_AsString(data); #elif defined(HAVE_LOCALEENC) s = PyBytes_AsString(PyUnicode_EncodeLocale(data, ENCODEERR)); #else s = PyBytes_AsString(PyUnicode_AsEncodedString(data, NULL, ENCODEERR)); #endif /* wg_encode_str is not guaranteed to check for NULL pointer */ if(s) { if(!param) { return wg_encode_xmlliteral(db->db, s, ext_str); } else { return wg_encode_query_param_xmlliteral(db->db, s, ext_str); } } else { return WG_ILLEGAL; } } /** Encode an atomic value of type WG_CHARTYPE * returns WG_ILLEGAL on failure * if param is 1, value is encoded as a query parameter. */ static wg_int encode_pyobject_char(wg_database *db, PyObject *data, int param) { char *s; #ifndef PYTHON3 s = PyString_AsString(data); #elif defined(HAVE_LOCALEENC) s = PyBytes_AsString(PyUnicode_EncodeLocale(data, ENCODEERR)); #else s = PyBytes_AsString(PyUnicode_AsEncodedString(data, NULL, ENCODEERR)); #endif /* wg_encode_str is not guaranteed to check for NULL pointer */ if(s) { if(!param) { return wg_encode_char(db->db, s[0]); } else { return wg_encode_query_param_char(db->db, s[0]); } } else { return WG_ILLEGAL; } } /** Encode an atomic value of type WG_FIXPOINTTYPE * returns WG_ILLEGAL on failure * if param is 1, value is encoded as a query parameter. */ static wg_int encode_pyobject_fixpoint(wg_database *db, PyObject *data, int param) { if(!param) { return wg_encode_fixpoint(db->db, (double) PyFloat_AsDouble(data)); } else { return wg_encode_query_param_fixpoint(db->db, (double) PyFloat_AsDouble(data)); } } /** Encode an atomic value of type WG_DATETYPE * returns WG_ILLEGAL on failure * if param is 1, value is encoded as a query parameter. */ static wg_int encode_pyobject_date(wg_database *db, PyObject *data, int param) { int datedata = wg_ymd_to_date(db->db, PyDateTime_GET_YEAR(data), PyDateTime_GET_MONTH(data), PyDateTime_GET_DAY(data)); if(datedata > 0) { if(!param) { return wg_encode_date(db->db, datedata); } else { return wg_encode_query_param_date(db->db, datedata); } } else { return WG_ILLEGAL; } } /** Encode an atomic value of type WG_TIMETYPE * returns WG_ILLEGAL on failure * if param is 1, value is encoded as a query parameter. */ static wg_int encode_pyobject_time(wg_database *db, PyObject *data, int param) { int timedata = wg_hms_to_time(db->db, PyDateTime_TIME_GET_HOUR(data), PyDateTime_TIME_GET_MINUTE(data), PyDateTime_TIME_GET_SECOND(data), PyDateTime_TIME_GET_MICROSECOND(data)/10000); if(timedata >= 0) { if(!param) { return wg_encode_time(db->db, timedata); } else { return wg_encode_query_param_time(db->db, timedata); } } else { return WG_ILLEGAL; } } /** Encode an atomic value of type WG_VARTYPE * returns WG_ILLEGAL on failure * if param is 1, value is encoded as a query parameter. */ static wg_int encode_pyobject_var(wg_database *db, PyObject *data, int param) { int intdata; #ifndef PYTHON3 intdata = (int) PyInt_AsLong(data); #else intdata = (int) PyLong_AsLong(data); #endif if(!param) { return wg_encode_var(db->db, intdata); } else { return wg_encode_query_param_var(db->db, intdata); } } /** Encode Python object as wgdb value of specific type. * returns WG_ILLEGAL if the conversion is not possible. The * database API may also return WG_ILLEGAL. */ static wg_int encode_pyobject(wg_database *db, PyObject *data, wg_int ftype, char *ext_str, int param) { switch(ftype) { case WG_NULLTYPE: return encode_pyobject_null(db); case WG_RECORDTYPE: return encode_pyobject_record(db, data); case WG_INTTYPE: return encode_pyobject_int(db, data, param); case WG_DOUBLETYPE: return encode_pyobject_double(db, data, param); case WG_STRTYPE: return encode_pyobject_str(db, data, ext_str, param); case WG_URITYPE: return encode_pyobject_uri(db, data, ext_str, param); case WG_XMLLITERALTYPE: return encode_pyobject_xmlliteral(db, data, ext_str, param); case WG_CHARTYPE: return encode_pyobject_char(db, data, param); case WG_FIXPOINTTYPE: return encode_pyobject_fixpoint(db, data, param); case WG_DATETYPE: return encode_pyobject_date(db, data, param); case WG_TIMETYPE: return encode_pyobject_time(db, data, param); case WG_VARTYPE: return encode_pyobject_var(db, data, param); default: break; } /* Handle unknown type */ return WG_ILLEGAL; } /** Encode Python object as wgdb value * The object may be an immediate value or a tuple containing * extended type information. * * Conversion rules: * Immediate Python value -> use the default wgdb type * (value, ftype) -> use the provided field type (if possible) * (value, ftype, ext_str) -> use the field type and extra string */ static wg_int encode_pyobject_ext(PyObject *self, wg_database *db, PyObject *obj, int param) { PyObject *data; wg_int enc, ftype = 0; char *ext_str = NULL; if(PyTuple_Check(obj)) { /* Extended value. */ int extargs = PyTuple_Size(obj); if(extargs<1 || extargs>3) { PyErr_SetString(PyExc_ValueError, "Values with extended type info must be 2/3-tuples."); return WG_ILLEGAL; } data = PyTuple_GetItem(obj, 0); if(extargs > 1) { #ifndef PYTHON3 ftype = (wg_int) PyInt_AsLong(PyTuple_GetItem(obj, 1)); #else ftype = (wg_int) PyLong_AsLong(PyTuple_GetItem(obj, 1)); #endif if(ftype<0) { PyErr_SetString(PyExc_ValueError, "Invalid field type for value."); return WG_ILLEGAL; } } if(extargs > 2) { #ifndef PYTHON3 ext_str = PyString_AsString(PyTuple_GetItem(obj, 2)); #elif defined(HAVE_LOCALEENC) ext_str = PyBytes_AsString( PyUnicode_EncodeLocale(PyTuple_GetItem(obj, 2), ENCODEERR)); #else ext_str = PyBytes_AsString( PyUnicode_AsEncodedString(PyTuple_GetItem(obj, 2), NULL, ENCODEERR)); #endif if(!ext_str) { /* Error has been set in conversion */ return WG_ILLEGAL; } } } else { data = obj; } /* Now do the actual conversion. */ ftype = pytype_to_wgtype(data, ftype); if(ftype == -1) { PyErr_SetString(PyExc_TypeError, "Requested encoding is not supported."); return WG_ILLEGAL; } else if(ftype == -2) { PyErr_SetString(PyExc_TypeError, "Value is of unsupported type."); return WG_ILLEGAL; } /* Now encode the given obj using the selected type */ enc = encode_pyobject(db, data, ftype, ext_str, param); if(enc==WG_ILLEGAL) wgdb_error_setstring(self, "Value encoding error."); return enc; } /** Update field data. * Data types supported: * Python None. Translates to WhiteDB NULL (empty) field. * Python integer. * Python float. * Python string. Embedded \0 bytes are not allowed (i.e. \0 is * treated as a standard string terminator). * XXX: add language support for str type? * wgdb.Record object * datetime.date object * datetime.time object */ static PyObject *wgdb_set_field(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *db = NULL, *rec = NULL; wg_int fieldnr, fdata = WG_ILLEGAL, err = 0, ftype = 0; PyObject *data; char *ext_str = NULL; static char *kwlist[] = {"db", "rec", "fieldnr", "data", "encoding", "ext_str", NULL}; if(!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!nO|ns", kwlist, &wg_database_type, &db, &wg_record_type, &rec, &fieldnr, &data, &ftype, &ext_str)) return NULL; /* Determine the argument type. If the optional encoding * argument is not supplied, default encoding for the Python type * of the data is selected. Otherwise the user-provided encoding * is used, with the limitation that the Python type must * be compatible with the encoding. */ ftype = pytype_to_wgtype(data, ftype); if(ftype == -1) { PyErr_SetString(PyExc_TypeError, "Requested encoding is not supported."); return NULL; } else if(ftype == -2) { PyErr_SetString(PyExc_TypeError, "Argument is of unsupported type."); return NULL; } /* Now encode the given data using the selected type */ fdata = encode_pyobject((wg_database *) db, data, ftype, ext_str, 0); if(fdata==WG_ILLEGAL) { wgdb_error_setstring(self, "Field data conversion error."); return NULL; } /* Store the encoded field data in the record */ err = wg_set_field(((wg_database *) db)->db, ((wg_record *) rec)->rec, fieldnr, fdata); if(err < 0) { wgdb_error_setstring(self, "Failed to set field value."); return NULL; } Py_INCREF(Py_None); return Py_None; } /** Set field data (assumes no previous content) * Skips some bookkeeping related to the previous field * contents, making the insert faster. Using it on fields * that have previous content is likely to corrupt the database. * Otherwise identical to set_field(). */ static PyObject *wgdb_set_new_field(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *db = NULL, *rec = NULL; wg_int fieldnr, fdata = WG_ILLEGAL, err = 0, ftype = 0; PyObject *data; char *ext_str = NULL; static char *kwlist[] = {"db", "rec", "fieldnr", "data", "encoding", "ext_str", NULL}; if(!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!nO|ns", kwlist, &wg_database_type, &db, &wg_record_type, &rec, &fieldnr, &data, &ftype, &ext_str)) return NULL; ftype = pytype_to_wgtype(data, ftype); if(ftype == -1) { PyErr_SetString(PyExc_TypeError, "Requested encoding is not supported."); return NULL; } else if(ftype == -2) { PyErr_SetString(PyExc_TypeError, "Argument is of unsupported type."); return NULL; } fdata = encode_pyobject((wg_database *) db, data, ftype, ext_str, 0); if(fdata==WG_ILLEGAL) { wgdb_error_setstring(self, "Field data conversion error."); return NULL; } err = wg_set_new_field(((wg_database *) db)->db, ((wg_record *) rec)->rec, fieldnr, fdata); if(err < 0) { wgdb_error_setstring(self, "Failed to set field value."); return NULL; } Py_INCREF(Py_None); return Py_None; } /** Get decoded field value. * Currently supported types: * NULL - Python None * record - wgdb.Record * int - Python int * double - Python float * string - Python string * char - Python string * fixpoint - Python float * date - datetime.date * time - datetime.time */ static PyObject *wgdb_get_field(PyObject *self, PyObject *args) { PyObject *db = NULL, *rec = NULL; wg_int fieldnr, fdata, ftype; if(!PyArg_ParseTuple(args, "O!O!n", &wg_database_type, &db, &wg_record_type, &rec, &fieldnr)) return NULL; /* First retrieve the field data. The information about * the field type is encoded inside the field. */ fdata = wg_get_field(((wg_database *) db)->db, ((wg_record *) rec)->rec, fieldnr); if(fdata==WG_ILLEGAL) { wgdb_error_setstring(self, "Failed to get field data."); return NULL; } /* Decode the type */ ftype = wg_get_encoded_type(((wg_database *) db)->db, fdata); if(!ftype) { wgdb_error_setstring(self, "Failed to get field type."); return NULL; } /* Decode (or retrieve) the actual data */ if(ftype==WG_NULLTYPE) { Py_INCREF(Py_None); return Py_None; } else if(ftype==WG_RECORDTYPE) { wg_record *ddata = (wg_record *) wg_record_type.tp_alloc( &wg_record_type, 0); if(!ddata) return NULL; ddata->rec = wg_decode_record(((wg_database *) db)->db, fdata); if(!ddata->rec) { wgdb_error_setstring(self, "Failed to fetch a record."); wg_record_type.tp_free(ddata); return NULL; } Py_INCREF(ddata); return (PyObject *) ddata; } else if(ftype==WG_INTTYPE) { wg_int ddata = wg_decode_int(((wg_database *) db)->db, fdata); return Py_BuildValue("n", ddata); } else if(ftype==WG_DOUBLETYPE) { double ddata = wg_decode_double(((wg_database *) db)->db, fdata); return Py_BuildValue("d", ddata); } else if(ftype==WG_STRTYPE) { char *ddata = wg_decode_str(((wg_database *) db)->db, fdata); /* Data is copied here, no leaking */ return Py_BuildValue("s", ddata); } else if(ftype==WG_URITYPE) { char *ddata = wg_decode_uri(((wg_database *) db)->db, fdata); char *ext_str = wg_decode_uri_prefix(((wg_database *) db)->db, fdata); if(ext_str) { #ifndef PYTHON3 return PyString_FromFormat("%s%s", ext_str, ddata); #else return PyUnicode_FromFormat("%s%s", ext_str, ddata); #endif } else return Py_BuildValue("s", ddata); } else if(ftype==WG_XMLLITERALTYPE) { char *ddata = wg_decode_xmlliteral(((wg_database *) db)->db, fdata); return Py_BuildValue("s", ddata); } else if(ftype==WG_CHARTYPE) { char ddata[2]; ddata[0] = wg_decode_char(((wg_database *) db)->db, fdata); ddata[1] = '\0'; return Py_BuildValue("s", ddata); /* treat as single-character string */ } else if(ftype==WG_FIXPOINTTYPE) { double ddata = wg_decode_fixpoint(((wg_database *) db)->db, fdata); return Py_BuildValue("d", ddata); } else if(ftype==WG_DATETYPE) { int year, month, day; int datedata = wg_decode_date(((wg_database *) db)->db, fdata); if(!datedata) { wgdb_error_setstring(self, "Failed to decode date."); return NULL; } wg_date_to_ymd(((wg_database *) db)->db, datedata, &year, &month, &day); return PyDate_FromDate(year, month, day); } else if(ftype==WG_TIMETYPE) { int hour, minute, second, fraction; int timedata = wg_decode_time(((wg_database *) db)->db, fdata); /* 0 is both a valid time of 00:00:00.00 and an error. So the * latter case is ignored here. */ wg_time_to_hms(((wg_database *) db)->db, timedata, &hour, &minute, &second, &fraction); return PyTime_FromTime(hour, minute, second, fraction*10000); } else if(ftype==WG_VARTYPE) { /* XXX: returns something that, if written back to database * unaltered, will result in the database field actually containing * the same variable. The literal value in Python is not very meaningful, * however this approach preserves consistency in handling the type * conversions. */ int ddata = wg_decode_var(((wg_database *) db)->db, fdata); return Py_BuildValue("(i,i)", ddata, WG_VARTYPE); } else { char buf[80]; snprintf(buf, 80, "Cannot handle field type %d.", (int) ftype); wgdb_error_setstring(self, buf); return NULL; } } /* * Functions to handle transactions. Logical level of * concurrency control with wg_start_write() and friends * is implemented here. In the simplest case, these functions * internally map to physical locking and unlocking, however they * should not be relied upon to do so. */ /** Start a writing transaction * Python wrapper to wg_start_write() * Returns lock id when successful, otherwise raises an exception. */ static PyObject * wgdb_start_write(PyObject *self, PyObject *args) { PyObject *db = NULL; wg_int lock_id = 0; if(!PyArg_ParseTuple(args, "O!", &wg_database_type, &db)) return NULL; lock_id = wg_start_write(((wg_database *) db)->db); if(!lock_id) { wgdb_error_setstring(self, "Failed to acquire write lock."); return NULL; } return Py_BuildValue("i", (int) lock_id); } /** Finish a writing transaction * Python wrapper to wg_end_write() * Returns None when successful, otherwise raises an exception. */ static PyObject * wgdb_end_write(PyObject *self, PyObject *args) { PyObject *db = NULL; wg_int lock_id = 0; if(!PyArg_ParseTuple(args, "O!n", &wg_database_type, &db, &lock_id)) return NULL; if(!wg_end_write(((wg_database *) db)->db, lock_id)) { wgdb_error_setstring(self, "Failed to release write lock."); return NULL; } Py_INCREF(Py_None); return Py_None; } /** Start a reading transaction * Python wrapper to wg_start_read() * Returns lock id when successful, otherwise raises an exception. */ static PyObject * wgdb_start_read(PyObject *self, PyObject *args) { PyObject *db = NULL; wg_int lock_id = 0; if(!PyArg_ParseTuple(args, "O!", &wg_database_type, &db)) return NULL; lock_id = wg_start_read(((wg_database *) db)->db); if(!lock_id) { wgdb_error_setstring(self, "Failed to acquire read lock."); return NULL; } return Py_BuildValue("i", (int) lock_id); } /** Finish a reading transaction * Python wrapper to wg_end_read() * Returns None when successful, otherwise raises an exception. */ static PyObject * wgdb_end_read(PyObject *self, PyObject *args) { PyObject *db = NULL; wg_int lock_id = 0; if(!PyArg_ParseTuple(args, "O!n", &wg_database_type, &db, &lock_id)) return NULL; if(!wg_end_read(((wg_database *) db)->db, lock_id)) { wgdb_error_setstring(self, "Failed to release read lock."); return NULL; } Py_INCREF(Py_None); return Py_None; } /* Functions to create and fetch data from queries. * The query object defined on wgdb module level stores both * the pointer to the query and all the encoded parameters - * since the parameters use database side storage, they * should preferrably be freed after the query is finished. */ /** Parse query arguments. * Creates wgdb query arglist and matchrec. */ static int parse_query_params(PyObject *self, PyObject *args, PyObject *kwds, wg_query_ob *query) { PyObject *db = NULL; PyObject *arglist = NULL; PyObject *matchrec = NULL; static char *kwlist[] = {"db", "matchrec", "arglist", NULL}; if(!PyArg_ParseTupleAndKeywords(args, kwds, "O!|OO", kwlist, &wg_database_type, &db, &matchrec, &arglist)) return 0; Py_INCREF(db); /* Make sure we don't lose database connection */ query->db = (wg_database *) db; /* Determine type of arglist */ query->argc = 0; if(arglist && arglist!=Py_None) { int len, i; if(!PySequence_Check(arglist)) { PyErr_SetString(PyExc_TypeError, "Query arglist must be a sequence."); return 0; } len = (int) PySequence_Size(arglist); /* Argument list was present. Extract the individual arguments. */ if(len > 0) { query->arglist = (wg_query_arg *) malloc(len * sizeof(wg_query_arg)); if(!query->arglist) { wgdb_error_setstring(self, "Failed to allocate memory."); return 0; } memset(query->arglist, 0, len * sizeof(wg_query_arg)); /* Now copy all the parameters. */ for(i=0; idb, PyTuple_GetItem(t, 2), 1); if(enc==WG_ILLEGAL) { /* Error set by encode function */ Py_DECREF(t); return 0; } /* Finally, set the argument fields */ query->arglist[i].column = col; query->arglist[i].cond = cond; query->arglist[i].value = enc; query->argc++; /* We have successfully encoded a parameter. We're * not setting this to len immediately, because * there might be an encoding error and part of * the arguments may be left uninitialized. */ Py_DECREF(t); } } } query->reclen = 0; /* Determine type of matchrec */ if(matchrec && matchrec!=Py_None) { if(PyObject_TypeCheck(matchrec, &wg_record_type)) { /* Database record pointer was given. Pass it directly * to the query. */ query->matchrec = ((wg_record *) matchrec)->rec; } else if(PySequence_Check(matchrec)) { int len = (int) PySequence_Size(matchrec); if(len) { int i; /* Construct the record. */ query->matchrec = malloc(len * sizeof(wg_int)); if(!query->matchrec) { wgdb_error_setstring(self, "Failed to allocate memory."); return 0; } memset(query->matchrec, 0, len * sizeof(wg_int)); for(i=0; idb, sg_t, 1); Py_DECREF(sg_t); if(enc==WG_ILLEGAL) { /* Error set by encode function */ return 0; } ((wg_int *) query->matchrec)[i] = enc; query->reclen++; /* Count the successfully encoded fields. */ } } } else { PyErr_SetString(PyExc_TypeError, "Query match record must be a sequence or a wgdb.Record"); return 0; } } return 1; } /** Create a query object. * Python wrapper to wg_make_query() */ static PyObject * wgdb_make_query(PyObject *self, PyObject *args, PyObject *kwds) { wg_query_ob *query; /* Build a new query object */ query = (wg_query_ob *) wg_query_type.tp_alloc(&wg_query_type, 0); if(!query) return NULL; query->query = NULL; query->db = NULL; query->arglist = NULL; query->argc = 0; query->matchrec = NULL; query->reclen = 0; /* Create the arglist and matchrec from parameters. */ if(!parse_query_params(self, args, kwds, query)) { wg_query_dealloc(query); return NULL; } query->query = wg_make_query(query->db->db, query->matchrec, query->reclen, query->arglist, query->argc); if(!query->query) { wgdb_error_setstring(self, "Failed to create the query."); /* Call destructor. It should take care of all the allocated memory. */ wg_query_dealloc(query); return NULL; } return (PyObject *) query; } /** Fetch next row from a query. * Python wrapper for wg_fetch() */ static PyObject * wgdb_fetch(PyObject *self, PyObject *args) { PyObject *db = NULL, *query = NULL; wg_record *rec; if(!PyArg_ParseTuple(args, "O!O!", &wg_database_type, &db, &wg_query_type, &query)) return NULL; /* Build a new record object */ rec = (wg_record *) wg_record_type.tp_alloc(&wg_record_type, 0); if(!rec) return NULL; rec->rec = wg_fetch(((wg_database *) db)->db, ((wg_query_ob *) query)->query); if(!rec->rec) { wgdb_error_setstring(self, "Failed to fetch a record."); wg_record_type.tp_free(rec); return NULL; } Py_INCREF(rec); return (PyObject *) rec; } /** Free query. * Python wrapper to wg_free_query() * In addition, this function frees the local memory for * the arguments and attempts to free database-side encoded data. */ static PyObject * wgdb_free_query(PyObject *self, PyObject *args) { PyObject *db = NULL, *query = NULL; if(!PyArg_ParseTuple(args, "O!O!", &wg_database_type, &db, &wg_query_type, &query)) return NULL; /* XXX: since the query contains the db pointer, ignore * the database object we were given (it is still required * for consistency between the API-s and possible future * extensions). */ free_query((wg_query_ob *) query); Py_INCREF(Py_None); return Py_None; } /** Helper function to free local query memory * (wg_query_ob *) query->db field is used as a marker * (set to NULL for queries that do not need deallocating). */ static void free_query(wg_query_ob *obj) { if(obj->db) { #if 0 /* Suppress the warning if we use local parameters */ if(!obj->db->db) { fprintf(stderr, "Warning: database connection lost before freeing encoded data\n"); } #endif /* Allow freeing the query object. * XXX: this is hacky. db pointer may become significant * in the future, which makes this a timebomb. */ if(obj->query) wg_free_query(obj->db->db, obj->query); if(obj->arglist) { if(obj->db->db) { int i; for(i=0; iargc; i++) wg_free_query_param(obj->db->db, obj->arglist[i].value); } free(obj->arglist); } if(obj->matchrec && obj->reclen) { if(obj->db->db) { int i; for(i=0; ireclen; i++) wg_free_query_param(obj->db->db, ((wg_int *) obj->matchrec)[i]); } free(obj->matchrec); } Py_DECREF(obj->db); obj->db = NULL; } } /* Methods for data types defined by this module. */ /** Database object desctructor. * Detaches from shared memory or frees local memory. */ static void wg_database_dealloc(wg_database *obj) { if(obj->db) { if(obj->local) wg_delete_local_database(obj->db); else wg_detach_database(obj->db); } #ifndef PYTHON3 obj->ob_type->tp_free((PyObject *) obj); #else Py_TYPE(obj)->tp_free((PyObject *) obj); #endif } /** Query object desctructor. * Frees query and encoded query parameters. */ static void wg_query_dealloc(wg_query_ob *obj) { free_query(obj); #ifndef PYTHON3 obj->ob_type->tp_free((PyObject *) obj); #else Py_TYPE(obj)->tp_free((PyObject *) obj); #endif } /** String representation of database object. This is used for both * repr() and str() */ static PyObject *wg_database_repr(wg_database * obj) { /* XXX: this is incompatible with eval(). If a need to * eval() such representations should arise, new initialization * function is also needed for the type. */ #ifndef PYTHON3 return PyString_FromFormat("", (void *) obj->db); #else return PyUnicode_FromFormat("", (void *) obj->db); #endif } /** String representation of record object. This is used for both * repr() and str() */ static PyObject *wg_record_repr(wg_record * obj) { /* XXX: incompatible with eval(). */ #ifndef PYTHON3 return PyString_FromFormat("", (void *) obj->rec); #else return PyUnicode_FromFormat("", (void *) obj->rec); #endif } /** String representation of query object. Used for both repr() and str() */ static PyObject *wg_query_repr(wg_query_ob *obj) { /* XXX: incompatible with eval(). */ #ifndef PYTHON3 return PyString_FromFormat("", (void *) obj->query); #else return PyUnicode_FromFormat("", (void *) obj->query); #endif } /** Get the number of rows in a query result */ static PyObject *wg_query_get_res_count(wg_query_ob *obj, void *closure) { if(obj->query) { if(obj->query->qtype == WG_QTYPE_PREFETCH) { return Py_BuildValue("K", (unsigned PY_LONG_LONG) obj->query->res_count); } else { return Py_None; } } else { PyErr_SetString(PyExc_ValueError, "Invalid query object"); return NULL; } return Py_None; /* satisfy the compiler */ } /** Set the number of rows in a query result (not allowed) */ static int wg_query_set_res_count(wg_query_ob *obj, PyObject *value, void *closure) { PyErr_SetString(PyExc_AttributeError, "res_count is a read only attribute"); return -1; } /** Set module exception. * */ static void wgdb_error_setstring(PyObject *self, char *err) { #ifndef PYTHON3 struct module_state *st = &_state; #else struct module_state *st = (struct module_state *) PyModule_GetState(self); #endif PyErr_SetString(st->wgdb_error, err); } /** Initialize module. * Standard entry point for Python extension modules, executed * during import. */ #ifdef PYTHON3 #define INITERROR return NULL; #else #define INITERROR return; #endif #ifndef PYTHON3 PyMODINIT_FUNC initwgdb(void) #else PyMODINIT_FUNC PyInit_wgdb(void) #endif { PyObject *m; struct module_state *st; wg_database_type.tp_new = PyType_GenericNew; if (PyType_Ready(&wg_database_type) < 0) INITERROR wg_record_type.tp_new = PyType_GenericNew; if (PyType_Ready(&wg_record_type) < 0) INITERROR wg_query_type.tp_new = PyType_GenericNew; if (PyType_Ready(&wg_query_type) < 0) INITERROR #ifndef PYTHON3 m = Py_InitModule3("wgdb", wgdb_methods, "WhiteDB database adapter"); #else m = PyModule_Create(&wgdb_def); #endif if(!m) INITERROR #ifndef PYTHON3 st = &_state; #else st = (struct module_state *) PyModule_GetState(m); #endif st->wgdb_error = PyErr_NewException("wgdb.error", NULL, NULL); Py_INCREF(st->wgdb_error); PyModule_AddObject(m, "error", st->wgdb_error); /* Expose wgdb internal encoding types */ PyModule_AddIntConstant(m, "NULLTYPE", WG_NULLTYPE); PyModule_AddIntConstant(m, "RECORDTYPE", WG_RECORDTYPE); PyModule_AddIntConstant(m, "INTTYPE", WG_INTTYPE); PyModule_AddIntConstant(m, "DOUBLETYPE", WG_DOUBLETYPE); PyModule_AddIntConstant(m, "STRTYPE", WG_STRTYPE); PyModule_AddIntConstant(m, "XMLLITERALTYPE", WG_XMLLITERALTYPE); PyModule_AddIntConstant(m, "URITYPE", WG_URITYPE); PyModule_AddIntConstant(m, "BLOBTYPE", WG_BLOBTYPE); PyModule_AddIntConstant(m, "CHARTYPE", WG_CHARTYPE); PyModule_AddIntConstant(m, "FIXPOINTTYPE", WG_FIXPOINTTYPE); PyModule_AddIntConstant(m, "DATETYPE", WG_DATETYPE); PyModule_AddIntConstant(m, "TIMETYPE", WG_TIMETYPE); PyModule_AddIntConstant(m, "VARTYPE", WG_VARTYPE); /* these types are not implemented yet: PyModule_AddIntConstant(m, "ANONCONSTTYPE", WG_ANONCONSTTYPE); */ /* Expose query conditions */ PyModule_AddIntConstant(m, "COND_EQUAL", WG_COND_EQUAL); PyModule_AddIntConstant(m, "COND_NOT_EQUAL", WG_COND_NOT_EQUAL); PyModule_AddIntConstant(m, "COND_LESSTHAN", WG_COND_LESSTHAN); PyModule_AddIntConstant(m, "COND_GREATER", WG_COND_GREATER); PyModule_AddIntConstant(m, "COND_LTEQUAL", WG_COND_LTEQUAL); PyModule_AddIntConstant(m, "COND_GTEQUAL", WG_COND_GTEQUAL); /* Initialize PyDateTime C API */ PyDateTime_IMPORT; #ifdef PYTHON3 return m; #endif } whitedb-0.7.3/Python/tests.py0000644000175000001440000006775112146112207013075 00000000000000#!/usr/bin/env python # -*- coding: latin-1 -*- # # Copyright (c) Priit Järv 2012,2013 # # This file is part of WhiteDB # # WhiteDB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # WhiteDB is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with WhiteDB. If not, see . """@file tests.py Unit tests for the WhiteDB Python API """ import unittest import wgdb import whitedb import datetime MINDBSIZE=8000000 # should cover 64-bit databases that need more memory class LowLevelTest(unittest.TestCase): """Provide setUp()/tearDown() for test cases that use the low level Python API.""" def setUp(self): self.d = wgdb.attach_database(size=MINDBSIZE, local=1) def tearDown(self): wgdb.detach_database(self.d) class RecordTests(LowLevelTest): """Test low level record functionality""" def test_creation(self): """Tests record creation and low level scanning to retrieve records from the database.""" rec = wgdb.create_record(self.d, 3) self.assertTrue(wgdb.is_record(rec)) l = wgdb.get_record_len(self.d, rec) self.assertEqual(l, 3) rec2 = wgdb.create_raw_record(self.d, 678) self.assertTrue(wgdb.is_record(rec2)) l = wgdb.get_record_len(self.d, rec2) self.assertEqual(l, 678) # wgdb module only allows comparing records by contents # so we need to use recognizable data for this test. wgdb.set_field(self.d, rec, 0, 99531179) wgdb.set_field(self.d, rec2, 0, 55498756) # XXX: the following relies on certain assumptions on memory # management of WhiteDB. By the API description, the records # are not necessarily fetched in order of creation, it is just # useful for the current test case that it happens to be the case. # cand = wgdb.get_first_record(self.d) self.assertEqual(wgdb.get_field(self.d, cand, 0), 99531179) cand = wgdb.get_next_record(self.d, cand) self.assertEqual(wgdb.get_field(self.d, cand, 0), 55498756) # This, however, should always work correctly wgdb.delete_record(self.d, rec) cand = wgdb.get_first_record(self.d) self.assertEqual(wgdb.get_field(self.d, cand, 0), 55498756) def test_field_data(self): """Tests field data encoding and decoding.""" # BLOBTYPE not supported yet #blob = "\045\120\104\106\055\061\056\065\012\045"\ # "\265\355\256\373\012\063\040\060\040\157\142\152\012\074\074"\ # "\040\057\114\145\156\147\164\150\040\064\040\060\040\122\012"\ # "\040\040\040\057\106\151\154\164\145\162\040\057\106\154\141"\ # "\164\145\104\145\143\157\144\145\012\076\076\012\163\164\162"\ # "\145\141\155\012\170\234\255\227\333\152\334\060\020\100\337"\ # "\375\025\372\001\357\152\106\067\013\312\076\024\112\041\120"\ # "\150\132\103\037\102\036\366\032\010\064\064\027\350\357\167"\ # "\106\222\327\326\156\222\125\152\141\144\153\155\315\350\150"\ # "\146\064\243\175\154\224\025\316\130\141\264\024\255\103\051"\ # "\236\366\342\227\170\150\100\360\365\164\047\226\153\051\356" s1 = "Qly9y63M84Qly9y63M84Qly9y63M84Qly9y63M84Qly9y63M84Qly9y63M84" s2 = "2O15At13Iu" s3 = "A Test String" s4 = "#testobject" s5 = "http://example.com/testns" s6 = "9091270" s7 = "xsd:integer" rec = wgdb.create_record(self.d, 16) # BLOBTYPE not supported yet #wgdb.set_field(self.d, rec, 0, blob, wgdb.BLOBTYPE, "blob.pdf") #val = wgdb.get_field(self.d, rec, 0) #self.assertEqual(type(val), type(())) #self.assertEqual(len(val), 3) #self.assertEqual(val[0], blob) #self.assertEqual(val[1], wgdb.BLOBTYPE) #self.assertEqual(val[2], "blob.pdf") # CHARTYPE wgdb.set_field(self.d, rec, 1, "c", wgdb.CHARTYPE) val = wgdb.get_field(self.d, rec, 1) self.assertEqual(val, "c") # DATETYPE wgdb.set_field(self.d, rec, 2, datetime.date(2040, 7, 24)) val = wgdb.get_field(self.d, rec, 2) self.assertTrue(isinstance(val, datetime.date)) self.assertEqual(val.day, 24) self.assertEqual(val.month, 7) self.assertEqual(val.year, 2040) # DOUBLETYPE wgdb.set_field(self.d, rec, 3, -0.94794830) val = wgdb.get_field(self.d, rec, 3) self.assertAlmostEqual(val, -0.94794830) # FIXPOINTTYPE wgdb.set_field(self.d, rec, 4, 549.8390, wgdb.FIXPOINTTYPE) val = wgdb.get_field(self.d, rec, 4) self.assertEqual(val, 549.8390) # INTTYPE wgdb.set_field(self.d, rec, 5, 2073741877) val = wgdb.get_field(self.d, rec, 5) self.assertEqual(val, 2073741877) wgdb.set_field(self.d, rec, 6, -10) val = wgdb.get_field(self.d, rec, 6) self.assertEqual(val, -10) # NULLTYPE wgdb.set_field(self.d, rec, 7, None) val = wgdb.get_field(self.d, rec, 7) self.assertIsNone(val) # RECORDTYPE rec2 = wgdb.create_record(self.d, 1) wgdb.set_field(self.d, rec, 8, rec2) wgdb.set_field(self.d, rec2, 0, 30755904) val = wgdb.get_field(self.d, rec, 8) self.assertTrue(wgdb.is_record(val)) self.assertEqual(wgdb.get_field(self.d, val, 0), 30755904) # STRTYPE wgdb.set_field(self.d, rec, 9, s1) val = wgdb.get_field(self.d, rec, 9) self.assertEqual(val, s1) wgdb.set_field(self.d, rec, 10, s2, wgdb.STRTYPE) val = wgdb.get_field(self.d, rec, 10) self.assertEqual(val, s2) # extra string not supported yet #wgdb.set_field(self.d, rec, 11, s3, ext_str="en") #val = wgdb.get_field(self.d, rec, 11) #self.assertEqual(val, s3) # TIMETYPE wgdb.set_field(self.d, rec, 12, datetime.time(23, 44, 6)) val = wgdb.get_field(self.d, rec, 12) self.assertTrue(isinstance(val, datetime.time)) self.assertEqual(val.hour, 23) self.assertEqual(val.minute, 44) self.assertEqual(val.second, 6) # URITYPE wgdb.set_field(self.d, rec, 13, s4, wgdb.URITYPE, s5) val = wgdb.get_field(self.d, rec, 13) self.assertEqual(val, s5 + s4) # XMLLITERALTYPE wgdb.set_field(self.d, rec, 14, s6, wgdb.XMLLITERALTYPE, s7) val = wgdb.get_field(self.d, rec, 14) self.assertEqual(val, s6) # VARTYPE # when decoded, a tuple is returned that contains the # value and database (kind of a representation of vartype). wgdb.set_field(self.d, rec, 15, 2, wgdb.VARTYPE) val = wgdb.get_field(self.d, rec, 15) self.assertEqual(type(val), type(())) self.assertEqual(len(val), 2) self.assertEqual(val[0], 2) self.assertEqual(val[1], wgdb.VARTYPE) class LowLevelQueryTest(LowLevelTest): """Helper functions for query testing""" def fetch(self, query): try: rec = wgdb.fetch(self.d, query) except wgdb.error: rec = None return rec def get_first_record(self): try: rec = wgdb.get_first_record(self.d) except wgdb.error: rec = None return rec def get_next_record(self, rec): try: rec = wgdb.get_next_record(self.d, rec) except wgdb.error: rec = None return rec class QueryTests(LowLevelQueryTest): """Test low level query functions""" def make_testdata(self, dbsize): """Generates patterned test data for the query.""" for i in range(dbsize): for j in range(50): for k in range(50): rec = wgdb.create_record(self.d, 3) c1 = str(10 * i) c2 = 100 * j c3 = float(1000 * k) wgdb.set_field(self.d, rec, 0, c1) wgdb.set_field(self.d, rec, 1, c2) wgdb.set_field(self.d, rec, 2, c3) def check_matching_rows(self, col, cond, val, expected): """Fetch all rows where "col" "cond" "val" is true (where cond is a comparison operator - equal, less than etc) Check that the val matches the field value in returned records. Check that the number of rows matches the expected value""" query = wgdb.make_query(self.d, arglist = [(col, cond, val)]) # XXX: should check rowcount here when it's implemented # self.assertEqual(expected, query rowcount) cnt = 0 rec = self.fetch(query) while rec is not None: dbval = wgdb.get_field(self.d, rec, col) self.assertEqual(type(val), type(dbval)) self.assertEqual(val, dbval) cnt += 1 rec = self.fetch(query) self.assertEqual(cnt, expected) def check_db_rows(self, expected): """Count db rows.""" cnt = 0 rec = self.get_first_record() while rec is not None: cnt += 1 rec = self.get_next_record(rec) self.assertEqual(cnt, expected) def test_query(self): """Tests various queries: - read pre-generated content; - update content; - read updated content; - delete rows; - check row count after deleting. """ dbsize = 10 # use a fairly small database self.make_testdata(dbsize) # Content check read queries for i in range(dbsize): val = str(10 * i) self.check_matching_rows(0, wgdb.COND_EQUAL, val, 50*50) for i in range(50): val = 100 * i self.check_matching_rows(1, wgdb.COND_EQUAL, val, dbsize*50) for i in range(50): val = float(1000 * i) self.check_matching_rows(2, wgdb.COND_EQUAL, val, dbsize*50) # Update queries for i in range(dbsize): c1 = str(10 * i) query = wgdb.make_query(self.d, arglist = [(0, wgdb.COND_EQUAL, c1)]) rec = self.fetch(query) while rec is not None: c2 = wgdb.get_field(self.d, rec, 1) wgdb.set_field(self.d, rec, 1, c2 - 34555) rec = self.fetch(query) for i in range(50): c2 = 100 * i - 34555 query = wgdb.make_query(self.d, arglist = [(1, wgdb.COND_EQUAL, c2)]) rec = self.fetch(query) while rec is not None: c3 = wgdb.get_field(self.d, rec, 2) wgdb.set_field(self.d, rec, 2, c3 + 177889.576) rec = self.fetch(query) for i in range(50): c3 = 1000 * i + 177889.576 query = wgdb.make_query(self.d, arglist = [(2, wgdb.COND_EQUAL, c3)]) rec = self.fetch(query) while rec is not None: c1val = int(wgdb.get_field(self.d, rec, 0)) c1 = str(c1val + 99) wgdb.set_field(self.d, rec, 0, c1) rec = self.fetch(query) # Content check read queries, iteration 2 for i in range(dbsize): val = str(10 * i + 99) self.check_matching_rows(0, wgdb.COND_EQUAL, val, 50*50) for i in range(50): val = 100 * i - 34555 self.check_matching_rows(1, wgdb.COND_EQUAL, val, dbsize*50) for i in range(50): val = 1000 * i + 177889.576 self.check_matching_rows(2, wgdb.COND_EQUAL, val, dbsize*50) # Delete query for i in range(dbsize): c1 = str(10 * i + 99) arglist = [ (0, wgdb.COND_EQUAL, c1), (1, wgdb.COND_GREATER, -30556), # 10 matching (2, wgdb.COND_LESSTHAN, 217889.575) # 40 matching ] query = wgdb.make_query(self.d, arglist = arglist) rec = self.fetch(query) while rec is not None: wgdb.delete_record(self.d, rec) rec = self.fetch(query) # Database scan self.check_db_rows(dbsize * (50 * 50 - 10 * 40)) class QueryParamTests(LowLevelQueryTest): """Test query parameter encoding through the wgdb module""" def test_params(self): """Test encoding parameters""" marker = "This is a marker" s1 = "ctGXioJeeUkTrxiSGaWxqFujCyWHJkmveMQXEnrHAMomjuPjKqUHlUtCVjOT" s2 = "zjXNNGYUBjmdCrLaAaKv" s3 = "GRvWOVYBMObOzWPqVFCt" s4 = "#eNijRGUJbuHoJEMxRUCQ" s5 = "http://example.com/?UQCOtBzWkdipHplZqwQF" s6 = "KqKVvVhVcxbLssirtydJ" s7 = "xsd:Name" # this row shouldn't be returned by the queries (except # the NULL query) rec0 = wgdb.create_record(self.d, 15) wgdb.set_field(self.d, rec0, 0, "This is not a marker") # this row should be returned by the queries rec = wgdb.create_record(self.d, 15) wgdb.set_field(self.d, rec, 0, marker) # CHARTYPE wgdb.set_field(self.d, rec, 1, "Z", wgdb.CHARTYPE) # DATETYPE wgdb.set_field(self.d, rec, 2, datetime.date(1943, 2, 28)) # DOUBLETYPE wgdb.set_field(self.d, rec, 3, 105819.387451) # FIXPOINTTYPE wgdb.set_field(self.d, rec, 4, 783.799, wgdb.FIXPOINTTYPE) # INTTYPE wgdb.set_field(self.d, rec, 5, -871043) # NULLTYPE wgdb.set_field(self.d, rec, 7, None) # RECORDTYPE wgdb.set_field(self.d, rec, 8, rec0) # STRTYPE wgdb.set_field(self.d, rec, 9, s1) wgdb.set_field(self.d, rec, 10, s2, wgdb.STRTYPE) wgdb.set_field(self.d, rec, 11, s3, ext_str="en") # TIMETYPE wgdb.set_field(self.d, rec, 12, datetime.time(11, 22, 33)) # URITYPE wgdb.set_field(self.d, rec, 13, s4, wgdb.URITYPE, s5) # XMLLITERALTYPE wgdb.set_field(self.d, rec, 14, s6, wgdb.XMLLITERALTYPE, s7) # CHARTYPE query = wgdb.make_query(self.d, arglist = [(1, wgdb.COND_EQUAL, ("Z", wgdb.CHARTYPE))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # DATETYPE query = wgdb.make_query(self.d, arglist = [(2, wgdb.COND_EQUAL, datetime.date(1943, 2, 28))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # DOUBLETYPE query = wgdb.make_query(self.d, arglist = [(3, wgdb.COND_EQUAL, 105819.387451)]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # FIXPOINTTYPE query = wgdb.make_query(self.d, arglist = [(4, wgdb.COND_EQUAL, (783.799, wgdb.FIXPOINTTYPE))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # INTTYPE query = wgdb.make_query(self.d, arglist = [(5, wgdb.COND_EQUAL, -871043)]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # NULLTYPE query = wgdb.make_query(self.d, arglist = [(7, wgdb.COND_EQUAL, None)]) self.assertEqual(query.res_count, 2) self.assertIsNotNone(self.fetch(query)) self.assertIsNotNone(self.fetch(query)) self.assertIsNone(self.fetch(query)) # RECORDTYPE query = wgdb.make_query(self.d, arglist = [(8, wgdb.COND_EQUAL, rec0)]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # STRTYPE query = wgdb.make_query(self.d, arglist = [(9, wgdb.COND_EQUAL, s1)]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) query = wgdb.make_query(self.d, arglist = [(10, wgdb.COND_EQUAL, (s2, wgdb.STRTYPE))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) query = wgdb.make_query(self.d, arglist = [(11, wgdb.COND_EQUAL, (s3, wgdb.STRTYPE, "en"))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # TIMETYPE query = wgdb.make_query(self.d, arglist = [(12, wgdb.COND_EQUAL, datetime.time(11, 22, 33))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # URITYPE query = wgdb.make_query(self.d, arglist = [(13, wgdb.COND_EQUAL, (s4, wgdb.URITYPE, s5))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) # XMLLITERALTYPE query = wgdb.make_query(self.d, arglist = [(14, wgdb.COND_EQUAL, (s6, wgdb.XMLLITERALTYPE, s7))]) self.assertEqual(query.res_count, 1) rec = self.fetch(query) self.assertEqual(wgdb.get_field(self.d, rec, 0), marker) self.assertIsNone(self.fetch(query)) class WhiteDBTest(unittest.TestCase): """Provide setUp()/tearDown() for test cases that use the WhiteDB module API.""" def setUp(self): self.d = whitedb.connect(shmsize=MINDBSIZE, local=1) def tearDown(self): self.d.close() def check_db_rows(self, expected): """Count db rows.""" cnt = 0 rec = self.d.first_record() while rec is not None: cnt += 1 rec = self.d.next_record(rec) self.assertEqual(cnt, expected) class WhiteDBConnection(WhiteDBTest): """Test WhiteDB connection class methods. Does not cover the functionality that is normally accessed through Cursor and Record classes""" def test_creation(self): """Tests record creation and low level scanning to retrieve records from the database.""" rec = self.d.create_record(3) self.assertTrue(isinstance(rec, whitedb.Record)) rec = self.d.atomic_create_record([0, 0, 0]) self.assertTrue(isinstance(rec, whitedb.Record)) rec = self.d.insert([0, 0, 0]) self.assertTrue(isinstance(rec, whitedb.Record)) with self.assertRaises(whitedb.DataError): self.d.insert([]) with self.assertRaises(whitedb.DataError): self.d.create_record(-3) def test_fielddata(self): """Test field data reading and writing on connection level. This would be normally accessed through the record, but we depend on these functions to check the first/next records""" rec = self.d.create_record(20) self.d.set_field(rec, 6, 372296787) # regular data self.d.set_field(rec, 13, "2467305", whitedb.wgdb.CHARTYPE) # data with encoding self.d.set_field(rec, 19, "#907735743", whitedb.wgdb.URITYPE, "http://unittest/") # data with extstr self.assertEqual(self.d.get_field(rec, 6), 372296787) self.assertEqual(self.d.get_field(rec, 13), "2") self.assertEqual(self.d.get_field(rec, 19), "http://unittest/#907735743") def test_firstnext(self): """Test fetching the first and next record""" self.d.insert([112060684]) self.d.insert([566973731]) rec = self.d.first_record() self.assertEqual(self.d.get_field(rec, 0), 112060684) rec = self.d.next_record(rec) self.assertEqual(self.d.get_field(rec, 0), 566973731) class WhiteDBRecord(WhiteDBTest): """Test WhiteDB Record class""" def test_highlevel(self): """Tests high level record functionality.""" rec = self.d.insert([197622332, (2.67985826, whitedb.wgdb.DOUBLETYPE), ("874485001", whitedb.wgdb.XMLLITERALTYPE,"xsd:integer") ]) self.assertTrue(isinstance(rec, whitedb.Record)) self.assertEqual(len(rec), 3) self.assertEqual(rec[0], 197622332) self.assertAlmostEqual(rec[1], 2.67985826) self.assertEqual(rec[2], "874485001") # XXX: test len() here once implemented. def test_deletion(self): """Tests deleting a record""" self.check_db_rows(0) rec = self.d.insert([None]) self.check_db_rows(1) rec.delete() self.check_db_rows(0) def test_update(self): """Test record updating""" rec = self.d.insert([None, None, None, None, 630781304]) rec.update(["This", "is", "an", "update", 345849564]) self.assertEqual(rec[0], "This") self.assertEqual(rec[1], "is") self.assertEqual(rec[2], "an") self.assertEqual(rec[3], "update") self.assertEqual(rec[4], 345849564) with self.assertRaises(whitedb.wgdb.error): # too long rec.update([None, None, None, None, 630781304, None]) # nevertheless, fields that fit are overwritten self.assertEqual(rec[4], 630781304) def test_fielddata(self): """Test set and get field functions""" rec = self.d.create_record(3) rec.set_field(0, "168691904") with self.assertRaises(TypeError): rec.set_field(1, ("notanumber", whitedb.wgdb.INTTYPE)) with self.assertRaises(TypeError): rec.set_field(2, (248557089, 959010401)) with self.assertRaises(whitedb.DataError): rec.set_field(3, "no such field") self.assertEqual(rec.get_field(0), "168691904") self.assertEqual(rec.get_field(1), None) self.assertEqual(rec.get_field(2), None) with self.assertRaises(whitedb.DataError): rec.get_field(3) def test_getsize(self): """Test record size helper function""" rec = self.d.create_record(275) self.assertEqual(rec.get_size(), 275) l = [ 0, 0, 0, 0 ] rec = self.d.insert(l) self.assertEqual(rec.get_size(), len(l)) def test_linkrec(self): """Test linked records""" rec = self.d.insert([737483554]) rec2 = self.d.insert([859310257, rec]) self.assertTrue(isinstance(rec2[1], whitedb.Record)) self.assertEqual(rec2[1][0], 737483554) rec[0] = 284107294 self.assertEqual(rec2.get_field(1).get_field(0), 284107294) class WhiteDBCursor(WhiteDBTest): """Test WhiteDB Cursor class""" def make_testdata(self): rows = [ [5038, 933, 2513, 3743, 1068], [1459, 6185, 8457, 277, 171], [7261, 9882, 172, 7034, 755], [3751, 3690, 9976, 1225, 5825], [9910, 8478, 595, 924, 8804], [6801, 745, 5993, 6331, 7807], [5255, 2481, 595, 5685, 8532], [4579, 9155, 595, 478, 1167], [6753, 3518, 5928, 9286, 1637], [2781, 3919, 786, 9286, 7953] ] for row in rows: self.d.insert(row) def count_results(self, cur): cnt = 0 while cur.fetchone() is not None: cnt += 1 return cnt def test_basic(self): """Tests record creation and low level scanning to retrieve records from the database.""" cur = self.d.cursor() self.assertTrue(isinstance(cur, whitedb.Cursor)) cur.execute() self.assertIsNone(cur.fetchone()) self.d.insert([None, None, 846516765]) cur.execute() self.assertEqual(cur.rowcount, 1) rec = cur.fetchone() self.assertEqual(rec[2], 846516765) def test_matchrec(self): """Test query with a match record""" self.make_testdata() wildcard = (0, whitedb.wgdb.VARTYPE) cur = self.d.cursor() # list matchrec cur.execute(matchrec = [wildcard, wildcard, wildcard, 9286, wildcard]) self.assertEqual(cur.rowcount, 2) self.assertEqual(self.count_results(cur), 2) cur.execute(matchrec = [wildcard, wildcard, wildcard, 9286, 7953]) self.assertEqual(cur.rowcount, 1) self.assertEqual(self.count_results(cur), 1) cur.execute(matchrec = [None, wildcard, wildcard, 9286, 7953]) self.assertEqual(cur.rowcount, 0) self.assertEqual(self.count_results(cur), 0) # shorter record with matching field values cur.execute(matchrec = [5038, 933, 2513]) self.assertEqual(cur.rowcount, 1) self.assertEqual(self.count_results(cur), 1) # actual record matchrec rec = self.d.insert([wildcard, wildcard, 595, wildcard, wildcard]) cur.execute(matchrec = rec) self.assertEqual(cur.rowcount, 4) self.assertEqual(self.count_results(cur), 4) # shorter record with matching field values rec = self.d.insert([2781, 3919, 786, 9286]) cur.execute(matchrec = rec) self.assertEqual(cur.rowcount, 2) self.assertEqual(self.count_results(cur), 2) def test_arglist(self): """Test query with an argument list""" self.make_testdata() cur = self.d.cursor() # one condition: COND_EQUAL cur.execute(arglist = [(2, wgdb.COND_EQUAL, 595)]) self.assertEqual(cur.rowcount, 3) self.assertEqual(self.count_results(cur), 3) # inverse of previous query: COND_NOT_EQUAL cur.execute(arglist = [(2, wgdb.COND_NOT_EQUAL, 595)]) self.assertEqual(cur.rowcount, 7) self.assertEqual(self.count_results(cur), 7) # two conditions: COND_LESSTHAN, COND_GREATER cur.execute(arglist = [(0, wgdb.COND_LESSTHAN, 6801), (4, wgdb.COND_GREATER, 1637)]) self.assertEqual(cur.rowcount, 3) self.assertEqual(self.count_results(cur), 3) # inclusive versions of previous query: COND_LTEQUAL, COND_GTEQUAL cur.execute(arglist = [(0, wgdb.COND_LTEQUAL, 6801), (4, wgdb.COND_GTEQUAL, 1637)]) self.assertEqual(cur.rowcount, 5) self.assertEqual(self.count_results(cur), 5) def test_fetch(self): """Test the fetchall() and fetchone() functions""" self.make_testdata() cur = self.d.cursor() with self.assertRaises(whitedb.ProgrammingError): cur.fetchone() cur.execute(arglist = [(3, wgdb.COND_NOT_EQUAL, 9286)]) self.assertEqual(cur.rowcount, 8) rows = cur.fetchall() self.assertEqual(len(rows), 8) for row in rows: self.assertNotEqual(row[3], 9286) cur.execute(arglist = [(3, wgdb.COND_NOT_EQUAL, 9286)]) self.assertEqual(cur.rowcount, 8) cnt = 0 row = cur.fetchone() while row is not None: cnt += 1 self.assertNotEqual(row[3], 9286) row = cur.fetchone() self.assertEqual(cnt, 8) cur.execute(arglist = [(3, wgdb.COND_NOT_EQUAL, 9286)]) cur.close() with self.assertRaises(whitedb.ProgrammingError): cur.fetchone() if __name__ == "__main__": unittest.main() whitedb-0.7.3/MANIFEST0000644000175000001440000000110212232205232011200 00000000000000MANIFEST ======== This is the top folder of the WhiteDB system. FOLDERS ------- Main components: Doc : plain text documentation Main : top level source, main compiled binaries Db : WhiteDB core source; start here json : json handling Python : Python bindings java : java bindings Under development: Reasoner : reasoner core Parser : parsers for various input languages: used by reasoner Printer : printing and other output functions: used by reasoner Rexamples: reasoner examples whitedb-0.7.3/Doc/0000755000175000001440000000000012426224010010642 500000000000000whitedb-0.7.3/Doc/Install.txt0000644000175000001440000001467712426116005012754 00000000000000WhiteDB Installation ==================== Introduction ------------ There are two primary ways you can use the distribution package: - compile the database library ('libwgdb.so' under Linux, 'wgdb.dll' under Windows) and link your application against that - compile your application program by including the database files directly In both of these cases your application using WhiteDB calls should include the API header file: 'dbapi.h' In addition, you may want to compile the included utility program (`wgdb`) to manage the database. If you're installing from a source package, see the "Quick-start instructions" immediately below. If you grabbed the source code from the source repository, please read "Building the repository version" first. If you have a binary package for your system, follow the instructions for installing packages on your system instead. Quick-start instructions ------------------------ These instructions assume you're installing from a distribution source package. Under Linux, type ./configure make make install This produces the database utilities, the library and installs the them together with the database header files. NOTE: on Debian and Ubuntu, you may need to additionally run `ldconfig` as root. Under Windows, check that you have MSVC installed. Open the command prompt with the Visual C environment configured and type: compile.bat This produces the database utilities, 'wgdb.lib' and 'wgdb.dll'. The shared memory ----------------- Under Linux, the default memory settings are sufficient for testing and initial evaluation. For increasing the maximum amount of shared memory, type: sysctl kernel.shmmax=100000000 This example sets the available shared memory to 100M bytes. Under Mac OS X you need to set a kern.sysv.shmmax and kern.sysv.shmall, type: sudo sysctl -w kern.sysv.shmmax=1073741824 sudo sysctl -w kern.sysv.shmall=262144 You can add these settings to '/etc/sysctl.conf' to make it permanent. Under Windows, the shared memory is not persistent. To maintain a persistent database, use wgdb server 100000000 This example creates a shared memory database of 100M bytes. Once this process is terminated, the shared memory is destroyed. The configure script -------------------- Some more relevant options to the configure script are: '--prefix=PREFIX' specifies the directory the program is installed under. The binaries go in 'PREFIX/bin', the header files in 'PREFIX/include/whitedb' and the libraries in 'PREFIX/lib'. The Python modules, if compiled, will be placed in 'PREFIX/lib/pythonX.Y/site-packages', where X.Y is the Python version '--with-python' compiles the Python bindings. By default, the configure script attempts to automatically locate a suitable version of Python. Use '--with-python=/usr/bin/pythonX.Y' to point to a specific version of Python. '--enable-locking' changes the locking protocol. The available options are: 'rpspin' (a reader preference spinlock), 'wpspin' (a writer preference spinlock), 'tfqueue' (task-fair queue, no preference) and 'no' (locking is disabled). The default value is 'tfqueue' which performs best under heavy workload. For simple applications 'rpspin' may be preferrable, as it has lower overhead. '--enable-logging' enables the journal log of the database. Still somewhat experimental; off by default. '--enable-reasoner' enables the Gandalf reasoner. Disabled by default. '--disable-backlink' disables references between records. May be used to increase performance if the database records never contain any links to other records. '--disable-checking' disables sanity checking in many internal database operations. Increases performance by a small percentage. `./configure --help` will provide the full list of available options. Building the repository version ------------------------------- The github repository (https://github.com/priitj/whitedb) does not contain a pre-generated configure script. You'll need the autoconf, automake and libtool packages. If you have those installed, run: ./Bootstrap This generates the `configure` script and other scripts used by the autotools build. Then you can continue with the normal installation process. Keep in mind that the repository version is a work in progress and may therefore be unstable and contain undocumented and incomplete features. Building the utilities without configure and GNU make ----------------------------------------------------- The `compile.sh` script is provided to allow compiling the utilities with the C compiler. This is intended to simplify building in cross-target or embedded environments. It is assumed that the GNU C Compiler (`gcc`) or the CLang Compiler (`clang`) is used. When the script is executed with 'gcc' as first parameter or without parameters, GNU C Compiler is used. You can use CLang compiler using 'clang' as first parameter for this script. When the script is executed the first time, it copies 'config-gcc.h' to 'config.h', unless that file is already present. Edit 'config.h' to change database options. Note that if your system generates 64-bit binaries, then the macro `HAVE_64BIT_GINT` needs to be enabled explicitly. Uncomment the compilation of `selftest` in the compilation script and run it, if in doubt about whether the configuration is correct. Under Windows, `compile.bat` serves a similar function. To change the database options, edit the 'config-w32.h' file. Note that in both cases, the config file for building the `wgdb` utility should match the config file for building your database application. Not building anything --------------------- Building the database library and the utilities is not strictly necessary. Alternatively you may compile the database sources directly into your program. An effective way of doing this is executing the shell script `unite.sh` which will produce an amalgamation of header files, and an amalgamation of source files. The end result is two files: 'whitedb.h', and 'whitedb.c'. These can easily be included in your repository, or code base, and compiled directly in, while conforming to the license terms. NOTE: The 'whitedb.h' header produced this way is not the same as the standard API header. For better compatibility, consider including the 'Db/dbapi.h' header in your own sources, as documented elsewhere. See 'Examples/compile_demo.sh' ('Examples\compile_demo.bat' under Windows). This compiles the demo program 'demo.c' with the WhiteDB source files. These programs and scripts may be used as templates for creating database applications. whitedb-0.7.3/Doc/Utilities.txt0000644000175000001440000002564112426223736013324 00000000000000WhiteDB command line utilities ============================== wgdb - general database management ---------------------------------- This is a simple command-line utility that allows creating and freeing a database, dump, import, run some tests and more. Usage: wgdb [shmname] [command arguments] The shared memory name identifies the database to use and is an arbitrary numeric value. If it is omitted, the default ("1000") will be used. Commands commonly available: help (or "-h") - display this text. version (or "-v") - display libwgdb version. free - free shared memory. export [-f] - write memory dump to disk (-f: force dump even if unable to get lock) import [-l] - read memory dump from disk. Overwrites existing memory contents (-l: enable logging after import). exportcsv - export data to a CSV file. importcsv - import data from a CSV file. replay - replay a journal file. info - print information about the memory database. add .. - store data row (only int or str recognized) select [start from] - print db contents. query "" .. - basic query. del "" .. - like query. Matching rows are deleted from database. createindex - create ttree index. createhash - create hash index (JSON support). dropindex - delete an index. listindex - list all indexes in database. server [-l] [size b] - provide persistent shared memory for other processes (Windows). (-l: enable logging in the database). create [-l] [size] - create empty db of given size (non-Windows). (-l: enable logging in the database, mode: segment permissions (octal)). Importing and exporting data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Data may be exported to and imported from text files. This provides a way to exchange data between WhiteDB on different platforms or other data sources. The simplest format that is always available is CSV (comma separated values). Since there is no straightforward mapping between most of WhiteDB types and the CSV format and as CSV is not standardized, only limited support for data types is available. The following data types are recognized when importing from CSV: - NULL - empty string - int - plain integer - double - floating point number in fixed decimal notation - date - ISO8601 date - time - ISO8601 time+fractions of second. - string - input data that does not match the above types The field separator is ',' (comma). The decimal point separator is '.' (dot). WhiteDB may also provide RDF (if libraptor is available) and JSON (ongoing development, undocumented) support. Memory dumps and journal logs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the default configuration, WhiteDB runs in shared memory only. There are two methods of providing data persistence: memory dumps, which are snapshots of the current database contents and journal logs which contain incremental updates to the database contents. Logs are only available if the database is configured with the `./configure --enable-logging` option and need to be explicitly enabled. Managing memory dumps ^^^^^^^^^^^^^^^^^^^^^ A memory dump is the memory image of a WhiteDB database, saved into a file. It stores everything except concurrency control and journal file metadata. Images are not compatible between systems of different endianness or word size (the most common case would probably be 32-bit vs 64-bit systems). Also, different versions of the database library may use different format for the memory image, therefore WhiteDB automatically refuses to import an image made with a different library version. Type `wgdb -v` to list the compatibility information of the database library. It will display something like this: libwgdb version: 0.7.0 byte order: little endian compile-time features: 64-bit encoded data: yes queued locks: yes chained nodes in T-tree: yes record backlinking: yes child databases: no index templates: yes Memory dumps are suitable for creating snapshots of the database for backup purposes. Type wgdb export imagename.bin to create a backup of the current database (since the shared memory name was omitted, the `wgdb` utility will use "1000" by default). wgdb import imagename.bin Will restore the image from disk. It will completely overwrite the current memory contents. Note that if there is an existing memory segment, it needs to be large enough to fit the image. Otherwise the import will fail with an error message (and the shared memory segment will not be modified). If the `wgdb` tool is unable to access the memory image (for example, due to a programming error that causes the database to become permanently locked), a "rescue" dump can be created with wgdb export -f rescue.bin Note however, that in such cases care must be taken, as it is unknown what type of errors the image may contain. Managing journal logs ^^^^^^^^^^^^^^^^^^^^^ Journal logs provide a way of keeping a continuous backup of the database. All of the changes to the shared memory are logged incrementally and the journal logs may be played back to repeat all of those changes, bringing the database to the same state as it was at the time the log file ended. To enable journal logging, use ./configure --enable-logging --with-logdir=./logs during the building of the database. Replace './logs' with wherever you'd like the library to store the journal files. This location and the names of the journal files are not changeable during runtime due to security reasons. If you do not specify the log directory, '/tmp' (or '\windows\temp') will be used by default, which may work for testing, but is probably undesirable in the long term. Journaling must be enabled at the time of database creation. To do this from the command line, supply the `-l` switch to either the `wgdb create` command or when importing an image with the `wgdb import` command. This will cause a journal file to be created. It will be placed in 'logdir/wgdb.journal.shmname' where shmname is the database name, for example, "1000". The journal is then incrementally written, until one of the three things happens: 1. A dump file is created, either by `wgdb export` or by calling the `wg_dump()` function 2. A dump file is imported (again, by command line or API) 3. A journal file is replayed. In each of these cases, the current journal file is backed up, appending '.0' to its name (or '.1', if '.0' already exists and so forth) and a fresh journal file is started. The first case can be considered normal usage, as it creates a snapshot of the database. Since this snapshot contains everything that the journal has logged up to this point, the journal is no longer necessary for recovery and a fresh one will be used. Importing the dump file will either be part of a recovery process or to simply work with a new image. In either case, the previous journal has become irrelevant to the current database contents, making it necessary to start a new one. Finally, a journal replay itself will be not logged in a journal. Therefore, the database contents after the replay and the journal file that was in use during the replay have become inconsistent, similarly than whan happens with importing a memory dump. Generally, journal backups caused by these recovery actions should be cleaned up or moved away. The user is expected to handle this manually, case by case. Journal log example ^^^^^^^^^^^^^^^^^^^ Assuming we use the './logs' directory to store the journal files and the database has been compiled with journal support, let's start by enabling the journal and adding data to the database: wgdb create -l wgdb 1011 add 1 2 3 The contents of the './logs' directory will now be: -rw-rw-rw- 1 user group 27 Dec 7 22:00 wgdb.journal.1011 And the contents of the database, by typing `wgdb 1011 select 10`: [1,2,3] Let's create a memory dump of this database. Make sure you don't have 'example.bin' already, as it will be overwritten. wgdb 1011 export example.bin Now we have these log files: -rw-rw-rw- 1 user group 4 Dec 7 22:04 wgdb.journal.1011 -rw-rw-rw- 1 user group 27 Dec 7 22:00 wgdb.journal.1011.0 Note that the original file received the suffix '.0' and a new one was created in it's place. Let's add more data: wgdb 1011 add Hello world The database now contains: [1,2,3] ["Hello","world"] Assume next that something destroyed our database. Try `wgdb 1011 free`. We now know that we have a recent dump called 'example.bin' and some journals: -rw-rw-rw- 1 user group 47 Dec 7 22:06 wgdb.journal.1011 -rw-rw-rw- 1 user group 27 Dec 7 22:00 wgdb.journal.1011.0 The newest journal is what we're interested in. However, *keep in mind* that importing the dump restarts the journal. Nothing will happen to our precious log file, but in order to avoid confusion, let's move it somewhere safe first: mv -i ./logs/wgdb.journal.1011 ./logs/recover.me.1011 Import the dump (note that the '-l' switch is used to re-enable journaling so that our updates will be logged again after we've completed the recovery): wgdb 1011 import -l example.bin Try to list the database contents (`wgdb 1011 select 10`): [1,2,3] Finally, recover the log: wgdb 1011 replay ./logs/recover.me.1011 And the database contents after this will be [1,2,3] ["Hello","world"] We managed to restore our latest state of the database by first importing the dump file, then replaying the journal file that was written after the dump was created. If we would now continue to modify the database, the state could be recovered by importing 'example.bin' and then replaying 'recover.me.1011' and the latest journal file 'wgdb.journal.1011' in that order. The recovery process creates a number of intermediate journals which we may now clean up by `rm ./logs/wgdb.journal.1011.?`. CAUTION: in this case, we moved the log file that we cared about, away first. This is why this command is safe to use here. In general, however, it is better to make sure that the deleted log files do not contain anything not backed up elsewhere. The easiest way would be to verify that the database is healthy and create a fresh memory dump. An automated backup procedure ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A reasonable procedure that helps keeping track of image dumps and journals could be implemented with a following script: 1. dump the memory segment into a file such as 'backup.YYYYMMDD.shmname.bin' 2. check that the dump was successful 3. move 'logdir/wgdb.journal.shmname.0' to 'journal.YYYYMMDD.shmname' This way, 'logdir' always contains only the current journal. Assuming that YYYYMMDD represents the current date, memory dumps and journals can be archived and accessed by date. If recovery is needed, the database can be restored from the latest image and the current journal in 'logdir/wgdb.journal.shmname' (which should first be archived separately). Any journal backups in 'logdir' should then be removed after the restore is successful, to ensure that step 3. archives the correct journal file next time. whitedb-0.7.3/Doc/python.txt0000644000175000001440000007524112421471034012662 00000000000000WhiteDB python bindings ======================== About this document ------------------- The second part, "Compilation and Installation" describes the compilation, installation and general usage of WhiteDB Python bindings. The third part, "wgdb.so (wgdb.pyd) module", describes the immediate low level API provided by the wgdb module. This API (in most cases) directly wraps functions provided by libwgdb. The last part, "whitedb.py module (high level API)" describes the DBI-style API, which is designed for convinience of usage and is not speed-optimized at the moment (start there if you just want to know how to put stuff into the database using Python). The examples in this document were create using Python 2. They should be syntactically correct for Python 3, but can produce slightly different output (particularly, the `print` statement vs the `print()` function). Compilation and Installation ---------------------------- Compiling Python bindings ~~~~~~~~~~~~~~~~~~~~~~~~~ Python module is not compiled by default. `./configure --with-python` enables the compilation (provided that the configure script is able to locate the 'Python.h' file in the system. If not, it is assumed that Python is not properly installed and WhiteDB will be compiled without Python bindings). When building manually, use the separate scripts in Python directory. Check that the Python path in 'compile.sh' ('compile.bat' for Windows) matches your system. On non-Windows systems, also check that the 'config.h' file in the top level directory exists. If not, `cp config-gcc.h config.h` will provide a default one. Installation ~~~~~~~~~~~~ The high level 'whitedb.py' module expects to find the compiled 'wgdb.so' module in the same directory it resides in. To install the modules, they can be copied to Python site-packages directory manually. Compatibility ~~~~~~~~~~~~~ Minimum version of Python required: 2.5. Other tested versions: 2.6, 2.7 and 3.3. Note that Python 3 is supported but is not extensively tested yet. wgdb.so (wgdb.pyd) module ------------------------- Attaching and deleting a database ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FUNCTIONS attach_database(shmname='', size=0, local=0) Connect to a shared memory database. If the database with the given name does not exist, it is created. If local is non-zero, the parameter shmname is ignored and the database is created in local memory instead. attach_existing_database(shmname) Connect to a shared memory database. Fails if the database with the given name does not exist. delete_database(shmname) Delete a shared memory database. detach_database(db) Detach from shared memory database. If the database is in the local memory, it is deleted. `attach_database()` allows keyword arguments. If either database name or size are omitted, default values are used. Note that the shared memory name is expected to be converted by `strtol()`. `detach_database()` tells the system that the current process is no longer interested in reading the shared memory. This allows the system to free the shared memory (applies to SysV IPC model - not Win32). In case of a local database, the allocated memory is freed on all systems. Examples: >>> a=wgdb.attach_database() >>> b=wgdb.attach_database("1001") >>> c=wgdb.attach_database(size=3000000) >>> d=wgdb.attach_database(size=500000, shmname="9999") >>> d=wgdb.attach_database(local=1) >>> wgdb.detach_database(d) `attach_existing_database()` requires that a shared memory base with the given name exists. >>> d=wgdb.attach_existing_database("1002") Traceback (most recent call last): File "", line 1, in wgdb.error: Failed to attach to database. >>> d=wgdb.attach_existing_database() `delete_database()` takes a single argument. If this is omitted, the default value will be used. >>> wgdb.delete_database("1001") >>> wgdb.delete_database() Exception handling. ~~~~~~~~~~~~~~~~~~~ wgdb module defines a `wgdb.error` exception object that can be used in error handling: >>> try: ... a=wgdb.attach_database() ... except wgdb.error, msg: ... print ('wgdb error') ... except: ... print ('other error') ... Creating and manipulating records ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FUNCTIONS create_record(db, length) Create a record with given length. create_raw_record(db, length) Create a record without indexing the fields. delete_record(db, rec) Delete a record. get_first_record(db) Fetch first record from database. get_next_record(db, rec) Fetch next record from database. get_record_len(db, rec) Get record length (number of fields). is_record(rec) Determine if object is a WhiteDB record. `db` is an object returned by `wgdb.attach_database()`. `rec` is an object returned by `get_first_record()` or other similar functions that return a record. Examples: >>> d=wgdb.attach_database() ... >>> a=wgdb.create_record(d,5) >>> a >>> b=wgdb.create_record(d,3) >>> b >>> rec=wgdb.get_first_record(d) >>> wgdb.get_record_len(d,rec) 5 >>> rec >>> rec=wgdb.get_next_record(d,rec) >>> wgdb.get_record_len(d,rec) 3 >>> rec >>> rec=wgdb.get_next_record(d,rec) Traceback (most recent call last): File "", line 1, in wgdb.error: Failed to fetch a record. Writing and reading field contents. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wgdb module handles data type conversion between Python and WhiteDB. Field contents will be converted to Python object when reading data and again encoded into field data when writing to database. Currently supported types include: None, int, float, string (regular 0-terminated string. Raw binary data is not allowed), record. Setting a field to None is equivalent to clearing the field data. Similarly, unwritten fields will be returned to Python as containing None. FUNCTIONS get_field(db, rec, fieldnr) Get field data decoded to corresponding Python type. set_field(db, rec, fieldnr, data, encoding=0, ext_str="") Set field value. set_new_field(db, rec, fieldnr, data, encoding=0, ext_str="") Set field value (assumes no previous content). `db` is an object returned by `wgdb.attach_database()`. `rec` is an object returned by `get_first_record()` or other similar functions that return a record. Encoding (or field type) is an optional keyword argument. If it is omitted, the type of the field is determined by the Python type. Following encoding types are defined by the wgdb module: BLOBTYPE CHARTYPE - Python string (length 1, longer is allowed but ignored) DATETYPE - datetime.date() DOUBLETYPE - default encoding for Python float FIXPOINTTYPE - Python float (small, low precision real numbers) INTTYPE - default encoding for Python int NULLTYPE - Python None RECORDTYPE - wgdb.Record type. STRTYPE - default encoding for Python string TIMETYPE - datetime.time() URITYPE - Python string. ext_str defines URI prefix XMLLITERALTYPE - Python string. ext_str defines type. VARTYPE - (varnum, VARTYPE) tuple. `ext_str` is an optional keyword argument. For string types it has varied meaning depending on the type selected. For other types it is ignored. NOTE: With Python 2, Unicode objects are not accepted where a string object is expected. However, this can be worked around by converting the 'unicode' type to 'str' type. Example: `unicodestr.encode('utf-8')`. Examples: >>> d=wgdb.attach_database() ... >>> tmp=wgdb.create_record(d,4) >>> tmp >>> print (wgdb.get_field(d,tmp,0),) (None,) >>> wgdb.set_field(d,tmp,0,0) >>> wgdb.set_field(d,tmp,1,256) >>> wgdb.set_field(d,tmp,2,78.3345) >>> wgdb.set_field(d,tmp,3,"hello") >>> print (wgdb.get_field(d,tmp,0),) (0,) >>> print (wgdb.get_field(d,tmp,1),) (256,) >>> print (wgdb.get_field(d,tmp,2),) (78.334500000000006,) >>> print (wgdb.get_field(d,tmp,3),) ('hello',) >>> wgdb.set_field(d,tmp,3,None) >>> print (wgdb.get_field(d,tmp,3),) (None,) Example with a field pointing to another record: >>> tmp=wgdb.create_record(d,4) >>> n=wgdb.create_record(d,4) >>> wgdb.set_field(d,tmp,3,n) >>> wgdb.set_field(d,n,0,1) >>> uu=wgdb.get_field(d,tmp,3) >>> uu >>> wgdb.get_field(d,uu,0) 1 Example with using specific encoding: >>> d=wgdb.attach_database() >>> tmp=wgdb.create_record(d,1) >>> wgdb.set_field(d,tmp,0,"Hello") >>> wgdb.get_field(d,tmp,0) 'Hello' >>> wgdb.set_field(d,tmp,0,"Hello", wgdb.STRTYPE) >>> wgdb.get_field(d,tmp,0) 'Hello' >>> wgdb.set_field(d,tmp,0,"Hello", wgdb.CHARTYPE) >>> wgdb.get_field(d,tmp,0) 'H' >>> wgdb.set_field(d,tmp,0,"H", wgdb.FIXPOINTTYPE) Traceback (most recent call last): File "", line 1, in TypeError: Requested encoding is not supported. Transaction handling ~~~~~~~~~~~~~~~~~~~~ Logical level of transaction handling is provided by the wgdb module. These functions should guarantee safe concurrent usage, however the method of providing that concurrency is up to the database engine (in simplest case, the method is a database level lock). FUNCTIONS end_read(db, lock_id) Finish reading transaction. end_write(db, lock_id) Finish writing transaction. start_read(db) Start reading transaction. start_write(db) Start writing transaction. Parameter `lock_id` is returned by `start_write()` and `start_read()` functions. The same lock id should be passed to `end_write()` and `end_read()` functions, respectively. Depending on the locking mode used, the id may or may not be meaningful, but in any case this should be handled by the database itself. If timeouts are enabled, `start_read()` and `start_write()` will raise the `wgdb.error` exception upon failure to acquire the lock. Examples: >>> d=wgdb.attach_database() ... >>> l=wgdb.start_write(d) >>> wgdb.create_record(d, 5) >>> wgdb.end_write(d,l) >>> l=wgdb.start_read(d) >>> wgdb.get_first_record(d) >>> wgdb.end_read(d,l) Date and time fields. ~~~~~~~~~~~~~~~~~~~~~ WhiteDB uses a compact encoding for date and time values, which is translated to and from Python datetime representation on the wgdb module level. See Python `datetime` module documentation for more information on how to construct and use date and time objects. Note that tzinfo field of the time object and general timezone awareness supported by the datetime module is ignored on wgdb module level. In practical applications, it's recommended to treat all time fields as UTC or local time. Examples: >>> import wgdb >>> import datetime >>> d=wgdb.attach_database() >>> tmp=wgdb.create_record(d,1) >>> a=datetime.date(1990,1,2) >>> wgdb.set_field(d,tmp,0,a) >>> x=wgdb.get_field(d,tmp,0) >>> x datetime.date(1990, 1, 2) >>> x.day 2 >>> x.month 1 >>> x.year 1990 >>> b=datetime.time(12,5) >>> wgdb.set_field(d,tmp,0,b) >>> x=wgdb.get_field(d,tmp,0) >>> x datetime.time(12, 5) >>> x.hour 12 >>> x.minute 5 >>> x.second 0 >>> x.microsecond 0 Queries ~~~~~~~ wgdb module provides a direct wrapper for `wg_make_query()` and `wg_fetch()` functions. The query building function uses a similar convention for handling wgdb data types as the 'whitedb.py' module (see "Specifying field encoding and extended information") - data values in query parameters may be given as immediate Python values or as tuples that add the field type and extra string information. FUNCTIONS fetch(db, query) Fetch next record from a query. free_query(db, query) Unallocates the memory (local and shared) used by the query. make_query(db, matchrec, arglist) Create a query object. `query` is the `wgdb.Query` object returned by the `make_query()` method. `matchrec` is either a sequence of values or a reference to an actual database record. In either case, rows that have exactly matching fields will be returned. The query object has a read-only attribute `res_count` that contains the number of matching rows. If the number of rows is not known, `query.res_count` will be None. `arglist` is a list of 3-tuples (column, condition, value). Conditions (defined in wgdb module) may be: COND_EQUAL COND_NOT_EQUAL COND_LESSTHAN COND_GREATER COND_LTEQUAL COND_GTEQUAL Both `matchrec` and `arglist` are optional keyword arguments. If neither is provided, the query will return all the rows in the database. Example: >>> d=wgdb.attach_database() >>> tmp=wgdb.create_record(d,2) >>> tmp >>> wgdb.set_field(d,tmp,0,2) >>> wgdb.set_field(d,tmp,1,"hello") >>> tmp=wgdb.create_record(d,2) >>> tmp >>> wgdb.set_field(d,tmp,0,3) >>> wgdb.set_field(d,tmp,1,4) >>> # column 0 equals 2 ... q=wgdb.make_query(d, arglist=[(0,wgdb.COND_EQUAL,2)]) >>> wgdb.fetch(d, q) >>> # column 1 does not equal "hello", column 0 is less than 100 ... q=wgdb.make_query(d, arglist=[(1,wgdb.COND_NOT_EQUAL,"hello"), ... (0,wgdb.COND_LESSTHAN,100)]) >>> wgdb.fetch(d, q) >>> # use match record ... q=wgdb.make_query(d, [3, 4]) >>> wgdb.fetch(d, q) >>> # all rows. ... q=wgdb.make_query(d) >>> q.res_count # number of rows matching 2 >>> wgdb.fetch(d, q) >>> wgdb.fetch(d, q) >>> wgdb.fetch(d, q) # runs out of rows Traceback (most recent call last): File "", line 1, in wgdb.error: Failed to fetch a record. >>> whitedb.py module (high level API) ----------------------------------- Overview ~~~~~~~~ High level access to database is provided by 'whitedb.py' module. This module requires the low level 'wgdb.so' ('wgdb.pyd' on Windows) module. CLASSES Connection Cursor Record wgdb.error(exceptions.StandardError) DatabaseError DataError InternalError ProgrammingError class Connection | The Connection class acts as a container for | wgdb.Database and provides all connection-related | and record accessing functions. | | Methods defined here: | | __init__(self, shmname=None, shmsize=0) | | atomic_create_record(self, fields) | Create a record and set field contents atomically. | | atomic_update_record(self, rec, fields) | Set the contents of the entire record atomically. | | close(self) | Close the connection. | | commit(self) | Commit the transaction (no-op) | | create_record(self, size) | Create new record with given size. | | cursor(self) | Return a DBI-style database cursor | | delete_record(self, rec) | Delete record. | | end_read(self) | Finish reading transaction | | end_write(self) | Finish writing transaction | | fetch(self, query) | Get next record from query result set. | | first_record(self) | Get first record from database. | | free_query(self, cur) | Free query belonging to a cursor. | | get_field(self, rec, fieldnr) | Return data field contents | | insert(self, fields) | Insert a record into database | | make_query(self, matchrec=None, *arg, **kwarg) | Create a query object. | | next_record(self, rec) | Get next record from database. | | rollback(self) | Roll back the transaction (no-op) | | set_field(self, rec, fieldnr, data, *arg, **kwarg) | Set data field contents | | set_locking(self, mode) | Set locking mode (1=on, 0=off) | | start_read(self) | Start reading transaction | | start_write(self) | Start writing transaction class Cursor | Cursor object. Supports wgdb-style queries based on match | records or argument lists. Does not currently support SQL. | | Methods defined here: | | __init__(self, conn) | | close(self) | Close the cursor | | execute(self, sql='', matchrec=None, arglist=None) | Execute a database query | | fetchall(self) | Fetch all (remaining) records from the result set | | fetchone(self) | Fetch the next record from the result set | | get__query(self) | Return low level query object | | insert(self, fields) | Insert a record into database --DEPRECATED-- | | set__query(self, query) | Overwrite low level query object class DataError(DatabaseError) | Exception class to indicate invalid data passed to the db adapter class DatabaseError(wgdb.error) | Base class for database errors class InternalError(DatabaseError) | Exception class to indicate invalid internal state of the module class ProgrammingError(DatabaseError) | Exception class to indicate invalid database usage class Record | Record data representation. Allows field-level and record-level | manipulation of data. Supports iterator and (partial) sequence protocol. | | Methods defined here: | | __getitem__(self, index) | # sequence protocol | | __init__(self, conn, rec) | | __iter__(self) | # iterator protocol | | __setitem__(self, index, data, *arg, **kwarg) | | delete(self) | Delete the record from database | | get__rec(self) | Return low level record object | | get_field(self, fieldnr) | Return data field contents | | get_size(self) | Return record size | | set__rec(self, rec) | Overwrite low level record object | | set_field(self, fieldnr, data, *arg, **kwarg) | Set data field contents with optional encoding | | update(self, fields) | Set the contents of the entire record FUNCTIONS connect(shmname=None, shmsize=0, local=0) Attaches to (or creates) a database. Returns a database object Examples: Connecting to database with default parameters (see examples for `wgdb.attach_database()` for possible arguments and their usage). >>> import whitedb >>> d=whitedb.connect() Cursor methods. Calling `execute()` without any parameters creates a query that returns all the rows in the database. At first the record set will be emtpy, then we insert one using the `insert()` method provided by the connection object. It will subsequently be returned by the query. >>> c=d.cursor() >>> c.execute() >>> c.fetchall() [] >>> d.insert(("This", "is", "my", 1.0, "record")) >>> c.execute() >>> rows=c.fetchall() >>> rows [] The `Record` class has some aspects of a sequence and also works as an iterator. To simply access the entire contents of the record, it can be converted to a normal sequence, such as with the `tuple()` function. Fields may be accessed by their index as well: >>> r=rows[0] >>> r[1] 'is' >>> r[2] 'my' >>> tuple(r) ('This', 'is', 'my', 1.0, 'record') >>> for column in r: print (column) ... This is my 1.0 record Record methods. We create a new record, then attempt to modify a single field and the full record. The last attempt will fail because record size is fixed. >>> new=d.insert(('My', 2, 'record')) >>> new >>> c.execute() >>> rows=c.fetchall() >>> rows [, ] >>> new.get_field(1) 2 >>> new.set_field(1, 2.0) >>> tuple(new) ('My', 2.0, 'record') >>> new.update(('this','will','not','fit')) wg data handling error: wrong field number given to wg_set_field Traceback (most recent call last): File "", line 1, in File "whitedb.py", line 433, in update self._conn.atomic_update_record(self, fields) File "whitedb.py", line 242, in atomic_update_record wgdb.set_field(*fargs) wgdb.error: Failed to set field value. >>> tuple(new) ('this', 'will', 'not') Records can be deleted like so (when using the method provided by the `Record` object, the Python level object itself will remain, but the database record will no longer be accessible): >>> new.delete() >>> new >>> tuple(new) Traceback (most recent call last): File "", line 1, in File "whitedb.py", line 442, in __iter__ yield self.get_field(fieldnr) File "whitedb.py", line 416, in get_field return self._conn.get_field(self, fieldnr) File "whitedb.py", line 264, in get_field data = wgdb.get_field(self._db, rec.get__rec(), fieldnr) TypeError: argument 2 must be wgdb.Record, not None Connections can be closed, after which the cursors and records created using that connection will no longer be usable. NOTE: if `Connection.close()` method is used, it is recommended to close all cursors first. >>> c.close() >>> d.close() >>> tuple(new) Traceback (most recent call last): File "", line 1, in File "whitedb.py", line 442, in __iter__ yield self.get_field(fieldnr) File "whitedb.py", line 416, in get_field return self._conn.get_field(self, fieldnr) File "whitedb.py", line 262, in get_field self.start_read() File "whitedb.py", line 108, in start_read self._lock_id = wgdb.start_read(self._db) TypeError: argument 1 must be wgdb.Database, not None Linked records ~~~~~~~~~~~~~~ WhiteDB record fields may contain references to other records. In high level API, these records are represented as instances of `whitedb.Record` class. Note that it is not useful to create such instances directly. Instances of `Record` class are always returned by WhiteDB operations (creating new records or retrieving existing ones). Example of linking to other records: >>> import whitedb >>> d=whitedb.connect() >>> rec=d.insert((1,2,3,4,5)) >>> c=d.cursor() >>> c.execute() >>> tuple(c.fetchone()) (1, 2, 3, 4, 5) >>> d.insert(('1st linked record', rec)) >>> d.insert(('2nd linked record', rec)) >>> c.execute() >>> l=c.fetchall() >>> list(map(tuple,l)) [(1, 2, 3, 4, 5), ('1st linked record', ), ('2nd linked record', )] Changing the contents of the original record will be visible through the records that refer to it: >>> linked=l[-2:] >>> linked [, ] >>> list(map(lambda x: tuple(x[1]), linked)) [(1, 2, 3, 4, 5), (1, 2, 3, 4, 5)] >>> rec.set_field(3, 99) >>> list(map(lambda x: tuple(x[1]), linked)) [(1, 2, 3, 99, 5), (1, 2, 3, 99, 5)] Transaction support ~~~~~~~~~~~~~~~~~~~ Transactions are handled internally by the whitedb module. By default the concurrency support is turned on and each database read or write is treated as a separate transaction. The user can turn this behaviour on and off (when there is a single database user, there will be a small performance gain with locking turned off). Turning locking (or transactional) mode off: >>> d=whitedb.connect() >>> d.set_locking(0) Turning it back on: >>> d.set_locking(1) Specifying field encoding and extended information. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The user can explicitly state which encoding should be used when writing data to the database. Examples of encodings where this is useful are 1-character strings and small fixed-point numbers. When encoded as such they consume less storage space in database and may speed up access as well. Allowed types are listed under the section "Writing and reading field contents". Example: >>> import whitedb >>> d=whitedb.connect() >>> r=d.insert((None,)) >>> r.set_field(0,"Hello") >>> tuple(r) ('Hello',) >>> r.set_field(0,"Hello",whitedb.wgdb.STRTYPE) >>> tuple(r) ('Hello',) >>> r.set_field(0,"Hello", encoding=whitedb.wgdb.CHARTYPE) >>> tuple(r) ('H',) >>> r.set_field(0,"Hello",whitedb.wgdb.INTTYPE) Traceback (most recent call last): File "", line 1, in File "whitedb.py", line 422, in set_field return self._conn.set_field(self, fieldnr, data, *arg, **kwarg) File "whitedb.py", line 283, in set_field rec.get__rec(), fieldnr, data, *arg, **kwarg) TypeError: Requested encoding is not supported. Some string types allow extra information, stored together with the value. This can be done by adding the `ext_str` keyword parameter. The specific types and meaning of the extra information: STRTYPE - language URITYPE - URI prefix XMLLITERAL - XML literal type Example: >>> r=d.create_record(3) >>> r >>> r.set_field(0, "#example", whitedb.wgdb.URITYPE, "http://example.com/myns") >>> r.set_field(1, "True", ext_str="xsd:boolean", encoding=whitedb.wgdb.XMLLITERALTYPE) >>> r.set_field(2, "#object_id", encoding=whitedb.wgdb.URITYPE) >>> tuple(r) ('http://example.com/myns#example', 'True', '#object_id') Finally, `Connection.insert()` method and `Record.update()` method allow the user to supply the additional field encoding and extra string parameters together with the data value. Field values passed to these methods may be given as tuples (data, encoding) or (data, encoding, ext_str). These additional parameters will be passed on to the database in a similar way to the positional parameters in the above examples with the `set_field()` method. If ext_str is given, encoding must also be present. Passing 0 for the encoding lets the wgdb module select the default encoding. Example: >>> r=d.insert((1,2.0,"3")) >>> tuple(r) (1, 2.0, '3') >>> r.update((None,None,("hello",whitedb.wgdb.CHARTYPE))) >>> tuple(r) (None, None, 'h') >>> r.update((None,None,("hello",0,"en"))) >>> tuple(r) (None, None, 'hello') >>> r=d.insert((("#example",whitedb.wgdb.URITYPE,"http://mydomain.org/"), ... ("False",whitedb.wgdb.XMLLITERALTYPE,"xsd:boolean"))) >>> tuple(r) ('http://mydomain.org/#example', 'False') >>> import math >>> r.update((math.pi,(math.pi,whitedb.wgdb.FIXPOINTTYPE))) >>> tuple(r) (3.1415926535897931, 3.1415999999999999) Using dates and times. ~~~~~~~~~~~~~~~~~~~~~~ Date and time support is implemented using the datetime module included with the standard Python distribution. Storing a `datetime.date` object in the database creates a WhiteDB date type field, similarly a `datetime.time` object is stored as a time field. When reading the database, low-level wgdb module converts the times and dates to datetime.date/time instances again. Timezones are not supported through the wgdb API, so timezone-awareness should be implemented on the application level, if needed. Date and time fields combined can be used to construct datetime data. Example: >>> import whitedb >>> import datetime >>> d=whitedb.connect() >>> a=datetime.date(2010,3,31) >>> b=datetime.time(12,59,microsecond=330000) >>> rec=d.insert((a,b)) >>> tuple(rec) (datetime.date(2010, 3, 31), datetime.time(12, 59, 0, 330000)) >>> rec[0].month 3 >>> rec[1].hour 12 Example of using combined date and time fields as a datetime object (continuing previous example): >>> x=datetime.datetime.combine(rec[0], rec[1]) >>> x datetime.datetime(2010, 3, 31, 12, 59, 0, 330000) >>> x.strftime("%d.%m.%Y") '31.03.2010' >>> x.ctime() 'Wed Mar 31 12:59:00 2010' Using queries. ~~~~~~~~~~~~~~ The `execute()` method of `Cursor` class implements non-DBI, WhiteDB-specific extensions. These can be used to query data that matches specific conditions. SQL support is currently not implemented in libwgdb and is non-functional in the whitedb Python module. Optional keyword parameters to `execute()`: - sql - ignored - matchrec - may be either a sequence of values or a whitedb.Record instance that points to an actual record in the database. In the first case, records with fields matching the values in the sequence will be returned. In the second case, equivalent records (including the match record itself) will be returned. - arglist - sequence of 3-tuples (column, condition, value) Values are either immediate Python values or tuples with extended type information (see "Specifying field encoding and extended information"). For the possible conditions, see the section "Queries". `arglist` and `matchrec` parameters may be present simultaneously. Also, `arglist` parameter may contain multiple conditions for one column. If neither parameter is present, the result set will include all the rows in the database unconditionally. After calling `execute()`, the attribute `rowcount` will indicate the number of rows matching the query (unless that information is not available from the wgdb layer). Examples: >>> import whitedb >>> from wgdb import COND_EQUAL, COND_LESSTHAN, COND_NOT_EQUAL >>> d=whitedb.connect() >>> d.insert((2,3,4)) >>> d.insert(("Hello", 110)) One condition (column 0 should not equal 2): >>> c=d.cursor() >>> c.execute(arglist=[(0, COND_NOT_EQUAL, 2)]) >>> tuple(c.fetchone()) ('Hello', 110) Multiple conditions (column 1 should be < 100, column 0 should equal 2): >>> c.execute(arglist=[(1, COND_LESSTHAN, 100), (0, COND_EQUAL, 2)]) >>> r=c.fetchone() >>> tuple(r) (2, 3, 4) Try match record: >>> d.insert((2,3,4,5)) >>> c.execute(matchrec=r) >>> c.rowcount 2 >>> list(map(tuple, c.fetchall())) [(2, 3, 4), (2, 3, 4, 5)] Empty query (all database rows match): >>> c.execute() >>> list(map(tuple, c.fetchall())) [(2, 3, 4), ('Hello', 110), (2, 3, 4, 5)] libwgdb query engine treats all match record fields that are of WG_VARTYPE, as wildcards. This can be used in Python-side match records as well (VARTYPE field is constructed using the extended type syntax convention): >>> x=(0, whitedb.wgdb.VARTYPE) >>> c.execute(matchrec=[2,x,4]) >>> list(map(tuple, c.fetchall())) [(2, 3, 4), (2, 3, 4, 5)] Database record fields can also be of WG_VARTYPE. Note that the query using such match record also returns the match record itself. The variables are represented as (varnum, VARTYPE) tuples in Python: >>> var_rec=d.insert((x,x,4)) >>> var_rec >>> c.execute(matchrec=var_rec) >>> list(map(tuple, c.fetchall())) [(2, 3, 4), (2, 3, 4, 5), ((0, 14), (0, 14), 4)] whitedb-0.7.3/Doc/Manual.txt0000644000175000001440000016552012426116005012555 00000000000000WhiteDB shared memory database ============================== Principles and goals --------------------- WhiteDB is a lightweight database library operating fully in main memory. Disk is used only for dumping/restoring database and logging. Data is persistantly kept in the shared memory area: it is available simultaneously to all processes and is kept intact even if no processes are currently using the database. WhiteDB has no server process. Data is read and written directly from/to memory, no sockets are used between WhiteDB and the application using WhiteDB. WhiteDB keeps data as N-tuples: each database record is a tuple of N elements. Each element (record field) may have an arbitrary type amongst the types provided by WhiteDB. Each record field contains exactly one integer (4 bytes or 8 bytes). Datatypes which cannot be fit into one integer are allocated separately and the record field contains an (encoded) pointer to the real data. WhiteDB is written in pure C in a portable manner and should compile and function without additional porting at least under Linux (gcc) and Windows (native Windows C compiler cl). It has Python and experimental Java bindings. The Python bindings and their usage is explained in the separate manual 'python.txt'. WhiteDB has several goals: - speed - portability - small footprint and low memory usage - usability as an rdf database - usability as an extended rdf database, xml database and outside these scopes - integration with the Gandalf rule engine (work in progress) NOTE: The name 'wgdb' is also used in some places, such as the name of loadable modules and libraries. In documentation it may be used interchangeable with WhiteDB, the letter 'G' refers to the Gandalf reasoner. Obtaining and licence --------------------- WhiteDB releases can be obtained from http://www.whitedb.org The development version can be obtained from the source repository: https://github.com/priitj/whitedb WhiteDB is licensed under GPL version 3. Using WhiteDB in applications ----------------------------- See 'demo.c' and 'query.c' in the 'Examples' directory of the distribution package for complete examples of basic database usage. Compiling and linking against WhiteDB installation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Include the API headers in your programs: [source,C] ---- #include #include /* only for using the raptor API */ #include /* only for using the index API */ ---- - Include -lwgdb to LDFLAGS in your Makefile or linker arguments If you used a non-standard installation prefix, using -I and -L compiler/linker flags is required as usual. Dynamic linking under Windows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Include the API headers [source,C] ---- #include #include /* only for using the raptor API */ #include /* only for using the index API */ ---- This requires providing the header file directory to the compiler. - Compile and link against the library cl.exe /I"..\whitedb-0.6\Db" yourprog.c ..\whitedb-0.6\wgdb.lib This produces 'yourprog.exe' that requires 'wgdb.dll' to run. The 'compile.bat' and Examples directory also contains compilation examples. Compiling with database source files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See 'Examples/compile_demo.sh' ('Examples\compile_demo.bat' under Windows). This compiles the demo program 'demo.c' with the WhiteDB source files. These programs and scripts may be used as templates for creating database applications. Additionally, the shell script 'unite.sh' allows creation of an amalgamation, resulting in two files: whitedb.c and whitedb.h. These files allow ease of use by simply including the source file (whitedb.c) with your application, and #include'ing the whitedb.h header file, allowing you to effectively embed whitedb without having to worry about source and header files en masse. Database API ------------- The database API prototypes and macros are all found in the 'Db/dbapi.h' file. You should include this single header file in all the files of your application calling WhiteDB functions. The database API has functions for: - creating and deleting the database - creating and deleting records - setting and reading record fields - encoding and decoding data stored in the record fields - dumping and restoring database contents to/from disk - read and write locking the database for concurrency control It is a good idea to check the usage of API calls from the example program 'Examples/demo.c' Preliminaries ~~~~~~~~~~~~~ All the API calls follow these principles: - each function has a wg_ prefix. - function names are all lower case, _ used as a separator - each function takes the pointer to the database as a first argument. The database pointer is obtained when creating a new database or attaching to an existing one. You can have several databases open at any time: they will simply have different pointers. Observe that the pointer you will get from two different processes for the same database will be different. The record pointer is returned when creating records or when fetching query results. This `void *` type pointer points directly to the record data in the shared memory segment and should be used with all the functions that read or manipulate record fields. You can also encode a record pointer and write it into another record, forming a link between records. All the record fields are ordinary C integers (32 or 64 bytes). In order to allow exact control over the integer length the datatype `wg_int` is used for all encoded data. This datatype is in normal usage equivalent (typedef-d) to an int (or a 64-bit integer if the database is configured as 64-bit). Strings given to the API functions are ordinary 0-terminated C strings, their length is an ordinary C string length as computed by strlen. Checks and errors ~~~~~~~~~~~~~~~~~ WhiteDB library performs a few checks for most library operations to ensure sanity. Checking causes a very small speed penalty and can be disabled by setting '--disable-checking' during installation. One of the standard checks is whether the database pointer passed as the first argument is not NULL and the first segment of the database area contains the specific integer indicating that the segment is actually created as a WhiteDB database. Whenever a field record is accessed, WhiteDB checks that the field number is not larger than the record length. Validity checks are also performed during data decoding and encoding. In case WhiteDB recognizes an error, the API function called returns an error value specified in the API doc. For example, failed record creation returns a NULL pointer. A WG_ILLEGAL value is returned in case of encoding error, NULL in case of string decoding errors, -1 in case of length decoding errors. In addition to returning a specific error value, WhiteDB prints an error message to stderr. In some cases the error message is a small error trace through several layers of internal calls. Printing to stderr can be inhibited by defining a macro WG_NO_ERRPRINT during WhiteDB compilation. Notice that in error cases, nothing is printed to stdout (only stderr) and WhiteDB does not exit: the corresponding API call returns an error value which should be handled by the code calling the API function. Creating and deleting the database ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: [source,C] ---- void* wg_attach_database(char* dbasename, wg_int size); void* wg_attach_existing_database(char* dbasename); void* wg_attach_logged_database(char* dbasename, wg_int size); void* wg_attach_database_mode(char* dbasename, wg_int size, int mode); void* wg_attach_logged_database_mode(char* dbasename, wg_int size, int mode); int wg_detach_database(void* dbase); int wg_delete_database(char* dbasename); void* wg_attach_local_database(wg_int size); void wg_delete_local_database(void* dbase); ---- Details: void* wg_attach_database(char* dbasename, int size) Returns a pointer to the database, NULL if failure. Size in bytes. Created database is a contiguous block of shared memory of size bytes. It cannot be shrinked or extended later. The returned pointer should be passed to all the WhiteDB API calls as the first parameter. Database name should be an integer. The call wg_attach_database(NULL, 0) creates a database with a default name ("1000") and default size 10000000 (10 megabytes). Both defaults can be configured from 'Db/dbmem.h'. If the size parameter is > 0, the named shared memory segment exists and it is smaller than the given size, the call returns NULL. NOTE: The typical default shared memory allocatable size of a linux system is under 100 megabytes. You can see the allocatable size in bytes by doing `cat /proc/sys/kernel/shmmax`. You can set the shared memory size by becoming root and doing `echo shared_memory_size > /proc/sys/kernel/shmmax` where shared_memory_size is a number of bytes. void* wg_attach_existing_database(char* dbasename) Like `wg_attach_database()`, but does not create a new database when no database with name dbasename exists. In the latter case returns NULL. void* wg_attach_logged_database(char* dbasename, wg_int size) Like `wg_attach_database()`, but starts journal logging when the database is initialized. If the named segment already exists and does not have logging enabled, the function returns NULL. void* wg_attach_database_mode(char* dbasename, wg_int size, int mode) Like `wg_attach_database()`, but create the memory segment with the given permissions. The parameter `mode` is the nine permission bits (3 per user, group and others, usually given in octal. Example: 0660 gives the read-write permission to the user and group and no permissions to others). NOTE: read-only permissions do not work. Also, this parameter has no effect on the Windows platform currently. void* wg_attach_logged_database_mode(char* dbasename, wg_int size, int mode) Like `wg_attach_logged_database()`, but create the memory segment with the given permissions. See the function `wg_attach_database_mode()` for details. int wg_detach_database(void* dbase) Detaches a database: returns 0 if OK. Exiting from the process detaches database automatically. int wg_delete_database(char* dbasename) Deletes a database: returns 0 if OK. NB! Database is not deleted unless all processes who have previously attached have detached from it and at least one process has made a delete call. void* wg_attach_local_database(int size) Returns a pointer to local memory database, NULL if failure. Size is given in bytes. The database is allocated in the private memory of the process and will neither be readable to other processes nor persist when the process closes. In every other aspect the database behaves similarly to a shared memory database. void wg_delete_local_database(void* dbase) Deletes a local memory database. Memory allocated for the database will be freed. Creating, deleting, scanning records ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: [source,C] ---- void* wg_create_record(void* db, wg_int length); void* wg_create_raw_record(void* db, wg_int length); wg_int wg_delete_record(void* db, void *rec); void* wg_get_first_record(void* db); void* wg_get_next_record(void* db, void* record); void *wg_get_first_parent(void* db, void *record); void *wg_get_next_parent(void* db, void* record, void *parent); ---- Details: void* wg_create_record(void* db, wg_int length) Creates a new record of length length and initialises all fields to 0 (used as a NULL value in WhiteDB). Returns NULL when error, ptr to record otherwise. void* wg_create_raw_record(void* db, wg_int length) Same as wg_create_record(), except the initial field values are not indexed. Use together with wg_set_new_field(). NOTE: using this together with index templates has complex and probably unexpected consequences. Not recommended. wg_int wg_delete_record(void* db, void *rec) Deletes a record with a pointer rec. Returns 0 if OK, non-0 on error. You should not worry about deallocation of data in the record fields: this is done automatically. void* wg_get_first_record(void* db) Returns first record pointer, NULL when error or no records available. void* wg_get_next_record(void* db, void* record) Returns next record pointer, NULL when error or no records available. record parameter is a pointer to the (previous) record. void *wg_get_first_parent(void* db, void *record) Return the first parent of the record. Record A is a parent of record B if record A contains a link to record B. Records may have more than one parent. Consult the section "Encoding and decoding data stored in the record fields" on how to link records. Returns the pointer to the first parent record or NULL if there are no parents or when the database is not configured to track parents. void *wg_get_next_parent(void* db, void* record, void *parent) Return the next parent of the record. The argument 'parent' is a record returned by a previous call of `wg_get_first_parent()` or `wg_get_next_parent()`. Returns NULL if there are no more parent records. NOTE: the current implementation of this function can be slow if there are many parents to a record. Setting and reading record fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: [source,C] ---- wg_int wg_get_record_len(void* db, void* record); wg_int wg_set_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_new_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_get_field(void* db, void* record, wg_int fieldnr); wg_int wg_get_field_type(void* db, void* record, wg_int fieldnr); wg_int wg_set_int_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_set_double_field(void* db, void* record, wg_int fieldnr, double data); wg_int wg_set_str_field(void* db, void* record, wg_int fieldnr, char* data); wg_int* wg_field_addr(void* db, void* record, wg_int fieldnr); ---- Details: wg_int wg_get_record_len(void* db, void* record) Gives record length (0,...). Returns negative int when error. wg_int wg_set_field(void* db, void* record, wg_int fieldnr, wg_int data) Sets field fieldnr value to encoded data. Field numbers start from 0. Passed data must be 0 (NULL value) or encoded (see next chapter). Returns negative int when err, 0 when ok. Do not worry about deallocating earlier data in the field: this is done automatically. wg_int wg_set_new_field(void* db, void* record, wg_int fieldnr, wg_int data) Same as wg_set_field() except it can only be used to write the contents of newly created fields that do not have values. Writing will be somewhat faster than with wg_set_field(). It is the responsibility of the caller to ensure that the field to be written really is one that contains no earlier data. Use together with wg_create_raw_record(). NOTE: using this together with index templates has complex and probably unexpected consequences. Not recommended. wg_int wg_get_field(void* db, void* record, wg_int fieldnr) Returns encoded data in field fieldnr. Data should be decoded later for ordinary use, see next chapter. wg_int wg_get_field_type(void* db, void* record, wg_int fieldnr) Returns datatype in field fieldnr. Datatypes are defined by these macros, avoid using corresponding numbers, since these may change: [source,C] ---- #define WG_NULLTYPE 1 #define WG_RECORDTYPE 2 #define WG_INTTYPE 3 #define WG_DOUBLETYPE 4 #define WG_STRTYPE 5 #define WG_XMLLITERALTYPE 6 #define WG_URITYPE 7 #define WG_BLOBTYPE 8 #define WG_CHARTYPE 9 #define WG_FIXPOINTTYPE 10 #define WG_DATETYPE 11 #define WG_TIMETYPE 12 ---- The following are convenience functions for common datatypes: wg_int wg_set_int_field(void* db, void* record, wg_int fieldnr, wg_int data) Like wg_set_field but automatically encodes data: pass ordinary integer. wg_int wg_set_double_field(void* db, void* record, wg_int fieldnr, double data) Like wg_set_field but automatically encodes data: pass ordinary double. wg_int wg_set_str_field(void* db, void* record, wg_int fieldnr, char* data) Like wg_set_field but automatically encodes data: pass ordinary null-terminated string. The following is a macro returning an address (C pointer) of a field: wg_int* wg_field_addr(void* db, void* record, wg_int fieldnr) Avoid wg_field_addr in normal cases: use wg_get_field and wg_set_field instead. The wg_field_addr macro performs no checks whatsoever: it is useful only for achieving maximum speed. While it is safe to read a value from the address returned, use it with extreme caution when storing data to the field. It is OK to directly store an encoded value to the field only if it currently contains an immediate value (immediates are NULL, short integer, date, time, char), is not indexed and no logging is used. Encoding and decoding data stored in the record fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The general principle of data storage in records is that each datatype has to be encoded before storage and decoded after reading before ordinary usage. Data stored in the fields is deallocated automatically if not used any more in any records. Hence you should not use the decoded data in your own variables after storage, unless you are sure the corresponding records are not deleted before you are using your variables again. The encoding principles are following, from smallest and fastest to largest and slowest: - 0, small (28 bit) integers, fixpoint doubles, chars, dates and times are stored directly in the field, no additional allocation is done, no special deallocation is done. - Records are encoded as an offset from the start of the shared memory segment to the start of the record. The encoded value is stored directly in a field. It can be decoded into a direct pointer to the start of the record data in the shared memory. - large integers and doubles are allocated one copy per data item, in a 4 byte or 8 byte chunk. - Short simple strings up to 32 bytes are allocated one copy per data item, always 32 bytes. - Long strings, strings with added language property, xmlliterals, uris, blobs are kept uniquely: only one copy of each item is allocated. They are deallocated automatically when the reference count falls to zero (reference counting garbage collection is used). - Long strings, xmlliterals, uris and blobs have different types (not equal even if they look the same when printed) and they all contain two strings: * main part (string, xmlliteral, uri, blob) * extra part (string language, xmlliteral namespace, uri prefix, blob type) where all these are ordinary 0-terminated C strings except blob, which is not 0-terminated. It is always possible to give a NULL value as an extra part. - Strings and blob returned by decoding strings, xmlliterals, uris and blobs should not be changed or used directly except for immediate copying to buffer. Prefer to use the decode...copy functions instead of direct decode functions giving a pointer to a string in the database. - A WG_ILLEGAL value is returned in case of encoding error. A value returned in case of decoding error is sometimes not recognizable as an error. In string-type value decoding NULL is returned in case of decoding errors, length and date/time decoding errors return -1. Functions: [source,C] ---- wg_int wg_get_encoded_type(void* db, wg_int data); wg_int wg_free_encoded(void* db, wg_int data); wg_int wg_encode_null(void* db, wg_int data); wg_int wg_decode_null(void* db, wg_int data); wg_int wg_encode_int(void* db, wg_int data); wg_int wg_decode_int(void* db, wg_int data); wg_int wg_encode_char(void* db, char data); char wg_decode_char(void* db, wg_int data); wg_int wg_encode_record(void* db, void* data); void* wg_decode_record(void* db, wg_int data); wg_int wg_encode_double(void* db, double data); double wg_decode_double(void* db, wg_int data); wg_int wg_encode_fixpoint(void* db, double data); double wg_decode_fixpoint(void* db, wg_int data); wg_int wg_encode_date(void* db, int data); int wg_decode_date(void* db, wg_int data); wg_int wg_encode_time(void* db, int data); int wg_decode_time(void* db, wg_int data); int wg_current_utcdate(void* db); int wg_current_localdate(void* db); int wg_current_utctime(void* db); int wg_current_localtime(void* db); int wg_strf_iso_datetime(void* db, int date, int time, char* buf); int wg_strp_iso_date(void* db, char* buf); int wg_strp_iso_time(void* db, char* inbuf); int wg_ymd_to_date(void* db, int yr, int mo, int day); int wg_hms_to_time(void* db, int hr, int min, int sec, int prt); void wg_date_to_ymd(void* db, int date, int *yr, int *mo, int *day); void wg_time_to_hms(void* db, int time, int *hr, int *min, int *sec, int *prt); wg_int wg_encode_str(void* db, char* str, char* lang); char* wg_decode_str(void* db, wg_int data); char* wg_decode_str_lang(void* db, wg_int data); wg_int wg_decode_str_len(void* db, wg_int data); wg_int wg_decode_str_lang_len(void* db, wg_int data); wg_int wg_decode_str_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_str_lang_copy(void* db, wg_int data, char* langbuf, wg_int buflen); wg_int wg_encode_xmlliteral(void* db, char* str, char* xsdtype); char* wg_decode_xmlliteral_copy(void* db, wg_int data); char* wg_decode_xmlliteral_xsdtype_copy(void* db, wg_int data); wg_int wg_decode_xmlliteral_len(void* db, wg_int data); wg_int wg_decode_xmlliteral_xsdtype_len(void* db, wg_int data); wg_int wg_decode_xmlliteral(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_xmlliteral_xsdtype(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_encode_uri(void* db, char* str, char* nspace); char* wg_decode_uri(void* db, wg_int data); char* wg_decode_uri_prefix(void* db, wg_int data); wg_int wg_decode_uri_len(void* db, wg_int data); wg_int wg_decode_uri_prefix_len(void* db, wg_int data); wg_int wg_decode_uri_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_uri_prefix_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_encode_blob(void* db, char* str, char* type, wg_int len); char* wg_decode_blob(void* db, wg_int data); char* wg_decode_blob_type(void* db, wg_int data); wg_int wg_decode_blob_len(void* db, wg_int data); wg_int wg_decode_blob_copy(void* db, wg_int data, char* strbuf, wg_int buflen); wg_int wg_decode_blob_type_len(void* db, wg_int data); wg_int wg_decode_blob_type_copy(void* db, wg_int data, char* langbuf, wg_int buflen); wg_int wg_encode_var(void* db, wg_int data); wg_int wg_decode_var(void* db, wg_int data); ---- Details: wg_int wg_get_encoded_type(void* db, wg_int data) Return a type of the encoded data (see the documentation for `wg_get_field_type()`) wg_int wg_free_encoded(void* db, wg_int data) Deallocate encoded data. You need to deallocate data if and only if you have encoded it yourself (not read from the field) and have not stored it into any fields. In case the data is stored in a field, you should never deallocate it, otherwise unexpected errors will occur. In case a field is written over or a record is deleted, deallocation is done automatically and properly. wg_int wg_encode_null(void* db, wg_int data) wg_int wg_decode_null(void* db, wg_int data) Not strictly needed; encoded value 0 stands for NULL. wg_int wg_encode_int(void* db, wg_int data) wg_int wg_decode_int(void* db, wg_int data) Encode/decode integers. Observe that shorter integers (28 bits) take less space and are a bit faster: they are kept directly in the field. wg_int wg_encode_char(void* db, char data) char wg_decode_char(void* db, wg_int data) Encode/decode a single char. Kept directly in the field. wg_int wg_encode_record(void* db, void* data) void* wg_decode_record(void* db, wg_int data) Encodes/decode a pointer to the record. wg_int wg_encode_double(void* db, double data) double wg_decode_double(void* db, wg_int data) Encode/decode ordinary doubles. Allocated separately. wg_int wg_encode_fixpoint(void* db, double data) double wg_decode_fixpoint(void* db, wg_int data) Encode/decode doubles as small and fast fixpoint numbers. Data must be a double between -800...800, four places after comma are kept after rounding. wg_int wg_encode_date(void* db, int data) int wg_decode_date(void* db, wg_int data) Unencoded date is a number of years since year 0. Use 1 as the first year. Kept directly in the field. wg_int wg_encode_time(void* db, int data) int wg_decode_time(void* db, wg_int data) Unencoded time is a number of 100-ths of a seconds past midnight. Kept directly in the field. int wg_current_utcdate(void* db) int wg_current_localdate(void* db) int wg_current_utctime(void* db) int wg_current_localtime(void* db) Gives current unencoded date or time, either utc or local. int wg_strf_iso_datetime(void* db, int date, int time, char* buf) Stores unencoded date and time as an iso datetime with 100-ths of seconds in the buf using iso format like 2010-03-31T12:59:00.33 int wg_strp_iso_date(void* db, char* buf) int wg_strp_iso_time(void* db, char* inbuf) Parses unencoded date or time from the part of iso string like 2010-03-31 or 12:59:00.33 and returns it. int wg_ymd_to_date(void* db, int yr, int mo, int day) int wg_hms_to_time(void* db, int hr, int min, int sec, int prt) Return scalar date or time like the above ISO string parsing functions, except the parameters are given as integer values (for ex: 2010, 1, 7). void wg_date_to_ymd(void* db, int date, int *yr, int *mo, int *day) void wg_time_to_hms(void* db, int time, int *hr, int *min, int *sec, int *prt) Reverse conversion functions for scalar date and time into separate integer values. wg_int wg_encode_str(void* db, char* str, char* lang) char* wg_decode_str(void* db, wg_int data) char* wg_decode_str_lang(void* db, wg_int data) wg_int wg_decode_str_len(void* db, wg_int data) wg_int wg_decode_str_lang_len(void* db, wg_int data) wg_int wg_decode_str_copy(void* db, wg_int data, char* strbuf, wg_int buflen) wg_int wg_decode_str_lang_copy(void* db, wg_int data, char* langbuf, wg_int buflen) All strings are 0-terminated standard C strings. Lang parameter is the extra-string which may be given 0. Simple decode returns a pointer to the string. `wg_decode_str_copy()` copies the string to the given buffer with a given buflen. A WG_ILLEGAL value is returned in case of encoding error, NULL in case of string decoding errors, -1 in case of length decoding errors. wg_int wg_encode_xmlliteral(void* db, char* str, char* xsdtype) char* wg_decode_xmlliteral_copy(void* db, wg_int data) char* wg_decode_xmlliteral_xsdtype_copy(void* db, wg_int data) wg_int wg_decode_xmlliteral_len(void* db, wg_int data) wg_int wg_decode_xmlliteral_xsdtype_len(void* db, wg_int data) wg_int wg_decode_xmlliteral(void* db, wg_int data, char* strbuf, wg_int buflen) wg_int wg_decode_xmlliteral_xsdtype(void* db, wg_int data, char* strbuf, wg_int buflen) Analogous to str functions, the extra-string represents xmlliteral xsdtype, may be NULL. wg_int wg_encode_uri(void* db, char* str, char* nspace) char* wg_decode_uri(void* db, wg_int data) char* wg_decode_uri_prefix(void* db, wg_int data) wg_int wg_decode_uri_len(void* db, wg_int data) wg_int wg_decode_uri_prefix_len(void* db, wg_int data) wg_int wg_decode_uri_copy(void* db, wg_int data, char* strbuf, wg_int buflen) wg_int wg_decode_uri_prefix_copy(void* db, wg_int data, char* strbuf, wg_int buflen) Analogous to str functions, the extra-string represents uri prefix, may be NULL. wg_int wg_encode_blob(void* db, char* str, char* type, wg_int len) char* wg_decode_blob(void* db, wg_int data) char* wg_decode_blob_type(void* db, wg_int data) wg_int wg_decode_blob_len(void* db, wg_int data) wg_int wg_decode_blob_copy(void* db, wg_int data, char* strbuf, wg_int buflen) wg_int wg_decode_blob_type_len(void* db, wg_int data) wg_int wg_decode_blob_type_copy(void* db, wg_int data, char* langbuf, wg_int buflen) Analogous to str functions, except that: - data is not 0-terminated, length must be always passed. - the extra-string represents blob type, may be NULL wg_int wg_encode_var(void* db, wg_int data) wg_int wg_decode_var(void* db, wg_int data) Data to be encoded is a variable identifier which is an integer. Values up to 28 bit size may be safely used on any modern hardware. Dumping and restoring database contents to/from disk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: [source,C] ---- wg_int wg_dump(void * db,char* fileName); wg_int wg_import_dump(void * db,char* fileName); wg_int wg_start_logging(void *db); wg_int wg_stop_logging(void *db); wg_int wg_replay_log(void *db, char *filename); ---- Details: wg_int wg_dump(void * db,char* fileName) Dump shared memory database to the disk. If the database has journal logging enabled, this will also restart the journal (creating a fresh journal file). Returns 0 on success, -1 on non-fatal error and -2 on a fatal error. In case of a fatal error, the database is in a corrupt state and should not (or cannot) be used further. wg_int wg_import_dump(void * db,char* fileName) Import database from the disk. If the database has journal logging enabled, this will also start the journal log (creating a fresh journal file) when the import is completed. Note that whether the journal is enabled is determined by the *current* memory segment, not the state of the database at the moment the dump was created. Returns 0 on success, -1 on non-fatal error and -2 on a fatal error. In case of a fatal error, the database is in a corrupt state. Otherwise, the import failed (dump file not found or incompatible format), but the memory image was not modified. wg_int wg_start_logging(void *db) Start the journal log. The journal logs are created in the directory determined at compilation time and have a name following the pattern 'wgdb.journal.' where 'shmname' is the name of the database. Call to this function always causes a new journal file to be created. When a previous journal file exists at the time the journal is started, it is backed up into a file named 'wgdb.journal..' where 'serial' is the next available suffix. If there are too many backups already present, the oldest one is overwritten instead. Returns 0 on success, -1 when logging is already active, -2 when the function failed and logging is not active and -3 when additionally, the log file was possibly destroyed NOTE: Normally, the journal is started upon the database creation by calling `wg_attach_logged_database()` and it is not necessary to call this function. wg_int wg_stop_logging(void *db) Suspend the journal log. None of the writes by any client connected to the database will be logged from this point. Returns 0 on success, non-zero on failure. NOTE: Normally it is not necessary to manually stop and start the journal. wg_int wg_replay_log(void *db, char *filename) Restore the database from the journal. If logging is enabled, this function will also suspend the journal during the restore and restart it afterwards (creating a fresh journal file). Returns 0 on success, -1 on non-fatal error and -2 on a fatal error. In case of a fatal error, the database is in a corrupt state. Otherwise, the replay failed, but the database currently in memory was not modified. Journal restarts and filenames ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The current journal file always has the name 'wgdb.journal.' (for example, 'wgdb.journal.1000'). If the database has logging enabled, all of the writes will be recorded in that file. Journal restarts will cause the current journal to be backed up and the 'wgdb.journal.' file will be replaced with a fresh journal. Example 1: Only 'wgdb.journal.99' exists. The database is dumped to the disk, causing a journal restart. The filenames after the restart will be: wgdb.journal.99 --> wgdb.journal.99.0 a new empty journal --> wgdb.journal.99 Example 2: The current journal is 'wgdb.journal.1000'. There is also an older backup with the name 'wgdb.journal.1000.0'. The new filenames: wgdb.journal.1000 --> wgdb.journal.1000.1 wgdb.journal.1000.0 --> wgdb.journal.1000.0 (unchanged) a new empty journal --> wgdb.journal.1000 Example 3: There are 10 backups (the maximum amount the database is configured to handle). The oldest one of them is 'wgdb.journal.1000.0', the newest one is 'wgdb.journal.1000.9'. There is also the current journal 'wgdb.journal.1000'. After the restart, the filenames are: wgdb.journal.1000 --> wgdb.journal.1000.0 (overwriting the oldest backup) wgdb.journal.1000.1 --> wgdb.journal.1000.1 (unchanged) ... wgdb.journal.1000.9 --> wgdb.journal.1000.9 (unchanged) a new empty journal --> wgdb.journal.1000 Interaction between dump files and journal ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If the database has journal logging enabled, the latest database state is normally recoverable by importing the latest dump (if it exists) and replaying the journal created after that dump (or at the initialization of the database, if there is no dump). When dumping the database, the journal will be restarted and will be generated into a new file. Importing a dump will also have the same effect. Journal replay also causes the journal to be restarted so that the point of restore is distinguishable later. However, in this situation, the latest database state will be represented, incrementally, by the latest dump, the recovered journal and the new journal (until a new dump is created). Read and write locking the database for concurrency control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: [source,C] ---- wg_int wg_start_write(void * dbase); /* start write transaction */ wg_int wg_end_write(void * dbase, wg_int lock); /* end write transaction */ wg_int wg_start_read(void * dbase); /* start read transaction */ wg_int wg_end_read(void * dbase, wg_int lock); /* end read transaction */ ---- Overview ^^^^^^^^ Concurrency control in WhiteDB is achieved using a single database-level shared/exclusive lock. It is implemented independently of the rest of the db API (currently) - therefore use of the locking routines does not automatically guarantee isolation. Generally, a database level lock is characterized by very low overhead but maximum possible contention. This means that processes should spend as little time between acquiring a lock and releasing it, as possible. Implementation and current limitations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ There are three alternative implementations. - Simple reader-preference lock using a single global spinlock (described by Mellor-Crummey & Scott '92). Reader-preference means that this lock can cause writer starvation. Tests have shown good performance under N>>P conditions (N- number of processes, P- number of CPU-s). - A writer-preference version of the spinlock. - A task-fair lock implemented using a queue. This lock is not susceptible to starvation, but has higher overhead compared to the spinlocks. The waiting processes are synchronized using the futex kernel interface. Current limitations: - dead processes hold locks indefinitely. - maximum timeout with spinlocks is 2000 ms. - the task-fair lock is only supported on Linux. Configuration ^^^^^^^^^^^^^ By default, WhiteDB is compiled with the task-fair lock if it is available and reader-preference spinlock otherwise. The writer-preference lock is selected by `./configure --enable-locking=wpspin`. The reader-preference lock is selected by `./configure --enable-locking=rpspin`. When using manual build, the LOCK_PROTO macro in 'config.h' (or 'config-w32.h') can be modified to select the locking method. For plaforms that do not support the atomic operations, use `./configure --disable-locking` or edit the appropriate header file and comment out the LOCK_PROTO macro. This will allow the code to compile correctly, but the database should be used by a single user or process only. Usage ^^^^^ Getting a shared (read) lock: [source,C] ---- wg_int lock_id; void *db; /* should be initialized before calling wg_start_read() */ ... /* acquire lock. This function normally blocks until the lock * is aquired */ lock_id = wg_start_read(db); if(!lock_id) { /* getting the lock failed, do something */ } else { ... one or more database reads ... /* release the lock */ if(!wg_end_read(db, lock_id)) { /* this is unlikely to fail, but if it does, the consequenses * could be severe, so this error should also be handled. */ } } ---- Getting an exclusive (write) lock is similar: [source,C] ---- wg_int lock_id; ... /* acquire lock. */ lock_id = wg_start_write(db); if(!lock_id) { /* getting the lock failed, do something */ } else { ... one or more database write operations ... /* release the lock */ if(!wg_end_write(db, lock_id)) { /* handle error */ } } ---- Porting ^^^^^^^ For platforms that do not support either GNU C or Win32 builtin functions that implement the atomic operations in 'dblock.c', appropriate code should be added to each of the platform-specific helper functions. The macro _MM_PAUSE can generally be defined as empty on platforms that do not support Pentium 4/Athlon64-specific "pause" instruction. This will not have a significant effect (or in other words, the "pause" instruction is only actually useful on aforementioned processor families). Writing safely without a write lock ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Although it is in general crucial to use wg_start_write before writing any data in a concurrent setting, in simple special cases it is possible to safely avoid write locks while writing data. The following atomic functions all assume that the field contains an immediate value (NULL, short integer, char, date or time), the value written is also immediate, the field is not indexed and logging is not activated. This guarantees that no allocation operations are performed and thus it is safe to rely on read locks (wg_start_read and wg_end_read) while writing data: [source,C] ---- wg_int wg_update_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data, wg_int old_data); wg_int wg_set_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data); wg_int wg_add_int_atomic_field(void* db, void* record, wg_int fieldnr, int data); ---- Details: wg_update_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data, wg_int old_data); Given the assumptions described before, write data to field which is currently contains old_data. If the field does not contain old_data while writing, an error is generated and writing is cancelled: this is checked by the atomic compare-and-swap operation. Returns 0 if the operation was successful. wg_set_atomic_field(void* db, void* record, wg_int fieldnr, wg_int data); Perform the wg_update_atomic_field operation using the current value as old_data iteratively until it succeeds. In a normal situation the operation is expected to succeed immediately without any iterations. All the preconditions described before are checked. Returns 0 if the operation was successful. wg_add_int_atomic_field(void* db, void* record, wg_int fieldnr, int data); Increase or decrease an existing short integer value in the field by adding integer data to this value. Performs an atomic update operation iteratively until it succeeds. In a normal situation the operation is expected to succeed immediately without any iterations. All the preconditions described before are checked. Returns 0 if the operation was successful. The three atomic functions may return any of these errors: - -1 if wrong db pointer - -2 if wrong fieldnr - -10 if new value non-immediate - -11 if old value non-immediate - -12 if cannot fetch old data - -13 if the field has an index - -14 if logging is active - -15 if the field value has been changed from old_data - -16 if the result of the addition does not fit into a smallint - -17 if atomic assignment failed after a large number (1000) of tries Semi-structured data ~~~~~~~~~~~~~~~~~~~~ [source,C] ---- wg_int wg_parse_json_file(void *db, char *filename); wg_int wg_parse_json_document(void *db, char *buf, void **document); wg_int wg_parse_json_fragment(void *db, char *buf, void **document); ---- Details: wg_int wg_parse_json_file(void *db, char *filename) Parses JSON data from a file and insert it into the database as structured records. The parsing is done in two passes - first a syntax checking pass and then data insertion pass. If the JSON data is invalid, the database contents are not modified. Returns 0 if the data is stored successfully, -1 if there is a non-fatal (most likely syntax) error and -2 if the storing fails and the database is inconsistent after the function returns. wg_int wg_parse_json_document(void *db, char *buf, void **document) Parses JSON data from the buffer and inserts it into the database. There is no separate syntax checking pass so the JSON input should be valid. Returns 0 if the data is stored successfully, -1 if there is a non-fatal error and -2 if the storing fails and the database is inconsistent after the function returns. If the function is successful, '**document' is set to point to the top-level record in the structure. The resulting data is marked as a whole document, meaning that it is can be treated as a single unit of data by API functions that are JSON-aware. wg_int wg_parse_json_fragment(void *db, char *buf, void **document) Like `wg_parse_json_document()` except the resulting data is not marked as a whole document. Data representation ^^^^^^^^^^^^^^^^^^^ The JSON is converted to a semi-structured schema by creating a hierarchy of records. The top-level record in this hierarchy is additionally marked as a document, allowing to handle JSON documents as single units of data. Conversion of JSON to whitedb semi-structured schema: |========================================================================== | JSON | whitedb | top-level | object or mapping | record containing references to key-value pairs | yes | - | record containing a single key-value pair | no | array | record (same length as array) | yes |========================================================================== Array record fields and value fields may contain either immediate values or recursively other arrays or objects. The object record fields always contain links to key-value pair records. The key-value pair record holds the key (a string) in column 1 and the value in column 2. Example: The JSON '{"a" : [1, 2, 3], "b" : "c"}' would be converted to [ record link | record link ]* / \ [ | "a" | record link ] [ | "b" | "c" ] / [ 1 | 2 | 3 ] Where '*' marks the top-level record in the document. Utilities ~~~~~~~~~ void wg_print_db(void *db) Print entire database contents in stdout, row by row. void wg_print_record(void *db, wg_int* rec) Print just one row, pointed to by rec. void wg_snprint_value(void *db, wg_int enc, char *buf, int buflen) Print a single, encoded value into a character buffer. wg_int wg_parse_and_encode(void *db, char *buf) Parse value from a string, encode it for WhiteDB. Returns WG_ILLEGAL if value could not be parsed or encoded. Following types are detected automatically from the input: - NULL - empty string - int - plain integer - double - floating point number in fixed decimal notation - date - ISO8601 date - time - ISO8601 time+fractions of second. - string - input data that does not match the above types Does NOT support ambiguous types: - fixpoint - floating point number in fixed decimal notation - uri - string starting with an URI prefix - char - single character Does NOT support types which would require a special encoding scheme in string form: record, XML literal, blob, anon const, variables Note that double values need to have CSV_DECIMAL_SEPARATOR as the decimal marker, independent of the system locale settings. wg_int wg_parse_and_encode_param(void *db, char *buf) Like `wg_parse_and_encode()`, except the returned value is encoded as a query parameter. Values encoded like this should be freed with wg_free_query_param() and cannot be used interchangeably with other encoded values. Query functions ~~~~~~~~~~~~~~~ [source,C] ---- wg_query *wg_make_query(void *db, void *matchrec, wg_int reclen, wg_query_arg *arglist, wg_int argc); void *wg_fetch(void *db, wg_query *query); void wg_free_query(void *db, wg_query *query); wg_int wg_encode_query_param_null(void *db, char *data); wg_int wg_encode_query_param_record(void *db, void *data); wg_int wg_encode_query_param_char(void *db, char data); wg_int wg_encode_query_param_fixpoint(void *db, double data); wg_int wg_encode_query_param_date(void *db, int data); wg_int wg_encode_query_param_time(void *db, int data); wg_int wg_encode_query_param_var(void *db, wg_int data); wg_int wg_encode_query_param_int(void *db, wg_int data); wg_int wg_encode_query_param_double(void *db, double data); wg_int wg_encode_query_param_str(void *db, char *data, char *lang); wg_int wg_encode_query_param_xmlliteral(void *db, char *data, char *xsdtype); wg_int wg_encode_query_param_uri(void *db, char *data, char *prefix); wg_int wg_free_query_param(void* db, wg_int data); ---- wg_query *wg_make_query(void *db, void *matchrec, wg_int reclen, wg_query_arg *arglist, wg_int argc) Build a query using parameters in match record and argument list formats. The match record is an array of encoded values of wg_int type. This can either be allocated by the caller, in which case the reclen should contain the size of the array, or point to an existing database record, in which case reclen must be zero. The argument list format consists of an array of: [source,C] ---- typedef struct { gint column; /** column (field) number this argument applies to */ gint cond; /** condition (equal, less than, etc) */ gint value; /** encoded value */ } wg_query_arg; ---- Available conditions are: WG_COND_EQUAL = WG_COND_NOT_EQUAL != WG_COND_LESSTHAN < WG_COND_GREATER > WG_COND_LTEQUAL <= WG_COND_GTEQUAL >= argc is the size of the array (at least 1 is required if arglist parameter is given). The function returns NULL if there is an error, otherwise a pointer to a query object is returned. When the query is no longer used, wg_free_query() should be called to release it's memory. If arglist and matchrec are NULL, the query has no parameters and will return all the rows in the database. void *wg_fetch(void *db, wg_query *query) Fetch next row from the query result. Returns a pointer to the next row (same as `wg_get_next_record()`). Returns NULL if there are no more rows. void wg_free_query(void *db, wg_query *query) Release the memory pointed to by query. wg_int wg_encode_query_param_*() Family of functions to prepare the parameters for `wg_make_query()`. They return a WhiteDB encoded value when successful or WG_ILLEGAL on failure. Locking the database when using these functions is not required, since they do not access shared memory. wg_int wg_free_query_param(void* db, wg_int data) Free the storage allocated for the encoded data which has been prepared with the `wg_encode_query_param_*()` family of functions. It is not advisable to call this on data encoded with other functions. Simplified query functions ^^^^^^^^^^^^^^^^^^^^^^^^^^ [source,C] ---- void *wg_find_record(void *db, wg_int fieldnr, wg_int cond, wg_int data, void* lastrecord); void *wg_find_record_null(void *db, wg_int fieldnr, wg_int cond, char *data, void* lastrecord); void *wg_find_record_record(void *db, wg_int fieldnr, wg_int cond, void *data, void* lastrecord); void *wg_find_record_char(void *db, wg_int fieldnr, wg_int cond, char data, void* lastrecord); void *wg_find_record_fixpoint(void *db, wg_int fieldnr, wg_int cond, double data, void* lastrecord); void *wg_find_record_date(void *db, wg_int fieldnr, wg_int cond, int data, void* lastrecord); void *wg_find_record_time(void *db, wg_int fieldnr, wg_int cond, int data, void* lastrecord); void *wg_find_record_var(void *db, wg_int fieldnr, wg_int cond, wg_int data, void* lastrecord); void *wg_find_record_int(void *db, wg_int fieldnr, wg_int cond, int data, void* lastrecord); void *wg_find_record_double(void *db, wg_int fieldnr, wg_int cond, double data, void* lastrecord); void *wg_find_record_str(void *db, wg_int fieldnr, wg_int cond, char *data, void* lastrecord); void *wg_find_record_xmlliteral(void *db, wg_int fieldnr, wg_int cond, char *data, char *xsdtype, void* lastrecord); void *wg_find_record_uri(void *db, wg_int fieldnr, wg_int cond, char *data, char *prefix, void* lastrecord); ---- These functions provide a simplified alternative to the query functions. void *wg_find_record(void *db, wg_int fieldnr, wg_int cond, wg_int data, void* lastrecord); Returns the first record in the database that where "fieldnr" "cond" "data" is true. `data` is an encoded value. `cond` is one of the conditions listed under "Query functions". The `wg_find_record_*()` group of functions are convinience functions for using unencoded data directly. The user is not required to encode or free encoded data when using these functions. Comparison of the query interfaces ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |========================================================================= | | Full query | simplified query | query type | conjunctive | one clause only | without index | slower | faster | with index, fetch one row | slower | faster | with index, fetch many (>5) rows | faster | much slower | isolation | "read commited" | none |========================================================================= NOTE: the isolation level given here is only an approximation. Up to "serializable" is currently possible with the use of `wg_start_*()` and `wg_end_*()` functions, but this may become relaxed during future development. Child databases ~~~~~~~~~~~~~~~ Note: child db is not compiled in by default. Use `./configure --enable-childdb` or for manual build, edit the appropriate 'config-xxx.h' file and enable the USE_CHILD_DB macro. wg_int wg_register_external_db(void *db, void *extdb) Store information in db about an external database extdb. This allows storing data from extdb inside db. Returns 0 on success, negative on error. wg_int wg_encode_external_data(void *db, void *extdb, wg_int encoded) Translate an encoded value from extdb to another encoded value which may be stored into db. Physically the data (assuming there is any memory allocated) continues to reside in extdb. Child databases are databases which contain references to data (fields and records) located in another database, called parent. The requirement is that both the child and parent are located in the same virtual address space. A typical scenario is that a "main" shared memory database is used as the parent and temporary, local memory databases are created as children. Main difference between referring to local and external data is that external references are (intentionally) not tracked by the parent database. This allows instantly deleting the child databases. On the other hand, extra measures must be taken to ensure that the referenced external data stays intact while in use by the child database. Read locking the parent database should be sufficient there. Typical usage scenario ^^^^^^^^^^^^^^^^^^^^^^ (assuming parent is already created) Create a child database and assign the parent. [source,C] ---- childdb = wg_attach_local_database(size); wg_register_external_db(childdb, parentdb); ---- Use parent data in child database. Encoded data from parent database must be re-encoded before writing it to the child database. [source,C] ---- tmp = wg_encode_external_data(childdb, parentdb, parentdata); wg_set_field(childdb, childrec, 0, tmp); ---- Free child database, when done. [source,C] wg_delete_local_database(childdb); There are three main restrictions when using external references: - External references may not be written into shared memory databases. For this reason, `wg_register_external_db()` may only be called with a local (non-shared) database as the first argument. - once an external database X is registered inside another database Y, the database Y may no longer be dumped/restored. - A database that contains external references cannot be indexed. Getting information about the database state ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [source,C] ---- wg_int wg_database_freesize(void *db); wg_int wg_database_size(void *db); ---- These functions provide information about the database size and available free space. wg_int wg_database_size(void *db) Returns the total memory segment size for the database, in bytes. wg_int wg_database_freesize(void *db) Returns the amount of free space in the database memory segment, in bytes. Note that this is a conservative estimate, meaning that the actual amount of free space may be more, but no less, than reported. RDF parsing / exporting API --------------------------- This API is dependent on libraptor. It is not available on Win32. When compiling WhiteDB without autotools (using `compile.sh`) the API can be enabled by defining HAVE_RAPTOR in 'config.h' and modifying build scripts to link with appropriate libraries. [source,C] ---- #include "rdfapi.h" wg_int wg_import_raptor_file(void *db, wg_int pref_fields, wg_int suff_fields, wg_int (*callback) (void *, void *), char *filename); wg_int wg_import_raptor_rdfxml_file(void *db, wg_int pref_fields, wg_int suff_fields, wg_int (*callback) (void *, void *), char *filename); wg_int wg_rdfparse_default_callback(void *db, void *rec); wg_int wg_export_raptor_file(void *db, wg_int pref_fields, char *filename, char *serializer); wg_int wg_export_raptor_rdfxml_file(void *db, wg_int pref_fields, char *filename); ---- wg_int wg_import_raptor_file(void *db, wg_int pref_fields, wg_int suff_fields, wg_int (*callback) (void *, void *), char *filename) Imports RDF file. Creates records with length = pref_fields + 3 + suff_fields. The data will be stored as follows: | pref_fields .. | predicate | subject | object | suff_fields | The file type is determined automatically from filename. Callback function should match the prototype of `wg_rdfparse_default_callback()` and can be used to calculate contents of fields other than the RDF triple. wg_int wg_import_raptor_rdfxml_file(void *db, wg_int pref_fields, wg_int suff_fields, wg_int (*callback) (void *, void *), char *filename) As above, but file type is assumed to be RDF/XML wg_int wg_rdfparse_default_callback(void *db, void *rec) Does nothing. Called when importing rdf files with the 'wgdb' commandline tool. May be modified to add field initialization functionality to commandline importing. wg_int wg_export_raptor_file(void *db, wg_int pref_fields, char *filename, char *serializer) Export triple data to file. The format is selected by the raptor serializer (more info about serializers can be found at http://librdf.org/raptor/. There is also serializers enumeration function in libraptor API). The pref_fields parameters marks the start position of the triple in WhiteDB records (storage schema is assumed to be the same as described above for wg_import_raptor_file() function). wg_int wg_export_raptor_rdfxml_file(void *db, wg_int pref_fields, char *filename) Export triple data to file in RDF/XML format. Index API --------- [source,C] ---- #include wg_int wg_create_index(void *db, wg_int column, wg_int type, wg_int *matchrec, wg_int reclen); wg_int wg_drop_index(void *db, wg_int index_id); wg_int wg_column_to_index_id(void *db, wg_int column, wg_int type, wg_int *matchrec, wg_int reclen); wg_int wg_get_index_type(void *db, wg_int index_id); void * wg_get_index_template(void *db, wg_int index_id, wg_int *reclen); void * wg_get_all_indexes(void *db, wg_int *count); ---- Index API header exposes functions to create and drop indexes. wg_int wg_create_index(void *db, wg_int column, wg_int type, wg_int *matchrec, wg_int reclen) Create an index on column. Index type must be specified. Currently supported index types: WG_INDEX_TYPE_TTREE - T-tree index on single column If matchrec is NULL, a normal index is created. If matchrec is non-null, the index will be created with a template. In this case reclen must specify the length of the array pointed to by matchrec. If an index has a template, only records that match the template are inserted into the index. Wildcards in the template are specified using WG_VARTYPE values. This function returns 0 if successful and non-0 in case of an error. wg_int wg_drop_index(void *db, wg_int index_id) Delete the specified index. Returns 0 on success, non-0 on error. wg_int wg_column_to_index_id(void *db, wg_int column, wg_int type, wg_int *matchrec, wg_int reclen) Find an index on a column. If type is specified, the first index with a matching type is returned. If type is 0, indexes of any type may be returned. If matchrec is non-NULL and WhiteDB is configured with USE_INDEX_TEMPLATE option, the provided match record will be used to locate an index with a specified template. If matchrec is NULL, this function finds a full index. Returns an index id on success. Returns -1 on error. wg_int wg_get_index_type(void *db, wg_int index_id) Finds index type. Returns type (>0) on success, -1 if the index was not found. void * wg_get_index_template(void *db, wg_int index_id, wg_int *reclen) Finds index template. Returns a pointer to the gint array used for the index template. reclen is set to the length of the array. The pointer may not be freed and it's contents should be accessed read-only. If the index is not found or has no template, NULL is returned. In that case contents of *reclen are unmodified. void * wg_get_all_indexes(void *db, wg_int *count) Returns a pointer to a NEW allocated array of index id-s. count is initialized to the number of indexes in the array. Returns NULL if there are no indexes. Examples ~~~~~~~~ Create a T-tree index on a column conditionally: [source,C] ---- if(wg_column_to_index_id(db, col, WG_INDEX_TYPE_TTREE, NULL, 0) == -1) { if(wg_create_index(db, col, WG_INDEX_TYPE_TTREE, NULL, 0)) { printf("index creation failed.\n"); } else { printf("index created.\n"); } } ---- Create an index on column 0 that only contains rows where the 2-nd column is equal to 6 (requires that WhiteDB is compiled with USE_INDEX_TEMPLATE defined in config.h): [source,C] ---- wg_int matchrec[3]; matchrec[0] = wg_encode_var(db, 0); matchrec[1] = wg_encode_var(db, 0); matchrec[2] = wg_encode_int(db, 6); if(wg_create_index(db, 0, WG_INDEX_TYPE_TTREE, matchrec, 3)) { printf("index creation failed.\n"); } ---- Delete all indexes in the database that have a template: [source,C] ---- wg_int *indexes = wg_get_all_indexes(db, &count); for(i=0; i /* or #include on Windows */ int main(int argc, char **argv) { void *db; db = wg_attach_database("1000", 2000000); return 0; } ---- First, the program needs to include the API headers. There are a few other header files distributed with WhiteDB, but 'dbapi.h' is the one we'll need for now. NOTE: The programs in the 'Examples' directory use a different way of including the headers, by referring to their location directly. This is so that the examples can be compiled before the installation of the database and it is perfectly acceptable - but let's stick to the standard way of using library headers in this tutorial. `void *db` is the database handle. Once we have the handle, we can use it in all the subsequent database operations - it will always point to the same database we originally attached to. Why stress that it is the same database? WhiteDB allows using multiple databases in parallel, without any prior configuration. The number "1000" we give to the `wg_attach_database()` function is the key that refers to the shared memory segment containing our database. Observe that when using `wg_attach_database()`, it does not matter whether the database already exists or not - it will be created, if necessary. The size of the database will be the one we supplied, 2MB in this case. When the program exits, the database will remain in memory. When you have already created a database in shared memory, you can later use `wg_attach_existing_database(dbname)` which functions exactly as `wg_attach_database(dbname,...)` but does not create a new database. If no database with the name `dbname` is found, it simply returns NULL. This is quite handy when you want to avoid creating a new base or just want to check whether it exists already. Adding data to the database --------------------------- An empty database isn't usually much of a practical use, so we need to learn how to populate it with data. It is actually a three-step process: creating a record, encoding the data and writing to the fields of the records. Records ~~~~~~~ A WhiteDB record is a n-tuple of encoded data. The n refers to the length of the record and there is no specific limit except that it must fit inside the database memory segment (of course, the size is given as `wg_int`, the universal datatype of WhiteDB, which itself has a maximum value, but this is quite large, especially on a 64-bit system). void *rec = wg_create_record(db, 10); The datatype of the record is `void *`, just like the database handle. Now we can use `rec` any time we need to do something with the record we've created. By the way, the records do not all need to be the same size, so we could do void *rec2 = wg_create_record(db, 2); and have two records, one of them 10 fields and the other 2 fields in size. However, the size is final and cannot be changed later. Data in WhiteDB ~~~~~~~~~~~~~~~ An important distinction between WhiteDB and traditional databases is that the user can and in some cases must pop the hood open and get their hands dirty. Data encoding is one of such cases. Everything inside the database is a "WhiteDB int", or a `wg_int` when we're writing C code. These are basically numbers (32-bit or 64-bit integers, depending on your system), but for WhiteDB they contain encoded pieces of information - type of a value and the value itself or some way to access the value. So whenever we need to write something, be it a string, a number or a date to the database, first we have to encode it so that WhiteDB is ready to handle it. wg_int enc = wg_encode_int(db, 443); wg_int enc2 = wg_encode_str(db, "this is my string", NULL); The first line should be self-explanatory - `enc` is now 443 in WhiteDB's internal format. When encoding a string, be aware that the string itself will be written to the database memory segment at that point - the encoded value `enc2` will merely contain a reference to it. Also, there is a third parameter which we can ignore for simple applications. Setting field values ~~~~~~~~~~~~~~~~~~~~ You may be asking yourself why do we need to bother with encoding the values when we could simply write things like integers or character arrays directly. The main reason for that is that WhiteDB is schemaless. When we created records, we did not specify what type any of the fields were - they can be of any type. The encoded value is how WhiteDB can tell what type of data it is dealing with, since field 1 could be an integer in one record, a floating-point number in another one and so on. With that out of the way, let's take our encoded data and store it properly in the database: wg_set_field(db, rec, 7, enc); wg_set_field(db, rec2, 0, enc2); Field 7 of the first record now contains 443 and field 0 of the second record (which has two fields, field 0 and field 1) contains "this is my string". We didn't touch any of the other fields and if we were to look at the contents of the records now, these would be filled with NULL values. Each time a new record is created, it initially contains a row of NULL-s which the user can then overwrite with their own data. Here is our complete example ('Examples/tut2.c'): [source,C] ---- #include int main(int argc, char **argv) { void *db, *rec, *rec2; wg_int enc, enc2; db = wg_attach_database("1000", 2000000); rec = wg_create_record(db, 10); rec2 = wg_create_record(db, 2); enc = wg_encode_int(db, 443); enc2 = wg_encode_str(db, "this is my string", NULL); wg_set_field(db, rec, 7, enc); wg_set_field(db, rec2, 0, enc2); return 0; } ---- It is likely that you need to deal with more types than just strings and integers. The manual will provide a full list of supported types. The wgdb utility ---------------- Once you've started working with WhiteDB, the `wgdb` tool may come in handy to manage the databases, so let's take a quick look at it. First we deal with database persistence, you may skip to "Looking at data" if you're not on Windows. Database persistence on Windows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The way shared memory works on Windows is that it is only present as long as there is a program holding a handle to it. So when we compile and run the previous example, the data gets written to the memory but then the program terminates and the database immediately disappears. To get around that, run wgdb.exe 1000 server 2000000 in another window. That will keep the shared memory present, until you press CTRL+C. You can now run the tutorial programs and the following examples should work. Looking at data ~~~~~~~~~~~~~~~ If you ran the program from the previous section, there should be some records in memory now. Let's take a look: wgdb 1000 select 20 It should return something like this: [NULL,NULL,NULL,NULL,NULL,NULL,NULL,443,NULL,NULL] ["this is my string",NULL] The "1000" in the command is the same shared memory key we used earlier. "select" prints records from the database and "20" limits the maximum number of records that will be shown. There is also a query command that lets you specify which records you are interested in: wgdb 1000 query 7 = 443 That will only return the first record, the one where field 7 equals 443. There are other comparison operators: "!=" for not equal, "<" for less than, "<=" for less than or equal and so forth. Currently the query command does not have a row limit parameter. Modifying data ~~~~~~~~~~~~~~ The command line tools allows some data manipulation: deleting and adding records. The "del" command has the same syntax as the query command, so wgdb 1000 del 7 = 443 will delete the first row from the database. We can also add records, but only integer and string values are recognized this way - dealing with other types unambiguously would become complicated. wgdb 1000 add 1 2 3 This created a record with the length 3 and inserted three integer values in it. Let's see what the database now contains. By the way, since "1000" is the default key, we may omit it: wgdb select 20 The entire contents of the database will now be: ["this is my string",NULL] [1,2,3] Freeing the memory ~~~~~~~~~~~~~~~~~~ At some point we may need to delete the database for whatever reason. The `wgdb` tool will help: wgdb 1000 free The database with the given key will be freed. Again, "1000" may be omitted as it is the default. Making queries -------------- Finding matching records ~~~~~~~~~~~~~~~~~~~~~~~~ Finding records that match some condition is easy: void *rec = wg_find_record_int(db, 7, WG_COND_EQUAL, 443, NULL); This returns the first record that has the integer 443 in field 7. That much is obvious, but some of the parameters might need extra explanation. First, just a reminder that `db` is the database handle we've been using each time we call a WhiteDB function. As a second parameter we give the number of the field that the database engine should check against the value we've given. The third parameter is the condition: we need some way of stating that we want records where "field 7" "equals" "443" so that is the "equals" part. There are other conditions, for example, if we substituted WG_COND_LESSTHAN there, we would receive a record where the value in field 7 is less than 443. The full list of possibe conditions is given in 'Manual.txt'. The fourth parameter is, of course, the value. The function we called ended with '_int' and that parameter should also be of the type `int`. There is a function for most of WhiteDB's datatypes, so if we were looking for a string we would use `wg_find_record_str()` instead. Now let's turn our attention to the mysterious NULL parameter. Remember that our example function call returned the *first* record that matched our parameters? What if there are more matching records and we want to find those too? That can be done: void *nextrec = wg_find_record_int(db, 7, WG_COND_EQUAL, 443, rec); Instead of the NULL, we can give the record that the function returned last time and WhiteDB will return the next one that matches the same condition. The following example will call `wg_find_record_int()` in a cycle, finding all the matching record from the database. We're adding some records, so it will print "Found a record..." at least once. Run it multiple times and see the number of matching records increase ('Examples/tut3.c'): [source,C] ---- #include #include int main(int argc, char **argv) { void *db, *rec; wg_int enc; db = wg_attach_database("1000", 2000000); /* create some records for testing */ rec = wg_create_record(db, 10); enc = wg_encode_int(db, 443); /* will match */ wg_set_field(db, rec, 7, enc); rec = wg_create_record(db, 10); enc = wg_encode_int(db, 442); wg_set_field(db, rec, 7, enc); /* will not match */ /* now find the records that match our condition * "field 7 equals 443" */ rec = wg_find_record_int(db, 7, WG_COND_EQUAL, 443, NULL); while(rec) { printf("Found a record where field 7 is 443\n"); rec = wg_find_record_int(db, 7, WG_COND_EQUAL, 443, rec); } return 0; } ---- Full query interface ~~~~~~~~~~~~~~~~~~~~ The above method of finding data is convinient, but it can be too limited (and in some specific cases inefficient) so eventually we may need to make use of full queries. The query API has a number of features we will not be discussing here, instead we'll look at only the basic steps. Running a query in WhiteDB consists of preparing the argument list, creating the query itself and then fetching the matching records from the query. wg_query_arg arglist[2]; arglist[0].column = 7; arglist[0].cond = WG_COND_EQUAL; arglist[0].value = wg_encode_query_param_int(db, 443); The `wg_query_arg` type is where we store one condition that the returned records should match (or, a "clause" of the query, if you like more exact terminology). Here we've specified again that we'd like to find records where "field 7 equals 443". Notice that we declared `arglist` as an array of 2 elements? Well, this is because we can give more than one argument: arglist[1].column = 6; arglist[1].cond = WG_COND_EQUAL; arglist[1].value = wg_encode_query_param_null(db, NULL); Now we're looking for records where "field 7 equals 443 and field 6 equals NULL". The value for both arguments is encoded and it's recommended to use the special `wg_encode_query_param_*()` functions for that purpose. wg_query *query = wg_make_query(db, NULL, 0, arglist, 2); We pass the argument list and it's size, which is 2, to WhiteDB (ignore the other parameters for now, they're not used if you use the argument list). We receive a query object in return and are finally ready to start fetching records: void *rec = wg_fetch(db, query); The `wg_fetch()` function will return a different record each time you call it and eventually it will return NULL, meaning that you've already fetched all the records that match our argument list. Finally we should do some housekeeping, as queries may take up quite a bit of memory: wg_free_query(db, query); wg_free_query_param(db, arglist[0].value); wg_free_query_param(db, arglist[1].value); That was quite a bit of work to do essentialy the same thing we achieved with the help of just one function earlier, but it will also give you more power and flexibility. The following program ('Examples/tut4.c') summarizes what we've looked at here: [source,C] ---- #include #include int main(int argc, char **argv) { void *db, *rec; wg_int enc; wg_query_arg arglist[2]; /* holds the arguments to the query */ wg_query *query; /* used to fetch the query results */ db = wg_attach_database("1000", 2000000); /* just in case, create some records for testing */ rec = wg_create_record(db, 10); enc = wg_encode_int(db, 443); /* will match */ wg_set_field(db, rec, 7, enc); rec = wg_create_record(db, 10); enc = wg_encode_int(db, 442); wg_set_field(db, rec, 7, enc); /* will not match */ /* now find the records that match the condition * "field 7 equals 443 and field 6 equals NULL". The * second part is a bit redundant but we're adding it * to show the use of the argument list. */ arglist[0].column = 7; arglist[0].cond = WG_COND_EQUAL; arglist[0].value = wg_encode_query_param_int(db, 443); arglist[1].column = 6; arglist[1].cond = WG_COND_EQUAL; arglist[1].value = wg_encode_query_param_null(db, NULL); query = wg_make_query(db, NULL, 0, arglist, 2); while((rec = wg_fetch(db, query))) { printf("Found a record where field 7 is 443 and field 6 is NULL\n"); } /* Free the memory allocated for the query */ wg_free_query(db, query); wg_free_query_param(db, arglist[0].value); wg_free_query_param(db, arglist[1].value); return 0; } ---- You may run this program a couple of times, then run `wgdb select 20` to verify that the tutorial program prints the correct number of rows. Doing things properly --------------------- The examples we've been following up to now have been a bit sloppy. We haven't bothered to check whether the WhiteDB functions fail or succeed, nor to clean up after after we were done - there was only the bit about freeing queries which was just too important to ignore. First thing you should consider is that attaching to a database can sometimes fail. For example, it is possible that you requested more shared memory than the system configuration allows. So do a check like this: void *db = wg_attach_database("1000", 1000000); if(db == NULL) { /* do something to handle the error */ } Creating records or encoding data can fail if the database is full - actually a common occurence since memory databases are naturally smaller than the traditional disk-based ones. void *rec = wg_create_record(db, 1000); if(rec == NULL) { /* record was not created, can't use it */ } wg_int enc = wg_encode_str(db, "This could fail", NULL); if(enc == WG_ILLEGAL) { /* string encoding failed */ } Notice the WG_ILLEGAL value? This is a special encoded value that WhiteDB uses to tell you that something went wrong. All `wg_encode_*()` functions return that so it is easy to check for encode errors. Decoding values can also fail. The most obvious case is when you expect some field in a record to be of a certain type, but some other program or user has written a different value there. This can sometimes be tricky to detect so you should consult the 'Manual.txt' file how a particular `wg_decode_*()` function behaves. If the database is used in a way that makes it difficult to predict what type of data a field contains, there is a way to find out: if(wg_get_field_type(db, rec, 0)) == WG_STRTYPE) { printf("Field 0 in rec is a string\n"); } Finally, here's something that is nice to do whenever a program stops using a database: wg_detach_database(db); This detaches us from the shared memory and also frees any memory that may be allocated for the database handle. Let's try to apply all of those things in practice ('Examples/tut5.c'). The program creates records in a loop and writes a short string value in each of them. We have a small database, so soon we'll run out of space, causing some errors which we are now able to cope with: [source,C] ---- #include #include #include int main(int argc, char **argv) { void *db, *rec, *lastrec; wg_int enc; int i; db = wg_attach_database("1000", 1000000); /* 1MB should fill up fast */ if(!db) { printf("ERR: Could not attach to database.\n"); exit(1); } lastrec = NULL; for(i=0;;i++) { char buf[20]; rec = wg_create_record(db, 1); if(!rec) { printf("ERR: Failed to create a record (made %d so far)\n", i); break; } lastrec = rec; sprintf(buf, "%d", i); /* better to use snprintf() in real applications */ enc = wg_encode_str(db, buf, NULL); if(enc == WG_ILLEGAL) { printf("ERR: Failed to encode a string (%d records currently)\n", i+1); break; } if(wg_set_field(db, rec, 0, enc)) { printf("ERR: This error is less likely, but wg_set_field() failed.\n"); break; } } /* For educational purposes, let's pretend we're interested in what's * stored in the last record. */ if(lastrec) { char *str = wg_decode_str(db, wg_get_field(db, lastrec, 0)); if(!str) { printf("ERR: Decoding the string field failed.\n"); if(wg_get_field_type(db, lastrec, 0) != WG_STRTYPE) { printf("ERR: The field type is not string - " "should have checked that first!\n"); } } } wg_detach_database(db); return 0; } ---- To try this out, let's first try to cause an error on attaching. Type these commands: wgdb free wgdb create 999999 Then run the example program. Since we've already created a database and it's smaller than what the progam is requesting, it should complain and exit early. When done with this, type `wgdb free` again to delete the smaller database. Run the example program again, this time there is nothing in the way so it can create the database named "1000" itself. The results can be a bit unpredictable, but you should either see a record creation error or a number of errors related to a string field. Of course, this does not mean that the program failed or did nothing useful - a number of records were created successfully, we just eventually ran out of database space. Everything our program printed has "ERR:" in front of it - the rest of the messages come from WhiteDB. Parallel use ------------ WhiteDB never locks the database for you. Whenever something is read or written, the engine just goes and does it without checking whether some other program (or user) is currently using the database. This goes with the philosophy of speed and simplicity. But there are many use cases where parallel use of the database is needed and in those cases everybody cannot just crowd the database at the same time and start making changes to the shared memory area - that could result in inconsistent data, or worse, a corrupt and useless database. Fortunately, WhiteDB does provide the user with the tools to handle that. The rule of thumb is that you need these concurrency control functions whenever the database is *both read and written* by several processes and possibly at the same time. For example, if a database is serving data to a webserver and there are occasional updates to the data (without shutting down the webserver), that would qualify as needing concurrency control. To implement this concurrency control, we first request permission to read whenever we are about to read something from the database and similarly declare our intention to write to the database. Once we're done we inform the database engine that we're finished so others may proceed. So, wg_int lock_id = wg_start_read(db); /* do some reading */ wg_end_read(db, lock_id); requests permission to read. There may be some time until the function `wg_start_read()` returns - it may need to wait for some other process to finish whatever it is doing with the database. Once it returns the `lock_id`, we have shared access to the database - we may read it safely and so may other processes, but no one can write anything. `wg_end_read()` declares that we no longer need the read access. It is quite possible that `wg_start_read()` fails - it can happen under heavy load or if some other process is hogging the database for a long time. We should always check: lock_id = wg_start_read(db); if(!lock_id) { printf("wg_start_read() timed out\n"); exit(1); /* or go and retry, whatever is appropriate */ } Getting write access is similar, the major difference is that once we get the permission, we have exclusive access - everyone else has to wait until we're done adding or updating the data: lock_id = wg_start_write(db); if(!lock_id) { printf("wg_start_write() timed out\n"); exit(1); } /* do some writing */ wg_end_write(db, lock_id); NOTE: At present time these functions behave exactly like operating on a single big database-level lock. This tutorial does not make a secret of it, however, the future direction may be that they start behaving more like transactions. The important thing to remember is that the purpose is to allow you to read and write data safely, without corruption and inconsistency. By following the pattern described here, your program will continue to work unmodified, no matter how WhiteDB implements things internally. To illustrate parallel use, we will implement a counter that is incremented from two programs simultaneously. This kind of example is frequently used in parallel programming tutorials, when done naively the counter counts incorrectly because the processes end up ignoring some of the increments done by the other process. We will place this counter value inside a WhiteDB database ('Examples/tut6.c'). [source,C] ---- #include #include #include #define NUM_INCREMENTS 100000 void die(void *db, int err) { wg_detach_database(db); exit(err); } int main(int argc, char **argv) { void *db, *rec; wg_int lock_id; int i, val; if(!(db = wg_attach_database("1000", 1000000))) { exit(1); /* failed to attach */ } /* First we need to make sure both counting programs start at the * same time (otherwise the example would be boring). */ lock_id = wg_start_read(db); rec = wg_get_first_record(db); /* our database only contains one record, * so we don't need to make a query. */ wg_end_read(db, lock_id); if(!rec) { /* There is no record yet, we're the first to run and have * to set up the counter. */ lock_id = wg_start_write(db); if(!lock_id) die(db, 2); rec = wg_create_record(db, 1); wg_end_write(db, lock_id); if(!rec) die(db, 3); printf("Press a key when all the counter programs have been started."); fgetc(stdin); /* Setting the counter to 0 lets each counting program know it can * start counting now. */ lock_id = wg_start_write(db); if(!lock_id) die(db, 2); wg_set_field(db, rec, 0, wg_encode_int(db, 0)); wg_end_write(db, lock_id); } else { /* Some other program has started first, we wait until the counter * is ready. */ int ready = 0; while(!ready) { lock_id = wg_start_read(db); if(!lock_id) die(db, 2); if(wg_get_field_type(db, rec, 0) == WG_INTTYPE) ready = 1; wg_end_read(db, lock_id); } } /* Now start the actual counting. */ for(i=0; i #include int main(int argc, char **argv) { void *db, *rec, *rec2, *rec3; wg_int enc; if(!(db = wg_attach_database("1000", 2000000))) exit(1); /* failed to attach */ rec = wg_create_record(db, 2); /* this is some record */ rec2 = wg_create_record(db, 3); /* this is another record */ rec3 = wg_create_record(db, 4); /* this is a third record */ if(!rec || !rec2 || !rec3) exit(2); /* Add some content */ wg_set_field(db, rec, 1, wg_encode_str(db, "hello", NULL)); wg_set_field(db, rec2, 0, wg_encode_str(db, "I'm pointing to other records", NULL)); wg_set_field(db, rec3, 0, wg_encode_str(db, "I'm linked from two records", NULL)); /* link the records to each other */ enc = wg_encode_record(db, rec); wg_set_field(db, rec2, 2, enc); /* rec2[2] points to rec */ enc = wg_encode_record(db, rec3); wg_set_field(db, rec2, 1, enc); /* rec2[1] points to rec3 */ wg_set_field(db, rec, 0, enc); /* rec[0] points to rec3 */ wg_detach_database(db); return 0; } ---- When to use the network model ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NOTE: the code included in this section isn't here to show you how to do things but rather to illustrate what would happen if things *were* done this way. Consider our earlier example with two records, one of them containing the important message "hello". Let's try to use techniques that work in relational databases to accomplish the same thing. Storing the data isn't complicated: void *rec = wg_create_record(db, 2); void *rec2 = wg_create_record(db, 3); wg_int hello_id = wg_encode_int(db, 11913); /* an arbitrary record id */ wg_set_field(db, rec, 0, hello_id); /* assign the id */ wg_set_field(db, rec, 1, wg_encode_str(db, "hello", NULL)); wg_set_field(db, rec2, 2, hello_id); /* reference by id */ So far so good. The records should now contain `[11913, "hello"]` and `[NULL, NULL, 11913]`. Pretend again that we have just the `rec2` (as a result of a query, for example) and need the contents of `rec`: int hello_id = wg_decode_int(db, wg_get_field(db, rec2, 2)); /* this will search the database for 11913 */ void *rec = wg_find_record_int(db, 0, WG_COND_EQUAL, hello_id, NULL); char *message = wg_decode_str(db, wg_get_field(db, rec, 1)); If you have an index on field 0, this doesn't look that bad. Sure, the value "11913" needs to be looked up, but `wg_find_record_int()` can manage it reasonably fast. What if you had to do this inside a loop, though? How about a nested loop? Executing a million queries isn't that fun anymore, even if they don't take up time individually - `wg_decode_record()` would have taken a fraction of that. The lesson to learn from here is that whenever you have a data model where objects have relations to each other and need to perform JOIN type queries on them, it can be much faster in WhiteDB to implement the "join" in advance by linking the object records to each other. Those links can then be navigated rapidly to collect all the data. Another use case is storing semi-structured data. We have used the network model in our implementation of JSON documents in WhiteDB (a work in progress) where for example an array can contain other arrays or objects: the record linking feature allows us to accomplish this elegantly by making the array a record whose fields contain links to other records holding the child elements. More examples ------------- There are a few more examples distributed with WhiteDB that were not covered in this tutorial. You may look at 'Examples/demo.c' and 'Examples/query.c' that should be commented well enough to be understandable by now. Examples in Examples/speed are geared towards speed testing and are covered in http://whitedb.org/speed.html whitedb-0.7.3/Doc/whitedb.70000644000175000001440000000464712426223742012326 00000000000000.\" Manpage for whitedb. .\" Contact tane.tammet@gmail.com to correct errors or typos. .TH man 7 "27 Jan 2014" "0.7" "whitedb man page" .SH NAME WhiteDB \- shared memory database library .SH SYNOPSIS [see Doc folder and http://whitedb.org for the full manual] .SH DESCRIPTION WhiteDB is a lightweight NoSQL database library written in C, operating fully in main memory. There is no server process. Data is read and written directly from/to shared memory, no sockets are used between WhiteDB and the application program. All the data is accessible to separate processes. Each database record is a tuple of N elements, encoded in WhiteDB-s simple compact format. You can store both conventional datatypes and direct pointers to records: the latter enables highly efficient traversal of complex data. Each element is encoded as an integer: configurable as either 32 or 64 bits. The integers in the tuple encode values directly or as pointers. Columns have no type: any encoded value can be stored to any field. You can always get a direct pointer to a record, store it into a field of a record or use it in your own program directly. A record pointer can thus be used as an automatically assigned id of the record which requires no search at all to access the record. The low bits of an integer in a record indicate the type of data. Anything which does not fit into the remainining bits is allocated separately and pointed to by the same integer. We use a database level lock implemented via a task-fair atomic spinlock queue for concurrency control, but alternative faster and simpler preference policies can be configured: either a reader-preference or a writer-preference spinlock. We provide safe atomic updates of simple values without taking a write lock. The simplest index provided is a T-tree index on any field containing any mixture of objects (integers, strings, etc). The index is automatically maintained when records are added, deleted or changed. Two mechanisms are available for storing the shared memory database to disk. First, the whole database can be dumped and restored. Second, all inserts, deletions and updates can be logged to a file. .SH SEE ALSO The Whitedb web site can be found at: http://whitedb.org .SH REPORTING PROBLEMS Please use either https://github.com/priitj/whitedb or email to authors. .SH AUTHORS Copyright (C) 2008-2014 Tanel Tammet (tanel.tammet@gmail.com), Priit Järv (priit@whitedb.org)