#!/bin/bash name=`basename $0` printusage(){ echo $2; echo "Usage: $name [file.pl] [output] where [file.pl] is your perl script and [output] the binary you want to create " exit $1; } [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]] && printusage 0; test -z $1 && printusage 1 "-- Missing perl file --"; test -z $2 && printusage 1 "-- Missing output filename -- "; test -f $1 || printusage 1 "-- Perl file not found or isn't a regular file -- "; c=`basename $1`; c="/tmp/"`echo $c | perl -pe 's/\.pl/.c/'`; echo -n "Loading DynaLoader... " ar xv /usr/lib/perl5/5.8.7/i386-linux/auto/DynaLoader/DynaLoader.a > /dev/null 2>&1 echo "done" echo -n "Writing C sources... " perl -MO=C,-o$c $1 > /dev/null 2>&1 echo "done" echo -n "Compiling... " perl /usr/lib/perl5/5.8.7/B/cc_harness `perl -MExtUtils::Embed -e ldopts` -L./ DynaLoader.o -o $2 $c > /dev/null 2>&1 echo "done" rm -f $c > /dev/null 2>&1 echo "$2 generated, you can now use it" exit 0;