1#--------------------------------------------------------------------
2# TCLGEOMAP_LIBRARY --
3#
4#	Locate the tclgeomap library.
5#
6# Arguments:
7#	none
8#
9# Results:
10#	Defines the following var:
11#		TCLGEOMAP_LIB_SPEC	Command line options to CC to link in
12#					tclgeomap library.
13#
14#--------------------------------------------------------------------
15
16AC_DEFUN(TCLGEOMAP_LIBRARY, [
17    if test "${SHARED_BUILD}" = "1"
18    then
19	AC_MSG_CHECKING(for tclgeomap)
20	cat > find_tclgeomap.tcl << END
21	lappend auto_path ${prefix}/lib ${TCLGEOMAP_LIB}
22	package require tclgeomap ${PACKAGE_VERSION}
23	puts \$::geomap::tclgeomap_lib_file
24END
25	TCLGEOMAP_BIN_FILE=`${TCLSH_PROG} ./find_tclgeomap.tcl 2> /dev/null`
26	rm -f find_tclgeomap.tcl
27	if test x"$TCLGEOMAP_BIN_FILE" = "x"
28	then
29	    AC_MSG_ERROR(shared build specified but could not find shared tclgeomap library)
30	else
31	    AC_MSG_RESULT(tclgeomap library is $TCLGEOMAP_BIN_FILE)
32	fi
33
34	# Define tclgeomap library specifier for link command,
35	# if system needs it.
36
37	tclgeomap_lib_dir=`dirname ${TCLGEOMAP_BIN_FILE}`
38	tclgeomap_lib_spec="-L$tclgeomap_lib_dir -ltclgeomap${PACKAGE_VERSION}"
39	system=`uname -s`-`uname -r`
40	if test "$?" -ne 0 ; then
41	    AC_MSG_RESULT([unknown (can't find uname command)])
42	    system=unknown
43	fi
44	TCLGEOMAP_LIB_SPEC=""
45	case $system in
46	    Darwin-*)
47		TCLGEOMAP_LIB_SPEC=$tclgeomap_lib_spec
48		;;
49	    SunOS-5*)
50		TCLGEOMAP_LIB_SPEC=$tclgeomap_lib_spec
51		;;
52	esac
53	AC_SUBST(TCLGEOMAP_LIB_SPEC)
54    fi
55])
56#--------------------------------------------------------------------
57# TCLGEOMAP_HEADERS --
58#
59#	Locate the tclgeomap library.
60#
61# Arguments:
62#	none
63#
64# Results:
65#	Defines the following var:
66#		TCLGEOMAP_INCLUDES	fully path name of directory with
67#					tclgeomap.h
68#
69#--------------------------------------------------------------------
70
71AC_DEFUN(TCLGEOMAP_HEADERS, [
72    AC_MSG_CHECKING(for Tclgeomap public headers)
73    AC_ARG_WITH(tclgeomap-include, [ --with-tclgeomap-include      directory containing the public tclgeomap header files.], with_tclgeomap_include=${withval})
74    if test x"${with_tclgeomap_include}" != x ; then
75	if test -f "${with_tclgeomap_include}/tclgeomap.h" ; then
76	    ac_cv_c_tclgeomap_h=${with_tclgeomap_include}
77	else
78	    AC_MSG_ERROR([${with_tclgeomap_include} directory does not contain Tclgeomap public header file tclgeomap.h])
79	fi
80    else
81	AC_CACHE_VAL(ac_cv_c_tclgeomap_h, [
82	    # Use the value from --with-tclgeomap-include, if it was given
83
84	    if test x"${with_tclgeomap_include}" != x ; then
85		ac_cv_c_tclgeomap_h=${with_tclgeomap_include}
86	    else
87		# Check in the includedir, if --prefix was specified
88		eval "temp_includedir=${includedir}"
89		for i in \
90			`ls -d ${temp_includedir} 2>/dev/null` \
91			${prefix}/include/tclgeomap${PACKAGE_VERSION} \
92			/usr/local/include/tclgeomap${PACKAGE_VERSION} \
93			/usr/include/tclgeomap${PACKAGE_VERSION} \
94			/usr/local/include /usr/include ; do
95		    if test -f "$i/tclgeomap.h" ; then
96			ac_cv_c_tclgeomap_h=$i
97			break
98		    fi
99		done
100	    fi
101	])
102    fi
103    if test x"${ac_cv_c_tclgeomap_h}" = x ; then
104	AC_MSG_ERROR(tclgeomap.h not found.  Please specify its location with --with-tclgeomap-include)
105    else
106	AC_MSG_RESULT(${ac_cv_c_tclgeomap_h})
107    fi
108    INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclgeomap_h}`
109    TCLGEOMAP_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\"
110    AC_SUBST(TCLGEOMAP_INCLUDES)
111])
112