Makefile 1.97 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		:= 2.2
Natanael Copa's avatar
Natanael Copa committed
4

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

10 11
SCRIPTS		:= abuild devbuild mkalpine buildrepo abuild-keygen \
		abuild-sign newapkbuild
12
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar
Natanael Copa's avatar
Natanael Copa committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install

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

28
CHMOD		:= chmod
Natanael Copa's avatar
Natanael Copa committed
29 30 31 32 33 34
SED		:= sed
TAR		:= tar

SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
			-e 's:@prefix@:$(prefix):g' \
			-e 's:@sysconfdir@:$(sysconfdir):g' \
35
			-e 's:@datadir@:$(datadir):g' \
36
			-e 's:@abuildrepo@:$(abuildrepo):g'
Natanael Copa's avatar
Natanael Copa committed
37

38 39
SSL_LIBS	:= $(shell pkg-config --libs openssl)

Natanael Copa's avatar
Natanael Copa committed
40 41 42
.SUFFIXES:	.sh.in .in
.sh.in.sh:
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
43
	${CHMOD} +x $@
Natanael Copa's avatar
Natanael Copa committed
44 45 46

.in:
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
47
	${CHMOD} +x $@
Natanael Copa's avatar
Natanael Copa committed
48

49
P=$(PACKAGE)-$(VERSION)
Natanael Copa's avatar
Natanael Copa committed
50

51
all: 	$(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
52

53 54
clean:
	@rm -f $(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
55

56 57
abuild-tar:	abuild-tar.c
	$(CC) -o $@ $(SSL_LIBS) $^
Natanael Copa's avatar
Natanael Copa committed
58

Natanael Copa's avatar
Natanael Copa committed
59 60 61 62 63
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"
	@echo "       make dist"

64
install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh
Natanael Copa's avatar
Natanael Copa committed
65
	mkdir -p $(DESTDIR)/$(prefix)/bin $(DESTDIR)/$(sysconfdir) \
66
		$(DESTDIR)/$(datadir)
67 68 69
	for i in $(USR_BIN_FILES); do\
		install -m 755 $$i $(DESTDIR)/$(prefix)/bin/$$i;\
	done
70
	if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
71 72
		cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
	fi
73
	cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild
74
	cp functions.sh $(DESTDIR)/$(datadir)/
Natanael Copa's avatar
Natanael Copa committed
75

76
dist:	$(P).tar.bz2
Natanael Copa's avatar
Natanael Copa committed
77

78
$(P).tar.bz2:	$(DISTFILES)
Natanael Copa's avatar
Natanael Copa committed
79 80 81
	rm -rf $(P)
	mkdir -p $(P)
	cp $(DISTFILES) $(P)/
82
	tar -cjf $@ $(P)
Natanael Copa's avatar
Natanael Copa committed
83 84 85
	rm -rf $(P)

.PHONY: install dist