
. ./libtemo.sh || exit 1

test_start

title Using Antimake with autoconf

msg Autoconf setup

cat_file autogen.sh <<"EOF"
	../../std-autogen.sh ../../..

	# fetch Antimake template from libusual
	cp ../../antimake.mk antimake.mk.in
EOF

cat_file configure.ac <<"EOF"
	AC_INIT([actest], [0.1])
	AC_CONFIG_SRCDIR([prog.c])
	AC_PREREQ([2.59])

	AC_USUAL_INIT
	AC_USUAL_PROGRAM_CHECK

	AC_OUTPUT([antimake.mk])
EOF

msg Here is the source we want to build:

cat_file prog.c <<"EOF"
	#include <stdio.h>
	#include <string.h>

	int main(void)
	{
		printf("hello\n");
		return 0;
	}
EOF

msg Antimake based Makefile

cat_file Makefile <<"EOF"
	# the automake-style build description for 'prog'
	noinst_PROGRAMS = prog
	prog_SOURCES = prog.c

	EXTRA_DIST = Makefile $(MAINTAINERCLEANFILES)

	# clean configured files
	DISTCLEANFILES = config.status config.log antimake.mk

	# clean generated files
	MAINTAINERCLEANFILES = configure config.guess config.sub install-sh antimake.mk.in

	# launch Antimake
	include antimake.mk
EOF

msg Build the project
runq sh ./autogen.sh
runq ./configure
run make
run ls
run ./prog

msg Create distribution package
run make dist
run 'tar tzf actest-0.1.tar.gz | sort'

msg Test the distribution package and separate build dir
run mkdir -p test
run cd test
run tar xf ../actest-0.1.tar.gz
run mkdir build
run cd build
runq ../actest-0.1/configure
run make
run ls
run ./prog
run cd ../..

msg Clean up
run make maintainer-clean
run ls

msg Done
