Makefile 2.39 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.11.2
Natanael Copa's avatar
Natanael Copa committed
4

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

Natanael Copa's avatar
Natanael Copa committed
10 11 12
LUA_VERSION	= 5.1
LUA_SHAREDIR	?= $(prefix)/share/lua/$(LUA_VERSION)/

Natanael Copa's avatar
Natanael Copa committed
13
SCRIPTS		:= abuild devbuild buildrepo abuild-keygen \
Natanael Copa's avatar
Natanael Copa committed
14
		abuild-sign newapkbuild abump apkgrel ap buildlab \
15
		apkbuild-cpan
16
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar
Natanael Copa's avatar
Natanael Copa committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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

32
CHMOD		:= chmod
Natanael Copa's avatar
Natanael Copa committed
33 34 35 36 37 38
SED		:= sed
TAR		:= tar

SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
			-e 's:@prefix@:$(prefix):g' \
			-e 's:@sysconfdir@:$(sysconfdir):g' \
39
			-e 's:@datadir@:$(datadir):g' \
40
			-e 's:@abuildrepo@:$(abuildrepo):g'
Natanael Copa's avatar
Natanael Copa committed
41

42
SSL_CFLAGS	:= $(shell pkg-config --cflags openssl)
43 44
SSL_LIBS	:= $(shell pkg-config --libs openssl)

Natanael Copa's avatar
Natanael Copa committed
45 46 47
.SUFFIXES:	.sh.in .in
.sh.in.sh:
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
48
	${CHMOD} +x $@
Natanael Copa's avatar
Natanael Copa committed
49 50 51

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

54
P=$(PACKAGE)-$(VERSION)
Natanael Copa's avatar
Natanael Copa committed
55

56
all: 	$(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
57

58 59
clean:
	@rm -f $(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
60

61
abuild-tar:	abuild-tar.c
62 63 64 65
	$(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
66

Natanael Copa's avatar
Natanael Copa committed
67 68 69 70 71
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"
	@echo "       make dist"

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

86
dist:	$(P).tar.bz2
Natanael Copa's avatar
Natanael Copa committed
87

88
$(P).tar.bz2:	$(DISTFILES)
Natanael Copa's avatar
Natanael Copa committed
89 90 91
	rm -rf $(P)
	mkdir -p $(P)
	cp $(DISTFILES) $(P)/
92
	tar -cjf $@ $(P)
Natanael Copa's avatar
Natanael Copa committed
93 94
	rm -rf $(P)

95 96 97 98 99 100 101
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


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