summaryrefslogtreecommitdiff
path: root/tiger-compiler/tcsh/generate-swig-mk
blob: 200d98b1135b36fec1e69692dd3f835e616cf7e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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