| 1 |
|
| 2 | PACKAGE := abuild
|
| 3 | VERSION := 2.0_rc8
|
| 4 |
|
| 5 | prefix ?= /usr
|
| 6 | sysconfdir ?= /etc
|
| 7 | datadir ?= $(prefix)/share/$(PACKAGE)
|
| 8 | apkcache ?= ~/.cache/apks
|
| 9 |
|
| 10 | SCRIPTS := abuild devbuild mkalpine buildrepo abuild-keygen abuild-sign
|
| 11 | USR_BIN_FILES := $(SCRIPTS) abuild-tar
|
| 12 | SAMPLES := sample.APKBUILD sample.initd sample.confd \
|
| 13 | sample.pre-install sample.post-install
|
| 14 |
|
| 15 | SCRIPT_SOURCES := $(addsuffix .in,$(SCRIPTS))
|
| 16 |
|
| 17 | DISTFILES=$(SCRIPT_SOURCES) $(SAMPLES) Makefile abuild.conf
|
| 18 |
|
| 19 | GIT_REV := $(shell test -d .git && git describe || echo exported)
|
| 20 | ifneq ($(GIT_REV), exported)
|
| 21 | FULL_VERSION := $(patsubst $(PACKAGE)-%,%,$(GIT_REV))
|
| 22 | FULL_VERSION := $(patsubst v%,%,$(FULL_VERSION))
|
| 23 | else
|
| 24 | FULL_VERSION := $(VERSION)
|
| 25 | endif
|
| 26 |
|
| 27 | SED := sed
|
| 28 | TAR := tar
|
| 29 |
|
| 30 | SED_REPLACE := -e 's:@VERSION@:$(FULL_VERSION):g' \
|
| 31 | -e 's:@prefix@:$(prefix):g' \
|
| 32 | -e 's:@sysconfdir@:$(sysconfdir):g' \
|
| 33 | -e 's:@datadir@:$(datadir):g' \
|
| 34 | -e 's:@apkcache@:$(apkcache):g'
|
| 35 |
|
| 36 | SSL_LIBS := $(shell pkg-config --libs openssl)
|
| 37 |
|
| 38 | .SUFFIXES: .sh.in .in
|
| 39 | .sh.in.sh:
|
| 40 | ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
| 41 |
|
| 42 | .in:
|
| 43 | ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
| 44 |
|
| 45 | P=$(PACKAGE)-$(VERSION)
|
| 46 |
|
| 47 | all: $(USR_BIN_FILES)
|
| 48 |
|
| 49 | clean:
|
| 50 | @rm -f $(USR_BIN_FILES)
|
| 51 |
|
| 52 | abuild-tar: abuild-tar.c
|
| 53 | $(CC) -o $@ $(SSL_LIBS) $^
|
| 54 |
|
| 55 | help:
|
| 56 | @echo "$(P) makefile"
|
| 57 | @echo "usage: make install [ DESTDIR=<path> ]"
|
| 58 | @echo " make dist"
|
| 59 |
|
| 60 | install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh
|
| 61 | mkdir -p $(DESTDIR)/$(prefix)/bin $(DESTDIR)/$(sysconfdir) \
|
| 62 | $(DESTDIR)/$(datadir)
|
| 63 | for i in $(USR_BIN_FILES); do\
|
| 64 | install -m 755 $$i $(DESTDIR)/$(prefix)/bin/$$i;\
|
| 65 | done
|
| 66 | if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
|
| 67 | cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
|
| 68 | fi
|
| 69 | cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild
|
| 70 | cp functions.sh $(DESTDIR)/$(datadir)/
|
| 71 |
|
| 72 | dist: $(P).tar.bz2
|
| 73 |
|
| 74 | $(P).tar.bz2: $(DISTFILES)
|
| 75 | rm -rf $(P)
|
| 76 | mkdir -p $(P)
|
| 77 | cp $(DISTFILES) $(P)/
|
| 78 | tar -cjf $@ $(P)
|
| 79 | rm -rf $(P)
|
| 80 |
|
| 81 | .PHONY: install dist
|