]> wagnertech.de Git - projects.git/commitdiff
Merge branch 'master' of http://wagnertech.de/git/projects
authorMichael Wagner <michael@wagnertech.de>
Mon, 15 Oct 2018 20:37:01 +0000 (22:37 +0200)
committerMichael Wagner <michael@wagnertech.de>
Mon, 15 Oct 2018 20:37:01 +0000 (22:37 +0200)
debian/mbuild.changelog
debian/mbuild.cp
doc/mbuild.8
doc/mconfigure.1 [new file with mode: 0644]
tools/make/makefile
tools/make/mconfigure
tools/make/rules

index 5346c34d2af3e57e8cc7e0d1468b6dd9bde636be..43d7988bba119a0d58b4c702b61e9fa859d4c9ac 100644 (file)
@@ -1,12 +1,11 @@
 projects (0.2-%BUILD%) unstable; urgency=medium
-
   * Build in svn-Umgebung
-
- -- Michael Wagner <michael@wagnertech.de>  Mon, 18 Apr 2018 09:45:25 +0100
+  * including build script
+  * new options
+  * including pre/post installation scripts
+ -- Michael Wagner <michael@wagnertech.de>  Fr 10. Aug 22:54:48 CEST 2018
 
 projects (0.1-%BUILD%) unstable; urgency=medium
-
   * Build in neuer git-Umgebung
-
  -- Michael Wagner <michael@wagnertech.de>  Mon, 12 Feb 2018 09:45:25 +0100
 
index 0a78def9946e4ec51f673249aee931b97c8215c3..824975c0890d40b67d33c588b47e17c3b627b7e3 100755 (executable)
@@ -9,4 +9,9 @@ cp tools/make/treecopy $base/usr/bin/
 
 mkdir -p $base/usr/share/mbuild/
 cp tools/make/rules $base/usr/share/mbuild/
+cp tools/make/insert_build.sh $base/usr/share/mbuild/
+
+mkdir -p $base/usr/share/man/man8
+gzip -c doc/mbuild.8 >$base/usr/share/man/man8/mbuild.8.gz
+gzip -c doc/mconfigure.1 >$base/usr/share/man/man8/mconfigure.1.gz
 
index 0f7b4f16fe3c0c992a46e9916271568f157e69e0..3209b7b6e6f3265f12c451555c385cdb0eba2c54 100644 (file)
@@ -1,6 +1,6 @@
 .\" Manpage for mbuild.
 .\" Contact mail@wagnertech.de to correct errors or typos.
-.TH man 8 "12 Jul 2018" "0.1" "mbuild man page"
+.TH mbuild 8 "Jul 2018" GNU "WagnerTech Utilities"
 .SH NAME
 mbuild \- build system of WagnerTech UG
 .SH SYNOPSIS
@@ -13,25 +13,59 @@ consists of 3 phases: configuration - compile - pack
 configuration
 is done by the
 .B mconfigure
-script. It determins the verion number from the git/subversion status. Per 
+script. It determins the verion number from the git/subversion status. A
+.B PAKET.changelog
+file is needed. Per 
 default this script also performs compile and pack step.
+
+If a
+.B PAKET.build
+file is present in the debian directory, it is called with a -prepare parameter.
 .TP
 compile
 To perform the compile step a
 .B PAKET.build
-script is needed in the debian directory.
+script is needed in the 
+.B debian 
+directory.
 .TP
 pack
 To perform the pack step a
 .B PAKET.cp
-script is needed in the debian directory.
-
+script and a
+.B PAKET.control
+file are needed in the debian directory. If pre/post installation scripts
+are needed, these files must be also placed in the
+.B debian 
+directory.
 .SH FILES
+.TP
+PAKET.changelog
+Example:
+.br
+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.build
-
+Any executable script file executing the build in the ../build directory
+.TP
 PAKET.cp
+An executable script file copying the artefacts to target paths preposed by $1:
+.br
+cp ../build/my_artefact $1/usr/bin/
+.TP
+PAKET.preinst PAKET.postint PAKET.prerm PAKET.postrm
+Optional pre/post installation scripts
+.TP
+PAKET.control
+Debian control file
+.PP
+These files are expected in a
+.B debian
+directory, placed below the projects main directory.
 .SH SEE ALSO
-make(1), mconfigure(8) 
+make(1), mconfigure(1)
 .SH BUGS
 No known bugs.
 .SH AUTHOR
