Permalink
Browse files

Octave: use common example.mk for examples, patterned after javascript

  • Loading branch information...
1 parent ebe1338 commit b2d492c15a0240d8954d3702a87f90eb34fd49fb @kwwette kwwette committed May 26, 2014
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -0,0 +1,32 @@
+# Note: as a convention an example must be in a child directory of this.
+# These paths are relative to such an example directory
+
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = swigexample
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
+
+build:
+ifneq (,$(SRCS))
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+else
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+endif
+ifneq (,$(TARGET2)$(SWIGOPT2))
+ifneq (,$(SRCS))
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave
+else
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp
+endif
+endif
+
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,18 +1,7 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
+TARGET = swigexample
+SWIGOPT = -module swigexample
+TARGET2 = swigexample2
+SWIGOPT2 = -module swigexample2 -globals .
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' SWIGOPT='-module $$(TARGET)' INTERFACE='$(INTERFACE)' octave
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
- rm -f $(TARGET).m
+include $(SRCDIR)../example.mk
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk

0 comments on commit b2d492c

Please sign in to comment.