changeset 354:eec3ed1c0578

build: generate PKG_ADD and PKG_DEL files from DEFUN_DLD declarations * Makefile.am (PKG_ADD, PKG_DEL): Generate autoload directives for functions declared in oct files with names different from file name. * .hgignore: Ignore PKG_ADD and PKG_DEL files.
author Mike Miller <mtmiller@octave.org>
date Mon, 22 Aug 2016 17:24:13 -0700
parents 826a23f63f75
children 8cdc94b83e98
files .hgignore Makefile.am
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Aug 22 14:55:19 2016 -0700
+++ b/.hgignore	Mon Aug 22 17:24:13 2016 -0700
@@ -43,6 +43,7 @@
 (^|/)\.deps
 (^|/)\.libs
 
+(^|/)PKG_(ADD|DEL)
 (^|/)octave-workspace
 
 # e.g. doc/faq/OctaveFAQ.info
--- a/Makefile.am	Mon Aug 22 14:55:19 2016 -0700
+++ b/Makefile.am	Mon Aug 22 17:24:13 2016 -0700
@@ -77,7 +77,7 @@
 libpytave_la_CPPFLAGS = $(AM_CPPFLAGS)
 libpytave_la_SOURCES = $(COMMON_SOURCE_FILES) $(PYTAVE_HEADER_FILES)
 
-CLEANFILES = *.oct
+CLEANFILES = *.oct PKG_ADD PKG_DEL
 SUFFIXES = .oct
 
 AM_V_MKOCTFILE = $(am__v_MKOCTFILE_$(V))
@@ -93,7 +93,27 @@
 %.oct: %.cc libpytave.la $(PYTAVE_HEADER_FILES)
 	$(AM_V_MKOCTFILE)$(OCT_LINK) $< $(OCT_LIBS)
 
-all-local: $(OCT_FILES)
+PKG_ADD: $(OCT_SOURCE_FILES)
+	$(AM_V_GEN)for f in $(OCT_SOURCE_FILES); do \
+	  b=$${f%.cc}; \
+	  funcs=`$(SED) -n 's/^DEFUN.*(\(\w\+\),.*/\1/p' $$f | grep -v $$b`; \
+	  if test -n "$$funcs"; then \
+	    echo "$$funcs" | $(SED) "s/.*/autoload (\"&\", \"$$b.oct\");/" > $@-t && \
+	    mv $@-t $@ || exit $?; \
+	  fi; \
+	done
+
+PKG_DEL: $(OCT_SOURCE_FILES)
+	$(AM_V_GEN)for f in $(OCT_SOURCE_FILES); do \
+	  b=$${f%.cc}; \
+	  funcs=`$(SED) -n 's/^DEFUN.*(\(\w\+\),.*/\1/p' $$f | grep -v $$b`; \
+	  if test -n "$$funcs"; then \
+	    echo "$$funcs" | $(SED) "s/.*/autoload (\"&\", which (\"&\"), \"remove\");/" > $@-t && \
+	    mv $@-t $@ || exit $?; \
+	  fi; \
+	done
+
+all-local: $(OCT_FILES) PKG_ADD PKG_DEL
 	@echo ""
 	@echo "Pytave successfully built.  Now choose from the following:"
 	@echo ""