[build] Create libguile/version.h using the configure script.
[bpt/guile.git] / libguile / Makefile.am
index 5eea8dc..f12c11b 100644 (file)
@@ -63,7 +63,7 @@ gen-scmconfig.$(OBJEXT): gen-scmconfig.c
        fi
 
 ## Override default rule; this should run on BUILD host.
-gen-scmconfig$(EXEEXT): $(gen_scmconfig_OBJECTS) $(gen_scmconfig_DEPENDENCIES) 
+gen-scmconfig$(EXEEXT): $(gen_scmconfig_OBJECTS) $(gen_scmconfig_DEPENDENCIES)
        $(AM_V_GEN) \
        rm -f gen-scmconfig$(EXEEXT); \
        if [ "$(cross_compiling)" = "yes" ]; then \
@@ -94,7 +94,7 @@ c-tokenize.$(OBJEXT): c-tokenize.c
        fi
 
 ## Override default rule; this should run on BUILD host.
-guile_filter_doc_snarfage$(EXEEXT): $(guile_filter_doc_snarfage_OBJECTS) $(guile_filter_doc_snarfage_DEPENDENCIES) 
+guile_filter_doc_snarfage$(EXEEXT): $(guile_filter_doc_snarfage_OBJECTS) $(guile_filter_doc_snarfage_DEPENDENCIES)
        $(AM_V_GEN) \
        rm -f guile_filter_doc_snarfage$(EXEEXT); \
        if [ "$(cross_compiling)" = "yes" ]; then \
@@ -128,7 +128,6 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES =                             \
        debug.c                                 \
        deprecated.c                            \
        deprecation.c                           \
-       discouraged.c                           \
        dynwind.c                               \
        eq.c                                    \
        error.c                                 \
@@ -230,7 +229,6 @@ DOT_X_FILES =                                       \
        debug.x                                 \
        deprecated.x                            \
        deprecation.x                           \
-       discouraged.x                           \
        dynl.x                                  \
        dynwind.x                               \
        eq.x                                    \
@@ -330,7 +328,6 @@ DOT_DOC_FILES =                             \
        debug.doc                               \
        deprecated.doc                          \
        deprecation.doc                         \
-       discouraged.doc                         \
        dynl.doc                                \
        dynwind.doc                             \
        eq.doc                                  \
@@ -415,8 +412,8 @@ DOT_I_FILES = vm-i-system.i vm-i-scheme.i vm-i-loader.i
 .c.i:
        $(AM_V_GEN)$(GREP) '^VM_DEFINE' $< > $@
 
-BUILT_SOURCES = cpp_err_symbols.c cpp_sig_symbols.c libpath.h \
-    version.h scmconfig.h \
+BUILT_SOURCES = cpp-E.c cpp-SIG.c libpath.h \
+    scmconfig.h \
     $(DOT_I_FILES) $(DOT_X_FILES) $(EXTRA_DOT_X_FILES)
 
 EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = _scm.h           \
@@ -466,7 +463,7 @@ endif HAVE_LD_VERSION_SCRIPT
 
 
 # These are headers visible as <guile/mumble.h>
-pkginclude_HEADERS = 
+pkginclude_HEADERS =
 
 # These are headers visible as <libguile/mumble.h>.
 modincludedir = $(pkgincludedir)/$(GUILE_EFFECTIVE_VERSION)/libguile
@@ -490,7 +487,6 @@ modinclude_HEADERS =                                \
        debug.h                                 \
        deprecated.h                            \
        deprecation.h                           \
-       discouraged.h                           \
        dynl.h                                  \
        dynwind.h                               \
        eq.h                                    \
@@ -593,34 +589,25 @@ bin_SCRIPTS = guile-snarf
 
 # We can re-enable install for some of these if/when they are documented
 # and people feel like maintaining them.  For now, this is not the case.
-noinst_SCRIPTS = guile-doc-snarf guile-snarf-docs guile-func-name-check
+noinst_SCRIPTS = guile-snarf-docs
 
 EXTRA_DIST = ChangeLog-scm ChangeLog-threads           \
-    ChangeLog-1996-1999 ChangeLog-2000 ChangeLog-2008 cpp_signal.c     \
-    cpp_errno.c cpp_err_symbols.in cpp_err_symbols.c                   \
-    cpp_sig_symbols.c cpp_sig_symbols.in cpp_cnvt.awk                  \
-    c-tokenize.lex version.h.in                                                \
+    ChangeLog-1996-1999 ChangeLog-2000 ChangeLog-2008  \
+    guile-func-name-check                              \
+    cpp-E.syms cpp-E.c cpp-SIG.syms cpp-SIG.c                  \
+    c-tokenize.lex                                             \
     scmconfig.h.top libgettext.h unidata_to_charset.pl libguile.map
 #    $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) \
 #    guile-procedures.txt guile.texi
 
