From: Lennart Poettering Date: Fri, 21 Aug 2009 01:43:53 +0000 (+0200) Subject: adjust various data/library paths automatically if we are run from a build tree X-Git-Tag: submit/2.0-panda/20130828.192557~1476 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a2a6b2004cd299467de1955f7f99e25033faa63;p=profile%2Fivi%2Fpulseaudio-panda.git adjust various data/library paths automatically if we are run from a build tree --- diff --git a/src/Makefile.am b/src/Makefile.am index 17011cd..fd44099 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,6 +74,7 @@ AM_CFLAGS = \ $(LIBSAMPLERATE_CFLAGS) \ $(LIBSNDFILE_CFLAGS) \ $(LIBSPEEX_CFLAGS) \ + -DPA_BUILDDIR=\"$(abs_builddir)\" \ -DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \ -DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \ -DPA_BINARY=\"$(PA_BINARY)\" \ @@ -83,8 +84,8 @@ AM_CFLAGS = \ -DAO_REQUIRE_CAS \ -DPULSE_LOCALEDIR=\"$(pulselocaledir)\" \ -DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\" \ - -DPA_ALSA_PATHS_DIR=\"$(alsapathsdir)\" \ - -DPA_ALSA_PROFILE_SETS_DIR=\"$(alsaprofilesetsdir)\" + -DPA_ALSA_PATHS_DIR=\"$(alsapathsdir)\" \ + -DPA_ALSA_PROFILE_SETS_DIR=\"$(alsaprofilesetsdir)\" AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS) AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS) diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 9a87b55..ec1ec5c 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -133,9 +133,25 @@ static const pa_daemon_conf default_conf = { }; pa_daemon_conf* pa_daemon_conf_new(void) { - pa_daemon_conf *c = pa_xnewdup(pa_daemon_conf, &default_conf, 1); + pa_daemon_conf *c; + + c = pa_xnewdup(pa_daemon_conf, &default_conf, 1); + +#if defined(__linux__) && !defined(__OPTIMIZE__) + + /* We abuse __OPTIMIZE__ as a check whether we are a debug build + * or not. If we are and are run from the build tree then we + * override the search path to point to our build tree */ + + if (pa_run_from_build_tree()) { + pa_log_notice("Detected that we are run from the build tree, fixing search path."); + c->dl_search_path = pa_xstrdup(PA_BUILDDIR "/.libs/"); + + } else + +#endif + c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH); - c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH); return c; } diff --git a/src/daemon/main.c b/src/daemon/main.c index 8521e72..7298459 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -774,6 +774,8 @@ int main(int argc, char *argv[]) { pa_log_info(_("Using state directory %s."), s); pa_xfree(s); + pa_log_info(_("Using modules directory %s."), conf->dl_search_path); + pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode())); if (pa_in_system_mode()) diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index a4c2ee0..61c92cd 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -929,7 +929,7 @@ static int element_zero_volume(pa_alsa_element *e, snd_mixer_t *m) { int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m) { pa_alsa_element *e; - int r; + int r = 0; pa_assert(m); pa_assert(p); @@ -1849,7 +1849,12 @@ pa_alsa_path* pa_alsa_path_new(const char *fname, pa_alsa_direction_t direction) items[1].data = &p->description; items[2].data = &p->name; - fn = pa_maybe_prefix_path(fname, PA_ALSA_PATHS_DIR); + fn = pa_maybe_prefix_path(fname, +#if defined(__linux__) && !defined(__OPTIMIZE__) + pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/paths/" : +#endif + PA_ALSA_PATHS_DIR); + r = pa_config_parse(fn, NULL, items, p); pa_xfree(fn); @@ -3110,7 +3115,12 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel if (!fname) fname = "default.conf"; - fn = pa_maybe_prefix_path(fname, PA_ALSA_PROFILE_SETS_DIR); + fn = pa_maybe_prefix_path(fname, +#if defined(__linux__) && !defined(__OPTIMIZE__) + pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/profile-sets/" : +#endif + PA_ALSA_PROFILE_SETS_DIR); + r = pa_config_parse(fn, NULL, items, ps); pa_xfree(fn); diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index ef8c847..843c837 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2862,3 +2862,22 @@ void pa_reset_personality(void) { #endif } + +#if defined(__linux__) && !defined(__OPTIMIZE__) + +pa_bool_t pa_run_from_build_tree(void) { + char *rp; + pa_bool_t b = FALSE; + + /* We abuse __OPTIMIZE__ as a check whether we are a debug build + * or not. */ + + if ((rp = pa_readlink("/proc/self/exe"))) { + b = pa_startswith(rp, PA_BUILDDIR); + pa_xfree(rp); + } + + return b; +} + +#endif diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index 3d3aec7..2551f79 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -243,4 +243,8 @@ size_t pa_pipe_buf(int fd); void pa_reset_personality(void); +#if defined(__linux__) && !defined(__OPTIMIZE__) +pa_bool_t pa_run_from_build_tree(void); +#endif + #endif