X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=Makefile;h=6cb5df23330c9a19db3f5effea523728d4b610d4;hb=HEAD;hp=eb4728c21f171ab10bc51fee06ffe4846f193802;hpb=e6bad58d5fb98b9170a75c401b059fdb6b2dce81;p=repo_shell.git diff --git a/Makefile b/Makefile index eb4728c..6cb5df2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ MAIN := repo_shell # Git derives its version "prefix" from tags +PREFIX := /usr/local +PROGRAMS := $(MAIN) mystrtok_test acl_test +SCRIPTS := $(shell ls scripts/*) +PACKAGE := $(MAIN)-package.tar.gz + # Add TMI's mkversion to render files xxx.in -> xxx, updating __appVersion__ # Massage the version coming back because setup.py build to exe only wants # versions of the form a.b.c.d. We'll use this to our advantage to cause @@ -11,24 +16,46 @@ INFILES := $(shell ls *.in 2>/dev/null) INFILES := $(INFILES:%.in=%) #$(warning INFILES $(INFILES)) -PROGRAMS = $(MAIN) mystrtok_test acl_test - all: $(MAIN) -repo_shell: repo_shell.c inih/ini.c git_acl.c mystrtok.c stra.c utility.c match.c version.c +$(MAIN):%: %.c inih/ini.c git_acl.c stringutils.c stra.c utility.c version.c $(CC) -I inih $^ -o $@ -mystrtok_test: mystrtok_test.c mystrtok.c utility.c +mystrtok_test: mystrtok_test.c stringutils.c utility.c $(CC) -g $^ -o $@ -acl_test: acl_test.c git_acl.c inih/ini.c mystrtok.c stra.c utility.c match.c +acl_test: acl_test.c git_acl.c inih/ini.c stringutils.c stra.c utility.c $(CC) -I inih $^ -o $@ -$(INFILES):%: %.in - @sed -e 's|__appVersion__|$(VERSION)|g' < $^ > $@-tmp +$(INFILES):%: %.in .version + @echo "building $@ for $(VERSION)" + @sed -e 's|__appVersion__|$(VERSION)|g' < $< > $@-tmp @diff -q $@-tmp $@ >/dev/null 2>&1 && rm -f $@-tmp || mv $@-tmp $@ +.version: FORCE + @[ "$$(cat $@ 2>/dev/null)" != "$(VERSION)" ] && \ + echo "$(VERSION)" > $@ || true + +install: $(MAIN) $(SCRIPTS) + @install -D -o root -g root -m 4755 $(MAIN) $(PREFIX)/bin/$(MAIN) + @install -o root -g root -m 0755 $(SCRIPTS) $(PREFIX)/bin + +uninstall: + @rm -f $(PREFIX)/bin/$(MAIN) + @for i in $(SCRIPTS); do rm -f $(PREFIX)/bin/$$i; done + +$(PACKAGE): $(MAIN) $(SCRIPTS) + @rm -rf pkg.tmp + @mkdir pkg.tmp + @install -D -o root -g root -m 4755 $(MAIN) pkg.tmp/$(PREFIX)/bin/$(MAIN) + @install -o root -g root -m 0755 $(SCRIPTS) pkg.tmp/$(PREFIX)/bin + @cd pkg.tmp && tar czf ../$(PACKAGE) . + @rm -rf pkg.tmp + @echo "$(PACKAGE) created" + +package: Makefile $(PACKAGE) + clean: @rm -rf $(PROGRAMS) $(INFILES) -.PHONY: all clean $(INFILES) +.PHONY: all install uninstall package clean FORCE