| 1 | # -*- Makefile -*- |
| 2 | |
| 3 | DIR = ../master/ |
| 4 | |
| 5 | FILES = $(shell cd $(DIR); find etc/ -type f) |
| 6 | |
| 7 | TARGET = ../$(MODULE)_$(VERSION)_$(ARCH).deb |
| 8 | |
| 9 | OBJECTS = deb/DEBIAN/preinst \ |
| 10 | deb/DEBIAN/postrm \ |
| 11 | deb/DEBIAN/postinst |
| 12 | |
| 13 | SHELL=/bin/bash |
| 14 | MODULE = $(shell basename `pwd`) |
| 15 | ARCH = all |
| 16 | |
| 17 | .DEFAULT: all |
| 18 | .PHONY: clean deb all |
| 19 | |
| 20 | VERSION = $(shell awk '/^$(MODULE)/ { gsub(/[()]/, ""); print $$2; exit }' changelog) |
| 21 | |
| 22 | |
| 23 | all: $(TARGET) deb |
| 24 | |
| 25 | clean: |
| 26 | rm -rf deb $(OBJECTS) $(TARGETS) |
| 27 | |
| 28 | deb: |
| 29 | rm -rf deb |
| 30 | mkdir --parent deb/etc/webconfig/ deb/etc/default/ deb/DEBIAN |
| 31 | |
| 32 | deb/DEBIAN/preinst: preinst deb $(addprefix $(DIR)/, $(FILES)) $(MAKEFILE_LIST) |
| 33 | rm -f $@ |
| 34 | cat $< > $@~ |
| 35 | for f in $(FILES); do echo '[ -f "/'$$f'" ] && dpkg-divert --add /'$$f; done >>$@~ |
| 36 | echo "exit 0" >>$@~ |
| 37 | chmod +x $@~ |
| 38 | mv $@~ $@ |
| 39 | |
| 40 | deb/DEBIAN/postrm: postrm deb $(addprefix $(DIR)/, $(FILES)) $(MAKEFILE_LIST) |
| 41 | rm -f $@ |
| 42 | cat $< > $@~ |
| 43 | for f in $(FILES); do echo '[ -f "/'$$f'" ] && dpkg-divert --remove /'$$f; done >>$@~ |
| 44 | echo "exit 0" >>$@~ |
| 45 | chmod +x $@~ |
| 46 | mv $@~ $@ |
| 47 | |
| 48 | deb/DEBIAN/postinst: postinst deb |
| 49 | cp $< $@ |
| 50 | |
| 51 | $(TARGET): deb $(OBJECTS) |
| 52 | sed s/@@version@@/$(VERSION)/ control > deb/DEBIAN/control |
| 53 | mkdir -p deb/usr/share/doc/$(MODULE) |
| 54 | cp changelog deb/usr/share/doc/$(MODULE)/changelog |
| 55 | cp -r $(DIR)/* deb/ |
| 56 | fakeroot dpkg --build deb |
| 57 | mv deb.deb $@ |