Author: Thibaut Paumard <thibaut@debian.org>
Date: 2016/11/30
Description: add autoload files for each plug-in
 PKG_I_START is also filled in each Makefile, although it is useless for the
 Debian package. Autoloads in yeti/yeti.i are removed.
Forwarded: yes

--- /dev/null
+++ b/fftw/yeti_fftw_start.i
@@ -0,0 +1,6 @@
+autoload, "yeti_fftw.i";
+// interpreted
+autoload, "yeti_fftw.i", cfftw, fftw_indgen, fftw_dist, fftw_smooth;
+autoload, "yeti_fftw.i", fftw_convolve;
+// compiled
+autoload, "yeti_fftw.i", fftw_plan, fftw;
--- /dev/null
+++ b/regex/yeti_regex_start.i
@@ -0,0 +1,5 @@
+autoload, "yeti_regex.i";
+autoload, "yeti_regex.i", regcomp;
+autoload, "yeti_regex.i", regmatch;
+autoload, "yeti_regex.i", regsub;
+autoload, "yeti_regex.i", regmatch_part;
--- /dev/null
+++ b/tiff/yeti_tiff_start.i
@@ -0,0 +1,8 @@
+autoload, "yeti_tiff.i";
+autoload, "yeti_tiff.i", tiff_open;
+autoload, "yeti_tiff.i", tiff_debug;
+autoload, "yeti_tiff.i", tiff_read_pixels;
+autoload, "yeti_tiff.i", tiff_read_image;
+autoload, "yeti_tiff.i", tiff_read_directory;
+autoload, "yeti_tiff.i", tiff_read;
+autoload, "yeti_tiff.i", tiff_check;
--- a/core/Makefile
+++ b/core/Makefile
@@ -79,13 +79,17 @@
 EXTRA_PKGS=$(Y_EXE_PKGS)
 
 # list of additional files for clean
-PKG_CLEAN=$(PKG_NAME)$(PLUG_SFX) $(PKG_NAME).dll $(PKG_NAME).so
+PKG_CLEAN=$(PKG_NAME)$(PLUG_SFX) $(PKG_NAME).dll $(PKG_NAME).so zzyeti_start.i
 
 # autoload file for this package, if any
-PKG_I_START=
+PKG_I_START=zzyeti_start.i yeti_yhdf_start.i
 # non-pkg.i include files for this package, if any
 PKG_I_EXTRA=yeti_yhdf.i
 
+# optional prerequisites for all:
+# yeti_start.i needs to be generated during "make"
+ALL_TARGETS=zzyeti_start.i
+
 #-------------------------------------- standard targets and rules (in Makepkg)
 
 # set macros Makepkg uses in target and dependency names
@@ -129,6 +133,18 @@
 yeti_utils.o: yeti.h ../config.h
 #yeti_new.o:
 
+zz$(PKG_NAME)_start.i:
+	echo '// cancel emulation layer' > $@
+	echo 'autoload, "emulate-yeti.i";' >> $@
+	echo '// there may be another instance in the path, hide it' >> $@
+	echo 'autoload, "$(PKG_I)";' >> $@
+	echo '// YETI functions may move to Yorick. Be forward-compatible' >> $@
+	grep "^func " $(PKG_I) | awk '{print $$2}' | awk -F\( '{print  "if (!is_func(" $$1 ")) autoload, \"$(PKG_I)\", " $$1 ";"}' >> $@
+	grep "^extern " $(PKG_I) | awk '{print $$2}' | awk -F\; '{print  "if (!is_func(" $$1 ")) autoload, \"$(PKG_I)\", " $$1}' >> $@
+
+clean::
+	rm -f zzyeti_start.i
+
 #
 # Local Variables:
 # mode: Makefile
--- a/fftw/Makefile
+++ b/fftw/Makefile
@@ -36,7 +36,7 @@
 PKG_CLEAN=
 
 # autoload file for this package, if any
-PKG_I_START=
+PKG_I_START=yeti_fftw_start.i
 # non-pkg.i include files for this package, if any
 PKG_I_EXTRA=
 
--- a/regex/Makefile
+++ b/regex/Makefile
@@ -36,7 +36,7 @@
 PKG_CLEAN=
 
 # autoload file for this package, if any
-PKG_I_START=
+PKG_I_START=yeti_regex_start.i
 # non-pkg.i include files for this package, if any
 PKG_I_EXTRA=
 
--- a/tiff/Makefile
+++ b/tiff/Makefile
@@ -36,7 +36,7 @@
 PKG_CLEAN=
 
 # autoload file for this package, if any
-PKG_I_START=
+PKG_I_START=yeti_tiff_start.i
 # non-pkg.i include files for this package, if any
 PKG_I_EXTRA=
 
--- /dev/null
+++ b/core/yeti_yhdf_start.i
@@ -0,0 +1,3 @@
+autoload, "yeti_yhdf.i";
+autoload, "yeti_yhdf.i", yhd_save, yhd_check, yhd_info, yhd_restore;
+
