bg
[libdbw.git] / Jamrules.configure
blob12f4845d2b960ea33e46d0a15be9305792a8fddd
1 -configure-enable-disable-vars- +=
2     "postgres"  USE_PGSQL       "auto"  "use PostgreSQL"
3     "mysql"     USE_MYSQL       "auto"  "use MySQL"
6 rule -custom-pkg-find- {
7     local r ;
8     local cmd = [ Command "whereis -b $(2) | awk '{print $2}'" : parse-output ] ;
9     Echo 'checking for' $(1) '... ' : -n ;
10     if $(cmd) {
11         r = [ Command $(2) --version : exit-code no-output ] ;
12     }
13     if $(r) {
14         Echo 'found' ;
15         return 1 ;
16     }
17     Echo 'not found' ;
18     return 0 ;
21 rule -pkg-find- {
22     local r ;
23     Echo 'checking for' $(1) '... ' : -n ;
24     if [ Command pkg-config --exists $(1) : exit-code no-output ] == 0 {
25         Echo 'found' ;
26         return 1 ;
27     }
28     Echo ' not found' ;
29     return 0 ;
32 rule -configure-test-gmp- {
33     return [
34         -configure-test-compile-cc- "libgmp" :
35         "#include <gmp.h>"
36         "int main () {"
37         "mpz_t x;"
38         "mpz_init_set_str(x, "1234567", 10);"
39         "return 0;"
40         "}"
41         : : "-lgmp"
42     ] ;
45 rule -configure- {
46     if ! $(PREFIX) {
47         PREFIX = /usr/local ;
48     }
49     -configure-pkg-config-necessary-
50         "libex"         "libex"
51     ;
52     HAVE_PGSQL = 'no' ;
53     if $(USE_PGSQL) {
54         if [ -custom-pkg-find- postgres : pg_config ] == 1 {
55             pg_include_dir = [ Command pg_config --includedir : parse-output no-space-break no-tab-break no-cr-break ] ;
56             -configure-add-line- "CFLAGS.all += -I$(pg_include_dir) ;" ;
57             pg_lib_dir = [ Command pg_config --libdir : parse-output no-space-break no-tab-break no-cr-break ] ;
58             -configure-add-line- "LINKLIBS.all += -L$(pg_lib_dir) -lpq -lpgtypes ;" ;
59             -configure-add-line- "SubInclude TOP src pg ;" ;
60             -configure-add-line- "SubInclude TOP include pg ;" ;
61             if [ -configure-test-gmp- ] == 1 {
62                 -configure-add-line- "LINKLIBS.all += -lgmp -lm ;" ;
63                 HAVE_PGSQL = 'yes' ;
64             } else {
65                 Exit "libgmp not found" ;
66             }
67         }
68     }
69     HAVE_MYSQL = 'no' ;
70     if $(USE_MYSQL) {
71         if [ -custom-pkg-find- mysql : mysql_config ] == 1 {
72             mysql_include_dir = [ Command mysql_config --include :  parse-output no-space-break no-tab-break no-cr-break ] ;
73             -configure-add-line- "CFLAGS.all += $(mysql_include_dir) ;" ;
74             mysql_libs = [ Command mysql_config --libs :  parse-output no-space-break no-tab-break no-cr-break ] ;
75             -configure-add-line- "LINKLIBS.all += $(mysql_libs) ;" ;
76             -configure-add-line- "SubInclude TOP src mysql ;" ;
77             -configure-add-line- "SubInclude TOP include mysql ;" ;
78             HAVE_MYSQL = 'yes' ;
79         }
80     }
81     Command "$(TOP)/config.sh $(TOP) $(PREFIX) $(HAVE_PGSQL) $(HAVE_MYSQL)" ;
82     Echo ;
83     Echo 'PostgreSql    ' $(HAVE_PGSQL) ;
84     Echo 'MySql         ' $(HAVE_MYSQL) ;
87 configure ;