posaune
[projects.git] / tools / make / rules
index 33e72e3..7d0fa32 100755 (executable)
@@ -6,21 +6,33 @@
 NOP = @echo "No operation for target $@"
 DEB = fakeroot dpkg-deb --build debian/tmp
 INSERT_BUILD = /usr/share/mbuild/insert_build.sh
+RSYNC_OPT = -av --exclude="build" --exclude="debian/tmp" --exclude="Packages" --exclude="*Aktuell" --exclude=".*"
+BUILD_DIR = .
+
+std_inst_tgt = debian/tmp/usr/share/doc/$(paket)/copyright debian/tmp/usr/share/doc/$(paket)/README.debian
+changelog_source = debian/$(paket).changelog
 
 include debian/rules.pre
 
-default:
-       echo "no default rule available"
+.PHONY: build
+
+default: $(BUILD)
 
 # Löschen aller kompilierten, erzeugten und nicht benötigten Dateien im Bauverzeichnis
 clean:
        -rm -rf debian/tmp
 
 # Bauen der kompilierten Programme und formatierten Dokumente aus den Quellen im Bauverzeichnis
-build: debian/$(paket).build sync
-       debian/$(paket).build
+build: $(BUILD_DIR)/debian/$(paket).build sync
+       cd $(BUILD_DIR) ; debian/$(paket).build
        # Build succeeded
 
+nobuild:
+       # No build required
+
+install:
+       debian/$(paket).cp $(INSTALL_DIR)
+
 pack: $(PACK)
        # packing succeeded
 
@@ -37,40 +49,49 @@ install:
 binary: binary-arch binary-indep 
 
 # Erstellen Architektur-abhängiger (Architecture: any) Binärpakete im übergeordneten Verzeichnis
-binary-arch:
+binary-arch: $(BINARY_ARCH)
 
 # Erstellen Architektur-unabhängiger (Architecture: all) Binärpakete im übergeordneten Verzeichnis
-binary-indep: copy ../$(paket)_$(version)-$(build)$(_arch).deb
+binary-indep: $(BINARY_INDEP)
 
-version: ~/build/$(TARGET)
-       $(INSERT_BUILD) ~/build/$(TARGET) $(build)
-       cp ~/build/*$(build)* ../
+version: $(BUILD_DIR)/$(TARGET)
+       $(INSERT_BUILD) $(BUILD_DIR)/$(TARGET) $(build)
+       cp $(BUILD_DIR)/*$(build)* ../
 
-../build:
-       mkdir ../build
+$(BUILD_DIR):
+       mkdir $(BUILD_DIR)
 
-sync:
-       bash -c 'for dirs in $$(ls); do rsync -av $$dirs ../build; done'
+sync: $(BUILD_DIR)
+       rsync $(RSYNC_OPT) ./ $(BUILD_DIR)/
 
-copy: debian/$(paket).cp
-       debian/$(paket).cp debian/tmp
+copy: debian/$(paket).cp install
+       create-conffiles debian/tmp
+       touch debian/tmp
 
-../$(paket)_$(version)-$(build)$(_arch).deb:debian/tmp/DEBIAN/control $(add_inst_tgt)
+../$(paket)_$(version)-$(build)_$(arch).deb:debian/tmp/DEBIAN/control $(std_inst_tgt) $(add_inst_tgt) debian/tmp
        $(DEB)
-       mv debian/tmp.deb ../$(paket)_$(version)-$(build)$(_arch).deb
+       mv debian/tmp.deb ../$(paket)_$(version)-$(build)_$(arch).deb
 
 debian/tmp/DEBIAN/control: debian/control debian/changelog
        dpkg-gencontrol
 
 debian/control: debian/$(paket).control
-       cp debian/$(paket).control debian/control
+       sed "s/_DEB_HOST_ARCH/${DEB_HOST_ARCH}/" debian/$(paket).control > debian/control
+
+debian/changelog: $(changelog_source) debian/rules.pre
+       sed "s/%BUILD%/$(build)/" $(changelog_source) > debian/changelog
 
-debian/changelog: debian/$(paket).changelog debian/rules.pre
-       sed "s/%BUILD%/$(build)/" debian/$(paket).changelog > debian/changelog
-#      echo "${pwd} (${build}) unstable; urgency=medium" > debian/changelog
-#      echo "  * generated by mbuild" >> debian/changelog
-#      echo " -- Michael Wagner <info@wagnertech.de>  Sun, 11 Feb 2018 20:03:04 +0100" >> debian/changelog
-#      mb_create_changelog
+debian/tmp/usr/share/doc/$(paket)/changelog: debian/changelog
+       mkdir -p debian/tmp/usr/share/doc/$(paket)
+       cp debian/changelog debian/tmp/usr/share/doc/$(paket)/changelog
+
+debian/tmp/usr/share/doc/$(paket)/copyright: debian/copyright
+       mkdir -p debian/tmp/usr/share/doc/$(paket)
+       cp debian/copyright debian/tmp/usr/share/doc/$(paket)/copyright
+
+debian/tmp/usr/share/doc/$(paket)/README.debian: debian/README.debian
+       mkdir -p debian/tmp/usr/share/doc/$(paket)
+       cp debian/README.debian debian/tmp/usr/share/doc/$(paket)/README.debian
 
 debian/tmp/DEBIAN/preinst: debian/$(paket).preinst
        cp debian/$(paket).preinst debian/tmp/DEBIAN/preinst
@@ -84,10 +105,20 @@ debian/tmp/DEBIAN/prerm: debian/$(paket).prerm
 debian/tmp/DEBIAN/postrm: debian/$(paket).postrm
        cp debian/$(paket).postrm debian/tmp/DEBIAN/postrm
 
+debian/README.debian:
+       echo "developed under:" > debian/README.debian
+       cat /etc/issue >> debian/README.debian
+       echo "Architecture: $(arch)" >> debian/README.debian
+
+debian/copyright:
+       cp /usr/share/mbuild/copyright debian/copyright
+
+debian/default.changelog:
+       @echo "$(paket) ($(version)-$(build)) unstable; urgency=medium" >debian/default.changelog
+       @echo "  * generated" >>debian/default.changelog
+       @echo " -- Michael Wagner <michael@wagnertech.de>  Thu, 11 Feb 2021 10:00:00 +0100" >>debian/default.changelog
+
 # Load project specification
 -include rules.post
 
-# if debian/control is missing, try old mbuild way
-#debian/control:
-#      if [ -e  debian/$(paket).control ]; then echo "trallala"; fi