Fix: out of tree examples build
[lttng-ust.git] / doc / examples / Makefile.am
index 25d34f3b881096841191b5bcce47756cda27551d..3f219c07c14183a239ee11b46907fcf51f871be1 100644 (file)
@@ -34,15 +34,42 @@ if NO_SHARED
 # Don't build examples if shared libraries support was explicitly
 # disabled.
 else
+# Copies are for VPATH build support
 SUBDIRS_PROXY = easy-ust demo gen-tp hello-static-lib
 
 all-local:
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for subdir in $(SUBDIRS_PROXY); do \
+                       cp -fR $(srcdir)/$$subdir $(builddir); \
+               done; \
+       fi; \
+       if [ x"$(shell echo "$(top_srcdir)" | grep "^/" | wc -l)" = x"1" ]; then \
+               echo "Examples: absolute top_srcdir path $(top_srcdir)"; \
+               rel_src_subdir=""; \
+       else \
+               echo "Examples: relative top_srcdir path $(top_srcdir)"; \
+               rel_src_subdir="../"; \
+       fi; \
+       if [ x"$(shell echo "$(top_builddir)" | grep "^/" | wc -l)" = x"1" ]; then \
+               echo "Examples: absolute top_builddir path $(top_builddir)"; \
+               rel_build_subdir=""; \
+       else \
+               echo "Examples: relative top_builddir path $(top_builddir)"; \
+               rel_build_subdir="../"; \
+       fi; \
        for subdir in $(SUBDIRS_PROXY); do \
-               cd $$subdir && $(MAKE) AM_CPPFLAGS="-I../../../include/" AM_LDFLAGS='-L../../../liblttng-ust/.libs/ -Wl,-rpath="$(PWD)/../../liblttng-ust/.libs/"' LTTNG_GEN_TP_PATH="../../tools/" $(AM_MAKEFLAGS) all; cd ..; \
+               (cd $$subdir && $(MAKE) AM_CC="$(CC)" AM_CPPFLAGS="$(CPPFLAGS) -I$$rel_src_subdir$(top_srcdir)/include/ -I$$rel_build_subdir$(top_builddir)/include/" AM_CFLAGS='$(CFLAGS)' AM_LDFLAGS='$(LDFLAGS) -L../../../liblttng-ust/.libs/ -Wl,-rpath="$(PWD)/../../liblttng-ust/.libs/"' LTTNG_GEN_TP_PATH="../../../tools/" $(AM_MAKEFLAGS) all && cd ..) || exit 1; \
        done
 
 clean-local:
-       for subdir in $(SUBDIRS_PROXY); do \
-               cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) clean; cd ..; \
-       done
+       @for subdir in $(SUBDIRS_PROXY); do \
+               if [ -d $$subdir ]; then \
+                       (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) clean && cd ..) || exit 1; \
+               fi; \
+       done; \
+       if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for subdir in $(SUBDIRS_PROXY); do \
+                       rm -rf $(builddir)/$$subdir; \
+               done; \
+       fi;
 endif
This page took 0.024008 seconds and 4 git commands to generate.