]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
change structure makefile with vars
authorBastian Dehn <hhaalo@arcor.de>
Fri, 5 Dec 2025 06:44:35 +0000 (07:44 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 5 Dec 2025 14:31:53 +0000 (15:31 +0100)
Makefile

index 8d22c2d56305f9175551766bc745343fcabe805f..b04dddf0e0fd91d69bf25974f1061cfebf1c9921 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,67 +5,85 @@ ARCHITECTURE = amd64
 VERSION = $(VERSIONNR)$(EXTRA)
 PACKAGENAME = scantopdf-$(VERSION)-$(BUILDVERSION)-$(ARCHITECTURE)
 
+BUILDDIR = build
+PACKAGEDIR = build/$(PACKAGENAME)
+SRCDIR = src
+BINDIR = usr/local/bin
+SHAREDIR = usr/local/share
+
+################################################################################
+.PHONY: all test build package clean
+
 all: test package
 
 test:
        ./tests/scanbasic.bats
 
-build: build/$(PACKAGENAME)/usr/local/bin/scantopdf \
-       build/$(PACKAGENAME)/usr/local/bin/scantopdfgray \
-       build/$(PACKAGENAME)/usr/local/bin/scantopdfbw
+build: $(PACKAGEDIR)/$(BINDIR)/scantopdf \
+       $(PACKAGEDIR)/$(BINDIR)/scantopdfgray \
+       $(PACKAGEDIR)/$(BINDIR)/scantopdfbw
+
+package: build $(BUILDDIR)/$(PACKAGENAME).deb
+
+clean:
+       rm -rf $(BUILDDIR)
 
-build/$(PACKAGENAME)/usr/local/bin:
-       mkdir -p build/$(PACKAGENAME)/usr/local/bin
+################################################################################
 
-build/$(PACKAGENAME)/usr/local/bin/scantopdf: \
-       build/$(PACKAGENAME)/usr/local/bin
-       cat src/scantopdf \
-                       | sed "/@scanbasic.sh@/r src/scanbasic.sh" \
+$(PACKAGEDIR)/$(BINDIR)/scantopdf: \
+       $(SRCDIR)/scantopdf \
+       $(SRCDIR)/scanbasic.sh
+       mkdir -p $(@D)
+       cat $(SRCDIR)/scantopdf \
+                       | sed "/@scanbasic.sh@/r $(SRCDIR)/scanbasic.sh" \
                        | sed "/@scanbasic.sh@/d" \
                        | sed "s/@VERSION@/$(VERSION)/" \
-                       > build/$(PACKAGENAME)/usr/local/bin/scantopdf
-       chmod 755 build/$(PACKAGENAME)/usr/local/bin/scantopdf
+                       > $(PACKAGEDIR)/$(BINDIR)/scantopdf
+       chmod 755 $(PACKAGEDIR)/$(BINDIR)/scantopdf
 
-build/$(PACKAGENAME)/usr/local/bin/scantopdfgray: \
-       build/$(PACKAGENAME)/usr/local/bin
-       cat src/scantopdfgray \
-                       | sed "/@scanbasic.sh@/r src/scanbasic.sh" \
+$(PACKAGEDIR)/$(BINDIR)/scantopdfgray: \
+       $(SRCDIR)/scantopdfgray \
+       $(SRCDIR)/scanbasic.sh
+       mkdir -p $(@D)
+       cat $(SRCDIR)/scantopdfgray \
+                       | sed "/@scanbasic.sh@/r $(SRCDIR)/scanbasic.sh" \
                        | sed "/@scanbasic.sh@/d" \
                        | sed "s/@VERSION@/$(VERSION)/" \
-                       > build/$(PACKAGENAME)/usr/local/bin/scantopdfgray
-       chmod 755 build/$(PACKAGENAME)/usr/local/bin/scantopdfgray
+                       > $(PACKAGEDIR)/$(BINDIR)/scantopdfgray
+       chmod 755 $(PACKAGEDIR)/$(BINDIR)/scantopdfgray
 
-build/$(PACKAGENAME)/usr/local/bin/scantopdfbw: \
-       build/$(PACKAGENAME)/usr/local/bin
+$(PACKAGEDIR)/$(BINDIR)/scantopdfbw: \
+       $(SRCDIR)/scantopdfbw \
+       $(SRCDIR)/scanbasic.sh
+       mkdir -p $(@D)
        cat src/scantopdfbw \
-                       | sed "/@scanbasic.sh@/r src/scanbasic.sh" \
+                       | sed "/@scanbasic.sh@/r $(SRCDIR)/scanbasic.sh" \
                        | sed "/@scanbasic.sh@/d" \
                        | sed "s/@VERSION@/$(VERSION)/" \
-                       > build/$(PACKAGENAME)/usr/local/bin/scantopdfbw
-       chmod 755 build/$(PACKAGENAME)/usr/local/bin/scantopdfbw
+                       > $(PACKAGEDIR)/$(BINDIR)/scantopdfbw
+       chmod 755 $(PACKAGEDIR)/$(BINDIR)/scantopdfbw
 
-build/$(PACKAGENAME)/usr/local/share/scantopdf:
-       mkdir -p build/$(PACKAGENAME)/usr/local/share/scantopdf
+################################################################################
 
-build/$(PACKAGENAME)/usr/local/share/scantopdf/cutpage.html: \
-       build/$(PACKAGENAME)/usr/local/share/scantopdf
-       cp src/cutpage.html build/$(PACKAGENAME)/usr/local/share/scantopdf/cutpage.html
+$(PACKAGEDIR)/$(SHAREDIR)/scantopdf/cutpage.html: \
+       $(SRCDIR)/cutpage.html
+       mkdir -p $(@D)
+       cp $(SRCDIR)/cutpage.html $(PACKAGEDIR)/$(SHAREDIR)/scantopdf/cutpage.html
 
-build/$(PACKAGENAME)/DEBIAN:
-       mkdir -p build/$(PACKAGENAME)/DEBIAN
+################################################################################
 
-build/$(PACKAGENAME)/DEBIAN/control: \
-       build/$(PACKAGENAME)/DEBIAN
-       cat src/control \
+$(PACKAGEDIR)/DEBIAN/control: \
+       $(SRCDIR)/control
+       mkdir -p $(@D)
+       cat $(SRCDIR)/control   \
                | sed "s/@VERSION@/$(VERSION)/" \
-               > build/$(PACKAGENAME)/DEBIAN/control
-
-build/$(PACKAGENAME).deb: build \
-       build/$(PACKAGENAME)/usr/local/share/scantopdf/cutpage.html \
-       build/$(PACKAGENAME)/DEBIAN/control
-       cd build && dpkg-deb --build --root-owner-group $(PACKAGENAME)
+               > $(PACKAGEDIR)/DEBIAN/control
 
-package: build/$(PACKAGENAME).deb
-
-clean:
-       rm -rf build
\ No newline at end of file
+$(BUILDDIR)/$(PACKAGENAME).deb: \
+       $(PACKAGEDIR)/$(BINDIR)/scantopdf \
+       $(PACKAGEDIR)/$(BINDIR)/scantopdfgray \
+       $(PACKAGEDIR)/$(BINDIR)/scantopdfbw \
+       $(PACKAGEDIR)/$(SHAREDIR)/scantopdf/cutpage.html \
+       $(PACKAGEDIR)/DEBIAN/control
+       mkdir -p $(@D)
+       cd build && dpkg-deb --build --root-owner-group $(PACKAGENAME)
\ No newline at end of file