summaryrefslogtreecommitdiff
path: root/tiger-compiler/tcsh/generate-swig-mk
diff options
context:
space:
mode:
Diffstat (limited to 'tiger-compiler/tcsh/generate-swig-mk')
-rwxr-xr-xtiger-compiler/tcsh/generate-swig-mk101
1 files changed, 101 insertions, 0 deletions
diff --git a/tiger-compiler/tcsh/generate-swig-mk b/tiger-compiler/tcsh/generate-swig-mk
new file mode 100755
index 0000000..200d98b
--- /dev/null
+++ b/tiger-compiler/tcsh/generate-swig-mk
@@ -0,0 +1,101 @@
+#! /bin/sh
+
+if test $# -ne 2; then
+ echo "Usage: $0 python filename" >&2
+ exit 1
+fi
+
+if test "x$1" != xpython; then
+ echo "$0: first argument must be \`python'"
+ exit 1
+fi
+
+if test -z "$top_srcdir"; then
+ echo "$0: top_srcdir undefined" >&2
+ exit 1
+fi
+
+lang=$1
+
+# Connect stdout to the output file.
+exec >$2
+
+cat <<EOF
+## Generated by $0. Do not edit by hand!
+
+AM_LDFLAGS = -avoid-version -module -shared
+AM_LIBADD = \$(top_builddir)/src/libtc.la
+tcdir = \$(top_srcdir)
+
+CLEANFILES =
+
+# The list of dependencies generated as a side-effect of running swig.
+SWIG_GENERATED_DEPS =
+
+EOF
+case $lang in
+ python) echo "nodist_python_PYTHON =" ;;
+esac
+
+# Compile swig modules.
+case $lang in
+ python) mod_dir=pyexec ;;
+esac
+for src in $(find $top_srcdir/tcsh/src -name '*.i' |
+ sed -e 's:'"$top_srcdir"':$(tcdir):')
+do
+ base=$(basename $src ".i")
+ module=$(echo $base | sed -e 's/tiger_//')
+ modulepath=$(dirname $src)
+ dest=$base-wrap.cc
+ case $lang in
+ python)
+ ltmodule=_tiger_$module
+ cleanfiles="$dest $base.py $base.pyc"
+ ;;
+ esac
+ # No $< and $@ here because NetBSD make does not like it. Two
+ # rules, because two outputs from a single input does not fit Make's
+ # model. See automake.info "Multiple Outputs".
+ cat <<EOF
+
+## Module: $module.
+${mod_dir}_LTLIBRARIES += $ltmodule.la
+nodist_${ltmodule}_la_SOURCES = $dest
+${ltmodule}_la_LIBADD = \$(AM_LIBADD)
+CLEANFILES += $cleanfiles
+$dest: $src
+ \$(AM_V_GEN)if \$(SWIG) \$(AM_SWIGFLAGS) \$(SWIGFLAGS) -MD -MF "\$(DEPDIR)/$base-wrap.Tcc" -o $dest $src; \\
+ then \\
+ mv -f "\$(DEPDIR)/$base-wrap.Tcc" "\$(DEPDIR)/$base-wrap.Pcc"; \\
+ else \\
+ rm -f "\$(DEPDIR)/$base-wrap.Tcc"; exit 1; \\
+ fi
+
+@AMDEP_TRUE@@am__include@ @am__quote@./\$(DEPDIR)/$base-wrap.Pcc@am__quote@
+
+@AMDEP_TRUE@ SWIG_GENERATED_DEPS += ./\$(DEPDIR)/$base-wrap.Pcc
+
+EOF
+ case $lang in
+ python) cat <<EOF
+nodist_python_PYTHON += $base.py
+$base.py: $src
+ \$(AM_V_GEN)\$(MAKE) \$(AM_MAKEFLAGS) $dest
+EOF
+ ;;
+ esac
+done
+cat <<EOF
+
+
+# Target \`deps-reset' re-initializes the dependencies generated as a
+# side-effect of running swig.
+.PHONY: deps-reset
+deps-reset:
+ @list='\$(SWIG_GENERATED_DEPS)'; for d in \$\$list; do \\
+ echo '# dummy' > \$\$d; \\
+ done
+
+
+EOF