diff --git a/doc/mconfigure.1 b/doc/mconfigure.1
new file mode 100644 (file)
index 0000000..c5b2eb6
--- /dev/null
@@ -0,0 +1,35 @@
+.\" Manpage for mconfigure.
+.\" Contact mail@wagnertech.de to correct errors or typos.
+.TH mconfigure 1 "Aug 2018" "GNU" "WagnerTech Utilities"
+.SH NAME
+mconfigure \- interface to build system of WagnerTech UG
+.SH SYNOPSIS
+.B mconfigure
+.I paket 
+.B [-cdp]
+.SH DESCRIPTION
+mconfigure builds the package 
+.I paket.
+mconfigure has to be called in the projects base directory containing a directoty named
+.B debian,
+that contains the files described in
+.B mbuild(8).
+.SH OPTIONS
+.TP
+-c
+select configuration step
+.TP
+-d
+select compile step
+.TP
+-p
+select pack step
+.PP
+If no steps are selected all steps are performed.
+.SH SEE ALSO
+mbuild(8): Overview description
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Michael Wagner (michael@wagnertech.de)
+
index 57dc39d5c289631491acbb91df3ddea44f992e8a..9ade43712317e64aa2ad5f6274d07f1aff33e952 100644 (file)
@@ -1,85 +1,34 @@
 # Generic makefile for mBuild build process
 
-# defile default operations
-
-NOP = @echo "No operation for target $@"
-COMPILE = $(NOP)
-COMPILE_TARGET = compile.stamp
-COPY = $(NOP)
-ZIP = zip -r $(project).zip $(project)
-DEB = fakeroot dpkg-deb --build $(project)
-INSERT_BUILD = projects/tools/make/insert_build.sh
 
-#default parameters
-project = default
-SOURCES =
-COPY_PRE =
+# default parameters
+CC = g++
+INSERT_BUILD = /usr/share/mbuild/insert_build.sh
 
-# Load project specification
 include make.pre
 
-.SUFFIXES: .stamp .zip
-
-
-#-----------------------------------------------------------------
-# Hauptziele:
-#
-#               : ohne Parameter wird compiliert
-# - zip         : packt ZIP file
-# - deb         : packt Debian package
-#
-#-----------------------------------------------------------------
-
-compile: $(COMPILE_TARGET)
-       # compile ist fertig
-
-zip: $(project).zip
-       # ZIP file ready
-
-deb: $(project).deb
-       # Debian package ready
-
-version: $(COMPILE_TARGET)
-       $(INSERT_BUILD) $(COMPILE_TARGET) $(build)
+# All Target
+all: $(DEPS) $(SOURCE:%.cpp=%.o) $(TARGET)
 
-#-----------------------------------------------------------------
-# compile steps
-#-----------------------------------------------------------------
-compile.stamp: $(SOURCES)
-       $(COMPILE)
-       @touch compile.stamp
+# Other Targets
+clean:
+       -rm *.o
+       -rm $(TARGET)
 
-#-----------------------------------------------------------------
-# pack steps
-#-----------------------------------------------------------------
 
-copy.stamp: $(COPY_PRE)
-       $(COPY) $(project) $(version) ${arch}
-       @touch copy.stamp
+.PHONY: all make.post
 
-control.stamp: $(project).control
-       mkdir -p $(project)/DEBIAN
-       cp $(project).control $(project)/DEBIAN/control
-       if [ -f $(project).preinst ]; then cp $(project).preinst $(project)/DEBIAN/preinst; fi
-       if [ -f $(project).postinst ]; then cp $(project).postinst $(project)/DEBIAN/postinst; fi
-       if [ -f $(project).prerm ]; then cp $(project).prerm $(project)/DEBIAN/prerm; fi
-       if [ -f $(project).postrm ]; then cp $(project).postrm $(project)/DEBIAN/postrm; fi
-       @touch control.stamp
+%.a: $(SOURCE:%.cpp=%.o)
+       ar r $(TARGET) *.o
 
-$(project).zip: copy.stamp $(project)
-       $(ZIP)
+%.so: $(SOURCE:%.cpp=%.o) $(LDLIBS)
+       $(CXX) -shared -o $(TARGET) *.o $(LDLIBS) $(EXTLIB)
 
-$(project).deb: copy.stamp control.stamp
-       $(DEB)
-       cp $(project).deb $(project)_$(version)$(_arch).deb
+make.pre: ~/build/debian/rules.pre
+       cp ~/build/debian/rules.pre make.pre
 
