Merge branch 'master' into javascript-binding
[gpgme.git] / src / gpgme-config.in
index 0cc639f..a4d152e 100644 (file)
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-includedir=@includedir@
-libdir=@libdir@
 
 # Make sure that no weird locale setting messes up our sed regexps etc.
 LC_COLLATE=C
 LC_ALL=C
 LANG=C
 
+# GPGME's own cflags and libs
+cflags="-I@includedir@"
+libs="-L@libdir@"
+
 # Network libraries.
-netlibs="@NETLIBS@"
+assuan_cflags="@LIBASSUAN_CFLAGS@"
+assuan_libs="@LIBASSUAN_LIBS@"
 
 # Configure libgpg-error.
 gpg_error_cflags="@GPG_ERROR_CFLAGS@"
@@ -29,14 +32,14 @@ gpg_error_libs="@GPG_ERROR_LIBS@"
 # Configure thread packages.
 thread_modules=""
 
-@HAVE_PTH_TRUE@thread_modules="$thread_modules pth"
-libs_pth="@PTH_LDFLAGS@ @PTH_LIBS@"
-cflags_pth="@PTH_CFLAGS@"
-
-@HAVE_PTHREAD_TRUE@thread_modules="$thread_modules pthread"
+# For compatibility we keep proving the
+# thread modules variable.
+thread_modules="$thread_modules pthread"
 libs_pthread="-lpthread"
 cflags_pthread=""
 
+avail_lang='c @GPGME_CONFIG_AVAIL_LANG@'
+
 # Configure glib.
 libs_glib="@GLIB_LIBS@"
 cflags_glib="@GLIB_CFLAGS@"
@@ -49,15 +52,15 @@ usage()
     cat <<EOF
 Usage: gpgme-config [OPTIONS]
 Options:
-       [--thread={${thread_modules}}]
-       [--prefix]
-       [--exec-prefix]
-       [--version]
-        [--api-version]
-       [--libs]
-       [--cflags]
-        [--get-gpg]
-        [--get-gpgsm]
+       --prefix
+       --exec-prefix
+       --version
+        --api-version
+        --host
+       --libs
+       --cflags
+        --print-lang           Print available language bindings
+        --have-lang=LANG       Return success if LANG is available
 EOF
     exit $1
 }
@@ -100,46 +103,74 @@ while test $# -gt 0; do
            echo "@GPGME_CONFIG_API_VERSION@"
            exit 0
            ;;
+        --host)
+           echo "@GPGME_CONFIG_HOST@"
+           exit 0
+           ;;
         --cflags)
-           if test "x$includedir" != "x/usr/include" -a "x$includedir" != "x/include"; then
-               output="$output -I$includedir"
-           fi
+            result=
+            tmp_c=
+            tmp_g=
            case "$thread_module" in
-               pthread)
-                   output="$output $cflags_pthread"
-                   ;;
-               pth)
-                   output="$output $cflags_pth"
-                   ;;
+               pthread) tmp_c="$cflags_pthread" ;;
            esac
-           output="$output $gpg_error_cflags"
-           if test "x$with_glib" = "xyes"; then
-               output="$output $glib_cflags"
-           fi
-           ;;
+           test "x$with_glib" = "xyes" && tmp_g="$cflags_glib"
+            for i in $cflags $tmp_c $assuan_cflags $gpg_error_cflags $tmp_g ; do
+              skip=no
+              case $i in
+                  -I/usr/include|-I/include)
+                      skip=yes
+                      ;;
+                  -I*)
+                      for j in $result ; do
+                          if test x"$j" = x"$i" ; then
+                              skip=yes
+                              break;
+                          fi
+                      done
+                      ;;
+              esac
+              if test $skip = no ; then
+                  result="$result $i"
+              fi
+            done
+            output="$output $result"
+            ;;
        --libs)
-           if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/lib"; then
-               output="$output -L$libdir"
-           fi
+            result=
+            tmp_x=
            case "$thread_module" in
-               pthread)
-                   output="$output -lgpgme-pthread $libs_pthread"
-                   ;;
-               pth)
-                   output="$output -lgpgme-pth $libs_pth"
-                   ;;
+            # deprecated
+               pthread) tmp_l="-lgpgme" ;;
                *)
-                   if test "x$with_glib" = "xyes"; then
-                       output="$output -lgpgme-glib"
+                   if test "x$with_glib" = "xyes" ; then
+                        tmp_l="-lgpgme-glib"
+                         tmp_x="$libs_glib"
                    else
-                       output="$output -lgpgme"
+                        tmp_l="-lgpgme"
                    fi
                    ;;
            esac
-           output="$output $gpg_error_libs $netlibs"
-           if test "x$with_glib" = "xyes"; then
-               output="$output $glib_cflags"
-           fi
+            for i in $libs $tmp_l $assuan_libs $gpg_error_libs $tmp_x; do
+              skip=no
+              case $i in
+                  -L/usr/lib|-L/lib)
+                      skip=yes
+                      ;;
+                  -L*|-l*)
+                      for j in $result ; do
+                          if test x"$j" = x"$i" ; then
+                              skip=yes
+                              break;
+                          fi
+                      done
+                      ;;
+              esac
+              if test $skip = no ; then
+                  result="$result $i"
+              fi
+            done
+            output="$output $result"
            ;;
        --thread=*)
             for thread_mod in $thread_modules; do
@@ -151,10 +182,23 @@ while test $# -gt 0; do
                usage 1 1>&2
            fi
            ;;
+       --print-lang)
+            output="$avail_lang"
+           ;;
+       --have-lang=*)
+            for lang in $avail_lang; do
+                if test x"$lang" = x"$optarg"; then
+                    exit 0
+                fi
+            done
+            exit 1
+           ;;
         --get-gpg)
+            # Deprecated
             output="$output @GPG@"
             ;;
         --get-gpgsm)
+            # Deprecated
             output="$output @GPGSM@"
             ;;
        *)