File: gst-package.m4

package info (click to toggle)
gnu-smalltalk 3.1-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 33,300 kB
  • ctags: 13,999
  • sloc: ansic: 88,106; sh: 23,223; asm: 7,889; perl: 4,493; cpp: 3,539; awk: 1,483; yacc: 1,355; xml: 1,272; makefile: 1,192; lex: 843; sed: 258; objc: 124
file content (123 lines) | stat: -rw-r--r-- 4,192 bytes parent folder | download | duplicates (2)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
dnl I'd like this to be edited in -*- Autoconf -*- mode...
dnl

dnl GST_PACKAGE_ENABLE(NAME, DIR, [TESTS], [VARS-TO-TEST], [CONFIG-FILES], [LIBS])
dnl ------------------------------------------------------------------------
dnl Arrange for installation of package NAME in directory DIR (prefixed
dnl by whatever was set up with GST_PACKAGE_PREFIX.
dnl TESTS are run and VARS-TO-TEST are inspected after running them -- if
dnl any of them is 'no' or 'not found' the package will not be built.
dnl CONFIG-FILES (prefixed by DIR) are created from corresponding .in files;
dnl it is important to specify package.xml here if it is automatically
dnl generated.  LIBS are libraries (possibly with .la extensions) that are
dnl built and will be preloaded by the wrapper script in `tests/gst'.

AC_DEFUN([GST_PACKAGE_PREFIX], [
m4_define([_GST_PKG_PREFIX], [$1/])])

AC_DEFUN([GST_PACKAGE_DEPENDENCIES], [
m4_define([_GST_PKG_DEPENDENCIES], [$1])])
m4_define([_GST_PKG_DEPENDENCIES], [])

m4_define([_GST_RULES_PREPARE],
[m4_expand_once([
  PACKAGE_RULES=pkgrules.tmp
  rm -f pkgrules.tmp])
  AC_SUBST_FILE([PACKAGE_RULES])])

m4_define([_GST_PKG_ENABLE], [
  cat >> pkgrules.tmp << \EOF
install-data-hook:: $1.star
	$(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=$(gstdatadir) --destdir=$(DESTDIR) $1.star

uninstall-local::
	$(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=$(gstdatadir) --destdir=$(DESTDIR) --uninstall $(DESTDIR)$(gstdatadir)/$1.star

-include $(srcdir)/_GST_PKG_MK
all-local: $1.star
EOF
  m4_if([$3], [], [], 
    [PACKAGE_DLOPEN_FLAGS="$PACKAGE_DLOPEN_FLAGS m4_foreach_w(GST_Lib,
	[$3], [-dlopen \"\${abs_top_builddir}/_GST_PKG_DIR/GST_Lib\"])"])
  m4_foreach_w(GST_File, [$2],
	       [m4_if(GST_File, Makefile,
		      [BUILT_PACKAGES="$BUILT_PACKAGES _GST_PKG_DIR"])])])

m4_define([_GST_PKG_IF_FILE], [dnl
m4_define([_GST_COND], [$4])dnl
m4_foreach_w(GST_File, [$1],
	    [m4_if(GST_File, $2, [m4_define([_GST_COND], [$3])])])dnl
_GST_COND])

m4_define([_GST_PKG_PREFIX], [])

AC_DEFUN([GST_PACKAGE_ENABLE], [
  $3
  AC_MSG_CHECKING([whether to install $1])
  _GST_RULES_PREPARE
  m4_define([_GST_PKG_DIR], [_GST_PKG_PREFIX[]$2])dnl
  m4_define([_GST_PKG_XML], [_GST_PKG_DIR/package.xml])dnl
  m4_define([_GST_PKG_DISTDIR], [$(distdir)/_GST_PKG_DIR])dnl
  m4_define([_GST_PKG_STAMP], [_GST_PKG_DIR/stamp-classes])dnl
  m4_define([_GST_PKG_MK], [_GST_PKG_DIR/Makefile.frag])dnl
  m4_define([_GST_PKG_XML_IN],
	    [_GST_PKG_IF_FILE([$5], [package.xml],
			      [$(srcdir)/_GST_PKG_DIR/package.xml.in],
			      [_GST_PKG_XML])])dnl

  cat >> pkgrules.tmp << \EOF
all-local: $(srcdir)/_GST_PKG_STAMP
$1.star: _GST_PKG_XML $(srcdir)/_GST_PKG_STAMP _GST_PKG_DEPENDENCIES
	_GST_PKG_IF_FILE([$5], [Makefile], [cd _GST_PKG_DIR && $(MAKE)
	])$(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=. $<

clean-local::
	-rm -f $1.star

dist-hook:: _GST_PKG_XML
	$(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=_GST_PKG_DISTDIR --dist $<

dist-hook:: $(srcdir)/_GST_PKG_STAMP $(srcdir)/_GST_PKG_MK
	cp -p $(srcdir)/_GST_PKG_STAMP _GST_PKG_DISTDIR/stamp-classes
	cp -p $(srcdir)/_GST_PKG_MK _GST_PKG_DISTDIR/Makefile.frag

$(srcdir)/_GST_PKG_MK: _GST_PKG_XML_IN
	(echo '$1_FILES = \'; \
	  $(GST_[]PACKAGE) --srcdir=$(srcdir) --vpath --list-files $1 $< | \
	    tr -d \\r | tr \\n " "; \
	echo; \
	echo '$$($1_FILES):'; \
	echo '$$(srcdir)/_GST_PKG_STAMP: $$($1_FILES)'; \
	echo '	touch $$(srcdir)/_GST_PKG_STAMP') > $(srcdir)/_GST_PKG_MK
EOF

    m4_if([$4], [],
      [_GST_PKG_ENABLE([$1], [$5], [$6])
      AC_MSG_RESULT([yes])],

      [(for i in $4; do
	eval ac_var='${'$i'-bad}'
	case "$ac_var" in
	  no* )
	    exit 1 ;;
	  bad )
	    AC_MSG_WARN([variable $i not set, proceeding as if \"no\"])
	    exit 1 ;;
	esac
      done)
      if test $? = 0; then
        _GST_PKG_ENABLE([$1], [$5], [$6])
	AC_MSG_RESULT([yes])
      else
	AC_MSG_RESULT([no])
      fi
      ])

  m4_if([$5], [], [], 
    [_GST_PKG_IF_FILE([$5], [Makefile], [ALL_PACKAGES="$ALL_PACKAGES _GST_PKG_DIR"])
    AC_CONFIG_FILES(m4_foreach_w(GST_File, [$5], [_GST_PKG_DIR/GST_File ])) ])

  AC_SUBST([ALL_PACKAGES])
  AC_SUBST([BUILT_PACKAGES])
  AC_SUBST([PACKAGE_DLOPEN_FLAGS])
])dnl