source: project/release/4/postgresql/trunk/postgresql.setup @ 27166

Last change on this file since 27166 was 27166, checked in by sjamaan, 9 years ago

postgresql: Fix build on OS X (again), this time by not trying to be clever and using pg_config --ldflags directly but passing -L and -rpath with the output of pg_config --libdir

File size: 1.6 KB
Line 
1;;; postgresql.setup -*- Scheme -*-
2
3(use files)
4
5(define libpq-flags
6  `(-C -I -C "\"`pg_config --includedir`\"" "-L\"`pg_config --libdir`\"" -rpath "`pg_config --libdir`" -lpq))
7
8(define PQescapeIdentifier-presence-checker #<<EOF
9  #include <libpq-fe.h>
10  int main(void)
11  {
12     PGconn *conn = NULL; /* Bork */
13     return PQescapeIdentifier(conn, "test", 4) != NULL;
14  }
15EOF
16)
17
18(define PQconnectdbParams-presence-checker #<<EOF
19  #include <libpq-fe.h>
20  int main(void)
21  {
22     const char *kw[] = {"a", NULL};
23     const char *val[] = {"b", NULL};
24     return PQconnectdbParams(kw, val, 0) != NULL;
25  }
26EOF
27)
28
29(define feature-checks
30  `((has-PQescapeIdentifier . ,PQescapeIdentifier-presence-checker)
31    (has-PQconnectdbParams . ,PQconnectdbParams-presence-checker)))
32
33(define-syntax try-compile-pgsql-prog
34  (syntax-rules ()
35    ((_ str)
36     (begin
37      (with-output-to-file "attempt.c" (lambda () (display str) (newline)))
38      (let ((result (handle-exceptions ex #f (compile "attempt.c" ,@libpq-flags))))
39        (delete-file* "attempt.c")
40        (delete-file* "attempt.o")
41        (delete-file* "attempt")
42        result)))))
43
44(define (check-features)
45  (fold (lambda (feature/test features)
46          (if (try-compile-pgsql-prog (cdr feature/test))
47              (append! `(-feature ,(car feature/test)) features)
48              features))
49        '()
50        feature-checks))
51
52(compile -s -O2 -d0 postgresql.scm -j postgresql ,@(check-features) ,@libpq-flags)
53
54(compile postgresql.import.scm -s -O2 -d0)
55
56(install-extension
57 'postgresql
58 '("postgresql.so" "postgresql.import.so")
59 '((version "3.8")
60   (documentation "postgresql.html")))
Note: See TracBrowser for help on using the repository browser.