# Minimal makefile for the configuration stuff.
# do not use if you do not know what you are doing...
# author: Jean-Marc Lasgouttes (Jean-Marc.Lasgouttes@inria.fr)

# You need to have GNU M4 to regenerate lib/configure 
M4=gm4
M4FILES=configure.in aclocal.m4 gettext.m4 lcmessage.m4 progtest.m4

all: ../src/config.h.in ../configure ../lib/configure 

# autoheader might not change config.h.in, so touch a stamp file.
../src/config.h.in: stamp-h.in
stamp-h.in: $(M4FILES) acconfig.h 
	(cd .. ; \
	for i in $(M4FILES) acconfig.h ; do ln -fs config/$$i $$i ; done ;\
	autoheader ; \
	rm -f $(M4FILES) acconfig.h config.cache)
	echo timestamp > stamp-h.in

../configure: $(M4FILES)
	(cd .. ; \
	for i in $(M4FILES) ; do ln -fs config/$$i $$i ; done ;\
	autoconf configure.in | \
	  sed -e 's/x_direct_test_library=Xt/x_direct_test_library=X11/' \
	      -e 's/x_direct_test_function=XtMalloc/x_direct_test_function=XFree/' >configure; \
	rm -f $(M4FILES) config.cache)

../lib/configure: lib_configure.m4
	rm -f $@
	$(M4) lib_configure.m4 >$@
	chmod a+x $@

clean:
	rm -f *~ *.orig *.rej
