#!/bin/sh # Copyright (C) 2001 AbiSource # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. abi_version=0.9.6 # abi_plugins is the list of subdirectories that are plugins # The definition of a plugin is a directory containing a file called "plugin.cfg". # abi_plugins= # abi_subdirs is a list of all directories in the current directory that are plugins or # which have plugins in subdirectories, i.e., those directories into which make should # recurse... # abi_subdirs= # abi_recurse is a subset of abi_subdirs which excludes plugins # abi_recurse= # abi_makefiles is the list of makefiles that configure must create # abi_makefiles= # abi_configs is the list of plugins that autoconf should scan # abi_configs= # abi_manual is the list of plugins that configure must run (i.e., w/o autoconf) # abi_manual= if test "x$SHELL" = "x"; then SHELL=/bin/sh export SHELL fi abi_mode=abi_build # Parse our command line options once, thoroughly. while test "$#" -gt 0 do arg="$1" shift case $arg in --query) abi_mode=abi_query ;; --help|-h) echo "Usage:" echo " --query list plugin subdirs" echo " -h, --help print this help and exit" exit 1 ;; *) echo 'Option `'$arg"' not recognized. Try --help for more information." exit 1 ;; esac done if test "x$abi_topdir" = "x"; then abi_topdir=`pwd` export abi_topdir if test $abi_mode = abi_build; then abi_mode=abi_all echo "Searching for AbiWord plugins. Please wait..." fi fi if test "x$abi_dir" = "x"; then abi_dir=. fi # Find plugins # for i in *; do if test -d $i; then if test -r $i/plugin.cfg; then # Found a plugin! abi_plugins="$abi_plugins $i" abi_subdirs="$abi_subdirs $i" else abi_subquery=`(cd $i > /dev/null && $SHELL $abi_topdir/autogen.sh --query)` if test "x$abi_subquery" != "x"; then for j in $abi_subquery; do abi_plugins="$abi_plugins $i/$j" done abi_subdirs="$abi_subdirs $i" abi_recurse="$abi_recurse $i" fi fi fi done if test $abi_mode = abi_query; then for i in $abi_plugins; do echo $i done # The rest is build stuff, so quit here. # if test $abi_mode != abi_all; then exit 0 fi else if test $abi_mode = abi_all; then if test "x$abi_subdirs" = "x"; then echo "Sorry. No AbiWord plugins found." exit 0 fi if test -f "ac-helpers/abi-plugin-init.m4"; then echo "Creating build system for AbiWord plugins" else echo "This script creates a build system for AbiWord plugins. It deletes and creates a number" echo "of files, so it must be run from the top directory of the plugin source tree." exit 1 fi else if test "x$abi_subdirs" = "x"; then echo "Glitch! Shouldn't be building when there are no subdirectories!" exit 1 fi fi # Create GNUmakefile.am - only a SUBDIRS entry is required. # if test $abi_dir = .; then abi_makefiles="GNUmakefile" else abi_makefiles="$abi_dir/GNUmakefile" fi rm -f GNUmakefile.am echo "SUBDIRS = $abi_subdirs" > GNUmakefile.am # and recurse into subdirectories... # _abi_dir=$abi_dir for i in $abi_recurse; do if test $_abi_dir = .; then abi_dir=$i else abi_dir=$_abi_dir/$i fi export abi_dir abi_subbuild=`(cd $i > /dev/null && $SHELL $abi_topdir/autogen.sh)` for j in $abi_subbuild; do abi_makefiles="$abi_makefiles $j" done done abi_dir=$_abi_dir # Standard build just creates GNUmakefile.am, so quit here. # if test $abi_mode = abi_build; then for i in $abi_makefiles; do echo $i done exit 0 fi fi # Determine which plugins wish to be configured # for i in $abi_plugins; do echo " $i" abi_plugin_autoconf=no abi_plugin_configure=no . $i/plugin.cfg if test $abi_plugin_autoconf = yes; then abi_plugin_configure=yes fi if test $abi_plugin_configure = yes; then if test $abi_plugin_autoconf = yes; then abi_configs="$abi_configs $i" else abi_manual="$abi_manual $i" fi fi done # Create configure.ac # rm -f configure.ac cat > configure.ac << EOF AC_INIT(abiword-plugins, $abi_version, [http://bugzilla.abisource.com/]) AC_CONFIG_SRCDIR([ac-helpers/abi-plugin-init.m4]) AM_INIT_AUTOMAKE(abiword, $abi_version) AC_DISABLE_STATIC AC_PROG_LIBTOOL dnl First of all AbiWord plugin macros: dnl ABI_PLUGIN_INIT($abi_version) dnl Configure plugin sources dnl AC_CONFIG_SUBDIRS($abi_configs) AC_CONFIG_FILES($abi_makefiles) AC_OUTPUT if test "x$abi_manual" != "x"; then for i in $abi_manual; do echo "Running configure in \$i..." (cd \$i > /dev/null && $CONFIG_SHELL configure $ac_configure_args) done fi EOF # Create configure.in # rm -f configure.in cat > configure.in << EOF AC_INIT(ac-helpers/abi-plugin-init.m4) AM_INIT_AUTOMAKE(abiword, $abi_version) AC_DISABLE_STATIC AC_PROG_LIBTOOL dnl First of all AbiWord plugin macros: dnl ABI_PLUGIN_INIT($abi_version) dnl Configure plugin sources dnl AC_CONFIG_SUBDIRS($abi_configs) AC_OUTPUT($abi_makefiles) if test "x$abi_manual" != "x"; then for i in $abi_manual; do echo "Running configure in \$i..." (cd \$i > /dev/null && $CONFIG_SHELL configure $ac_configure_args) done fi EOF # And, finally, call in the big boys... # rm -f autogen.out rm -f autogen.err echo "Running libtoolize -f -c" ($SHELL libtoolize -f -c >> $abi_topdir/autogen.out 2>> $abi_topdir/autogen.err) || { echo "libtoolize failed! Unable to continue." exit 1 } echo "Running aclocal -I ac-helpers" ($SHELL aclocal -I ac-helpers >> $abi_topdir/autogen.out 2>> $abi_topdir/autogen.err) || { echo "aclocal failed! Unable to continue." exit 1 } echo "Running automake -a --foreign" ($SHELL automake -a --foreign >> $abi_topdir/autogen.out 2>> $abi_topdir/autogen.err) || { echo "automake failed! Unable to continue." exit 1 } echo "Running autoconf" ($SHELL autoconf >> $abi_topdir/autogen.out 2>> $abi_topdir/autogen.err) || { echo "autoconf failed! Unable to continue." exit 1 } # If plugin requests, run a desired script # for i in $abi_plugins; do abi_plugin_script=no . $i/plugin.cfg if test "x$abi_plugin_script" != "xno"; then echo 'Running `'$abi_plugin_script"' in $i" >> $abi_topdir/autogen.err echo 'Running `'$abi_plugin_script"' in $i" (cd $i && $SHELL $abi_plugin_script 2>> $abi_topdir/autogen.err) fi done