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