1# -*- Mode: Makefile; -*-
2#
3# (C) 2011 by Argonne National Laboratory.
4#     See COPYRIGHT in top-level directory.
5#
6
7## TODO: need to write an automakefile that handles two primary cases:
8## 1) that ROMIO is being embedded within the MPI library, as in MPICH2 or Open
9##    MPI
10## 2) that ROMIO is being built standalone, old-school style.  This case is
11##    basically unused in modern practice.
12
13# help autoreconf and friends realize where the macros live
14ACLOCAL_AMFLAGS = -I confdb
15
16# empty variable initializations so that later code can append (+=)
17include_HEADERS =
18nodist_include_HEADERS =
19noinst_HEADERS =
20AM_CPPFLAGS =
21EXTRA_DIST =
22SUFFIXES =
23doc1_src_txt =
24
25# ------------------------------------------------------------------------
26# variables to be populated by the included Makefile.mk fragments:
27
28# These are files that contain MPI routines (e.g., MPI_File_open).
29# In MPICH2 these will have an MPI_ and a PMPI_ version.  Other implementations
30# (like OMPI) only want these to be MPI_ routines, possibly with some
31# name-shifting prefix.
32romio_mpi_sources =
33
34# regular old source files that implement ROMIO, such as ADIO code
35romio_other_sources =
36
37# code that may need to be "up" called from the MPI library and/or is
38# MPI-implementation-specific in some way
39glue_sources =
40
41# ------------------------------------------------------------------------
42# when building under MPICH2 we must be able to find mpi.h
43AM_CPPFLAGS += $(MPI_H_INCLUDE)
44
45# ------------------------------------------------------------------------
46# handle the "include" directory here
47AM_CPPFLAGS += -I$(top_builddir)/include -I$(top_srcdir)/include
48# nodist_ b/c these are created by config.status and should not be distributed
49nodist_include_HEADERS += include/mpio.h include/mpiof.h
50
51# ------------------------------------------------------------------------
52
53SUBDIRS =
54DIST_SUBDIRS = test test-internal
55
56# for the sake of parallel make and avoiding an excessive number of convenience
57# libs, we use a subdir automake fragment strategy
58include mpi-io/Makefile.mk
59include adio/Makefile.mk
60
61EXTRA_DIST += autogen.sh
62
63if BUILD_ROMIO_EMBEDDED
64# Build a libtool convenience library that the enclosing MPI implementation can
65# use by adding it to the right _LIBADD variable.
66noinst_LTLIBRARIES = libromio.la
67libromio_la_SOURCES = $(romio_mpi_sources) $(romio_other_sources) $(glue_sources)
68
69## NOTE: ROMIO's old build system builds a bunch of _foo.o objects that contain
70## PMPI_ implementations as well as calls to only other PMPI routines.  In
71## MPICH2, these are the objects that need to go into libmpich, while the foo.o
72## objects should go into libpmpich.  Furthermore, the -D option for ROMIO's
73## source files is different and inverted (in the boolean sense) compared with
74## MPICH2's defintion.  And ROMIO was dumping all of the symbols into the main
75## libmpich library, regardless of the separate profiling library's existence.
76##
77## Annoying, right?
78if BUILD_PROFILING_LIB
79# The current best strategy for now is to build the PMPI symbols as a separate
80# convenience lib to permit adding the special "-D..." argument for all objects.
81# MPICH2 will then link in both convenience library into libmpich, since it
82# won't work very well the other way around.
83noinst_LTLIBRARIES += libpromio.la
84libpromio_la_SOURCES = $(romio_mpi_sources)
85libpromio_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPIO_BUILD_PROFILING
86endif BUILD_PROFILING_LIB
87
88else !BUILD_ROMIO_EMBEDDED
89## TODO build a libromio.la (non-convenience) and possibly a libglue.la or something?
90
91endif
92
93# --------------------------------------------------------------------------
94.PHONY: coverage
95gcov_sources = $(libmpl_la_SOURCES)
96# assumes that these sources were compiled appropriately ("-fprofile-arcs"
97# and "-ftest-coverage")
98coverage:
99	@for file in $(gcov_sources) ; do \
100	    dir=`dirname $$file` ; \
101	    bname=`basename $$file` ; \
102	    aux=`echo $$bname | sed -e 's,\.*$$,,'` ; \
103	    echo "( $(GCOV) -b -f -o $$file $$file && mv $${bname}.gcov $$dir )" ; \
104	    ( $(GCOV) -b -f -o $$file $$file && mv $${bname}.gcov $$dir ) ; \
105	    rm -f *.gcov ; \
106	done
107	for subdir in $(SUBDIRS) - ; do \
108	    if test $$subdir = "-" ; then break ; fi ; \
109	    ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) coverage ) ; \
110	done
111# --------------------------------------------------------------------------
112.PHONY: mandoc mandoc-local htmldoc htmldoc-local
113SUFFIXES += .man-phony .html-phony .man1-phony .html1-phony .txt
114
115# "make V=1" support for our documentation recipes
116doctextman_verbose = $(doctextman_verbose_$(V))
117doctextman_verbose_ = $(doctextman_verbose_$(AM_DEFAULT_VERBOSITY))
118doctextman_verbose_0 = @echo "   DOCTEXTMAN  " $@;
119doctexthtml_verbose = $(doctexthtml_verbose_$(V))
120doctexthtml_verbose_ = $(doctexthtml_verbose_$(AM_DEFAULT_VERBOSITY))
121doctexthtml_verbose_0 = @echo "   DOCTEXTHTML  " $@;
122
123# Build dir paths where the man pages will be created.  Will usually be
124# overridden by MPICH2 make.
125mandoc_path1=$(abs_top_builddir)/man/man1
126mandoc_path3=$(abs_top_builddir)/man/man3
127htmldoc_path1=$(abs_top_builddir)/www/www1
128htmldoc_path3=$(abs_top_builddir)/www/www3
129doctext_docnotes=
130
131.c.man-phony:
132	$(doctextman_verbose)$(DOCTEXT) -man -mpath $(mandoc_path3) -ext 3 \
133	    -heading MPI -quotefmt $(doctext_docnotes) $<
134.c.html-phony:
135	$(doctexthtml_verbose)$(DOCTEXT) -html -mpath $(htmldoc_path3) \
136	    -heading MPI -quotefmt $(doctext_docnotes) $<
137
138.txt.man1-phony:
139	$(doctextman_verbose)$(DOCTEXT) -man -mpath $(mandoc_path1) -ext 1 \
140	    -heading MPI -quotefmt $(doctext_docnotes) $<
141.txt.html1-phony:
142	$(doctexthtml_verbose)$(DOCTEXT) -html -mpath $(htmldoc_path1) \
143	    -heading MPI -quotefmt $(doctext_docnotes) $<
144
145# use mandoc-local target to force directory creation before running DOCTEXT
146mandoc:
147	test -d $(mandoc_path1) || $(MKDIR_P) $(mandoc_path1)
148	test -d $(mandoc_path3) || $(MKDIR_P) $(mandoc_path3)
149	$(MAKE) $(AM_MAKEFLAGS) mandoc-local
150mandoc-local: $(romio_mpi_sources:.c=.man-phony) $(doc1_src_txt:.txt=.man1-phony)
151
152# use htmldoc-local target to force directory creation before running DOCTEXT
153htmldoc:
154	test -d $(top_builddir)/www/www1 || $(MKDIR_P) $(top_builddir)/www/www1
155	test -d $(top_builddir)/www/www3 || $(MKDIR_P) $(top_builddir)/www/www3
156	$(MAKE) $(AM_MAKEFLAGS) htmldoc-local
157htmldoc-local: $(romio_mpi_sources:.c=.html-phony) $(doc1_src_txt:.txt=.html1-phony)
158
159# --------------------------------------------------------------------------
160
161