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