configure.in 9.54 KB
Newer Older
pj2m's avatar
pj2m committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT(dep2pict, 2.0.3, paul.masson@inria.fr)

AC_ARG_ENABLE(
	[config],
 	[AS_HELP_STRING(
		[--enable-config],
		[Enable configuration check (default is yes)])],
	[config=$enableval],
	[config=yes])

if test "$config" = yes ; then

	# Checks for programs.
	AC_CHECK_PROGS(OCAMLC,ocamlc.opt ocamlc,no)
	if test "$OCAMLC" = no ; then
		AC_MSG_ERROR(Cannot find ocamlc.)
	fi

	# Checks for libraries.
	AC_MSG_CHECKING(for ocaml library path)
	OCAMLLIB=$($OCAMLC -where)
	AC_MSG_RESULT($OCAMLLIB)
	if test "$OCAMLLIB" = ""; then
		AC_MSG_ERROR(Cannot find ocaml library path)
	fi

	# Look for camllex and camlyacc
	AC_PATH_PROG(OCAMLLEX,ocamllex,no)
	if test "$OCAMLLEX" = no ; then
		AC_MSG_ERROR(Cannot find ocamllex)
	fi

	AC_PATH_PROG(OCAMLYACC,ocamlyacc,no)
	if test "$OCAMLYACC" = no ; then
		AC_MSG_ERROR(Cannot find ocamlyacc)
	fi

	AC_PATH_PROG(RSVG,rsvg,no)
	if test "$RSVG" = no ; then
		AC_MSG_WARN(Cannot find rsvg)
	fi

	AC_PATH_PROG(RSVG_CONVERT,rsvg-convert,no)
bguillaum's avatar
bguillaum committed
48
	if test "$RSVG_CONVERT" = no ; then
pj2m's avatar
pj2m committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
		AC_MSG_ERROR(Cannot find rsvg-convert)
	fi

	# Look for ocamlfind
	AC_PATH_PROG(OCAMLFIND,ocamlfind,no)
	if test "$OCAMLFIND" = no ; then
		AC_MSG_WARN(Cannot find ocamlfind)
	fi

	AC_ARG_ENABLE(
		[debug],
	 	[AS_HELP_STRING([--enable-debug], [Display debug trace])],
		[with_debug=$enableval],
		[with_debug=no])
	AC_ARG_ENABLE(
		[warning],
	 	[AS_HELP_STRING([--enable-warning], [Display warning trace])],
		[with_warning=$enableval],
		[with_warning=no])
	AC_ARG_ENABLE(
		[message],
	 	[AS_HELP_STRING([--enable-message], [Display message trace])],
		[with_message=$enableval],
		[with_message=yes])
	AC_ARG_ENABLE(
		[info],
	 	[AS_HELP_STRING([--enable-info], [Display info trace])],
		[with_info=$enableval],
		[with_info=yes])


	# Look for cairo
	AC_MSG_CHECKING([for cairo])
	if test -f c_check_cairo.ml ; then
	   	if test -w c_check_cairo.ml ; then
		       	rm c_check_cairo.ml >& /dev/null
	   	else
		       	AC_MSG_ERROR(Cannot remove c_check_cairo.ml. Please change its right with chmod 666 c_check_cairo.ml)
	   	fi
	fi
	echo "open Cairo;;" > c_check_cairo.ml
	if (ocamlc -c -I +lablgtk2 lablgtk.cma -I +cairo cairo.cma c_check_cairo.ml >& /dev/null) ; then
		AC_MSG_RESULT(standard)
		CAIRO="yes"
	else
		if test "$OCAMLFIND" = no ; then
			AC_MSG_ERROR(The cairo library is missing.)
			CAIRO=no
		else
			if $OCAMLFIND query cairo > /dev/null 2>&1 ; then
				AC_MSG_RESULT(ocamlfind)
			else	
	  			AC_MSG_ERROR(The cairo library is missing.)
				CAIRO=no
			fi
		fi	
	fi
	rm c_check_cairo.ml >& /dev/null
	rm c_check_cairo.cmo >& /dev/null
	rm c_check_cairo.cmi >& /dev/null

	# look for dep2pict$
	AC_MSG_CHECKING([for dep2pict])
		if test -f c_check_dep2pict.ml ; then
		   	if test -w c_check_dep2pict.ml ; then
			       	rm c_check_dep2pict.ml >& /dev/null
		   	else
			       	AC_MSG_ERROR(Cannot remove c_check_dep2pict.ml. Please change its right with chmod 666 c_check_dep2pict.ml)
		   	fi
	fi
	echo "open Dep2pict;;" > c_check_dep2pict.ml
	if (ocaml c_check_dep2pict.ml >& /dev/null) ; then
		AC_MSG_RESULT(standard)
		DEP2PICT="yes"
	else
		if test "$OCAMLFIND" = no ; then
		AC_MSG_ERROR(The dep2pict lib is missing.)
		DEP2PICT=no
		else
			if $OCAMLFIND query dep2pict > /dev/null 2>&1 ; then
				DEP2PICT="yes"
				DEP2PICT_LIB="-I `$OCAMLFIND query dep2pict`"
				AC_MSG_RESULT(ocamlfind)
			else	
			AC_MSG_ERROR(The dep2pict lib is missing.)
		  		DEP2PICT=no
			fi
		fi	
	fi
	rm c_check_dep2pict.ml >& /dev/null
	
	# look for log$
	AC_MSG_CHECKING([for log])
		if test -f c_check_log.ml ; then
		   	if test -w c_check_log.ml ; then
			       	rm c_check_log.ml >& /dev/null
		   	else
			       	AC_MSG_ERROR(Cannot remove c_check_log.ml. Please change its right with chmod 666 c_check_log.ml)
		   	fi
	fi
	echo "open Log;;" > c_check_log.ml
	if (ocaml c_check_log.ml >& /dev/null) ; then
		AC_MSG_RESULT(standard)
		LOG="yes"
	else
		if test "$OCAMLFIND" = no ; then
		AC_MSG_ERROR(The log lib is missing.)
		LOG=no
		else
			if $OCAMLFIND query log > /dev/null 2>&1 ; then
				LOG="yes"
				LOG_LIB="-I `$OCAMLFIND query log`"
				AC_MSG_RESULT(ocamlfind)
			else	
			AC_MSG_ERROR(The log lib is missing.)
		  		LOG=no
			fi
		fi	
	fi
	rm c_check_log.ml >& /dev/null
	
	# look for ansiterminal
	AC_MSG_CHECKING([for ansiterminal])
		if test -f c_check_ansiterminal.ml ; then
		   	if test -w c_check_ansiterminal.ml ; then
			       	rm c_check_ansiterminal.ml >& /dev/null
		   	else
			       	AC_MSG_ERROR(Cannot remove c_check_ansiterminal.ml. Please change its right with chmod 666 c_check_ansiterminal.ml)
		   	fi
	fi
	echo "open ANSITerminal;;" > c_check_ansiterminal.ml
	if (ocaml c_check_ansiterminal.ml >& /dev/null) ; then
		AC_MSG_RESULT(standard)
		ANSITERMINAL="yes"
	else
		if test "$OCAMLFIND" = no ; then