-## We use @-...-@ as the substitution brackets here, instead of the
-## usual @...@, so autoconf doesn't go and substitute the values
-## directly into the left-hand sides of the sed substitutions.  *sigh*
-version.h: version.h.in $(top_builddir)/config.status
-       $(AM_V_GEN)sed < $(srcdir)/version.h.in > $@.tmp \
-         -e s:@-GUILE_MAJOR_VERSION-@:${GUILE_MAJOR_VERSION}: \
-         -e s:@-GUILE_MINOR_VERSION-@:${GUILE_MINOR_VERSION}: \
-         -e s:@-GUILE_MICRO_VERSION-@:${GUILE_MICRO_VERSION}: \
-         -e s:@-GUILE_EFFECTIVE_VERSION-@:${GUILE_EFFECTIVE_VERSION}: && mv $@.tmp $@
-
 ## FIXME: Consider using timestamp file, to avoid unnecessary rebuilds.
 libpath.h: $(srcdir)/Makefile.in  $(top_builddir)/config.status
        @rm -f libpath.tmp
        @echo '/* generated by Makefile */' > libpath.tmp
        @echo '#define SCM_PKGDATA_DIR "$(pkgdatadir)"' >> libpath.tmp
        @echo '#define SCM_LIBRARY_DIR "$(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp
-       @echo '#define SCM_SITE_DIR "$(pkgdatadir)/site"' >> libpath.tmp
+       @echo '#define SCM_SITE_DIR "$(pkgdatadir)/site/$(GUILE_EFFECTIVE_VERSION)"' >> libpath.tmp
+       @echo '#define SCM_GLOBAL_SITE_DIR "$(pkgdatadir)/site"' >> libpath.tmp
        @echo '#define SCM_LIB_DIR "$(libdir)"' >> libpath.tmp
        @echo '#define SCM_EXTENSIONS_DIR "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/extensions"' >> libpath.tmp
        @echo '#define SCM_CCACHE_DIR "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/ccache"' >> libpath.tmp
@@ -646,7 +633,7 @@ libpath.h: $(srcdir)/Makefile.in  $(top_builddir)/config.status
        @echo ' { "pkglibdir",     "$(pkglibdir)" }, \' >> libpath.tmp
        @echo ' { "pkgincludedir", "$(pkgincludedir)" }, \' \
                >> libpath.tmp
-       @echo ' { "extensionsdir", "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/extensions" }, \' >> libpath.tmp
+       @echo ' { "extensiondir", "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/extensions" }, \' >> libpath.tmp
        @echo ' { "guileversion", "@GUILE_VERSION@" }, \' >> libpath.tmp
        @echo ' { "libguileinterface", "@LIBGUILE_INTERFACE@" }, \' \
                >> libpath.tmp
@@ -668,14 +655,14 @@ AM_V_FILTER_0 = @echo "  FILTER" $@;
 .c.x:
        $(AM_V_SNARF)$(GUILE_SNARF) -o $@ $< $(snarfcppopts)
 .c.doc:
-       -$(AM_V_FILTER)$(AWK) -f ./guile-func-name-check $< && (./guile-snarf-docs $(snarfcppopts) $< | ./guile_filter_doc_snarfage$(EXEEXT) --filter-snarfage) > $@ || { rm $@; false; }
+       -$(AM_V_FILTER)$(AWK) -f $(srcdir)/guile-func-name-check $< && (./guile-snarf-docs $(snarfcppopts) $< | ./guile_filter_doc_snarfage$(EXEEXT) --filter-snarfage) > $@ || { rm $@; false; }
 
-$(DOT_X_FILES) $(EXTRA_DOT_X_FILES): scmconfig.h snarf.h guile-snarf.in
+$(DOT_X_FILES) $(EXTRA_DOT_X_FILES): scmconfig.h snarf.h guile-snarf.in version.h
 
 $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES): scmconfig.h snarf.h guile-snarf-docs.in guile_filter_doc_snarfage$(EXEEXT)
 
-error.x: cpp_err_symbols.c
-posix.x: cpp_sig_symbols.c
+error.x: cpp-E.c
+posix.x: cpp-SIG.c
 load.x: libpath.h
 
 alldotdocfiles    = $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES)
@@ -710,51 +697,57 @@ schemelib_DATA = guile-procedures.txt
 ## Add -MG to make the .x magic work with auto-dep code.
 MKDEP = gcc -M -MG $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS)
 
