From 5ccac21dc303615e5c80c51927169c486eadd6bb Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 11 Jan 2010 14:36:29 +0000 Subject: [PATCH] wip move towards adding directory layout control to configure git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16238 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- Makefile.am | 9 ++-- build/config.layout | 66 +++++++++++++++++++++++++++++ build/modmake.rules.in | 37 ++++++++++------ build/modmake.rulesam | 2 +- configure.in | 95 +++++++++++++++++++++++++++++------------- src/switch_core.c | 2 +- 6 files changed, 161 insertions(+), 50 deletions(-) create mode 100644 build/config.layout diff --git a/Makefile.am b/Makefile.am index b190d93d79..7004a18085 100644 --- a/Makefile.am +++ b/Makefile.am @@ -317,11 +317,10 @@ samples: samples-conf samples-htdocs install-data-local: @echo Installing $(NAME) - @for x in mod db log log/xml_cdr bin scripts grammar recordings ; do \ - $(mkinstalldirs) $(DESTDIR)$(prefix)/$$x ; \ + @for x in @modulesdir@ @runtimedir@ @dbdir@ @logfiledir@ @logfiledir@/xml_cdr @bindir@ @scriptdir@ @recordingsdir@ ; do \ + $(mkinstalldirs) $(DESTDIR)$$x ; \ done - $(mkinstalldirs) $(DESTDIR)@recordingsdir@ - $(mkinstalldirs) $(DESTDIR)@modinstdir@ + $(mkinstalldirs) $(DESTDIR)$(prefix)/grammar test -d $(DESTDIR)@confdir@ || $(MAKE) samples-conf test -d $(DESTDIR)$(prefix)/htdocs || $(MAKE) samples-htdocs @@ -530,7 +529,7 @@ dox: scripts/fsxs: scripts/fsxs.in @echo creating fsxs - @sed -e "s,@MODULES_DIR\@,@modinstdir@," \ + @sed -e "s,@MODULES_DIR\@,@modulesdir@," \ -e "s,@LIB_DIR\@,@libdir@," \ -e "s,@BIN_DIR\@,@bindir@," \ -e "s,@INC_DIR\@,@includedir@," \ diff --git a/build/config.layout b/build/config.layout new file mode 100644 index 0000000000..deb0a951e7 --- /dev/null +++ b/build/config.layout @@ -0,0 +1,66 @@ +## +## config.layout -- Pre-defined Installation Path Layouts +## +## Hints: +## - layouts can be loaded with configure's --enable-layout=ID option +## - when no --enable-layout option is given, the default layout is `FreeSWITCH' +## - a trailing plus character (`+') on paths is replaced with a +## `/' suffix where is currently hardcoded to 'freeswitch'. +## (This may become a configurable parameter at some point.) +## + +# Default FreeSWITCH path layout. + + prefix: /usr/local/freeswitch + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/bin + libdir: ${exec_prefix}/lib + libexecdir: ${exec_prefix}/modules + modulesdir: ${exec_prefix}/modules + mandir: ${prefix}/man + sysconfdir: ${prefix}/conf + datadir: ${prefix} + includedir: ${prefix}/include + localstatedir: ${prefix} + runtimedir: ${localstatedir}/log + logfiledir: ${localstatedir}/log + + +# GNU standards conforming path layout. +# See FSF's GNU project `make-stds' document for details. + + prefix: /usr/local + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/sbin + libdir: ${exec_prefix}/lib + libexecdir: ${exec_prefix}/libexec + modulesdir: ${libdir}/freeswitch/modules + mandir: ${prefix}/man + sysconfdir: ${prefix}/etc/freeswitch + datadir: ${prefix}/share/freeswitch + includedir: ${prefix}/include/freeswitch + localstatedir: ${prefix}/var/freeswitch + runtimedir: ${localstatedir}/run + logfiledir: ${localstatedir}/log + + +# Linux FHS (File Hierarchy Standard) layout +# see + + prefix: /usr + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/sbin + libdir: ${exec_prefix}/lib/freeswitch + libexecdir: ${exec_prefix}/libexec + modulesdir: ${libdir}/modules + mandir: ${prefix}/man + sysconfdir: /etc/freeswitch + datadir: ${prefix}/share/freeswitch + includedir: ${prefix}/include/freeswitch + localstatedir: /var/lib/freeswitch + runtimedir: /var/run/freeswitch + logfiledir: /var/log/freeswitch + diff --git a/build/modmake.rules.in b/build/modmake.rules.in index e66080c4c8..c4b6dc82e0 100644 --- a/build/modmake.rules.in +++ b/build/modmake.rules.in @@ -7,6 +7,17 @@ build=@build@ host=@host@ target=$(host) +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +libexecdir=@libexecdir@ +includedir=@includedir@ +modulesdir=@modulesdir@ +runtimedir=@runtimedir@ +logfiledir=@logfiledir@ +sysconfdir=@sysconfdir@ +localstatedir=@localstatedir@ + CC=@CC@ CXX=@CXX@ AWK=@AWK@ @@ -31,8 +42,6 @@ OPENSSL_CFLAGS=@openssl_CFLAGS@ LIBS=$(switch_builddir)/libfreeswitch.la DEFS=@DEFS@ -PREFIX = @prefix@ -MODINSTDIR = @modinstdir@ DYLD_LIBRARY_PATH=@libdir@:$DYLD_LIBRARY_PATH LD_LIBRARY_PATH=@libdir@:$LD_LIBRARY_PATH @@ -46,18 +55,20 @@ CXXFLAGS=@CXXFLAGS@ LDFLAGS=@SWITCH_AM_LDFLAGS@ @LDFLAGS@ $(OUR_LDFLAGS) ALL_CFLAGS = $(LOCAL_CFLAGS) $(MOD_CFLAGS) @SWITCH_AM_CFLAGS@ @CFLAGS@ @SWITCH_ANSI_CFLAGS@ -D_GNU_SOURCE $(OUR_CFLAGS) -ALL_CXXFLAGS = $(LOCAL_CFLAGS) $(MOD_CFLAGS) @SWITCH_AM_CXXFLAGS@ @CXXFLAGS@ -D_GNU_SOURCE $(OUR_CFLAGS) +ALL_CXXFLAGS = $(LOCAL_CFLAGS) $(MOD_CFLAGS) @SWITCH_AM_CXXFLAGS@ @CXXFLAGS@ -D_GNU_SOURCE $(OUR_CFLAGS) -DEFAULT_ARGS:= --build=$(build) --host=$(host) --target=$(target) --prefix=$(PREFIX) --disable-shared --with-pic DEFAULT_VARS:= CFLAGS="$(CFLAGS)" CPPFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" CC="$(CC)" CXX="$(CXX)" +DEFAULT_ARGS:= --build=$(build) --host=$(host) --target=$(target) \ + --prefix="$(prefix)" --exec_prefix="$(exec_prefix)" --libdir="$(libdir)" \ + --disable-shared --with-pic -COMPILE = $(CC) $(ALL_CFLAGS) $(DEFS) +COMPILE = $(CC) $(ALL_CFLAGS) $(DEFS) LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(COMPILE) -LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(ALL_CFLAGS) $(LDFLAGS) -shared -module -avoid-version -rpath $(MODINSTDIR) -o $@ +LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(ALL_CFLAGS) $(LDFLAGS) -shared -module -avoid-version -rpath $(modulesdir) -o $@ CXXCOMPILE = $(CXX) $(ALL_CXXFLAGS) $(DEFS) LTCXXCOMPILE = $(LIBTOOL) --mode=compile --tag=CXX $(CXXCOMPILE) -CXXLINK = $(LIBTOOL) --mode=link --tag=CXX $(CXXLD) $(ALL_CXXFLAGS) $(LDFLAGS) -shared -module -avoid-version -rpath $(MODINSTDIR) -o $@ +CXXLINK = $(LIBTOOL) --mode=link --tag=CXX $(CXXLD) $(ALL_CXXFLAGS) $(LDFLAGS) -shared -module -avoid-version -rpath $(modulesdir) -o $@ CSOURCEFILE=$(MODNAME).c CXXSOURCEFILE=$(MODNAME).cpp @@ -128,22 +139,22 @@ $(MODNAME).$(LIBTOOL_LIB_EXTEN): $(LIBS) $(LOCAL_LIBADD) $(OUR_DEPS) $(LOCAL_OBJ @test -d .libs || mkdir .libs @error="";\ if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \ - $(LINK) $(SOLINK) $(MODNAME).lo $(LIBS) $(LOCAL_LDFLAGS) $(LOCAL_OBJS) $(OUR_OBJS) $(LOCAL_LIBADD) $(LOCAL_LDFLAGS_POST) $(LINK_OUTPUT_REDIR) ;\ + $(LINK) $(SOLINK) $(MODNAME).lo $(LIBS) $(LOCAL_LDFLAGS) $(LOCAL_OBJS) $(OUR_OBJS) $(LOCAL_LIBADD) $(LOCAL_LDFLAGS_POST) $(LINK_OUTPUT_REDIR) ;\ else \ - $(CXXLINK) $(SOLINK) $(MODNAME).lo $(LIBS) $(LOCAL_LDFLAGS) $(LOCAL_OBJS) $(OUR_OBJS) $(LOCAL_LIBADD) $(LOCAL_LDFLAGS_POST) $(LINK_OUTPUT_REDIR) ;\ + $(CXXLINK) $(SOLINK) $(MODNAME).lo $(LIBS) $(LOCAL_LDFLAGS) $(LOCAL_OBJS) $(OUR_OBJS) $(LOCAL_LIBADD) $(LOCAL_LDFLAGS_POST) $(LINK_OUTPUT_REDIR) ;\ fi; mod_clean: @rm -fr *.$(LIBTOOL_LIB_EXTEN) *.o *.lo *~ .libs $(LOCAL_OBJS) -mod_install: $(DESTDIR)$(MODINSTDIR)/$(MODNAME).$(LIBTOOL_LIB_EXTEN) +mod_install: $(DESTDIR)$(modulesdir)/$(MODNAME).$(LIBTOOL_LIB_EXTEN) -$(DESTDIR)$(MODINSTDIR)/$(MODNAME).$(LIBTOOL_LIB_EXTEN):$(MODNAME).$(LIBTOOL_LIB_EXTEN) +$(DESTDIR)$(modulesdir)/$(MODNAME).$(LIBTOOL_LIB_EXTEN):$(MODNAME).$(LIBTOOL_LIB_EXTEN) @echo installing $< - @$(LTINSTALL) $(MODNAME).$(LIBTOOL_LIB_EXTEN) $(DESTDIR)$(MODINSTDIR) >/dev/null + @$(LTINSTALL) $(MODNAME).$(LIBTOOL_LIB_EXTEN) $(DESTDIR)$(modulesdir) >/dev/null mod_uninstall: - @$(LTUNINSTALL) $(DESTDIR)$(MODINSTDIR)/$(MODNAME).$(LIBTOOL_LIB_EXTEN) + @$(LTUNINSTALL) $(DESTDIR)$(modulesdir)/$(MODNAME).$(LIBTOOL_LIB_EXTEN) # define these in your makefile if you wish local_all local_depend local_clean depend_install local_install local_distclean local_extraclean local_uninstall: diff --git a/build/modmake.rulesam b/build/modmake.rulesam index 348c27b45a..51e2f809c2 100644 --- a/build/modmake.rulesam +++ b/build/modmake.rulesam @@ -8,7 +8,7 @@ AM_MAKEFLAGS=`test -n "$(VERBOSE)" || echo -s` # Dirty trick to override the link output LIBS+=> $(MODNAME).log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat $(MODNAME).log;fi;if test "$$error" = "yes";then exit 1;fi -moddir=@modinstdir@ +moddir=@modulesdir@ all-modules: all depend-modules: depend diff --git a/configure.in b/configure.in index e282429878..b4e60ff356 100644 --- a/configure.in +++ b/configure.in @@ -34,17 +34,27 @@ AC_SUBST(switch_builddir) # Where to install the modules AC_ARG_WITH([modinstdir], - [AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: $prefix/mod)])], [modinstdir="$withval"], [modinstdir="${prefix}/mod"]) - -AC_SUBST(modinstdir) -AC_DEFINE_UNQUOTED([SWITCH_MOD_DIR],"${modinstdir}",[where to install the modules to]) + [AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: $prefix/mod)])], [modulesdir="$withval"], [modulesdir="${prefix}/mod"]) +AC_SUBST(modulesdir) +AC_DEFINE_UNQUOTED([SWITCH_MOD_DIR],"${modulesdir}",[where to install the modules to]) # Where to put pidfile AC_ARG_WITH([rundir], - [AS_HELP_STRING([--with-rundir=DIR], [Put pidfile into this location (default: $prefix/log)])], [rundir="$withval"], [rundir="${prefix}/log"]) + [AS_HELP_STRING([--with-rundir=DIR], [Put pidfile into this location (default: $prefix/run)])], [runtimedir="$withval"], [runtimedir="${prefix}/run"]) +AC_SUBST(runtimedir) +AC_DEFINE_UNQUOTED([SWITCH_RUN_DIR],"${runtimedir}",[where to put pidfile to]) -AC_SUBST(rundir) -AC_DEFINE_UNQUOTED([SWITCH_RUN_DIR],"${rundir}",[where to put pidfile to]) +logfiledir="${prefix}/log" +AC_SUBST(logfiledir) +AC_DEFINE_UNQUOTED([SWITCH_LOG_DIR],"${logfiledir}",[where to put log files]) + +dbdir="${prefix}/db" +AC_SUBST(dbdir) +AC_DEFINE_UNQUOTED([SWITCH_DB_DIR],"${dbdir}",[where to put db files]) + +scriptdir="${prefix}/scripts" +AC_SUBST(scriptdir) +AC_DEFINE_UNQUOTED([SWITCH_SCRIPT_DIR],"${scriptdir}",[where to put script files]) recordingsdir="${prefix}/recordings" AC_SUBST(recordingsdir) @@ -56,6 +66,8 @@ else confdir="$sysconfdir" fi +sysconfdir="$confdir" + AC_SUBST(confdir) AC_DEFINE_UNQUOTED([SWITCH_CONF_DIR],"${confdir}",[directory for configuration files]) @@ -887,33 +899,56 @@ AC_SUBST(OUR_DISABLED_INSTALL_MODS) AC_SUBST(OUR_DISABLED_UNINSTALL_MODS) AC_SUBST(AM_MAKEFLAGS) -ac_configure_args="$ac_configure_args \"CONFIGURE_CFLAGS=$CFLAGS\" \"CONFIGURE_CXXFLAGS=$CXXFLAGS\" \"CONFIGURE_LDFLAGS=$LDFLAGS\"" +ac_configure_args="$ac_configure_args \"CONFIGURE_CFLAGS=$CFLAGS\" \"CONFIGURE_CXXFLAGS=$CXXFLAGS\" \"CONFIGURE_LDFLAGS=$LDFLAGS\" \ + --prefix='$prefix' --exec_prefix='$exec_prefix' --libdir='$libdir' --libexecdir='$libexecdir' --bindir='$bindir' --sbindir='$sbindir' \ + --localstatedir='$localstatedir' --datadir='$datadir'" # Run configure in all the subdirs -AC_CONFIG_SUBDIRS(libs/srtp) -AC_CONFIG_SUBDIRS(libs/sqlite) +AC_CONFIG_SUBDIRS([libs/srtp]) +AC_CONFIG_SUBDIRS([libs/sqlite]) if test "$enable_core_libedit_support" = "yes" ; then - AC_CONFIG_SUBDIRS(libs/libedit) + AC_CONFIG_SUBDIRS([libs/libedit]) fi -AC_CONFIG_SUBDIRS(libs/pcre) -AC_CONFIG_SUBDIRS(libs/apr) -AC_CONFIG_SUBDIRS(libs/apr-util) -AC_CONFIG_SUBDIRS(libs/ilbc) -AC_CONFIG_SUBDIRS(libs/curl) -AC_CONFIG_SUBDIRS(libs/iksemel) -AC_CONFIG_SUBDIRS(libs/js/nsprpub) -AC_CONFIG_SUBDIRS(libs/js) -AC_CONFIG_SUBDIRS(libs/libdingaling) -AC_CONFIG_SUBDIRS(libs/libsndfile) -AC_CONFIG_SUBDIRS(libs/sofia-sip) -AC_CONFIG_SUBDIRS(libs/speex) -AC_CONFIG_SUBDIRS(libs/portaudio) -AC_CONFIG_SUBDIRS(libs/openzap) -AC_CONFIG_SUBDIRS(libs/unimrcp) -AC_CONFIG_SUBDIRS(libs/tiff-3.8.2) -AC_CONFIG_SUBDIRS(libs/spandsp) -AC_CONFIG_SUBDIRS(libs/broadvoice) -AC_CONFIG_SUBDIRS(libs/libg722_1) +AC_CONFIG_SUBDIRS([libs/pcre]) +AC_CONFIG_SUBDIRS([libs/apr]) +AC_CONFIG_SUBDIRS([libs/apr-util]) +AC_CONFIG_SUBDIRS([libs/ilbc]) +AC_CONFIG_SUBDIRS([libs/curl]) +AC_CONFIG_SUBDIRS([libs/iksemel]) +AC_CONFIG_SUBDIRS([libs/js/nsprpub]) +AC_CONFIG_SUBDIRS([libs/js]) +AC_CONFIG_SUBDIRS([libs/libdingaling]) +AC_CONFIG_SUBDIRS([libs/libsndfile]) +AC_CONFIG_SUBDIRS([libs/sofia-sip]) +AC_CONFIG_SUBDIRS([libs/speex]) +AC_CONFIG_SUBDIRS([libs/portaudio]) +AC_CONFIG_SUBDIRS([libs/openzap]) +AC_CONFIG_SUBDIRS([libs/unimrcp]) +AC_CONFIG_SUBDIRS([libs/tiff-3.8.2]) +AC_CONFIG_SUBDIRS([libs/spandsp]) +AC_CONFIG_SUBDIRS([libs/broadvoice]) +AC_CONFIG_SUBDIRS([libs/libg722_1]) AC_OUTPUT + +## +## Configuration summary +## + +echo +echo "-------------------------- FreeSWITCH configuration ------------------------" +echo "" +echo " Locations:" +echo " Selected layout: ${layout_name}" +echo "" +echo " prefix: ${prefix}" +echo " exec_prefix: ${exec_prefix}" +echo " bindir: ${bindir}" +echo " libdir: ${libdir}" +echo " modulesdir: ${modulesdir}" +echo " sysconfdir: ${sysconfdir}" +echo " runtimedir: ${runtimedir}" +echo " logfiledir: ${logfiledir}" +echo "" +echo "----------------------------------------------------------------------------" diff --git a/src/switch_core.c b/src/switch_core.c index 288cc227e7..30dc569209 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -454,7 +454,7 @@ SWITCH_DECLARE(void) switch_core_set_globals(void) #ifdef SWITCH_RUN_DIR switch_snprintf(SWITCH_GLOBAL_dirs.run_dir, BUFSIZE, "%s", SWITCH_RUN_DIR); #else - switch_snprintf(SWITCH_GLOBAL_dirs.run_dir, BUFSIZE, "%s%slog", base_dir, SWITCH_PATH_SEPARATOR); + switch_snprintf(SWITCH_GLOBAL_dirs.run_dir, BUFSIZE, "%s%srun", base_dir, SWITCH_PATH_SEPARATOR); #endif }