# This is the developer's makefile, not the user's makefile.
# Don't use it unless you know exactly what you do!

SHELL = /bin/sh
MAKE = make

all : autoconf/aclocal.m4 configures avcall/avcall.h.msvc avcall/avcall-i386-msvc.c vacall/config.h.msvc vacall/vacall.h.msvc vacall/vacall-i386-msvc.c trampoline/config.h.msvc callback/vacall_r/config.h.msvc callback/vacall_r/vacall_r.h.msvc callback/vacall_r/vacall-i386-msvc.c callback/trampoline_r/config.h.msvc

CONFIGURES = configure avcall/configure vacall/configure trampoline/configure callback/configure callback/vacall_r/configure callback/trampoline_r/configure
CONFIGURES_IN = configure.in avcall/configure.in vacall/configure.in trampoline/configure.in callback/configure.in callback/vacall_r/configure.in callback/trampoline_r/configure.in

CLISP_DIR = ..
ACLOCAL = $(CLISP_DIR)/src/autoconf/aclocal.m4
ACSELECT = $(CLISP_DIR)/src/autoconf/acselect
OTHERMACROS = $(CLISP_DIR)/src/autoconf/libtool.m4

autoconf/aclocal.m4 : $(ACLOCAL)
	($(ACSELECT) `cat $(CONFIGURES_IN) | grep '^[A-Z][A-Z]_' | sed 's,[^A-Z_].*$$,,g' | sort | uniq` < $(ACLOCAL) ; cat $(OTHERMACROS) | sed -e 's,AC_CANONICAL_HOST,CL_CANONICAL_HOST,g' -e 's,AC_PROG_RANLIB,CL_PROG_RANLIB,g' -e 's,AC_PROG_LN_S,CL_PROG_LN_S,g') > autoconf/aclocal.m4

configures : $(CONFIGURES)

AUTOCONF_FILES = autoconf/aclocal.m4 autoconf/acgeneral.m4 autoconf/acspecific.m4

configure : configure.in $(AUTOCONF_FILES)
	autoconf/autoconf -m autoconf

avcall/configure : avcall/configure.in $(AUTOCONF_FILES)
	cd avcall ; ../autoconf/autoconf -m ../autoconf

vacall/configure : vacall/configure.in $(AUTOCONF_FILES)
	cd vacall ; ../autoconf/autoconf -m ../autoconf

trampoline/configure : trampoline/configure.in $(AUTOCONF_FILES)
	cd trampoline ; ../autoconf/autoconf -m ../autoconf

callback/configure : callback/configure.in $(AUTOCONF_FILES)
	cd callback ; ../autoconf/autoconf -m ../autoconf

callback/vacall_r/configure : callback/vacall_r/configure.in $(AUTOCONF_FILES)
	cd callback/vacall_r ; ../../autoconf/autoconf -m ../../autoconf

callback/trampoline_r/configure : callback/trampoline_r/configure.in $(AUTOCONF_FILES)
	cd callback/trampoline_r ; ../../autoconf/autoconf -m ../../autoconf

check-configures : $(CONFIGURES)
	set -e; for f in $(CONFIGURES); do bash -x -n $$f; done

avcall/avcall.h.msvc : avcall/avcall.h.in
	cd avcall ; $(MAKE) -f Makefile.devel avcall.h.msvc

avcall/avcall-i386-msvc.c : avcall/avcall-i386.S avcall/asmi386.sh
	cd avcall ; $(MAKE) -f Makefile.devel avcall-i386-msvc.c

vacall/config.h.msvc : vacall/config.h.in
	cd vacall ; $(MAKE) -f Makefile.devel config.h.msvc

vacall/vacall.h.msvc : vacall/vacall.h.in
	cd vacall ; $(MAKE) -f Makefile.devel vacall.h.msvc

vacall/vacall-i386-msvc.c : vacall/vacall-i386.S vacall/asmi386.sh
	cd vacall ; $(MAKE) -f Makefile.devel vacall-i386-msvc.c

trampoline/config.h.msvc : trampoline/config.h.in
	cd trampoline ; $(MAKE) -f Makefile.devel config.h.msvc

callback/vacall_r/config.h.msvc : callback/vacall_r/config.h.in
	cd callback ; $(MAKE) -f Makefile.devel vacall_r/config.h.msvc

callback/vacall_r/vacall_r.h.msvc : callback/vacall_r/vacall_r.h.in
	cd callback ; $(MAKE) -f Makefile.devel vacall_r/vacall_r.h.msvc

callback/vacall_r/vacall-i386-msvc.c : callback/vacall_r/vacall-i386.S callback/vacall_r/asmi386.sh
	cd callback ; $(MAKE) -f Makefile.devel vacall_r/vacall-i386-msvc.c

callback/trampoline_r/config.h.msvc : callback/trampoline_r/config.h.in
	cd callback ; $(MAKE) -f Makefile.devel trampoline_r/config.h.msvc

COMPILERS="cc -O" "gcc -freg-struct-return" "gcc -fpcc-struct-return"

multibuild : force
	for compiler in $(COMPILERS) ; do \
	  dir=build-`echo $$compiler | sed -e 's, ,,g' -e 's,/,_,g'`; \
	  mkdir $$dir; cd $$dir; \
	  CC="$$compiler" ../configure --srcdir=.. && make && make check; \
	  cd ..; \
	done

force :

