grim/guifications3
Clone
Summary
Browse
Changes
Graph
closing this since most of it will happen on default since libgds now exists ;)
the_plugin_problem
2010-12-20, Gary Kramlich
1f195d42369a
file is
Executable
closing this since most of it will happen on default since libgds now exists ;)
#!/bin/sh
# Guifications - The end-all, be-all notification framework
# Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
###############################################################################
# Globals
###############################################################################
SEQ_COMMAND
=
"seq"
###############################################################################
# A list library similar to the lists in TCL
# Copyright (C) 2009 Ethan Blanton
# Heavily modified by Gary Kramlich
###############################################################################
linsert
()
{
__list
=
${
1
}
__index
=
${
2
}
shift
2
__item
=
${
@
}
# dirty hack to make sure we handle empty item. Basically we just turn
# them into a space
if
[
-z
"
${
__item
}
"
]
;
then
__item
=
" "
fi
eval
"
${
__list
}
=\`catlist
${
__list
}
| sed -e '
${
__index
}
i\\\\
${
__item
}
'\`"
}
lappend
()
{
__list
=
${
1
}
shift
__item
=
${
@
}
# dirty hack to make sure we handle empty item. Basically we just turn
# them into a space
if
[
-z
"
${
__item
}
"
]
;
then
__item
=
" "
fi
if
lempty
${
__list
}
;
then
eval
"
${
__list
}
='
${
__item
}
'"
else
__index
=
`
llength
${
__list
}
`
eval
"
${
__list
}
=\"\`catlist
${
__list
}
\`
${
__item
}
\""
fi
}
lreplace
()
{
__list
=
${
1
}
__index
=
${
2
}
shift
2
__item
=
${
@
}
# dirty hack to make sure we handle empty item. Basically we just turn
# them into a space
if
[
-z
"
${
__item
}
"
]
;
then
__item
=
" "
fi
eval
"
${
__list
}
=\`catlist
${
__list
}
| sed -e '
${
__index
}
,
${
__index
}
c\\\\
${
__item
}
'\`"
}
lindex
()
{
eval
__list
=
\$
$1
cat
<<EOF | sed -e "$2!d"
$__list
EOF
}
lempty
()
{
eval
test
-z
\"\$
$1
\"
}
llength
()
{
eval
__list
=
\$
$1
cat
<<EOF | wc -l
$__list
EOF
}
lrange
()
{
catlist
$1
|
sed
-e
"
$2
,
$3
!d"
}
catlist
()
{
eval
__list
=
\$
$1
cat
<<EOF
$__list
EOF
}
debuglist
()
{
i
=
1
catlist
$1
|
while
read
ITEM
;
do
echo
$1
[
$i
]
${
ITEM
}
i
=
$((
${
i
}
+
1
))
done
}
lsearch
()
{
catlist
$1
|
sed
-n
"/
$2
/{
=
q
}"
}
###############################################################################
# Some helper functions
###############################################################################
add_command
()
{
__cmd
=
${
1
}
shift
__flags
=
${
@
}
lappend
COMMANDS
${
__cmd
}
lappend
FLAGS
${
__flags
}
}
insert_command
()
{
__insert
=
${
1
}
__cmd
=
${
2
}
shift
2
__flags
=
${
@
}
__index
=
`
lsearch
COMMANDS
${
__insert
}
`
linsert
COMMANDS
${
__index
}
${
__cmd
}
linsert
FLAGS
${
__index
}
${
__flags
}
}
update_command
()
{
__old_command
=
$1
__new_command
=
$2
shift
2
__flags
=
${
@
}
__index
=
`
lsearch
COMMANDS
${
__old_command
}
`
test
${
__index
}
-ne
0
||
return
lreplace
COMMANDS
${
__index
}
${
__new_command
}
test
-z
"
${
__flags
}
"
||
lreplace
FLAGS
${
__index
}
${
__flags
}
}
check_config_file
()
{
test
"
${
ARGS_FILE
}
"
||
ARGS_FILE
=
"autogen.args"
printf
"checking for argument file %s: "
${
ARGS_FILE
}
if
test
-f
${
ARGS_FILE
}
;
then
echo
"found."
printf
"sourcing %s ... "
${
ARGS_FILE
}
# dash will only source a file from a source file if it's in the path
# so we add . to the PATH for the source and then revert the path back
# to what it was.
__old_path
=
${
PATH
}
PATH
=
".:
${
PATH
}
"
.
${
ARGS_FILE
}
PATH
=
"
${
__old_path
}
"
echo
"done."
else
echo
"not found."
fi
}
check_command
()
{
__cmd
=
$1
printf
"checking for
${
__cmd
}
... "
__bin
=
`
which
${
__cmd
}
`
if
[
x
"
${
__bin
}
"
=
x
""
]
;
then
echo
"not found."
echo
"
${
__cmd
}
is required to build
${
PACKAGE
}
!"
exit
1
;
fi
echo
"
${
__bin
}
"
}
check_commands
()
{
catlist
COMMANDS
|
while
read
__cmd
;
do
check_command
${
__cmd
}
done
}
run_command
()
{
__cmd
=
$1
shift
# we need to make sure to use a six-character template because some versions
# of mktemp blow up on anything shorter or longer.
__output
=
`
mktemp
autogen-XXXXXX
`
# we have to stash ${@} into a variable, otherwise printf has "issues" if
# ${@} was expanded from a variable. Fortunately, this lets us clean up
# the output a bit too.
__args
=
"
${
@
}
"
if
[
x
"
${
__args
}
"
!
=
x
""
]
;
then
ARGS
=
"
${
__args
}
"
fi
__display
=
${
__cmd
}
if
[
-n
"
${
__args
}
"
]
;
then
__display
=
"
${
__display
}
${
__args
}
"
fi
printf
"running '
${
__display
}
' ... "
${
__cmd
}
${
__args
}
>
${
__output
}
2
>
&
1
if
[
$?
!
=
0
]
;
then
echo
"failed."
cat
${
__output
}
rm
-f
${
__output
}
exit
1
else
echo
"done."
cat
${
__output
}
rm
-f
${
__output
}
fi
}
run_commands
()
{
__len
=
`
llength
COMMANDS
`
for
i
in
`
${
SEQ_COMMAND
}
1
${
__len
}
`
;
do
__cmd
=
`
lindex
COMMANDS
${
i
}
`
__flags
=
`
lindex
FLAGS
${
i
}
`
run_command
${
__cmd
}
${
__flags
}
done
}
run_configure
()
{
echo
"running configure
${
@
}
..."
./configure
${
CONFIGURE_FLAGS
}
"
${
@
}
"
}
add_default_commands
()
{
add_command
libtoolize
-c
-f
--automake
add_command
intltoolize
-c
-f
--automake
add_command
aclocal
add_command
autoheader
add_command
automake
-a
-c
-f
--gnu
add_command
autoconf
-f
}
add_default_library_commands
()
{
add_default_commands
# gtkdocize needs be to run before aclocal, so we insert it before aclocal
insert_command
aclocal
gtkdocize
--copy
}
find_command
()
{
echo
`
lsearch
COMMANDS
${
1
}
`
}
cleanup
()
{
rm
-f
autogen-??????
echo
exit
2
}
###############################################################################
# Platform specific stuff
###############################################################################
platform_bsd
()
{
SEQ_COMMAND
=
"jot -"
}
platform_darwin
()
{
# run the bsd platform specific stuff too
platform_bsd
# change libtoolize to glibtoolize
update_command
libtoolize
glibtoolize
__flags
=
""
# look for fink and add it's aclocal dir to the aclocal flags
if
[
-d
/sw/share/aclocal
]
;
then
__flags
=
"
${
__flags
}
-I /sw/share/aclocal"
fi
# look for macports and add it's aclocal dir to the aclocal flags
if
[
-d
/opt/local/share/aclocal
]
;
then
__flags
=
"
${
__flags
}
-I /opt/local/share/aclocal"
fi
update_command
aclocal
aclocal
${
__flags
}
}
check_platform
()
{
__platform
=
$(
uname
-s
)
printf
"adjusting for platform '%s' ... "
${
__platform
}
case
${
__platform
}
in
*BSD*
)
platform_bsd
;;
Darwin*
)
platform_darwin
;;
esac
echo
"done."
}
###############################################################################
# API
###############################################################################
autogen
()
{
# add our cleanup trap
trap
cleanup
2
FIGLET
=
`
which
figlet
`
if
[
x
"
${
FIGLET
}
"
!
=
x
""
]
;
then
${
FIGLET
}
${
PACKAGE
}
echo
"build system is being generated"
else
echo
"autogenerating build system for '
${
PACKAGE
}
'"
fi
check_config_file
check_platform
check_commands
test
$?
!
=
0
&&
exit
-1
run_commands
test
$?
!
=
0
&&
exit
-1
# remove our cleanup trap
trap
-
2
run_configure
"
${
@
}
"
}