changeset 3431:a7c772aa106f

Move mk-dist script functionality into Makefile. * mk-dist: Delete. * binary-dist-rules.mk: New file. * Makefile.in: Include binary-dist-rules.mk. (STRIP_DIST_FILES, STABLE_BUILD, DATE): New variables. * configure.ac: New option --disable-strip-dist-files. * makeinst-script.sh: Require output file as second argument.
author John W. Eaton <jwe@octave.org>
date Thu, 16 Jan 2014 18:03:14 -0500
parents 2183ac663bcb
children 5fc3d674ca3a
files Makefile.in binary-dist-rules.mk configure.ac makeinst-script.sh mk-dist
diffstat 5 files changed, 174 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Thu Jan 16 14:09:19 2014 -0500
+++ b/Makefile.in	Thu Jan 16 18:03:14 2014 -0500
@@ -3,6 +3,12 @@
 
 PWD := $(shell pwd)
 
+STRIP_DIST_FILES := @STRIP_DIST_FILES@
+
+STABLE_BUILD := no
+
+DATE := $(shell date +%Y-%m-%d-%H-%M)
+
 ## Configuration variables.
 
 # Set the following configuration variables with a configure script?
@@ -740,3 +746,5 @@
 	mkdir $(distdir)
 	$(TAR) cf - $(DIST_FILES) | ( cd $(distdir) ; $(TAR) xpf - )
 	$(TAR) czf $(distdir).tar.gz $(distdir)
