From c121d33a960cf7fb52dfb4d61afb9add018e0d64 Mon Sep 17 00:00:00 2001
From: Michael Wagner <info@wagnertech.de>
Date: Wed, 3 Jun 2020 12:00:30 +0200
Subject: [PATCH] phpide-d10

---
 debian/mbuild.changelog |  6 +++++
 debian/mbuild.cp        |  2 ++
 doc/mbuild.8            | 18 ++++++++++++++-
 tools/make/mconfigure   | 50 +++++++++++++++++------------------------
 tools/make/rules        |  8 +++----
 verleihnix/.dummy       |  0
 6 files changed, 50 insertions(+), 34 deletions(-)
 create mode 100644 verleihnix/.dummy

diff --git a/debian/mbuild.changelog b/debian/mbuild.changelog
index 67fcbc7..6244599 100644
--- a/debian/mbuild.changelog
+++ b/debian/mbuild.changelog
@@ -1,3 +1,9 @@
+projects (0.6-%BUILD%) unstable; urgency=medium
+  * calls PAKET.prepare (if present) in config step
+  * RSYNC_OPTS in rules.pre
+  * cpp build support
+ -- Michael Wagner <michael@wagnertech.de>  Thu, 11 Apr 2019 22:54:48 +0100
+
 projects (0.5-%BUILD%) unstable; urgency=medium
   * mconfigure -o for Debian 7 downward compatibility
   * works with multiple git tags on the same commit
diff --git a/debian/mbuild.cp b/debian/mbuild.cp
index 5c8b90b..47558c7 100755
--- a/debian/mbuild.cp
+++ b/debian/mbuild.cp
@@ -11,6 +11,8 @@ mkdir -p $base/usr/share/mbuild/
 cp tools/make/rules $base/usr/share/mbuild/
 cp tools/make/insert_build.sh $base/usr/share/mbuild/
 cp tools/make/mMakefile $base/usr/share/mbuild/makefile
+cp tools/make/c_configure.sh $base/usr/share/mbuild/
+cp tools/make/cpp.make $base/usr/share/mbuild/
 
 mkdir -p $base/usr/share/man/man8
 gzip -c doc/mbuild.8 >$base/usr/share/man/man8/mbuild.8.gz
diff --git a/doc/mbuild.8 b/doc/mbuild.8
index 3209b7b..7b26cfc 100644
--- a/doc/mbuild.8
+++ b/doc/mbuild.8
@@ -18,9 +18,19 @@ script. It determins the verion number from the git/subversion status. A
 file is needed. Per 
 default this script also performs compile and pack step.
 
+If a
+.B PAKET.prepare
+file is present in the debian directory, it is called.
+
 If a
 .B PAKET.build
-file is present in the debian directory, it is called with a -prepare parameter.
+file is present in the debian directory, it is called with a -prepare parameter (deprecated).
+The current tree is rsync_ed to ~/build.
+
+If a
+.B PAKET.prebuild
+file is present in the debian directory, it is called in the ~/build directory.
+
 .TP
 compile
 To perform the compile step a
@@ -47,6 +57,12 @@ projects (0.2-%BUILD%) unstable; urgency=medium
   * Build in svn-Umgebung
  -- Michael Wagner <michael@wagnertech.de>  Fr 10. Aug 22:54:48 CEST 2018
 .TP
+PAKET.prepare
+Any executable script file executed in configure step
+.TP
+PAKET.prebuild
+Any executable script file executed in configure step in the ../build directory
+.TP
 PAKET.build
 Any executable script file executing the build in the ../build directory
 .TP
