1########################################################################
2##
3## Copyright (C) 2009-2021 The Octave Project Developers
4##
5## See the file COPYRIGHT.md in the top-level directory of this
6## distribution or <https://octave.org/copyright/>.
7##
8## This file is part of Octave.
9##
10## Octave is free software: you can redistribute it and/or modify it
11## under the terms of the GNU General Public License as published by
12## the Free Software Foundation, either version 3 of the License, or
13## (at your option) any later version.
14##
15## Octave is distributed in the hope that it will be useful, but
16## WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18## GNU General Public License for more details.
19##
20## You should have received a copy of the GNU General Public License
21## along with Octave; see the file COPYING.  If not, see
22## <https://www.gnu.org/licenses/>.
23##
24########################################################################
25
26BEGIN {
27  FS = "|";
28  nfiles = 0;
29
30  print "## DO NOT EDIT -- generated from module-files by config-module.awk";
31  print ""
32  print "EXTRA_DIST += \\"
33  print "  %reldir%/config-module.sh \\"
34  print "  %reldir%/config-module.awk \\"
35  print "  %reldir%/module-files \\"
36  print "  %reldir%/oct-qhull.h"
37  print ""
38}
39/^#.*/ { next; }
40{
41  nfiles++;
42  files[nfiles] = $1;
43  cppflags[nfiles] = $2;
44  ldflags[nfiles] = $3;
45  libraries[nfiles] = $4;
46} END {
47  sep = " \\\n";
48  print "DLDFCN_SRC = \\";
49  for (i = 1; i <= nfiles; i++) {
50    if (i == nfiles)
51      sep = "\n";
52    printf ("  %%reldir%%/%s%s", files[i], sep);
53  }
54  print "";
55
56  sep = " \\\n";
57  print "DLDFCN_LIBS = $(DLDFCN_SRC:.cc=.la)";
58  print "";
59  print "octlib_LTLIBRARIES += $(DLDFCN_LIBS)";
60  print "";
61  print "## Use stamp files to avoid problems with checking timestamps";
62  print "## of symbolic links";
63  print "";
64  print "%.oct : %.la"
65  print "\t$(AM_V_GEN)$(INSTALL_PROGRAM) %reldir%/.libs/$(shell $(SED) -n -e \"s/dlname='\\([^']*\\)'/\\1/p\" < $<) $@"
66
67  for (i = 1; i <= nfiles; i++) {
68    basename = files[i];
69    sub (/\.cc$/, "", basename);
70    print "";
71    printf ("%%canon_reldir%%_%s_la_SOURCES = %%reldir%%/%s\n",
72            basename, files[i]);
73    if (cppflags[i])
74      {
75        printf ("%%canon_reldir%%_%s_la_CPPFLAGS = $(libinterp_liboctinterp_la_CPPFLAGS) %s\n",
76                basename, cppflags[i]);
77      }
78    printf ("%%canon_reldir%%_%s_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED_LDFLAG) %s $(OCT_LINK_OPTS) $(WARN_LDFLAGS)\n",
79            basename, ldflags[i]);
80    printf ("%%canon_reldir%%_%s_la_LIBADD = $(DLD_LIBOCTINTERP_LIBADD) %s\n",
81            basename, libraries[i]);
82    printf ("%%canon_reldir%%_%s_la_DEPENDENCIES = $(OCT_LINK_DEPS)\n",
83            basename);
84  }
85
86  print "";
87  print "$(srcdir)/%reldir%/module.mk: $(srcdir)/%reldir%/config-module.sh $(srcdir)/%reldir%/config-module.awk $(srcdir)/%reldir%/module-files";
88  print "\t$(AM_V_GEN)$(SHELL) $(srcdir)/%reldir%/config-module.sh $(srcdir)";
89
90  print "";
91  print "DLDFCN_OCT_FILES = $(DLDFCN_LIBS:.la=.oct)";
92  print "";
93  print "DLDFCN_DEFUN_FILES = $(DLDFCN_SRC)";
94  print "";
95  print "DLDFCN_PKG_ADD_FILE = %reldir%/PKG_ADD";
96  print "";
97  print "%reldir%/PKG_ADD: $(DLDFCN_DEFUN_FILES) $(srcdir)/build-aux/mk-pkg-add.sh | %reldir%/$(octave_dirstamp)";
98  print "	$(AM_V_GEN)rm -f $@-t && \\"
99  print "	$(SHELL) $(srcdir)/build-aux/mk-pkg-add.sh \"$(srcdir)\" $(DLDFCN_DEFUN_FILES) > $@-t && \\";
100  print "	mv $@-t $@";
101  print "";
102  print "LIBINTERP_DEFUN_FILES += \\";
103  print "  $(DLDFCN_DEFUN_FILES)";
104  print "";
105  print "OCT_FILE_PKG_ADD_FILES += \\";
106  print "  $(DLDFCN_PKG_ADD_FILE)";
107  print "";
108  print "OCTAVE_INTERPRETER_TARGETS += \\";
109  print "  $(DLDFCN_OCT_FILES)";
110  print "";
111  print "OCT_FILE_LIBS += \\";
112  print " $(DLDFCN_LIBS)";
113  print "";
114  print "OCT_FILES += \\";
115  print " $(DLDFCN_OCT_FILES)";
116  print "";
117  print "DIRSTAMP_FILES += %reldir%/$(octave_dirstamp)";
118
119  print "";
120  print "libinterp_CLEANFILES += \\";
121  print "  $(DLDFCN_PKG_ADD_FILE) \\";
122  print "  $(DLDFCN_OCT_FILES)";
123  print "";
124  print "libinterp_MAINTAINERCLEANFILES += \\";
125  print "  $(srcdir)/%reldir%/module.mk";
126}
127