#!/bin/bash
## src2pkg script for: 	abiword
## Auto-generated by src2pkg-1.9.7
## src2pkg Copyright 2005-2009 Gilbert Ashley <amigo@ibilio.org>

add_source_to_package_1 () {
if [[ $1 = "" ]] ; then
	echo $RED"Failed! "$NORMAL"You must supply an argument (source name) to add_source_to_package_1"
	FAILED="MANDATORY ARGUMENT NOT GIVEN"
fi
# save the main source and package names
# the conditional syntax means they only get set once
! [[ $NAME_1 ]] && NAME_1=$NAME
! [[ $VERSION_1 ]] && VERSION_1=$VERSION
! [[ $SRC_DIR_1 ]] && SRC_DIR_1=$SRC_DIR
! [[ $PKG_DIR_1 ]] && PKG_DIR_1=$PKG_DIR
! [[ $CONFIG_DIR_1 ]] && CONFIG_DIR_1=$CONFIG_DIR
! [[ $SRC_DIR_NAME_1 ]] && SRC_DIR_NAME_1=$SRC_DIR_NAME
# blank the derived variable values
reset_vars
# reset the derived variables using the current SOURCE_URL
SOURCE_URL=$1
pre_process
# override PKG_DIR so everything goes into one package
PKG_DIR=$PKG_DIR_1
# do these normal functions here
find_source
make_dirs
unpack_source
fix_source_perms
}

finish_package_1() {
reset_vars

NAME=$NAME_1
VERSION=$VERSION_1

pre_process
# reset the package dir to the main PKG_DIR so that the
#  contents of this package get combined with the first one
SRC_DIR=$SRC_DIR_1
SRC_DIR_NAME=$SRC_DIR_NAME_1
PKG_DIR=$PKG_DIR_1
CONFIG_DIR=$CONFIG_DIR_1
}

reset_vars () {
[[ $DEBUG ]] && echo "Resetting variables...!!!"
BIN_DIR=''
SBIN_DIR=''
LIBEXEC_DIR=''
SYSCONF_DIR=''
SHAREDSTATE_DIR=''
LOCALSTATE_DIR=''
LIB_DIR=''
INCLUDE_DIR=''
DATA_DIR=''
INFO_DIR=''
LOCALE_DIR=''
MAN_DIR=''
DOC_DIR=''
GAMESBIN_DIR=''
GAMESDATA_DIR=''
PIXMAPS_DIR=''
ICONS_DIR=''
# these are the obvious ones that need to be reset
SOURCE_URL=''
SOURCE_NAME=''
SOURCE=''
NAME=''
VERSION=''
ALT_NAME=''
ALT_VERSION=''
ORIG_NAME=''
ORIG_VERSION=''
SRC_DIR=''
SRC_DIR_NAME=''
PKG_DIR=''
PKG_DIR_NAME=''
OBJ_DIR=''
OBJ_DIR_NAME=''
CONFIG_DIR=''
CONFIG_SUBDIR=''
CONFIG_COMMAND=''
MAKE_COMMAND=''
VERIFY=''
}
# All the above functions could be put into the main FUNCTIONS file or elsewhere


# Instead of recycling SOURCE_URL, use EXTRA_SOURCES so that everything gets downloaded at once.
#SOURCE_URL='http://www.abisource.com/downloads/abiword/2.6.6/source/abiword-2.6.6.tar.gz'
#EXTRA_SOURCES='http://www.abisource.com/downloads/abiword/2.6.6/source/abiword-plugins-2.6.6.tar.gz
#http://www.abisource.com/downloads/abiword/2.6.6/source/abiword-extras-2.6.6.tar.gz
#http://www.abisource.com/downloads/abiword/2.6.6/source/abiword-docs-2.6.6.tar.gz
#'

# Since the sources all come from a common dir, you could also do the above this way:
BASE_URL='http://www.abisource.com/downloads/abiword/2.6.6/source'
SOURCE_URL='abiword-2.6.6.tar.gz'
EXTRA_SOURCES='abiword-plugins-2.6.6.tar.gz
abiword-extras-2.6.6.tar.gz
abiword-docs-2.6.6.tar.gz'

SOURCE_2="abiword-plugins-2.6.6.tar.gz"
SOURCE_3="abiword-extras-2.6.6.tar.gz"
SOURCE_4="abiword-docs-2.6.6.tar.gz"

####################################### SOURCE 1
# SOURCE_NAME='abiword-2.6.6.tar.gz'
#NAME='abiword'
#VERSION='2.6.6'
#SOURCE_URL from above is all we need

# ARCH='i486'
BUILD='1'
PRE_FIX='usr'
# Any extra options go here
EXTRA_CONFIGS='--disable-printing --disable-spellcheck'
# STD_FLAGS='-O2 -march=i486 -mtune=i686'

# Get the functions and configs
. /usr/libexec/src2pkg/FUNCTIONS ;

pre_process
find_source
make_dirs
unpack_source
fix_source_perms
configure_source
compile_source
fake_install
# leave the rest of the functions till last
####################################### SOURCE 1

####################################### SOURCE 2
## reset the vars and build a second tarball

EXTRA_CONFIGS="--with-abiword=$SRC_DIR_1"

add_source_to_package_1 $SOURCE_2
# do the standard 'build' functions or write custom code
configure_source
compile_source
# fake_install
cp $SRC_DIR/$NAME $PKG_DIR/usr/bin
## cleanup the added sources
CLEANUP=SRC
post_process
####################################### SOURCE 2

####################################### SOURCE 3
## reset the vars and build a third tarball

EXTRA_CONFIGS=''

add_source_to_package_1 $SOURCE_3
# do the standard 'build' functions or write custom code
configure_source
compile_source
# fake_install
cp $SRC_DIR/$NAME $PKG_DIR/usr/bin
## cleanup the added sources
CLEANUP=SRC
post_process
####################################### SOURCE 3

####################################### SOURCE 4
## reset the vars and build a fourth tarball
add_source_to_package_1 $SOURCE_4
# do the standard 'build' functions or write custom code
configure_source
compile_source
# fake_install
cp $SRC_DIR/$NAME $PKG_DIR/usr/bin
## cleanup the added sources
CLEANUP=SRC
post_process
####################################### SOURCE 4

####################################### SOURCE 1
## reset the vars and go back to the original sources
CLEANUP=ALL
finish_package_1

fix_pkg_perms
strip_bins
create_docs
compress_man_pages
make_description
make_doinst
make_package
post_process

# src2pkg - Copyright 2005-2009  Gilbert Ashley <amigo@ibiblio.org>
## See the documentation for more help and examples. Below are some of
# the most common Extras and Options for easy cut-and-paste use.
# EXTRA_CONFIGS='' PRE_FIX='' DOCLIST=''
# MAKE_COMMAND='' INSTALL_LINE='' 
# SHELL_INSTALL='YES' CORRECT_PERMS='NO'
# When editing src2pkg scripts to add custom code, use these variables
# to refer to the current directory, the sources or the package tree:
# $CWD (current directory), $SRC_DIR (sources), $PKG_DIR (package tree)
# Other commonly-used directories include: $DOC_DIR (document directory)
# $MAN_DIR (man-page directory) $DATA_DIR (shared-data directory)
