Commit 272bea11 272bea11eeed8d2a07695f31dc1b561a729c4de5 by Sergey Poznyakoff

Rewritten sql-related part. Allow to specify several SQL libraries simultaneously.

1 parent 67b60251
Showing 1 changed file with 129 additions and 37 deletions
...@@ -56,6 +56,7 @@ if test ".$BUILD_INCLUDED_LIBINTL" = ".yes" ; then ...@@ -56,6 +56,7 @@ if test ".$BUILD_INCLUDED_LIBINTL" = ".yes" ; then
56 fi 56 fi
57 57
58 dnl Check for libraries 58 dnl Check for libraries
59 USE_LOADABLE_MODULES=no
59 AC_CHECK_LIB(resolv, res_query) 60 AC_CHECK_LIB(resolv, res_query)
60 LTDL_LIB= 61 LTDL_LIB=
61 AC_SUBST(LTDL_LIB) 62 AC_SUBST(LTDL_LIB)
...@@ -64,9 +65,16 @@ if test "$enable_shared" = yes; then ...@@ -64,9 +65,16 @@ if test "$enable_shared" = yes; then
64 AC_DEFINE(HAVE_LIBLTDL, 65 AC_DEFINE(HAVE_LIBLTDL,
65 1, 66 1,
66 [Define to 1 if you have the `ltdl' library (-lltdl).]) 67 [Define to 1 if you have the `ltdl' library (-lltdl).])
67 LTDL_LIB=-lltdl], 68 LTDL_LIB=-lltdl
69 _USE_LOADABLE_MODULES=yes], # FIXME: Remove leading _ when ltd support
70 # is added to SQL.
68 [LTDL_LIB=""]) 71 [LTDL_LIB=""])
69 fi 72 fi
73 if test $USE_LOADABLE_MODULES = yes; then
74 AC_DEFINE(USE_LOADABLE_MODULES,1,
75 [Define if mailutils is able to use loadable modules])
76 fi
77
70 MU_DEBUG_MODE 78 MU_DEBUG_MODE
71 79
72 # Initialize authlibs 80 # Initialize authlibs
...@@ -412,51 +420,134 @@ AC_CHECK_FUNCS(_obstack_begin, ...@@ -412,51 +420,134 @@ AC_CHECK_FUNCS(_obstack_begin,
412 [AC_LIBOBJ(obstack)]) 420 [AC_LIBOBJ(obstack)])
413 421
414 422
415 dnl check if SQL support is required 423
416 AC_SUBST(SQLLIBS)
417 AC_ARG_WITH([mysql],
418 AC_HELP_STRING([--with-mysql],
419 [enable mysql support (default no)]),
420 [use_mysql=${withval}],,)
421 424
422 AC_ARG_WITH([postgres], 425
423 AC_HELP_STRING([--with-postgres], 426 ## SQL support
424 [enable postgres support (default no)]),
425 [use_postgres=${withval}],,)
426 427
427 AH_TEMPLATE(USE_SQL,[Enables SQL support]) 428 AH_TEMPLATE(USE_SQL,[Enables SQL support])
428 AH_TEMPLATE(HAVE_MYSQL,[Define if you have libmysql]) 429 AH_TEMPLATE(HAVE_MYSQL,[Define if you have libmysql])
429 AH_TEMPLATE(HAVE_PGSQL,[Define if you have libpq]) 430 AH_TEMPLATE(HAVE_PGSQL,[Define if you have libpq])
430 431
431 if test x"$use_mysql" = x"yes" -a x"$use_postgres" = x"yes"; then 432 SQL_MODULES=
432 AC_MSG_ERROR([Use either --with-mysql or --with-postgres, not both]) 433 AC_SUBST(SQL_MODULES)
433 else 434
434 if test x"$use_mysql" = x"yes"; then 435 SQL_LIBOBJS=
435 AC_CHECK_HEADER(mysql/mysql.h, 436 AC_SUBST(SQL_LIBOBJS)
436 [MU_CHECK_LIB(mysqlclient, mysql_real_connect, "-lm", 437
437 [ USE_SQL=1 438 SQL_LTLIBOBJS=
438 AC_DEFINE(USE_SQL) 439 AC_SUBST(SQL_LTLIBOBJS)
439 AC_DEFINE(HAVE_MYSQL) 440
440 SQLLIBS="$mu_cv_lib_mysqlclient" 441 BUILD_SQL=
441 ], 442 AC_SUBST(BUILD_SQL)
442 [ AC_MSG_ERROR(-lmysqlclient not found) ], 443 AC_SUBST(SQLLIB)
443 [/usr/local/lib/mysql /usr/lib/mysql])])
444 fi
445 if test x"$use_postgres" = x"yes"; then
446 MU_CHECK_LIB(pq, PQconnectStart, [],
447 [ USE_SQL=1
448 AC_DEFINE(HAVE_PGSQL)
449 SQLLIBS=$mu_cv_lib_pq],
450 [ AC_MSG_ERROR(-lpq not found) ],
451 [/usr/local/pgsql/lib /usr/pgsql/lib])
452 fi
453 fi
454 444
455 if test x"$USE_SQL" = x1; then 445 SQL_LOADABLE_MODULES=
456 AUTHLIBS="$AUTHLIBS $SQLLIBS" 446 AC_SUBST(SQL_LOADABLE_MODULES)
457 AC_DEFINE(USE_SQL,1,[Define this to enable SQL support]) 447
448 AC_DEFUN([MU_SQL_LDADD],[
449 if test "$USE_LOADABLE_MODULES" = yes; then
450 $1=$2
451 else
452 SQLLIB="$SQLLIB $2"
453 fi
454 ])
455
456 ## *********
457 ## MySQL
458 ## *********
459 AC_SUBST(MYSQLLIBS)
460
461 mysql_init() {
462 MU_CHECK_LIB(mysqlclient,
463 mysql_real_connect,
464 [-lm],
465 [ AC_DEFINE(USE_SQL)
466 AC_DEFINE(HAVE_MYSQL)
467 MU_SQL_LDADD(MYSQLLIBS, $mu_cv_lib_mysqlclient) ],
468 [ AC_MSG_FAILURE([The requested library libmysqlclient is not found or is unusable])],
469 [/usr/local/lib/mysql /usr/lib/mysql])
470 }
471
472 AC_ARG_WITH(mysql,
473 AC_HELP_STRING([--with-mysql],
474 [Configure to work with MySQL]),
475 [case $withval in
476 yes) SQL_MODULES="$SQL_MODULES mysql"
477 ;;
478 no) ;;
479 esac])
480
481
482 # *********
483 # Postgres
484 # *********
485
486 postgres_init() {
487 MU_CHECK_LIB(pq, PQconnectStart, [],
488 [ AC_DEFINE(USE_SQL)
489 AC_DEFINE(HAVE_PGSQL)
490 MU_SQL_LDADD(POSTGRESLIBS, $mu_cv_lib_pq)],
491 [ AC_MSG_FAILURE([The requested library libpq is not found or is unusable])],
492 [/usr/local/pgsql/lib /usr/pgsql/lib])
493 }
494
495 AC_ARG_WITH(postgres,
496 AC_HELP_STRING([--with-postgres],
497 [Configure to work with Postgres]),
498 [case $withval in
499 yes) SQL_MODULES="$SQL_MODULES postgres"
500 ;;
501 no) ;;
502 esac])
503
504 ### General SQL support
505 AC_ARG_WITH(sql,
506 AC_HELP_STRING([--with-sql=modlist],
507 [Configure to work with SQL]),
508 [for mod in `echo $withval | tr ':,' ' '`
509 do
510 if test -r $srcdir/sql/${mod}.c; then
511 SQL_MODULES="$SQL_MODULES ${mod}"
512 else
513 AC_MSG_ERROR(No such SQL module: $mod)
514 fi
515 done])
516
517 dummy_init() {
518 :
519 }
520
521 if test -n "$SQL_MODULES"; then
522 USE_SQL=1
523 AC_DEFINE(USE_SQL)
524 BUILD_SQL=libsql.la
525 SQLLIB=../sql/libsql.la
526
527 for module in $SQL_MODULES
528 do
529 ${module:-dummy}_init
530 if test $USE_LOADABLE_MODULES = yes; then
531 SQL_LOADABLE_MODULES="$SQL_LOADABLE_MODULES ${module}.la"
532 else
533 SQL_LIBOBJS="$SQL_LIBOBJS ${module}.o"
534 fi
535 done
536 S=`echo "$SQL_LIBOBJS" |
537 sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'`
538 SQL_LTLIBOBJS=`echo "$S" |
539 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
540
541 AC_CONFIG_COMMANDS([sql/modlist.h],
542 [$srcdir/scripts/sqlmod.sh $SQL_MODULES > sql/modlist.h],
543 [if test $USE_LOADABLE_MODULES = yes; then
544 SQL_MODULES=
545 else
546 SQL_MODULES="$SQL_MODULES"
547 fi])
458 fi 548 fi
459 549
550
460 dnl Virtual domain support 551 dnl Virtual domain support
461 MU_ENABLE_SUPPORT(virtual-domains) 552 MU_ENABLE_SUPPORT(virtual-domains)
462 AC_SUBST(SITE_VIRTUAL_PWDDIR) 553 AC_SUBST(SITE_VIRTUAL_PWDDIR)
...@@ -732,6 +823,7 @@ MU_COMMON_LIBRARIES='$(LTLIBINTL) $(LTLIBICONV)' ...@@ -732,6 +823,7 @@ MU_COMMON_LIBRARIES='$(LTLIBINTL) $(LTLIBICONV)'
732 823
733 dnl Output Makefiles 824 dnl Output Makefiles
734 AC_CONFIG_FILES([Makefile 825 AC_CONFIG_FILES([Makefile
826 sql/Makefile
735 auth/Makefile 827 auth/Makefile
736 comsat/Makefile 828 comsat/Makefile
737 doc/Makefile 829 doc/Makefile
......