+
+include binary-dist-rules.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/binary-dist-rules.mk	Thu Jan 16 18:03:14 2014 -0500
@@ -0,0 +1,143 @@
+
+ifeq ($(STABLE_BUILD),yes)
+  OCTAVE_TARGET := stable-octave
+  OCTAVE_DIST_NAME := octave-$($(OCTAVE_TARGET)_VERSION)
+else
+  OCTAVE_TARGET := octave
+  OCTAVE_DIST_NAME := octave-$(DATE)
+endif
+
+OCTAVE_DIST_DIR := $(TOP_DIR)/dist/$(OCTAVE_DIST_NAME)
+
+OCTAVE_NSI_FILE := $(TOP_DIR)/dist/octave.nsi
+
+## FIXME: We need a way to ask "is this a windows build?"
+ifeq ($(MXE_SYSTEM), mingw)
+  WINDOWS_BINARY_DIST_DEPS := msys-base npp
+endif
+ifeq ($(MXE_SYSTEM), msvc)
+  WINDOWS_BINARY_DIST_DEPS := msys-base npp
+endif
+
+BINARY_DIST_DEPS := \
+  $(OCTAVE_TARGET) \
+  native-gcc \
+  native-binutils \
+  octave-forge-packages \
+  units \
+  transfig \
+  $(WINDOWS_BINARY_DIST_FILES)
+
+define delete-dist-directory
+  echo "deleting previous dist directory..."
+  rm -rf $(TOP_DIR)/dist
+endef
+
+define make-dist-directory
+  echo "creating dist directory..."
+  mkdir -p $(TOP_DIR)/dist/octave-$(DATE)
+endef
+
+define make-stable-dist-directory
+  echo "creating dist directory..."
+  mkdir -p $(OCTAVE_DIST_DIR)
+endef
+
+define generate-dist-exclude-list
+  echo "generating lists of files to exclude..."
+  echo "  native files..."
+  echo "./$(TARGET)" > $(TOP_DIR)/excluded-native-files
+  echo "./bin/$(TARGET)-*.exe" >> $(TOP_DIR)/excluded-native-files
+  echo "  gcc cross compiler files..."
+  cd $(TOP_DIR)/cross-tools/$(HOST_PREFIX) \
+    && find . -type f -o -type l | sed "s,./,," > $(TOP_DIR)/excluded-gcc-files
+endef
+
+define copy-dist-files
+  echo "copying files..."
+  echo "  octave and dependencies..."
+  cd $(HOST_PREFIX) \
+    && tar -c -h -X $(TOP_DIR)/excluded-gcc-files -f - . | ( cd $(OCTAVE_DIST_DIR) ; tar xpf - )
+  echo "  octaverc file..."
+  cp $(TOP_DIR)/build_packages.m $(OCTAVE_DIST_DIR)/src \
+    && cp $(TOP_DIR)/octaverc $(OCTAVE_DIST_DIR)/share/octave/site/m/startup/octaverc
+  echo "  native tools..."
+  cd $(TOP_DIR)/native-tools/usr \
+    && tar -c -h -X $(TOP_DIR)/excluded-native-files -f - . | ( cd $(OCTAVE_DIST_DIR) ; tar xpf - )
+  echo "  libgcc_s_dw2-1.dll to bin directory"
+  cd $(OCTAVE_DIST_DIR) \
+    && cp lib/gcc/i686-pc-mingw32/libgcc_s_dw2-1.dll bin
+  echo "  msys base files..."
+  cd $(TOP_DIR)/msys-base \
+    && tar -c -h -f - . | ( cd $(OCTAVE_DIST_DIR) ; tar xpf - )
+  echo "  msys extension files..."
+  cd $(TOP_DIR)/msys-extension \
+    && tar -c -h -f - . | ( cd $(OCTAVE_DIST_DIR) ; tar xpf - )
+  echo "  notepad++..."
+  cd $(TOP_DIR) \
+    && tar -c -h -f - notepad++ | ( cd $(OCTAVE_DIST_DIR) ; tar xpf - )
+  echo "  build_packages.m..."
+  cp $(TOP_DIR)/build_packages.m $(OCTAVE_DIST_DIR)/src
+endef
+
+define make-dist-files-writable
+  echo "making all dist files writable by user..."
+  chmod -R u+w $(OCTAVE_DIST_DIR)
+endef
+
+ifeq ($(STRIP_DIST_FILES),yes)
+define strip-dist-files
+  echo "stripping files..."
+  for f in $$(find $(OCTAVE_DIST_DIR) -name '*.dll' -o -name '*.exe'); do \
+    $(MXE_STRIP) $$f; \
+  done
+endef
+else
+define strip-dist-files
+  echo "not stripping files..."
+endef
+endif
+
+.PHONY: binary-dist-files
+binary-dist-files: $(BINARY_DIST_DEPS)
+	@$(delete-dist-directory)
+	@$(make-dist-directory)
+	@$(generate-dist-exclude-list)
+	@$(copy-dist-files)
+	@$(make-dist-files-writable)
+	@$(strip-dist-files)
+
+define make-installer-file
+  echo "generating installer script..."
+  ./makeinst-script.sh $(OCTAVE_DIST_DIR) $(OCTAVE_NSI_FILE)
+  echo "generating installer..."
+  $(TARGET)-makensis $(OCTAVE_NSI_FILE) > $(TOP_DIR)/dist/nsis.log
+  echo "deleting installer script..."
+  rm -f $(OCTAVE_NSI_FILE)
+endef
+
+$(OCTAVE_DIST_NAME)-installer.exe: nsis binary-dist-files
+	@$(make-installer-file)
+
+.PHONY: nsis-installer
+nsis-installer: $(OCTAVE_DIST_NAME)-installer.exe
+
+define make-zip-dist
+  echo "generating zip file..."
+  cd $(TOP_DIR)/dist \
+    && zip -q -9 -r $(OCTAVE_DIST_NAME).zip $(OCTAVE_DIST_NAME)
+endef
+
+.PHONY: zip-dist
+zip-dist: binary-dist-files
+	@$(make-zip-dist)
+
+define make-tar-dist
+  echo "generating tar file..."
+  cd $(TOP_DIR)/dist \
+    && tar -c -z -f $(OCTAVE_DIST_NAME).zip $(OCTAVE_DIST_NAME)
+endef
+
+.PHONY: tar-dist
+tar-dist: binary-dist-files
+	@$(make-tar-dist)
--- a/configure.ac	Thu Jan 16 14:09:19 2014 -0500
+++ b/configure.ac	Thu Jan 16 18:03:14 2014 -0500
@@ -126,6 +126,12 @@
   [if test "$enableval" = yes; then USE_PIC_FLAG=yes; fi], [])
 AC_SUBST(USE_PIC_FLAG)
 
