mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	adjust various data/library paths automatically if we are run from a build tree
This commit is contained in:
		
							parent
							
								
									a562978509
								
							
						
					
					
						commit
						8a2a6b2004
					
				
					 6 changed files with 59 additions and 7 deletions
				
			
		| 
						 | 
					@ -74,6 +74,7 @@ AM_CFLAGS = \
 | 
				
			||||||
	$(LIBSAMPLERATE_CFLAGS) \
 | 
						$(LIBSAMPLERATE_CFLAGS) \
 | 
				
			||||||
	$(LIBSNDFILE_CFLAGS) \
 | 
						$(LIBSNDFILE_CFLAGS) \
 | 
				
			||||||
	$(LIBSPEEX_CFLAGS) \
 | 
						$(LIBSPEEX_CFLAGS) \
 | 
				
			||||||
 | 
						-DPA_BUILDDIR=\"$(abs_builddir)\" \
 | 
				
			||||||
	-DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \
 | 
						-DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \
 | 
				
			||||||
	-DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \
 | 
						-DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \
 | 
				
			||||||
	-DPA_BINARY=\"$(PA_BINARY)\" \
 | 
						-DPA_BINARY=\"$(PA_BINARY)\" \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -133,9 +133,25 @@ static const pa_daemon_conf default_conf = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pa_daemon_conf* pa_daemon_conf_new(void) {
 | 
					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;
 | 
					    return c;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -774,6 +774,8 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
    pa_log_info(_("Using state directory %s."), s);
 | 
					    pa_log_info(_("Using state directory %s."), s);
 | 
				
			||||||
    pa_xfree(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()));
 | 
					    pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pa_in_system_mode())
 | 
					    if (pa_in_system_mode())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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) {
 | 
					int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m) {
 | 
				
			||||||
    pa_alsa_element *e;
 | 
					    pa_alsa_element *e;
 | 
				
			||||||
    int r;
 | 
					    int r = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(m);
 | 
					    pa_assert(m);
 | 
				
			||||||
    pa_assert(p);
 | 
					    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[1].data = &p->description;
 | 
				
			||||||
    items[2].data = &p->name;
 | 
					    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);
 | 
					    r = pa_config_parse(fn, NULL, items, p);
 | 
				
			||||||
    pa_xfree(fn);
 | 
					    pa_xfree(fn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3110,7 +3115,12 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
 | 
				
			||||||
    if (!fname)
 | 
					    if (!fname)
 | 
				
			||||||
        fname = "default.conf";
 | 
					        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);
 | 
					    r = pa_config_parse(fn, NULL, items, ps);
 | 
				
			||||||
    pa_xfree(fn);
 | 
					    pa_xfree(fn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2862,3 +2862,22 @@ void pa_reset_personality(void) {
 | 
				
			||||||
#endif
 | 
					#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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -243,4 +243,8 @@ size_t pa_pipe_buf(int fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pa_reset_personality(void);
 | 
					void pa_reset_personality(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__linux__) && !defined(__OPTIMIZE__)
 | 
				
			||||||
 | 
					pa_bool_t pa_run_from_build_tree(void);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue