[PATCH] gst-package --prepare

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] gst-package --prepare

Paolo Bonzini
Creates configure.ac and Makefile.am automatically.  Most useful for
distributing packages with C parts or with a manual, but makes sense
also for developing other packages (which would then be distributed as
the .star file only).

Paolo

* looking for [hidden email]--2004b/smalltalk--devo--2.2--patch-482 to compare with
* comparing to [hidden email]--2004b/smalltalk--devo--2.2--patch-482
M  scripts/Package.st
M  gst-tool.c
M  build-aux/gst-package.m4
M  configure.ac
M  doc/gst.texi
M  gst-config.in
M  Makefile.am
M  build-aux/gst.m4
=> build-aux/.arch-ids/package.m4.id build-aux/.arch-ids/gst-package.m4.id
=> build-aux/package.m4 build-aux/gst-package.m4

* modified files

--- orig/Makefile.am
+++ mod/Makefile.am
@@ -20,6 +20,7 @@ AUTOMAKE_OPTIONS = gnu 1.8
 ACLOCAL_AMFLAGS = -I build-aux
 
 PACKAGE=smalltalk
+gstdatadir=$(pkgdatadir)
 
 DIST_SUBDIRS = lib-src snprintfv lightning sigsegv libffi opcode libgst \
  . $(ALL_PACKAGES) tests doc