diff --git a/tools/make/mconfigure b/tools/make/mconfigure
index f37f6a3..ed40855 100755
--- a/tools/make/mconfigure
+++ b/tools/make/mconfigure
@@ -14,6 +14,7 @@ function check_unversioned {
 	# has to be called in the projects base directory
 	# result: "M" in stdout or nothing
 	
+	set -e
 	project=$(pwd)
 	project=${project##*/}
 	pushd .. >/dev/null
@@ -28,6 +29,7 @@ function check_unversioned {
 }
 
 function set_build {
+	set -e
 	if [ -e .svn ]
 	then
 		version="0.0"
@@ -53,6 +55,7 @@ function set_build {
 }
 
 function check_version {
+	set -e
 	
 	vline=$(head -1 debian/$paket.changelog)
 	vline=${vline%-*}
@@ -75,9 +78,6 @@ function check_version {
 		exit 1
 	fi
 }
-# to build a package you need ...
-# <package>.cp (optional): copy step for package production
-# <package>.cpp.sh (optional): commands to setup the C++ compile environment
 
 if [ ! -d debian ]
 then
@@ -144,7 +144,6 @@ then
 	
 	echo "paket=$paket" >> debian/setenv.sh
 	echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
-	cpp_build=0
 
 	set_build
 	check_version
@@ -187,18 +186,8 @@ then
 		    echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
 	fi
 	
-	#cat setenv.sh >> rules.pre
-
 	mkdir -p tmp/DEBIAN
 
-	# load util functions for C/C++ - build
-	if [ -f $paket.cpp.sh ]
-	then
-		cpp_build=1
-		. projects/tools/make/c_configure.sh
-		. $paket.cpp.sh
-	fi
-	
 	# add export to setenv.sh
 	sed -i "s/^/export /" setenv.sh
 
@@ -211,23 +200,15 @@ then
 		# proceed
 		echo
 	else
-		# try old fashoned way
-		control=$(find etc -name $paket.control) || true
-		if [ -z "$control" ]
-		then
-			echo "warning: control file not found"
-			echo "  this file is necessary for any package production."
-		else	
-			echo "Source: $paket
-Section: main
-Priority: optional
-Maintainer: WagnerTech UG <mail@wagnertech.de>
-" > debian/$paket.control
-			grep -v "Version:" $control |grep -v "Maintainer:" >> debian/$paket.control 
-		fi
+		echo "warning: control file not found"
+		echo "  this file is necessary for any package production."
 	fi
 	
 	# build prepare
+	if [ -x debian/$paket.prepare ]
+	then
+		debian/$paket.prepare
+	fi
 	if [ -e debian/$paket.build ]
 	then
 		if [ -e ../build ]
@@ -240,6 +221,17 @@ Maintainer: WagnerTech UG <mail@wagnertech.de>
 			debian/rules sync
 			debian/$paket.build -prepare
 		fi
+		# sync build dir
+		. debian/setenv.sh
+		debian/rules sync
+		
+		# executing prebuild
+		if [ -x debian/$paket.prebuild ]
+		then
+			pushd ~/build >/dev/null
+			debian/$paket.prebuild
+			popd >/dev/null
+		fi
 	fi
 	
 	# pack prepare
@@ -264,7 +256,7 @@ fi
 
 if [ $compile -eq 1 -a ! -e debian/$paket.build ]
 then
-	echo "no debian/build.sh: skipping build step"
+	echo "no debian/$paket.build: skipping build step"
 	compile=0
 fi
 if [ $compile -eq 1 ]
diff --git a/tools/make/rules b/tools/make/rules
index aa4f5d5..e446d53 100755
--- a/tools/make/rules
+++ b/tools/make/rules
@@ -6,6 +6,7 @@
 NOP = @echo "No operation for target $@"
 DEB = fakeroot dpkg-deb --build $(oldpack) debian/tmp
 INSERT_BUILD = /usr/share/mbuild/insert_build.sh
+RSYNC_OPT = -av --exclude="build" --exclude="debian/tmp" --exclude="Packages" --exclude=".*"
 
 include debian/rules.pre
 
@@ -18,7 +19,7 @@ clean:
 
 # Bauen der kompilierten Programme und formatierten Dokumente aus den Quellen im Bauverzeichnis
 build: debian/$(paket).build sync
-	debian/$(paket).build
+	cd ../build ; debian/$(paket).build
 	# Build succeeded
 
 pack: $(PACK)
@@ -51,9 +52,8 @@ version: ~/build/$(TARGET)
 ../build:
 	mkdir ../build
 
-sync:
-	#bash -c 'for dirs in $$(ls); do rsync -av $$dirs ../build; done'
-	rsync -av --exclude="build" --exclude="debian/tmp" --exclude="Packages" --exclude=".*" ./ ../build/
+sync: ../build
+	rsync $(RSYNC_OPT) ./ ../build/
 
 copy: debian/$(paket).cp
 	debian/$(paket).cp debian/tmp
diff --git a/verleihnix/.dummy b/verleihnix/.dummy
new file mode 100644
index 0000000..e69de29
-- 
2.20.1