From 302e95d80865075e76c3d5acfb503448b1d5cdb6 Mon Sep 17 00:00:00 2001
From: Ali Mohammed <amohamme@daint105.login.cscs.ch>
Date: Mon, 11 Apr 2022 13:29:58 +0200
Subject: [PATCH] add 'make examples' to automake to compile from installed
 maestro

---
 Makefile.am          | 10 ++++++++--
 configure.ac         |  1 +
 examples/Makefile    | 30 ------------------------------
 examples/Makefile.am | 16 ++++++++++++++++
 4 files changed, 25 insertions(+), 32 deletions(-)
 delete mode 100644 examples/Makefile
 create mode 100644 examples/Makefile.am

diff --git a/Makefile.am b/Makefile.am
index 6b208215..59fa7fe9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,7 +47,7 @@ dist-hook:
 # end of version number magic
 
 
-SUBDIRS = deps include protocols transport transformation attributes maestro . tests docs
+SUBDIRS = deps include protocols transport transformation attributes maestro . tests docs 
 
 # extra dependencies for parallel builds:
 maestro: deps protocols
@@ -63,6 +63,7 @@ libmaestro_la_LIBADD = 			 \
 	attributes/libattributes.la \
 	$(LIBS)
 
+
 # README
 dist_doc_DATA = README.md
 
@@ -75,7 +76,11 @@ all-local: TAGS tags
 endif
 
 # documentation shortcut
-.PHONY: doc docs
+.PHONY: doc docs examples 
+	
+examples: maestro
+	$(MAKE) $(AM_MAKEFLAGS) -C examples
+
 doc docs:
 	$(MAKE) -C docs
 
@@ -87,6 +92,7 @@ devel-clean:
 	$(MAKE) -C transformation clean
 	$(MAKE) -C attributes clean
 	$(MAKE) -C tests clean
+	$(MAKE) -C examples clean
 
 if CODE_COVERAGE_ENABLED
 coverage: all
diff --git a/configure.ac b/configure.ac
index 6bdf3a42..b946628c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -619,6 +619,7 @@ AC_CONFIG_FILES([
   maestro/Makefile
   attributes/Makefile
   tests/Makefile
+  examples/Makefile
   docs/Makefile
   docs/doxygen/Makefile
   docs/sphinx/Makefile
diff --git a/examples/Makefile b/examples/Makefile
deleted file mode 100644
index da727adc..00000000
--- a/examples/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-MAESTRO ?=../
-
-CC ?= cc
-MPICC ?= cc
-
-INC=-I$(MAESTRO)/include
-LDFLAGS=-L$(MAESTRO)/.libs
-
-LIBS=-lmaestro
-LIBS_OMP=-fopenmp -lmaestro
-
-CFLAGS=-O3
-
-OBJs = core_bench local_pool_op
-
-
-all: core_bench local_pool_op
-
-%: %.c
-	$(CC) $(CFLAGS) $(INC) $< $(LDFLAGS) $(LIBS) -o $@
-
-%.o: %.c
-	$(MPICC) -c $(CFLAGS) $(INC) $< -o $@
-
-core_bench: omp_injector.o omp_consumer.o core_benchmark.o
-	$(MPICC) $(CFLAGS)  $(LDFLAGS) $^ $(LIBS_OMP) -o $@
-
-
-clean:
-	rm -f $(OBJs) *.o *CDO*
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644
index 00000000..b709f8d9
--- /dev/null
+++ b/examples/Makefile.am
@@ -0,0 +1,16 @@
+AM_CFLAGS = -I$(includedir)/maestro 
+
+
+AM_LDFLAGS  = -L$(libdir) -fopenmp -lmaestro
+
+
+include_HEADERS =
+
+
+examples_bin = core_bench
+
+examplesdir = $(top_srcdir)/examples
+examples_PROGRAMS = $(examples_bin)
+
+
+core_bench_SOURCES = omp_injector.c omp_consumer.c core_benchmark.c
-- 
GitLab