+STRIP_DIST_FILES=yes
+AC_ARG_ENABLE([strip-dist-files],
+  [AS_HELP_STRING([--disable-strip-dist-files], [Don't strip distributed files])],
+  [if test "$enableval" = no; then STRIP_DIST_FILES=no; fi], [])
+AC_SUBST(STRIP_DIST_FILES)
+
 ENABLE_OPENBLAS=no
 AC_ARG_ENABLE([openblas],
   [AS_HELP_STRING([--enable-openblas],
--- a/makeinst-script.sh	Thu Jan 16 14:09:19 2014 -0500
+++ b/makeinst-script.sh	Thu Jan 16 18:03:14 2014 -0500
@@ -1,15 +1,14 @@
 #! /bin/bash
 set -e
 
-if [ $# != 1 ]; then
-  echo "Expected octave folder"
-  exit
+if [ $# != 2 ]; then
+  echo "usage: makeinst-script.sh dist-dir output-script-name" 1>&2
+  exit 1
 fi
 
-ARG1=$1
-
-TOPDIR=`dirname $ARG1`
-OCTAVE_SOURCE=`basename $ARG1`
+OUTFILE="$2"
+TOPDIR=`dirname $1`
+OCTAVE_SOURCE=`basename $1`
 
 echo "Generating installer script ... "
 
@@ -24,10 +23,10 @@
 VERSION=`echo $OCTAVE_VERSION | sed -n 's,\([0-9\.]*\).*,\1,p'`
 
 # create installer script
-echo "; octave setup script $OCTAVE_SOURCE" > octave.nsi
+echo "; octave setup script $OCTAVE_SOURCE" > $OUTFILE
 
 # installer settings
-  cat >> octave.nsi << EOF
+  cat >> $OUTFILE << EOF
 !define APP_NAME "GNU Octave"
 !define COMP_NAME "GNU Project"
 !define WEB_SITE "http://www.octave.org"
@@ -134,12 +133,12 @@
   IFS=$'\n'
   for f in $(find $OCTAVE_SOURCE -type d -printf "%P\n"); do
     winf=`echo $f | sed 's,/,\\\\,g'`
-    echo " CreateDirectory \"\$INSTDIR\\$winf\"" >> octave.nsi
-    echo " SetOutPath \"\$INSTDIR\\$winf\"" >> octave.nsi
-    find "$OCTAVE_SOURCE/$f" -maxdepth 1 -type f -printf " File \"%p\"\n" >> octave.nsi 
+    echo " CreateDirectory \"\$INSTDIR\\$winf\"" >> $OUTFILE
+    echo " SetOutPath \"\$INSTDIR\\$winf\"" >> $OUTFILE
+    find "$OCTAVE_SOURCE/$f" -maxdepth 1 -type f -printf " File \"%p\"\n" >> $OUTFILE 
   done
 
-  cat >> octave.nsi << EOF
+  cat >> $OUTFILE << EOF
 
  ; add qt.conf
  Push \$0
@@ -172,7 +171,7 @@
 EOF
   # if we have documentation files, create shortcuts
   if [ -d $OCTAVE_SOURCE/share/doc/octave ]; then
-    cat >> octave.nsi << EOF
+    cat >> $OUTFILE << EOF
     CreateDirectory "\$SMPROGRAMS\\Octave-$VERSION\\Documentation"
     CreateShortCut "\$SMPROGRAMS\\Octave-$VERSION\\Documentation\\Octave C++ Classes (PDF).lnk" "\$INSTDIR\\share\\doc\\octave\\liboctave.pdf" "" "" 0
     CreateShortCut "\$SMPROGRAMS\\Octave-$VERSION\\Documentation\\Octave C++ Classes (HTML).lnk" "\$INSTDIR\\share\\doc\\octave\\liboctave.html\\index.html" "" "" 0
@@ -181,7 +180,7 @@
 EOF
   fi
  
-  cat >> octave.nsi << EOF
+  cat >> $OUTFILE << EOF
 SectionEnd
 
 Section "Uninstall"
@@ -206,12 +205,12 @@
 # insert dir list (backwards order) for uninstall files
   for f in $(find $OCTAVE_SOURCE -depth -type d -printf "%P\n"); do
     winf=`echo $f | sed 's,/,\\\\,g'`
-    echo " Delete \"\$INSTDIR\\$winf\\*.*\"" >> octave.nsi
-    echo " RmDir \"\$INSTDIR\\$winf\"" >> octave.nsi
+    echo " Delete \"\$INSTDIR\\$winf\\*.*\"" >> $OUTFILE
+    echo " RmDir \"\$INSTDIR\\$winf\"" >> $OUTFILE
   done
 
 # last bit of the uninstaller
-  cat >> octave.nsi << EOF
+  cat >> $OUTFILE << EOF
  Delete "\$INSTDIR\\*.*"
  RmDir "\$INSTDIR"
 SectionEnd
--- a/mk-dist	Thu Jan 16 14:09:19 2014 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-#! /bin/bash
-
-set -e
-
-## Override with --jobs option or set JOBS variable in settings.mk
-jobs=0
-
-OCTAVE_TARGET=octave
-TOPDIR=$(pwd)
-PATH=$TOPDIR/usr/bin:$PATH
-TARGET=i686-pc-mingw32
-PREFIX=/usr/$TARGET
-STRIP=$TARGET-strip
-DATE=$(date +%Y-%m-%d-%H-%M)
-OCTAVE_DIST_NAME=octave-$DATE
-INSTALLER_PKG=
-
-strip=yes
-installer=no
-while [ $# -gt 0 ]; do
-  case "$1" in
-    --jobs)
-      shift
-      if [ $# -gt 0 ]; then
-        jobs=$1
-        shift
-      else
-        echo "mk-dist: expecting argument for --jobs option" 1>&2
-        exit 1
-      fi
-    ;;
-    --stable)
-      # for stable, use octave-version as the folder
-      OCTAVE_TARGET=stable-octave
-      shift
-    ;;
-    --no-strip)
-      strip=no
-      shift
-    ;;
-    --installer)
-      installer=yes
-      echo "making installer"
-      shift
-    ;;
-    *)
-      echo "mk-dist: unrecognized option: $1" 1>&2
-      exit 1
-    ;;
-  esac
-done
-
-if [ $installer = "yes" ]; then
-  echo "Adding installer to build dependancies"
-  INSTALLER_PKG="nsis"
-fi
-
-echo "deleting previous dist directory..."
-rm -rf $TOPDIR/dist
-
-echo "building octave and dependencies..."
-if [ $jobs -gt 0 ]; then
-  make $OCTAVE_TARGET $INSTALLER_PKG msys-base native-gcc native-binutils octave-forge-packages npp units transfig JOBS=$jobs
-else
-  make $OCTAVE_TARGET $INSTALLER_PKG msys-base native-gcc native-binutils octave-forge-packages npp units transfig
-fi
-
-OCTAVE_VERSION=`head -1 $TOPDIR/octave/octave-version`
-
-if [ "$OCTAVE_TARGET" = "stable-octave" ]; then
-  # if building stable version, use the octave version number aspart of
-  # the dist name
-  OCTAVE_DIST_NAME=octave-$OCTAVE_VERSION
-fi
-# make dist folder
-OCTAVE_DIST_DIR=$TOPDIR/dist/$OCTAVE_DIST_NAME
-mkdir -p $OCTAVE_DIST_DIR
-
-echo "generating lists of files to exclude..."
-
-echo "  native files..."
-cat > $TOPDIR/excluded-native-files << EOF
-./$TARGET
-./bin/$TARGET-*.exe
-EOF
-
-echo "  gcc cross compiler files..."
-cd $TOPDIR/cross-tools/$TOPDIR/$PREFIX
-find . -type f -o -type l | sed "s,./,," > $TOPDIR/excluded-gcc-files
-
-echo "copying files..."
-
-echo "  octave and dependencies..."
-cd $TOPDIR/$PREFIX
-tar -c -h -X $TOPDIR/excluded-gcc-files -f - . | ( cd $OCTAVE_DIST_DIR ; tar xpf - )
-cp $TOPDIR/build_packages.m $OCTAVE_DIST_DIR/src
-
-echo "  octaverc file..."
-cp $TOPDIR/octaverc $OCTAVE_DIST_DIR/share/octave/site/m/startup/octaverc
-
-echo "  native tools..."
-cd $TOPDIR/native-tools/usr
-tar -c -h -X $TOPDIR/excluded-native-files -f - . | ( cd $OCTAVE_DIST_DIR ; tar xpf - )
-
-echo "  libgcc_s_dw2-1.dll to bin directory"
-cd $OCTAVE_DIST_DIR
-cp lib/gcc/i686-pc-mingw32/libgcc_s_dw2-1.dll bin
-
-echo "  msys base files..."
-cd $TOPDIR/msys-base
-tar -c -h -f - . | ( cd $OCTAVE_DIST_DIR ; tar xpf - )
-
-echo "  msys extension files..."
-cd $TOPDIR/msys-extension
-tar -c -h -f - . | ( cd $OCTAVE_DIST_DIR ; tar xpf - )
-
-
-echo "  notepad++..."
-cd $TOPDIR
-tar -c -h -f - notepad++ | ( cd $OCTAVE_DIST_DIR ; tar xpf - )
-cp $TOPDIR/build_packages.m $OCTAVE_DIST_DIR/src
-
-echo "making all files writable by user..."
-chmod -R u+w $OCTAVE_DIST_DIR
-
-if [ $strip = "yes" ]; then
-  echo "stripping files..."
-  cd $OCTAVE_DIST_DIR
-  for f in $(find . -name '*.dll' -o -name '*.exe'); do
-    echo "  $f"
-    $STRIP $f
-  done
-fi
-
-cd $TOPDIR/dist
-
-if [ $installer = "yes" ]; then
-  ../makeinst-script.sh $OCTAVE_DIST_NAME
-
-  echo "Generating installer ..."
-  $TOPDIR/usr/bin/$TARGET-makensis octave.nsi > /dev/null
-
-  if [ -e octave-$OCTAVE_VERSION-installer.exe ]; then
-    echo "Installer created"
-    rm octave.nsi
-  fi
-
-else
-  echo "creating zip file..."
-  zip -q -9 -r $OCTAVE_DIST_DIR.zip $OCTAVE_DIST_NAME
-fi
-