bguillaum's avatar
bguillaum committed
185
		AC_MSG_ERROR(The ANSITerminal lib is missing.)
pj2m's avatar
pj2m committed
186 187
		ANSITERMINAL=no
		else
bguillaum's avatar
bguillaum committed
188
			if $OCAMLFIND query ANSITerminal > /dev/null 2>&1 ; then
pj2m's avatar
pj2m committed
189
				ANSITERMINAL="yes"
bguillaum's avatar
bguillaum committed
190
				ANSITERMINAL_LIB="-I `$OCAMLFIND query ANSITerminal`"
pj2m's avatar
pj2m committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
				AC_MSG_RESULT(ocamlfind)
			else	
			AC_MSG_ERROR(The ansiterminal lib is missing.)
		  		ANSITERMINAL=no
			fi
		fi	
	fi
	rm c_check_ansiterminal.ml >& /dev/null

	# Look for xml-light
	AC_MSG_CHECKING([for Xml-light])
	if test -f c_check_xml-light.ml ; then
		if test -w c_check_xml-light.ml ; then
			rm c_check_xml-light.ml >& /dev/null
		else
			AC_MSG_ERROR(Cannot remove c_check_xml-light.ml. Please change its right with chmod 666 c_check_xml-light.ml)
		fi
	fi
	echo "open Xml;;" > c_check_xml-light.ml
	if ($OCAML -I +xml-light xml-light.cma c_check_xml-light.ml >& /dev/null) ; then
	   	XMLLIGHT_INCLUDE="-I +xml-light"
		AC_MSG_RESULT(xml-light)
	else

		if test "$OCAMLFIND" = no ; then
			AC_MSG_ERROR(The xml-light library is missing.)
		else	
			if ocamlfind query xml-light > /dev/null 2>&1 ; then
			           	XMLLIGHT_INCLUDE="-I `ocamlfind query xml-light`"
				AC_MSG_RESULT(ocamlfind)
			else	
		  			AC_MSG_ERROR(The xml-light ocamlfind library is missing.)
			fi
		fi	
	fi
	rm c_check_xml-light.ml >& /dev/null

	# Build GUI.
	AC_ARG_ENABLE(
		[gui],
	 	[AS_HELP_STRING(
			[--enable-gui],
			[build GUI extension (default is yes)])],
		[with_gui=$enableval],
		[with_gui=yes])
	

	if test "x$with_gui" != xno ; then
		echo ""
		echo "Trying to configure with gui enabled."
		echo ""
		# Look for lablgtk2
		AC_PATH_PROG(LABLGTK2,lablgtk2,no)
		if test "$LABLGTK2" = no ; then
			AC_MSG_WARN(Cannot find lablgtk2.)
		else
			AC_SUBST(HAVE_GTK,yes)
		fi


	
	
		# Look for lablgtkrsvg with or without ocamlfind
		AC_MSG_CHECKING([for lablrsvg])
			if test -f c_check_lablrsvg.ml ; then
			   	if test -w c_check_lablrsvg.ml ; then
				       	rm c_check_lablrsvg.ml >& /dev/null
			   	else
				       	AC_MSG_ERROR(Cannot remove c_check_lablrsvg.ml. Please change its right with chmod 666 c_check_lablrsvg.ml)
			   	fi
		fi
		echo "open Rsvg;;" > c_check_lablrsvg.ml
		if (ocaml -I +lablgtk2 lablgtk.cma lablrsvg.cma c_check_lablrsvg.ml >& /dev/null) ; then
			AC_MSG_RESULT(standard)
			LABLRSVG="yes"
		else
			if test "$OCAMLFIND" = no ; then
				AC_MSG_WARN(The lablrsvg library is missing.)
				LABLRSVG="no"
			else
				if $OCAMLFIND query lablrsvg > /dev/null 2>&1 ; then
					AC_MSG_RESULT(ocamlfind)
				else	
			  			AC_MSG_WARN(The lablrsvg library is missing.)
					LABLRSVG="no"
				fi
			fi	
		fi
		rm c_check_lablrsvg.ml >& /dev/null
	
		# Look for lablglade with or without ocamlfind
		AC_MSG_CHECKING([for lablglade])
			if test -f c_check_lablglade.ml ; then
			   	if test -w c_check_lablglade.ml ; then
				       	rm c_check_lablglade.ml >& /dev/null
			   	else
				       	AC_MSG_ERROR(Cannot remove c_check_lablglade.ml. Please change its right with chmod 666 c_check_lablglade.ml)
			   	fi
		fi
		echo "open GMain;; open Glade;;" > c_check_lablglade.ml
		if (ocamlc -I +lablgtk2 lablgtk.cma lablglade.cma c_check_lablglade.ml >& /dev/null) ; then
			AC_MSG_RESULT(lablglade)
			LABLGLADE="yes"
		else
			if test "$OCAMLFIND" = no ; then
				AC_MSG_WARN(The lablglade library is missing.)
				LABLGLADE="no"
			else
				if $OCAMLFIND query lablglade > /dev/null 2>&1 ; then
					AC_MSG_RESULT(ocamlfind)
				else	
			  			AC_MSG_WARN(The lablglade library is missing.)
					LABLGLADE="no"	
				fi
			fi	
		fi
		rm c_check_lablglade.ml >& /dev/null

		# Check whether build or not gui
		if test "$LABLGTK2" = no || test "$DOT" = no || test "$LABLRSVG" = no || test $CAIRO = no || test $LABLGLADE = no; then
		    	AC_MSG_WARN(Will not build leopar GUI extension.)
		else
		    	AC_SUBST(BUILD_GUI,yes)
		fi

	fi


	if test "x$with_debug" != xno ; then
		AC_SUBST(DEBUG,yes)
	else
		AC_SUBST(DEBUG,no)
	fi
	if test "x$with_warning" != xno ; then
		AC_SUBST(WARNING,yes)
	else
		AC_SUBST(WARNING,no)
	fi
	if test "x$with_message" != xno ; then
		AC_SUBST(MESSAGE,yes)
	else
		AC_SUBST(MESSAGE,no)
	fi
	if test "x$with_info" != xno ; then
		AC_SUBST(INFO,yes)
	else
		AC_SUBST(INFO,no)
	fi


	#lib directory
	LIB=`pwd`/lib
	AC_SUBST(LIB)

	# System
	SYSTEM=`uname`
	AC_SUBST(SYSTEM)

	# Checks for header files.

	# Checks for typedefs, structures, and compiler characteristics.

	# Checks for library functions.

	AC_SUBST(OCAMLLIB)
	AC_SUBST(OCAMLYACC)
	AC_SUBST(OCAMLLEX)
	AC_SUBST(OCAMLFIND)
	AC_SUBST(RSVG)
	AC_SUBST(XMLLIGHT_INCLUDE)
	AC_SUBST(RSVG_CONVERT)
	AC_SUBST(DEP2PICT_LIB)
	AC_SUBST(LOG_LIB)
	AC_SUBST(ANSITERMINAL_LIB)
	AC_SUBST(DEBUG)
	AC_SUBST(WARNING)
	AC_SUBST(INFO)
	AC_SUBST(MESSAGE)
	AC_SUBST(LIB)

fi

AC_SUBST(SET_MAKE)
AC_CONFIG_FILES(config/Makefile Makefile src/Makefile)
AC_PROG_MAKE_SET
AC_OUTPUT

cd config && make infos
echo ""