]> git.draconx.ca Git - upkg.git/blobdiff - configure.ac
Use GLib detection macros from dxcommon.
[upkg.git] / configure.ac
index 6dfc336ef3ef53da6358affed1b66a640446bb55..36c3ffdae6f53e8e4e8e7b87ed7ff05f8f1d7a8e 100644 (file)
@@ -1,8 +1,8 @@
-dnl Copyright (C) 2009 Nick Bowler
-dnl Copying and distribution of this file, with or without modification,
-dnl are permitted in any medium without royalty provided the copyright
-dnl notice and this notice are preserved.  This file is offered as-is,
-dnl without any warranty.
+dnl Copyright © 2009-2012, 2015, 2019-2020 Nick Bowler
+dnl
+dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+dnl This is free software: you are free to do what the fuck you want to.
+dnl There is NO WARRANTY, to the extent permitted by law.
 
 AC_PREREQ(2.62)
 AC_INIT([upkg],[0.1],[nbowler@draconx.ca])
@@ -10,21 +10,24 @@ AC_CONFIG_SRCDIR([src/libupkg.c])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 
-AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
+AM_SILENT_RULES([yes])
+DX_AUTOMAKE_COMPAT
 
 AC_PROG_CC_C99
 gl_EARLY
 
 LT_CONFIG_LTDL_DIR([libltdl])
 LT_INIT([dlopen])
-LTDL_INIT([recursive])
-
-AM_CONDITIONAL([BUNDLED_LIBLTDL], [test x$LTDLDEPS != x])
+LTDL_INIT([nonrecursive])
 
 gl_INIT
 
-CHECK_GLIB_2([], [gobject])
+AC_CACHE_SAVE
+
+m4_include([lib/gnulib.mk])
+
+DX_LIB_GLIB2([], [gobject])
 
 AC_ARG_WITH([modlib],
        [AS_HELP_STRING([--with-modlib],
@@ -33,37 +36,43 @@ AC_ARG_WITH([modlib],
        [with_modlib=$withval],
        [with_modlib=auto])
 
-case $with_modlib in
-no|none)
-       use_modlib=none
-;;
-modplug)
-       CHECK_LIBMODPLUG([use_modlib=modplug], [])
-;;
-auto)
-       CHECK_LIBMODPLUG([have_libmodplug=yes], [have_libmodplug=no])
+use_modlib=none
+AS_CASE([$with_modlib],
+  [no|none], [:],
+  [modplug], [DX_LIB_LIBMODPLUG([use_modlib=modplug])],
+  [auto], [DX_LIB_LIBMODPLUG([use_modlib=modplug], [:])],
+  [AC_MSG_ERROR([Invalid argument to --with-modlib: $with_modlib])])
 
-       if test x$have_libmodplug = xyes; then
-               use_modlib=modplug
-       else
-               use_modlib=none
-       fi
-;;
-*)
-       AC_MSG_ERROR([Invalid argument to --with-modlib: $with_modlib])
-;;
-esac
 AC_MSG_CHECKING([which module library to use])
 AC_MSG_RESULT([$use_modlib])
 
 AM_CONDITIONAL([USE_LIBMODPLUG], [test x$use_modlib = xmodplug])
 AM_CONDITIONAL([USE_DUMMYMOD],   [test x$use_modlib = xnone])
 
-AC_CONFIG_FILES([
-       Makefile
-       libltdl/Makefile
-       lib/Makefile
-       src/Makefile
-       libuobject.pc
+DX_PROG_GOB2([2.0.0], [have_gob2=yes], [have_gob2=no])
+AM_CONDITIONAL([HAVE_GOB2], [test x"$have_gob2" = x"yes"])
+
+AS_IF([test x"$have_gob2" != x"yes"], [dx_cv_gob2_dynamic_types=no])
+AC_CACHE_CHECK([Whether $GOB2 supports dynamic types],
+  [dx_cv_gob2_dynamic_types], [cat >conftest.gob <<'EOF'
+class :Conftest from G:Object (dynamic)
+{
+  public void test(void)
+  {
+  }
+}
+EOF
+dx_cv_gob2_dynamic_types=no
+AS_IF([$GOB2 conftest.gob >/dev/null 2>&1],
+[mv conftest.c conftest.inc
+save_CFLAGS=$CFLAGS save_LIBS=$LIBS
+CFLAGS="$GLIB_CFLAGS $CFLAGS"
+LIBS="$LIBS $GLIB_LIBS"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#]include "conftest.inc"],
+[conftest_register_type(0);])], [dx_cv_gob2_dynamic_types=yes])
+CFLAGS=$save_CFLAGS LIBS=$save_LIBS])
 ])
+AM_CONDITIONAL([HAVE_GOB2_DYN], [test x"$dx_cv_gob2_dynamic_types" = x"yes"])
+
+AC_CONFIG_FILES([Makefile libuobject.pc])
 AC_OUTPUT