-#-----------------------------------------------------------------
-# utilities
-#-----------------------------------------------------------------
-clean:
-       -rm *.stamp 2>/dev/null
-       if [ -e $(project).zip ]; then rm $(project).zip; fi
-       if [ -e $(project) ]; then rm -rf $(project); fi
+-include make.post
+# defile default operations
 
 #-----------------------------------------------------------------
 # Build-Regeln
index f745effe4cbc03c25a5ba2202426fd6642e1701c..c164f10bb6b94a3976b59727a1cda6fcb3c7c257 100755 (executable)
@@ -4,9 +4,9 @@ set -e
 function echo_usage {
        echo "usage: mconfigure <package> [options]"
        echo "  -a <arch>"
-       echo "  -c : configure only, no compile, pack"
-       echo "  -d : compile only"
-       echo "  -p : pack only"
+       echo "  -c : configure"
+       echo "  -d : compile"
+       echo "  -p : pack default: do all"
 }
 
 function set_build {
@@ -30,6 +30,9 @@ function set_build {
                version=${tag%%-*}
                version=${version##*_}
                build=${tag#*-}
+       else
+               echo "No configuration system found. Cannot determine version."
+               exit 1
        fi
 }
 
@@ -66,21 +69,19 @@ fi
 
 paket=$1
 
-configure=1
-compile=1
-pack=1
-while getopts ":ap" opt; do
+configure=0
+compile=0
+pack=0
+shift
+while getopts ":acdp" opt; do
        case $opt in
                a) ARCH=$OPTARG
                        ;;
-               c) compile=0
-                       pack=0
+               c) configure=1
                        ;;
-               d)      configure=0
-                       pack=0
+               d)      compile=1
                        ;;
-               p)      configure=0
-                       compile=0
+               p)      pack=1
                        ;;
                \?) echo "Invalid option: -$OPTARG"
                        echo_usage
@@ -93,27 +94,36 @@ while getopts ":ap" opt; do
        esac
 done
 
+# if nothing is selected, select all
+if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ]
+then
+       configure=1
+       compile=1
+       pack=1
+fi
+
 if [ $configure -eq 1 ]
 then
-       echo "export paket=$1" > debian/setenv.sh
-       shift
+       echo "paket=$paket" > debian/rules.pre
+#      shift
        ARCH=""
        cpp_build=0
 
        set_build
        check_version
-       echo "export version=$version" >> debian/setenv.sh
-       echo "export build=$build" >> debian/setenv.sh
+       echo "version=$version" >> debian/rules.pre
+       echo "build=$build" >> debian/rules.pre
 
        # get repository name
