Makefile 1.9 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.0_rc9
Natanael Copa's avatar
Natanael Copa committed
4

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

Natanael Copa's avatar
Natanael Copa committed
10
SCRIPTS		:= abuild devbuild mkalpine buildrepo abuild-keygen abuild-sign
11
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar
Natanael Copa's avatar
Natanael Copa committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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

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
SSL_LIBS	:= $(shell pkg-config --libs openssl)

Natanael Copa's avatar
Natanael Copa committed
38 39 40 41 42 43 44
.SUFFIXES:	.sh.in .in
.sh.in.sh:
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@

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

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

47
all: 	$(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
48

49 50
clean:
	@rm -f $(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
51

52 53
abuild-tar:	abuild-tar.c
	$(CC) -o $@ $(SSL_LIBS) $^
Natanael Copa's avatar
Natanael Copa committed
54

Natanael Copa's avatar
Natanael Copa committed
55 56 57 58 59
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"
	@echo "       make dist"

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

72
dist:	$(P).tar.bz2
Natanael Copa's avatar
Natanael Copa committed
73

74
$(P).tar.bz2:	$(DISTFILES)
Natanael Copa's avatar
Natanael Copa committed
75 76 77
	rm -rf $(P)
	mkdir -p $(P)
	cp $(DISTFILES) $(P)/
78
	tar -cjf $@ $(P)
Natanael Copa's avatar
Natanael Copa committed
79 80 81
	rm -rf $(P)

.PHONY: install dist