Created idzebra-config that returns compiler flags and libs
authorAdam Dickmeiss <adam@indexdata.dk>
Sun, 29 Aug 2004 12:31:32 +0000 (12:31 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sun, 29 Aug 2004 12:31:32 +0000 (12:31 +0000)
Makefile.am
configure.in
idzebra-config.in [new file with mode: 0755]
util/Makefile.am

index 9cb40d4..27762d5 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.15 2004-08-06 13:14:46 adam Exp $
+## $Id: Makefile.am,v 1.16 2004-08-29 12:31:32 adam Exp $
 
 AUTOMAKE_OPTIONS=foreign
 
@@ -7,7 +7,7 @@ SUBDIRS=util bfile dfa dict isams isamb isamc rset data1 \
 
 SPEC_FILE=$(PACKAGE).spec
 
-EXTRA_DIST= README NEWS $(SPEC_FILE) idzebra.spec.in
+EXTRA_DIST= README NEWS $(SPEC_FILE) idzebra.spec.in idzebra-config.in
 
 dist-hook:
        cp $(srcdir)/LICENSE* $(distdir)
index b43eaba..100c591 100644 (file)
@@ -1,5 +1,5 @@
 dnl Zebra, Index Data Aps, 1995-2004
-dnl $Id: configure.in,v 1.95 2004-08-25 09:23:35 adam Exp $
+dnl $Id: configure.in,v 1.96 2004-08-29 12:31:32 adam Exp $
 dnl
 AC_INIT(include/idzebra/version.h)
 AM_INIT_AUTOMAKE(idzebra,1.4.0)
@@ -362,6 +362,10 @@ AC_STDC_HEADERS
 if test "$ac_cv_header_stdc" = "no"; then
        AC_MSG_WARN(Your system doesn't seem to support ANSI C)
 fi
+AC_SUBST(IDZEBRA_SRC_ROOT)
+AC_SUBST(IDZEBRA_BUILD_ROOT)
+IDZEBRA_SRC_ROOT=`cd ${srcdir}; pwd`
+IDZEBRA_BUILD_ROOT=`pwd`
 dnl ------ Create Makefiles
 AC_OUTPUT([
   Makefile
@@ -393,7 +397,8 @@ AC_OUTPUT([
   test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile
   examples/Makefile examples/gils/Makefile examples/zthes/Makefile
   idzebra.spec
-])
+  idzebra-config
+],[sed s%idzebra_echo_source=yes%idzebra_echo_source=no%g < idzebra-config > util/idzebra-config && chmod +x idzebra-config util/idzebra-config])
 if test -x "$perlbin"; then
        res=`cd perl ; $perlbin Makefile.PL ; cd .. ;`;
 fi
diff --git a/idzebra-config.in b/idzebra-config.in
new file mode 100755 (executable)
index 0000000..5c91ce6
--- /dev/null
@@ -0,0 +1,120 @@
+#!/bin/sh
+# $Id: idzebra-config.in,v 1.1 2004-08-29 12:31:32 adam Exp $
+idzebraprefix=@prefix@
+idzebra_echo_cflags=no
+idzebra_echo_libs=no
+idzebra_echo_help=no
+idzebra_echo_tabs=no
+idzebra_echo_source=yes
+idzebra_echo_lalibs=no
+idzebra_src_root=@IDZEBRA_SRC_ROOT@
+idzebra_build_root=@IDZEBRA_BUILD_ROOT@
+
+yazlibs="@YAZLIB@ @LIBS@"
+yazlalibs="@YAZLALIB@ @LIBS@"
+IDZEBRAVERSION=@VERSION@
+
+usage()
+{
+       cat <<EOF
+Usage: idzebra-config [OPTIONS] [LIBRARIES]
+Options:
+       [--prefix[=DIR]]
+       [--version]
+       [--libs]
+       [--lalibs]
+       [--cflags]
+EOF
+       exit $1
+}
+
+if test $# -eq 0; then
+       idzebra_echo_help=yes
+fi
+
+modules=""
+while test $# -gt 0; do
+  case "$1" in
+  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  case $1 in
+    --prefix=*)
+      idzebraprefix=$optarg
+      ;;
+    --prefix)
+      echo $idzebraprefix
+      exit 0
+      ;;
+    --version)
+      echo $IDZEBRAVERSION
+      exit 0
+      ;;
+    --cflags)
+      idzebra_echo_cflags=yes
+      ;;
+    --libs)
+      idzebra_echo_libs=yes
+      ;;
+    --tabs)
+      idzebra_echo_tabs=yes
+      ;;
+    --lalibs)
+      idzebra_echo_lalibs=yes
+      ;;
+    -*)
+      idzebra_echo_help=yes
+      ;;
+    *)
+      modules="$modules $1"
+      ;;
+  esac
+  shift
+done
+
+IDZEBRALIB=""
+IDZEBRALALIB=""
+IDZEBRAINC="@YAZINC@"
+
+if test -z "$modules"; then
+    modules="util bfile dfa dict isamc isamb isams data1 recctrl rset api"
+fi
+for m in $modules; do
+    d=$m
+    if test "$m" = "api"; then
+        d="index"
+    fi
+    if test "$idzebra_echo_source" = "yes"; then
+       IDZEBRALIB="$IDZEBRALIB -L${idzebra_build_root}/$d/.libs -lidzebra-$m"
+        IDZEBRALALIB="$IDZEBRALALIB ${idzebra_build_root}/$d/libidzebra-$m.la"
+    else
+       IDZEBRALIB="$IDZEBRALIB -lidzebra-$m"
+    fi
+done
+
+if test "$idzebra_echo_source" = "yes"; then
+    IDZEBRALIB="$IDZEBRALIB $yazlibs"
+    IDZEBRALALIB="$IDZEBRALALIB $yazlalibs"
+    IDZEBRAINC="$IDZEBRAINC -I${idzebra_src_root}/include"
+else
+    if test "$idzebraprefix" != "/usr"; then
+       IDZEBRALIB="-L${idzebraprefix}/lib $IDZEBRALIB"
+       IDZEBRAINC="$IDZEBRAINC -I${idzebraprefix}/include"
+    fi
+    IDZEBRALIB="$IDZEBRALIB $yazlibs"
+    IDZEBRALALIB="$IDZEBRALIB"
+fi
+
+if test "$idzebra_echo_help" = "yes"; then
+       usage 1 1>&2
+fi
+if test "$idzebra_echo_cflags" = "yes"; then
+       echo $IDZEBRAINC
+fi
+if test "$idzebra_echo_libs" = "yes"; then
+       echo $IDZEBRALIB
+fi
+if test "$idzebra_echo_lalibs" = "yes"; then
+       echo $IDZEBRALALIB
+fi
index 12e2f59..e20962a 100644 (file)
@@ -1,11 +1,15 @@
-## $Id: Makefile.am,v 1.10 2004-08-24 10:37:20 adam Exp $
+## $Id: Makefile.am,v 1.11 2004-08-29 12:31:32 adam Exp $
 
 lib_LTLIBRARIES = libidzebra-util.la
 
 noinst_PROGRAMS = passtest
 
+bin_SCRIPTS = idzebra-config
+
 EXTRA_DIST = zebrasrv.rh
 
+DISTCLEANFILES = idzebra-config
+
 AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) -DDEFAULT_PROFILE_PATH=\"$(pkgdatadir)/tab\"
 LDADD = libidzebra-util.la $(TCL_LIB) $(YAZLALIB)