Makefile 2.2 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.5
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

Natanael Copa's avatar
Natanael Copa committed
10
SCRIPTS		:= abuild devbuild buildrepo abuild-keygen \
11
		abuild-sign newapkbuild abump
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
SSL_CFLAGS	:= $(shell pkg-config --cflags openssl)
39 40
SSL_LIBS	:= $(shell pkg-config --libs openssl)

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

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

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

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

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

57
abuild-tar:	abuild-tar.c
58 59 60 61
	$(CC) -o $@ $^ -Wl,--as-needed $(SSL_LIBS)

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

Natanael Copa's avatar
Natanael Copa committed
63 64 65 66 67
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"
	@echo "       make dist"

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

80
dist:	$(P).tar.bz2
Natanael Copa's avatar
Natanael Copa committed
81

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

89 90 91 92 93 94 95
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


Natanael Copa's avatar
Natanael Copa committed
96
.PHONY: install dist