-       tmp=$(pwd)
-       pwd=${tmp##*/}
-       pwd=${pwd,,*}
-       echo "export pwd=$pwd" >> debian/setenv.sh
+#      tmp=$(pwd)
+#      pwd=${tmp##*/}
+#      pwd=${pwd,,*}
+#      echo "pwd=$pwd" >> debian/rules.pre
 
        echo "building $paket with build $version-$build"
 
        pushd debian >/dev/null
+       # ./debian -------------------------------------
 
        ln -sf /usr/share/mbuild/rules .
 
@@ -121,8 +131,24 @@ then
        then
                rm -rf tmp
        fi
-       #rm *.stamp 2>/dev/null || true
-       #rm make.pre 2>/dev/null || true
+
+       # check for pre/post installation scripts
+       if [ -f $paket.preinst ]
+       then
+               echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
+       fi
+        if [ -f $paket.postinst ]
+        then
+                echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
+        fi
+        if [ -f $paket.prerm ]
+        then
+                echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
+        fi
+        if [ -f $paket.postrm ]
+        then
+                echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
+        fi
 
        mkdir -p tmp/DEBIAN
 
@@ -135,11 +161,15 @@ then
        fi
 
        popd >/dev/null
+       # ./. ---------------------------------------------
 
        # copy package control
-       if [ ! -f debian/control ]
+       if [ -f debian/$paket.control ]
        then
-               control=$(find etc -name $paket.control)
+               cp debian/$paket.control debian/control
+       else
+               # try old fashoned way
+               control=$(find etc -name $paket.control) || true
                if [ -z "$control" ]
                then
                        echo "warning: control file not found"
@@ -153,34 +183,44 @@ then
                        grep -v "Version:" $control |grep -v "Maintainer:" >> debian/control 
                fi
        fi
+       
+       # build prepare
+       if [ -e debian/$paket.build ]
+       then
+               if [ -e ../build ]
+               then
+                       rm -rf ../build
+                       mkdir ../build
+               fi
+               debian/$paket.build -prepare
+       fi
+       
+       # pack prepare
+       if [ -f debian/$paket.cp -a -f $paket.control ]
+       then
+               echo "PACK=binary" >> debian/rules.pre
+       elif [ -f debian/$paket.cp ]
+       then
+               echo "PACK=zip" >> debian/rules.pre
+       else
+               echo "PACK=version" >> debian/rules.pre
+       fi
 fi
 
-# check for copy file
-#if [ ! -f debian/$paket.cp ]
-#then
-#      # search for copy file
-#      copy=$(find . -name $paket.cp)
-#      if [ -n "$copy" ]
-#      then
-#              echo "ln -sf ../$copy debian/"
-#              ln -sf ../$copy debian/
-#      else
-#              echo "warning: file $paket.cp missing or not executable:"
-#              echo "  this file is necessary for any package production."
-#      fi
-#fi
-
+if [ $compile -eq 1 -a ! -e debian/build.sh ]
+then
+       echo "no debian/build.sh: skipping build step"
+       compile=0
+fi
 if [ $compile -eq 1 ]
 then
        # build artefacts
-       . debian/setenv.sh
        debian/rules build
 fi
 
 if [ $pack -eq 1 ]
 then
        # build package
-       . debian/setenv.sh
-       debian/rules binary
+       debian/rules pack
 fi
 
index da98ee5605b1d7c7777714b023e691484c604f0b..13b9e20cae5754d3f7b7e80273b975a3d83b2448 100755 (executable)
@@ -6,6 +6,8 @@
 NOP = @echo "No operation for target $@"
 DEB = fakeroot dpkg-deb --build debian/tmp
 
+include debian/rules.pre
+
 default:
        echo "no default rule available"
 
@@ -14,7 +16,12 @@ clean:
        -rm -rf debian/tmp
 
 # Bauen der kompilierten Programme und formatierten Dokumente aus den Quellen im Bauverzeichnis
-build:
+build: debian/$(paket).build sync
+       debian/$(paket).build
+       # Build succeeded
+
+pack: $(PACK)
+       # packing succeeded
 
 # Bauen der kompilierten architekturabhängigen Programme aus den Quellen im Bauverzeichnis
 build-arch:
@@ -34,10 +41,19 @@ binary-arch:
 # Erstellen Architektur-unabhängiger (Architecture: all) Binärpakete im übergeordneten Verzeichnis
 binary-indep: copy ../$(paket)_$(version)-$(build)$(_arch).deb
 
+version: $(TARGET)
+       $(INSERT_BUILD) $(TARGET) $(build)
+
+../build:
+       mkdir ../build
+
+sync:
+       bash -c 'for dirs in $$(ls); do rsync -av $$dirs ../build; done'
+
 copy: debian/$(paket).cp
        debian/$(paket).cp debian/tmp
 
-../$(paket)_$(version)-$(build)$(_arch).deb:debian/tmp/DEBIAN/control
+../$(paket)_$(version)-$(build)$(_arch).deb:debian/tmp/DEBIAN/control $(add_inst_tgt)
        $(DEB)
        mv debian/tmp.deb ../$(paket)_$(version)-$(build)$(_arch).deb
 
@@ -51,6 +67,18 @@ debian/changelog: debian/$(paket).changelog debian/setenv.sh
 #      echo " -- Michael Wagner <info@wagnertech.de>  Sun, 11 Feb 2018 20:03:04 +0100" >> debian/changelog
 #      mb_create_changelog
 
+debian/tmp/DEBIAN/preinst: debian/$(paket).preinst
+       cp debian/$(paket).preinst debian/tmp/DEBIAN/preinst
+
+debian/tmp/DEBIAN/postinst: debian/$(paket).postinst
+       cp debian/$(paket).postinst debian/tmp/DEBIAN/postinst
+
+debian/tmp/DEBIAN/prerm: debian/$(paket).prerm
+       cp debian/$(paket).prerm debian/tmp/DEBIAN/prerm
+
+debian/tmp/DEBIAN/postrm: debian/$(paket).postrm
+       cp debian/$(paket).postrm debian/tmp/DEBIAN/postrm
+
 # Load project specification
 -include rules.post