diff --git a/Makefile.am b/Makefile.am index 0cadc50bfe..a838bc1c13 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \.*~` diff --git a/scripts/fsxs.in b/scripts/fsxs.in index 805c48a16b..89783afbe1 100755 --- a/scripts/fsxs.in +++ b/scripts/fsxs.in @@ -52,14 +52,16 @@ sub do_exec { } sub fsxs_usage { - print "FreeSwitch fsxs\n(C) 2006 Stefan Knoblich \n"; + print "FreeSwitch fsxs\n(C) 2006-2008 Stefan Knoblich \n"; print "\n"; print "Usage:\n"; print "\t$0 compile [options] \n"; print "\t$0 link [options] \n"; print "\t$0 build [options] \n"; - print "\t$0 install [options] \n"; - print "\t$0 show \n\n"; + print "\t$0 install [options] \n\n"; + print "\t$0 show ...[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 ); }