1#!/bin/sh
2
3built_sources=""
4
5headers=`find .. -name "*.h" -a -not -name libmesh_config.h -type f | LC_COLLATE=POSIX sort`
6
7for header_with_path in $headers ; do
8
9    #echo $header_with_path
10    header=`basename $header_with_path`
11    #echo $header
12    built_sources="$built_sources $header"
13done
14
15specializations=`find .. -name "*specializations" -type f | sort`
16
17for specialization_with_path in $specializations ; do
18
19    #echo $specialization_with_path
20    specialization=`basename $specialization_with_path`
21    #echo $specialization
22    built_sources="$built_sources $specialization"
23done
24
25cat <<EOF > Makefile.am
26# Note - this file is automatically generated by $0
27# do not edit manually
28
29#
30# include the magic script!
31EXTRA_DIST = rebuild_makefile.sh
32
33EOF
34
35printf '%s' "BUILT_SOURCES =" >> Makefile.am
36for built_src in $built_sources ; do
37    echo " \\" >> Makefile.am
38    printf '%s' "        "$built_src >> Makefile.am
39done
40
41echo >> Makefile.am
42echo >> Makefile.am
43echo "DISTCLEANFILES = \$(BUILT_SOURCES)" >> Makefile.am
44
45
46# handle contrib directly
47cat <<EOF >> Makefile.am
48
49#
50# contrib rules
51if LIBMESH_ENABLE_FPARSER
52
53fparser.hh: \$(top_srcdir)/contrib/fparser/fparser.hh
54	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
55
56fparser_ad.hh: \$(top_srcdir)/contrib/fparser/fparser_ad.hh
57	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
58
59  BUILT_SOURCES  += fparser.hh fparser_ad.hh
60  DISTCLEANFILES += fparser.hh fparser_ad.hh
61
62endif
63
64if LIBMESH_ENABLE_NANOFLANN
65
66nanoflann.hpp: \$(top_srcdir)/contrib/nanoflann/include/nanoflann.hpp
67	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
68
69  BUILT_SOURCES  += nanoflann.hpp
70  DISTCLEANFILES += nanoflann.hpp
71
72endif
73
74if LIBMESH_ENABLE_EXODUS_V509
75
76exodusII.h: \$(top_srcdir)/contrib/exodusii/v5.09/include/exodusII.h
77	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
78
79  BUILT_SOURCES  += exodusII.h
80  DISTCLEANFILES += exodusII.h
81
82exodusII_ext.h: \$(top_srcdir)/contrib/exodusii/v5.09/include/exodusII_ext.h
83	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
84
85  BUILT_SOURCES  += exodusII_ext.h
86  DISTCLEANFILES += exodusII_ext.h
87
88endif
89
90if LIBMESH_ENABLE_EXODUS_V522
91
92exodusII.h: \$(top_srcdir)/contrib/exodusii/v5.22/exodus/cbind/include/exodusII.h
93	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
94
95  BUILT_SOURCES  += exodusII.h
96  DISTCLEANFILES += exodusII.h
97
98endif
99
100if LIBMESH_ENABLE_NETCDF_V4
101
102netcdf.h: \$(top_srcdir)/contrib/netcdf/v4/include/netcdf.h
103	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
104
105  BUILT_SOURCES  += netcdf.h
106  DISTCLEANFILES += netcdf.h
107
108endif
109
110if LIBMESH_ENABLE_CAPNPROTO
111
112rb_data.capnp.h:
113	\$(MAKE) -C \$(top_builddir)/contrib/capnproto rb_data.capnp.h
114	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) \$(top_builddir)/contrib/capnproto/rb_data.capnp.h \$@
115
116  BUILT_SOURCES  += rb_data.capnp.h
117  DISTCLEANFILES += rb_data.capnp.h
118
119endif
120
121EOF
122
123
124
125# handle libmesh_config.h
126cat <<EOF >> Makefile.am
127#
128# libmesh_config.h rule
129libmesh_config.h: \$(top_builddir)/include/libmesh_config.h
130	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
131
132  BUILT_SOURCES  += libmesh_config.h
133  DISTCLEANFILES += libmesh_config.h
134
135EOF
136
137
138
139# now automatically handle our headers
140cat <<EOF >> Makefile.am
141#
142# libMesh header rules
143EOF
144for header_with_path in $headers $specializations ; do
145    header=`basename $header_with_path`
146    source=`echo $header_with_path | sed 's/../$(top_srcdir)\/include/'`
147    #echo "source = $source"
148    cat <<EOF >> Makefile.am
149$header: $source
150	\$(AM_V_GEN)rm -f \$@ && \$(LN_S) -f \$< \$@
151
152EOF
153done
154#cat Makefile.am
155