Makefile 1.74 KB
Newer Older
Natanael Copa's avatar
Natanael Copa committed
1

Natanael Copa's avatar
Natanael Copa committed
2
PACKAGE		:= abuild
Natanael Copa's avatar
Natanael Copa committed
3
VERSION		:= 1.15
Natanael Copa's avatar
Natanael Copa committed
4

5 6 7 8
prefix		?= /usr
sysconfdir	?= /etc
datadir		?= $(prefix)/share/$(PACKAGE)
apkcache	?= /var/cache/abuild/apks
Natanael Copa's avatar
Natanael Copa committed
9

Natanael Copa's avatar
Natanael Copa committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
USR_BIN_FILES	:= abuild devbuild mkalpine buildrepo
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install

SCRIPTS		:= $(USR_BIN_FILES)
SCRIPT_SOURCES	:= $(addsuffix .in,$(SCRIPTS))

DISTFILES=$(SCRIPT_SOURCES) $(SAMPLES) Makefile abuild.conf 

GIT_REV		:= $(shell test -d .git && git describe || echo exported)
ifneq ($(GIT_REV), exported)
FULL_VERSION    := $(patsubst $(PACKAGE)-%,%,$(GIT_REV))
FULL_VERSION    := $(patsubst v%,%,$(FULL_VERSION))
else
FULL_VERSION    := $(VERSION)
endif

SED		:= sed
TAR		:= tar

SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
			-e 's:@prefix@:$(prefix):g' \
			-e 's:@sysconfdir@:$(sysconfdir):g' \
33 34
			-e 's:@datadir@:$(datadir):g' \
			-e 's:@apkcache@:$(apkcache):g'
Natanael Copa's avatar
Natanael Copa committed
35 36 37 38 39 40 41 42 43 44 45

.SUFFIXES:	.sh.in .in
.sh.in.sh:
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@

.in:
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@




Natanael Copa's avatar
Natanael Copa committed
46 47
P=$(PACKAGE)-$(VERSION)

Natanael Copa's avatar
Natanael Copa committed
48 49
all: 	$(SCRIPTS)

Natanael Copa's avatar
Natanael Copa committed
50 51 52 53 54
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"
	@echo "       make dist"

55
install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh
Natanael Copa's avatar
Natanael Copa committed
56
	mkdir -p $(DESTDIR)/$(prefix)/bin $(DESTDIR)/$(sysconfdir) \
57
		$(DESTDIR)/$(datadir)
58 59 60
	for i in $(USR_BIN_FILES); do\
		install -m 755 $$i $(DESTDIR)/$(prefix)/bin/$$i;\
	done
61
	if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
62 63
		cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
	fi
64
	cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild
65
	cp functions.sh $(DESTDIR)/$(datadir)/
Natanael Copa's avatar
Natanael Copa committed
66

67
dist:	$(P).tar.bz2
Natanael Copa's avatar
Natanael Copa committed
68

69
$(P).tar.bz2:	$(DISTFILES)
Natanael Copa's avatar
Natanael Copa committed
70 71 72
	rm -rf $(P)
	mkdir -p $(P)
	cp $(DISTFILES) $(P)/
73
	tar -cjf $@ $(P)
Natanael Copa's avatar
Natanael Copa committed
74 75 76
	rm -rf $(P)

.PHONY: install dist