@@ -44,7 +45,7 @@ GST_PACKAGE = ./gst-tool gst-package $(G
 ###########################################################
 
 aclocaldir = $(datadir)/aclocal
-dist_aclocal_DATA = build-aux/gst.m4
+dist_aclocal_DATA = build-aux/gst.m4 build-aux/gst-package.m4
 dist_noinst_DATA = Doxyfile
 dist_noinst_SCRIPTS = build-aux/texi2dvi build-aux/texi2html \
  build-aux/help2man build-aux/config.rpath


--- orig/build-aux/package.m4
+++ mod/build-aux/gst-package.m4
@@ -1,7 +1,7 @@
 dnl I'd like this to be edited in -*- Autoconf -*- mode...
 dnl
 
-dnl GST_PACKAGE(NAME, DIR, [TESTS], [VARS-TO-TEST], [CONFIG-FILES], [LIBS])
+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.
@@ -26,7 +26,7 @@ m4_define([_GST_PKG_ENABLE], [
 dnl If this is unconditionally included, the rule for $1.star will be
 dnl invoked on install
 install-data-hook:: $1.star
- $(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=$(pkgdatadir) --destdir=$(DESTDIR) $1.star
+ $(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=$(gstdatadir) --destdir=$(DESTDIR) $1.star
 
 -include $(srcdir)/_GST_PKG_STAMP
 all-local: $1.star
@@ -46,7 +46,7 @@ _GST_COND])
 
 m4_define([_GST_PKG_PREFIX], [])
 
-AC_DEFUN([GST_PACKAGE], [
+AC_DEFUN([GST_PACKAGE_ENABLE], [
   $3
   AC_MSG_CHECKING([whether to install $1])
   _GST_RULES_PREPARE
@@ -68,7 +68,7 @@ clean-local::
  -rm -f $1.star
 
 uninstall-local::
- $(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=$(pkgdatadir) --destdir=$(DESTDIR) --uninstall $(DESTDIR)$(pkgdatadir)/$1.star
+ $(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=$(gstdatadir) --destdir=$(DESTDIR) --uninstall $(DESTDIR)$(gstdatadir)/$1.star
 
 dist-hook:: _GST_PKG_XML
  $(GST_[]PACKAGE) --srcdir=$(srcdir) --target-directory=_GST_PKG_DISTDIR --dist $<


--- orig/build-aux/gst.m4
+++ mod/build-aux/gst.m4
@@ -8,23 +8,29 @@ AC_DEFUN([AM_PATH_GST],[
 dnl Various autoconf user options
 
 AC_ARG_WITH(gst,
-[  --with-gst=PFX   ]dnl
-[Prefix where GNU Smalltalk is installed],
+AS_HELP_STRING([--with-gst=PFX], [Prefix where GNU Smalltalk is installed]),
 gst_prefix="$withval", gst_prefix="")
 
     if test x$gst_prefix != x; then
-        GST_CONFIG="$gst_prefix/bin/gst-config"
+        : ${GST="$gst_prefix/bin/gst"}
+        : ${GST_CONFIG="$gst_prefix/bin/gst-config"}
+        : ${GST_PACKAGE="$gst_prefix/bin/gst-package"}
     fi
 
     have_gst="no";
     
-    AC_PATH_PROG(GST_CONFIG, gst-config, no)
+    AC_PATH_PROG([GST], [gst], no)
+    AC_PATH_PROG([GST_CONFIG], [gst-config], no)
+    AC_PATH_PROG([GST_PACKAGE], [gst-package], no)
+
     min_gst_version=ifelse([$1],,0.0.0,$1)
     AC_MSG_CHECKING(for GNU Smalltalk version >= $min_gst_version)
     if test "x$GST_CONFIG" != xno; then
         GST_CFLAGS=`$GST_CONFIG --cflags`
         GST_LIBS=`$GST_CONFIG --libs $extra_libs`
         GST_PREFIX=`$GST_CONFIG --prefix`
+        gstlibdir=`$GST_CONFIG --libdir`
+        gstdatadir=`$GST_CONFIG --datadir`
 
         gst_config_major_version=`$GST_CONFIG --version | \
             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
@@ -66,10 +72,14 @@ gst_prefix="$withval", gst_prefix="")
 
  GST_CFLAGS=""
  GST_LIBS=""
+ gstlibdir=${libdir}/smalltalk
+ gstdatadir=${datadir}/smalltalk
  ifelse([$3], , :, [$3])
     fi
 
     AC_SUBST(GST_CFLAGS)
     AC_SUBST(GST_LIBS)
     AC_SUBST(GST_PREFIX)
+    AC_SUBST(gstlibdir)
+    AC_SUBST(gstdatadir)
 ])    


--- orig/configure.ac
+++ mod/configure.ac
@@ -241,21 +241,21 @@ GST_HAVE_GMP
 GST_HAVE_READLINE
 
 GST_PACKAGE_PREFIX([packages])
-GST_PACKAGE([BloxTK], [blox/tk],
+GST_PACKAGE_ENABLE([BloxTK], [blox/tk],
    [GST_HAVE_TCLTK],
    [gst_cv_tcltk_libs],
    [Makefile], [blox-tk.la])
-GST_PACKAGE([Browser], [browser])
-GST_PACKAGE([Complex], [complex])
-GST_PACKAGE([Continuations], [continuations])
-GST_PACKAGE([DebugTools], [debug])
-GST_PACKAGE([DB], [db])
-GST_PACKAGE([GDBM], [gdbm],
+GST_PACKAGE_ENABLE([Browser], [browser])
+GST_PACKAGE_ENABLE([Complex], [complex])
+GST_PACKAGE_ENABLE([Continuations], [continuations])
+GST_PACKAGE_ENABLE([DebugTools], [debug])
+GST_PACKAGE_ENABLE([DB], [db])
+GST_PACKAGE_ENABLE([GDBM], [gdbm],
    [AC_CHECK_HEADER([gdbm.h])],
    [ac_cv_header_gdbm_h],
    [Makefile], [gdbm.la])
-GST_PACKAGE([Glorp], [glorp])
-GST_PACKAGE([GTK], [gtk], [
+GST_PACKAGE_ENABLE([Glorp], [glorp])
+GST_PACKAGE_ENABLE([GTK], [gtk], [
   AC_ARG_ENABLE(gtk,
   [  --enable-gtk={yes,no,blox}
                           enable GTK+ bindings.  Blox/GTK is experimental.], ,
@@ -274,46 +274,46 @@ GST_PACKAGE([GTK], [gtk], [
   fi],
   [enable_gtk],
   [Makefile], [gst-gtk.la])
-GST_PACKAGE([BloxGTK], [blox/gtk],, [enable_gtk])
-GST_PACKAGE([Blox], [blox/tests],
+GST_PACKAGE_ENABLE([BloxGTK], [blox/gtk],, [enable_gtk])
+GST_PACKAGE_ENABLE([Blox], [blox/tests],
     [enable_blox=no
      case x"$enable_gtk" in
  xno|xnot\ found) ;; *) enable_blox=yes ;; esac
      case x"$gst_cv_tcltk_libs" in
  xno|xnot\ found) ;; *) enable_blox=yes ;; esac],
     [enable_blox], [package.xml])
-GST_PACKAGE([WebServer], [httpd])
-GST_PACKAGE([I18N], [i18n],
+GST_PACKAGE_ENABLE([WebServer], [httpd])
+GST_PACKAGE_ENABLE([I18N], [i18n],
   [AC_CHECK_FUNCS_ONCE([nl_langinfo])
   AM_LANGINFO_CODESET
   AM_ICONV],
   [ac_cv_func_nl_langinfo am_cv_func_iconv],
   [Makefile], [i18n.la])
-GST_PACKAGE([Iconv], [iconv],
+GST_PACKAGE_ENABLE([Iconv], [iconv],
   [AM_ICONV],
   [am_cv_func_iconv],
   [Makefile], [iconv.la])
-GST_PACKAGE([Java], [java])
-GST_PACKAGE([Digest], [digest], [], [], [Makefile], [digest.la])
-GST_PACKAGE([MySQL], [mysql])
-GST_PACKAGE([NCurses],
+GST_PACKAGE_ENABLE([Java], [java])
+GST_PACKAGE_ENABLE([Digest], [digest], [], [], [Makefile], [digest.la])
+GST_PACKAGE_ENABLE([MySQL], [mysql])
+GST_PACKAGE_ENABLE([NCurses],
   [ncurses],
   [GST_HAVE_LIB(ncurses, initscr)],
   [ac_cv_lib_ncurses_initscr])
-GST_PACKAGE([NetClients], [net])
-GST_PACKAGE([DhbNumericalMethods], [numerics])
-GST_PACKAGE([Compiler], [stinst/compiler])
-GST_PACKAGE([Parser], [stinst/parser])
-GST_PACKAGE([SUnit], [sunit])
-GST_PACKAGE([TCP], [tcp],
+GST_PACKAGE_ENABLE([NetClients], [net])
+GST_PACKAGE_ENABLE([DhbNumericalMethods], [numerics])
+GST_PACKAGE_ENABLE([Compiler], [stinst/compiler])
+GST_PACKAGE_ENABLE([Parser], [stinst/parser])
+GST_PACKAGE_ENABLE([SUnit], [sunit])
+GST_PACKAGE_ENABLE([TCP], [tcp],
   [GST_INET_SOCKETS],
   [gst_cv_inet_sockets],
   [Makefile], [tcp.la])
-GST_PACKAGE([VFSAddOns], [vfs], [], [], [Makefile])
-GST_PACKAGE([XML], [xml])
-GST_PACKAGE([XPath], [xpath])
-GST_PACKAGE([XSL], [xsl])
-GST_PACKAGE([ZLib],
+GST_PACKAGE_ENABLE([VFSAddOns], [vfs], [], [], [Makefile])
+GST_PACKAGE_ENABLE([XML], [xml])
+GST_PACKAGE_ENABLE([XPath], [xpath])
+GST_PACKAGE_ENABLE([XSL], [xsl])
+GST_PACKAGE_ENABLE([ZLib],
   [zlib],
   [AC_CHECK_HEADER([zlib.h])],
   [ac_cv_header_zlib_h],


--- orig/doc/gst.texi
+++ mod/doc/gst.texi
@@ -1838,17 +1838,33 @@ of the testing subpackage, and the defau
 
 To install your package, you only have to do
 @example
-    gst-package mypkg.xml
+    gst-package path/to/package.xml
 @end example
 
-@command{gst-package} is a small shell script which will merge the file
-with @file{packages.xml}, install the files specified in the @code{file} tags
-and load the packages.  The @gst{} makefile also use @file{gst-package}
-to install packages and to prepare the distribution tarballs.@footnote{The
-  operation of gst-package is subject to change in future releases, while
-  keeping backwards compatibility.}
+@command{gst-package} is a Smalltalk script which will create a
+@file{.star} archive in the current image directory, with the files
+specified in the @code{file} tags (you can use the option
+@option{--target-directory} to create the @file{.star} file
+elsewhere).
 
-The rest of this chapter discusses the packages provided with @gst{}.
+Alternatively, @code{gst-package} can be used to create a skeleton
+GNU style source tree.  This include a @file{configure.ac} that will
+find the installation path of GNU Smalltalk, and a @file{Makefile.am}
+to support all the standard Makefile targets (including @command{make
+install} and @command{make dist}).  To do so, go in the directory that
+is to become the top of the source tree and type.
+
+@example
+    gst-package --prepare path1/package.xml path2/package.xml
+@end example
+
+In this case the generated configure script and Makefile will use
+some of the more advanced features of @command{gst-package} (to be
+documented).  The @gst{} makefile similarly uses
+@command{gst-package} to install packages and to prepare the distribution
+tarballs.
+
+The rest of this chapter discusses some of the packages provided with @gst{}.
 
 @menu
 * Blox, BloxTK, and Browser:             Blox.


--- orig/gst-config.in
+++ mod/gst-config.in
@@ -2,6 +2,7 @@
 
 : ${prefix:=@prefix@}
 : ${exec_prefix:=@exec_prefix@}
+: ${datarootdir:=@datarootdir@}
 exec_prefix_set=no
 
 usage()
@@ -12,6 +13,8 @@ Options:
  [--prefix[=DIR]]
  [--exec-prefix[=DIR]]
  [--version]
+ [--libdir]
+ [--datadir]
  [--libs]
  [--cflags]
 Libraries:
@@ -46,6 +49,12 @@ while test $# -gt 0; do
       exec_prefix=$optarg
       exec_prefix_set=yes
       ;;
+    --datadir)
+      echo_datadir=yes
+      ;;
+    --libdir)
+      echo_libdir=yes
+      ;;
     --exec-prefix)
       echo_exec_prefix=yes
       ;;
@@ -72,6 +81,7 @@ while test $# -gt 0; do
 done
 
 : ${pkglibdir:="@libdir@/@PACKAGE@"}
+: ${pkgdatadir:="@datadir@/@PACKAGE@"}
 gst_libs="-L${pkglibdir} @LIBS@"
 
 if test "$echo_prefix" = "yes"; then
@@ -97,3 +107,11 @@ if test "$echo_libs" = "yes"; then
 
       echo $my_gst_libs -lgst
 fi      
+
+if test "$echo_datadir" = "yes"; then
+      echo $pkgdatadir
+fi
+
+if test "$echo_libdir" = "yes"; then
+      echo $pkglibdir
+fi


--- orig/gst-tool.c
+++ mod/gst-tool.c
@@ -97,7 +97,7 @@ struct tool tools[] = {
   {
     "gst-package", "scripts/Package.st",
     "-h|--help --version --load --no-load --no-install --uninstall --dist \
-        --test -t|--target-directory: --list-files: --list-packages \
+        --prepare --test -t|--target-directory: --list-files: --list-packages \
         --srcdir: --distdir|--destdir: --copy --all-files --vpath \
         -n|--dry-run -I|--image-file: --kernel-directory:",
     NULL


--- orig/scripts/Package.st
+++ mod/scripts/Package.st
@@ -79,7 +79,7 @@ Kernel.PackageDirectories subclass: Pack
  aCollection do: [ :each | self addFile: each ]
     ]
 
-    addFile: fileName [
+    parse: fileName [
  | packageFile |
  packageFile := ('*.star' match: fileName)
     ifFalse: [
@@ -92,7 +92,11 @@ Kernel.PackageDirectories subclass: Pack
     baseDirectories: [ fileName, '#uzip' ] ].
 
  packageFile refresh.
- self add: packageFile.
+ ^packageFile
+    ]
+
+    addFile: fileName [
+ self add: (self parse: fileName).
     ]
 
     baseDirsFor: fileName [
@@ -478,6 +482,161 @@ PkgList subclass: PkgPackageList [
     runOnPackage: aPackage [ aPackage name displayNl ]
 ]
 
+Command subclass: PkgPrepare [
+    | srcFile |
+    validateDestDir: destdir installDir: installDir [
+ destdir = ''
+    ifFalse: [ self error: '--destdir not needed with --prepare' ].
+ installDir isNil
+    ifFalse: [ self error: '--target-directory not needed with --prepare' ]
+    ]
+
+    addAllFiles: aCollection [
+ | f |
+ aCollection isEmpty ifTrue: [
+    (File exists: self srcdir, '/package.xml')
+ ifTrue: [ srcFile := 'package.xml' ].
+    (File exists: self srcdir, '/package.xml.in')
+ ifTrue: [ srcFile := 'package.xml.in' ].
+    ^super addAllFiles: { srcFile } ].
+
+ srcFile isNil ifTrue: [
+    f := Directory append: aCollection first to: self srcdir.
+            (File exists: f)
+        ifTrue: [ srcFile := (Directory name: self srcdir) pathTo: f ].
+
+    f := Directory append: aCollection first, '.in' to: self srcdir.
+            (File exists: f)
+        ifTrue: [ srcFile := (Directory name: self srcdir) pathTo: f ]
+ ].
+
+ super addAllFiles: aCollection.
+    ]
+
+    run [
+        | base configureAC makefileAM gstIN |
+ base := Directory name: self srcdir.
+ configureAC := base at: 'configure.ac'.
+ makefileAM := base at: 'Makefile.am'.
+ gstIN := base at: 'gst.in'.
+
+ configureAC exists ifFalse: [
+    configureAC withWriteStreamDo: [ :ws | self writeConfigure: ws ] ].
+ gstIN exists ifFalse: [
+    gstIN withWriteStreamDo: [ :ws | self writeGstIn: ws ] ].
+ makefileAM exists ifFalse: [
+    makefileAM withWriteStreamDo: [ :ws | self writeMakefile: ws ] ]
+    ]
+
+    writeGstIn: ws [
+ ws nextPutAll:
+'#! /bin/sh
+abs_top_builddir=@abs_top_builddir@
+: ${LIBTOOL=$abs_top_builddir/libtool}
+
+exec $LIBTOOL --mode=execute @PACKAGE_DLOPEN_FLAGS@ @GST@ ${1+"$@"}
+'
+    ]
+
+    writeConfigure: ws [
+ | numPackages pkgName tarName |
+ numPackages := 0.
+ self packages do: [ :each |
+    pkgName := each name.
+    numPackages := numPackages + 1 ].
+
+ numPackages = 1 ifFalse: [ pkgName := 'XYZ' ].
+
+        tarName := 'gst-',
+    (pkgName asLowercase copyReplacingAllRegex: '[-_ ]+' with: '-').
+
+ ws nextPutAll: ('AC_PREREQ(2.59)
+AC_INIT([GNU Smalltalk package %1], [0.0], , %2)
+AC_CONFIG_SRCDIR([%3])
+
+AM_INIT_AUTOMAKE
+
+AM_PATH_GST([2.95b], , [AC_MSG_ERROR([GNU Smalltalk not found])])
+' % { pkgName. tarName. srcFile }).
+
+ packages filesDo: [ :each |
+    self writeConfigureEntry: each to: ws ].
+
+ ws nextPutAll: '
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([gst], [chmod +x gst])
+AC_OUTPUT
+'
+    ]
+
+    writeConfigureEntry: each to: ws [
+ | pkgName buildPath srcPath pkgSrcDir relPkgSrcDir generated |
+ buildPath := (Directory name: Directory working) pathTo: each.
+ srcPath := (Directory name: self srcdir) pathTo: each.
+
+ pkgSrcDir := srcPath size < buildPath size
+    ifTrue: [ File pathFor: srcPath ifNone: [ self srcdir ] ]
+    ifFalse: [ Directory append: (File pathFor: buildPath) to: self srcdir ].
+
+ relPkgSrcDir := (Directory name: self srcdir) pathTo: pkgSrcDir.
+
+ ('*.in' match: each)
+    ifTrue: [
+ srcPath := srcPath allButLast: 3.
+ buildPath := buildPath allButLast: 3.
+ generated := true ]
+    ifFalse: [
+ generated := (File name: srcPath, '.in') exists ].
+
+ (File name: each) withReadStreamDo: [ :rs |
+    | pkg |
+    [ pkg := Package parse: rs ]
+        on: Kernel.PackageNotAvailable
+        do: [ :ex | ex resume ].
+    pkgName := pkg name ].
+
+ ws nextPutAll: ('GST_PACKAGE_ENABLE([%1], [%2]' % {
+    pkgName. relPkgSrcDir }).
+
+ generated ifTrue: [
+    ws nextPutAll: (', , , [%1]' % {
+ (Directory name: relPkgSrcDir) pathTo: srcPath }) ].
+
+ ws nextPutAll: ')'; nl.
+    ]
+
+    writeMakefile: ws [
+ ws nextPutAll:
+'AUTOMAKE_OPTIONS = foreign
+AM_CPPFLAGS = $(GST_CFLAGS)
+
+## Example:
+##
+## gst_module_ldflags = -rpath $(gstlibdir) -module \
+##        -no-undefined -export-symbols-regex gst_initModule
+##
+## noinst_HEADERS = md5.h sha1.h
+## gstlib_LTLIBRARIES = digest.la
+## digest_la_SOURCES = digest.c md5.c sha1.c
+## digest_la_LDFLAGS = $(gst_module_ldflags)
+
+
+### -------------------------------------- ###
+### Rules completed by GST_PACKAGE_ENABLE. ###
+### -------------------------------------- ###
+
+DISTCLEANFILES = pkgrules.tmp
+all-local:
+clean-local::
+install-data-hook::
+dist-hook::
+uninstall-local::
+
+@PACKAGE_RULES@
+'
+    ]
+]
+
 | srcdir installDir mode listFiles destdir packageFiles helpString options |
 
 mode := nil.
@@ -536,7 +695,7 @@ The default target directory is ', Direc
  --no-install is also present for backwards compatibility."
         arguments: '-h|--help --no-load --test --load --no-install --uninstall
             --dist -t|--target-directory: --list-files: --list-packages
-            --srcdir: --distdir|--destdir: -n|--dry-run --all-files
+            --prepare --srcdir: --distdir|--destdir: -n|--dry-run --all-files
     --vpath --copy -I|--image-file: --kernel-directory: --version'
 
         do: [ :opt :arg |
@@ -560,6 +719,9 @@ The default target directory is ', Direc
             opt = 'no-install' ifTrue: [
  mode isNil ifFalse: [ self error: 'multiple modes specified' ].
  mode := PkgList ].
+            opt = 'prepare' ifTrue: [
+ mode isNil ifFalse: [ self error: 'multiple modes specified' ].
+ mode := PkgPrepare ].
             opt = 'list-files' ifTrue: [
  mode isNil ifFalse: [ self error: 'multiple modes specified' ].
  listFiles add: arg.




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk