The fsxs tool (sort of apxs for FreeSWITCH) is back from the dead.

Changes include an extended usage message and support for e.g. "fsxs --cflags"
style calls to get one or more defined variables on one line (instead of the
"show" command; easier for scripting).


git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7247 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Stefan Knoblich 2008-01-16 14:27:03 +00:00
parent cc3a95c1da
commit 92b2011b37
2 changed files with 71 additions and 13 deletions

View File

@ -157,7 +157,7 @@ libfreeswitch_la_SOURCES += src/switch_odbc.c
libfreeswitch_la_LDFLAGS += -lodbc
endif
bin_SCRIPTS = scripts/gentls_cert
bin_SCRIPTS = scripts/gentls_cert scripts/fsxs
libs/libedit/src/.libs/libedit.a:
@ -305,6 +305,27 @@ modwipe:
dox:
cd docs && doxygen $(PWD)/docs/Doxygen.conf
scripts/fsxs: scripts/fsxs.in
@echo creating fsxs
@sed -e "s,@MODULES_DIR\@,$(PREFIX)/mod," \
-e "s,@LIB_DIR\@,$(PREFIX)/lib," \
-e "s,@BIN_DIR\@,$(PREFIX)/bin," \
-e "s,@INC_DIR\@,$(PREFIX)/include," \
-e "s,@CFG_DIR\@,$(PREFIX)/conf," \
-e "s,@DB_DIR\@,$(PREFIX)/db," \
-e "s,@PREFIX\@,$(PREFIX)," \
-e "s,@CC\@,$(CC)," \
-e "s,@LD\@,$(CC)," \
-e "s,@INSTALL\@,$(INSTALL)," \
-e "s,@MKINSTALLDIRS\@,$(mkdir_p)," \
\
-e "s|@CFLAGS\@|$(CFLAGS) `$(switch_srcdir)/libs/apr/apr-1-config --cflags --cppflags`|" \
-e "s|@INCLUDES\@|-I$(PREFIX)/include|" \
-e "s|@SOLINK\@|$(SOLINK)|" \
-e "s|@LDFLAGS\@|-L$(PREFIX)/lib|" \
-e "s|@LIBS\@|`$(switch_srcdir)/libs/apr/apr-1-config --libs` `$(switch_srcdir)/libs/apr-util/apu-1-config --libs`|" \
scripts/fsxs.in > scripts/fsxs
eclean: clean
rm -f `find . -type f -name \*~`
rm -f `find . -type f -name \.*~`

View File

@ -52,14 +52,16 @@ sub do_exec {
}
sub fsxs_usage {
print "FreeSwitch fsxs\n(C) 2006 Stefan Knoblich <stkn\@netdomination.org>\n";
print "FreeSwitch fsxs\n(C) 2006-2008 Stefan Knoblich <stkn\@netdomination.org>\n";
print "\n";
print "Usage:\n";
print "\t$0 compile [options] <file1 ...>\n";
print "\t$0 link [options] <target> <file1 ...>\n";
print "\t$0 build [options] <target> <file1 ...>\n";
print "\t$0 install [options] <file1 ...>\n";
print "\t$0 show <var1 ...>\n\n";
print "\t$0 install [options] <file1 ...>\n\n";
print "\t$0 show <var1>...[varN]\n";
print "\t$0 <--var1>...<--varN>\n\n";
print "Command description:\n";
print "\tcompile: Compile source file(s) into object file(s)\n";
print "\tlink: Create module from object file(s)\n";
@ -80,6 +82,11 @@ sub fsxs_usage {
print "\t--destdir Installation prefix [install]\n";
print "\n";
print "Variable names for \"fsxs show\" / \"fsxs --var\":\n";
print "\tcflags ldflags libs solink includes cc ld mkdir install\n";
print "\tprefix lib_dir modules_dir db_dir inc_dir cfg_dir bin_dir\n";
print "\n";
print "Examples:\n";
print "\t$0 compile --add-cflags=\"-DFOO=1 -DBAR\" mod_test.c mod_test2.c\n\n";
print "\t$0 link --add-ldflags=\"-ltest\" mod_test.so mod_test.o mod_test2.o\n\n";
@ -168,23 +175,50 @@ sub fsxs_show {
}
}
sub fsxs_showq {
my @varlist = @_;
if( $#varlist >= 0 ) {
foreach( @varlist ) {
if( defined $vars{$_} ) {
print "$vars{$_} ";
}
}
}
}
#
# main part
#
if( $#ARGV < 0 ) {
fsxs_usage;
}
chomp( $command = shift @ARGV );
if( $command =~ /^install|build|link|compile|show$/ ) {
if( $command =~ /^show|compile|install$/ ) {
$needs_target = 0;
}
if( @ARGV[0] =~ /^\--.+$/ ) {
# 'show' shortcut for using fsxs in scripts
$needs_target = 0;
$command = "showq";
}
else {
print STDERR "Unknown command: $command\n";
fsxs_usage;
chomp( $command = shift @ARGV );
if( $command =~ /^install|build|link|compile|show$/ ) {
# add -lfreeswitch to the front of the library list
# we don't want it to be in the show / showq output
# but we still want to be able to override it with --set-libs
if( $command ne "show" ) {
$vars{LIBS} = "-lfreeswitch $vars{LIBS}";
}
if( $command =~ /^show|compile|install$/ ) {
$needs_target = 0;
}
}
else {
print STDERR "Unknown command: $command\n";
fsxs_usage;
}
}
# parse environment variables
@ -196,7 +230,7 @@ if( defined $ENV{DEBUG} && $ENV{DEBUG} ) {
foreach(@ARGV) {
chomp( $_ );
if( $command ne 'show' )
if( $command ne "show" && $command ne "showq" )
{
if( /^\--add-cflags=(.*)$/ ) {
$vars{CFLAGS} = "$vars{CFLAGS} $1";
@ -272,6 +306,9 @@ elsif( $command eq 'build' ) {
elsif( $command eq 'show' ) {
fsxs_show( @files );
}
elsif( $command eq 'showq' ) {
fsxs_showq( @files );
}
elsif( $command eq 'install' ) {
fsxs_install( @files );
}