From c38f830abf1e54cb5a2fd1ec94c34181734ae5ae Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 5 Dec 2025 07:44:35 +0100 Subject: [PATCH] change structure makefile with vars --- Makefile | 102 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index 8d22c2d..b04dddf 100644 --- 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 -- 2.47.3