-cpp_err_symbols.c: cpp_err_symbols.in cpp_cnvt.awk
-       $(AWK) -f $(srcdir)/cpp_cnvt.awk < $(srcdir)/cpp_err_symbols.in > \
-               cpp_err_symbols.tmp
-       mv cpp_err_symbols.tmp cpp_err_symbols.c
-
-cpp_sig_symbols.c: cpp_sig_symbols.in cpp_cnvt.awk
-       $(AWK) -f $(srcdir)/cpp_cnvt.awk < $(srcdir)/cpp_sig_symbols.in > \
-               cpp_sig_symbols.tmp
-       mv cpp_sig_symbols.tmp cpp_sig_symbols.c
-
-## Create a new version of the cpp_sig_symbols.in file, including all SIGXXX
-## macros defined on this platform.
-check_signals:
-       gcc -undef -dM -E $(srcdir)/cpp_signal.c | $(EGREP) ' SIG[A-Z]+' \
-         | cut -f2 -d' ' | sort > cpp_sig_symbols_here
-       diff -u $(srcdir)/cpp_sig_symbols.in cpp_sig_symbols_here \
-          | $(EGREP) '^\+S' \
-         | cut -c2- > cpp_sig_symbols_diff
-       if test -s cpp_sig_symbols_diff ; then \
-         cat $(srcdir)/cpp_sig_symbols.in cpp_sig_symbols_diff \
-           | sort > cpp_sig_symbols_new ;\
-         echo "cpp_sig_symbols_new has the following additions:" ;\
-         cat cpp_sig_symbols_diff ;\
-       else echo "No new symbols found."; \
-       fi
-
-## Likewise for cpp_err_symbols.in.
-check_errnos:
-       gcc -undef -dM -E $(srcdir)/cpp_errno.c | $(EGREP) ' E.+' \
-         | cut -f2 -d' ' | sort > cpp_err_symbols_here
-       diff -u $(srcdir)/cpp_err_symbols.in cpp_err_symbols_here \
-          | $(EGREP) '^\+E' \
-         | cut -c2- > cpp_err_symbols_diff
-       if test -s cpp_err_symbols_diff ; then \
-         cat $(srcdir)/cpp_err_symbols.in cpp_err_symbols_diff \
-           | sort > cpp_err_symbols_new ;\
-         echo "cpp_err_symbols_new has the following additions:" ;\
-         cat cpp_err_symbols_diff ;\
-       else echo "No new symbols found."; \
-       fi
+\f
+# This page is for maintenance of the lists of CPP symbols that are eventually
+# included in error.c (‘errno’ values: E*) and posix.c (signal names: SIG*),
+# in the funcs scm_init_{error,posix}, respectively.
+#
+# The lists (files cpp-{E,SIG}.syms) are not included verbatim, but processed
+# (via pattern rule ‘.syms.c’ below) so that each CPP symbol is transformed to
+# fragment of #ifdef'd C code that defines a Scheme variable of the same name.
+# The resulting files, cpp-{E,SIG}.c, are the ones #include:d.
+#
+# To maintain the (source) lists of symbols, we use a GCC-specific feature
+# to list all symbols #define:d when expanding <{errno,signal}.h>, grep
+# the output for {E,SIG}*, massage the result into a usable form, and
+# construct a union of the current and new symbols.  This is written to
+# files cpp-{E,SIG}.syms.NEW for review.  If things look ok, you can then
+# "mv foo.NEW foo" and commit.  Generating the foo.NEW files and showing
+# an informative message is the job of targets chknew-{E,SIG}.
+
+# For each line in foo.syms, transform:
+#      SYMBOL
+# to:
+#      #ifdef SYMBOL
+#      scm_c_define ("SYMBOL", scm_from_int (SYMBOL));
+#      #endif
+# writing output to foo.c.
+.syms.c:
+       sed 's/.*/#ifdef &\nscm_c_define ("&", scm_from_int (&));\n#endif/' \
+         $< > $@T
+       mv $@T $@
+
+# Write $(srcdir)/cpp-{E,SIG}.syms.NEW if there are any not-yet-seen
+# ("new" to us) E* or SIG* symbols in <errno.h> or <signal.h>, respectively.
+chknew-E chknew-SIG:
+       @bit=`echo $@ | sed s/^chknew-//` ;                     \
+       old="$(srcdir)/cpp-$$bit.syms" ;                        \
+       echo "#include <$${bit}.h>"                             \
+        | sed 's/E/errno/;s/SIG/signal/'                       \
+        | gcc -undef -dM -E -                                  \
+        | sed 's/^#define //;/^'$$bit'[A-Z][A-Z]*/!d;s/ .*//'  \
+        | sort | diff -u $$old - | sed '1,2d;/^+/!d;s/^.//'    \
+        > TMP ;                                                \
+       if [ -s TMP ] ; then new="$$old.NEW" ;                  \
+         cat $$old TMP | sort > $$new ;                        \
+         echo "$$new: `sed -n '$$=' TMP` new symbol(s)." ;     \
+         sed 's/^/  /' TMP ;                                   \
+       else echo "No new symbols found." ;                     \
+       fi ; rm TMP
+
+\f
 
 MOSTLYCLEANFILES = \
-       cpp_err_symbols_here cpp_err_symbols_diff cpp_err_symbols_new \
-       cpp_sig_symbols_here cpp_sig_symbols_diff cpp_sig_symbols_new \
-       version.h version.h.tmp \
        scmconfig.h scmconfig.h.tmp
 
 CLEANFILES = libpath.h *.x *.doc guile-procedures.txt guile-procedures.texi guile.texi \