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

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

Natanael Copa's avatar
Natanael Copa committed
11
LUA_VERSION	= 5.2
Natanael Copa's avatar
Natanael Copa committed
12
LUA_SHAREDIR	?= $(prefix)/share/lua/$(LUA_VERSION)/
Natanael Copa's avatar
Natanael Copa committed
13
LUA_SHEBANG	?= /usr/bin/lua$(LUA_VERSION)
Natanael Copa's avatar
Natanael Copa committed
14

15
SCRIPTS		:= abuild buildrepo abuild-keygen abuild-sign newapkbuild \
Natanael Copa's avatar
Natanael Copa committed
16
		   abump apkgrel ap buildlab apkbuild-cpan checkapk
Natanael Copa's avatar
Natanael Copa committed
17
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar abuild-sudo
Natanael Copa's avatar
Natanael Copa committed
18 19
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install
Natanael Copa's avatar
Natanael Copa committed
20
AUTOTOOLS_TOOLCHAIN_FILES := config.sub
Natanael Copa's avatar
Natanael Copa committed
21 22 23 24 25 26 27 28 29 30 31

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

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
SED		:= sed
TAR		:= tar
Natanael Copa's avatar
Natanael Copa committed
35
LINK		= $(CC) $(OBJS-$@) -o $@ $(LDFLAGS) $(LDFLAGS-$@) $(LIBS-$@)
Natanael Copa's avatar
Natanael Copa committed
36 37 38 39

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

Natanael Copa's avatar
Natanael Copa committed
44 45 46
SSL_CFLAGS	= $(shell pkg-config --cflags openssl)
SSL_LIBS	= $(shell pkg-config --libs openssl)

47
LDFLAGS ?=
Natanael Copa's avatar
Natanael Copa committed
48 49 50 51 52 53

OBJS-abuild-tar  = abuild-tar.o
LIBS-abuild-tar = $(SSL_LIBS)
CFLAGS-abuild-tar = $(SSL_CFLAGS)

OBJS-abuild-sudo = abuild-sudo.o
54

Natanael Copa's avatar
Natanael Copa committed
55
.SUFFIXES:	.sh.in .in
Natanael Copa's avatar
Natanael Copa committed
56
%.sh: %.sh.in
Natanael Copa's avatar
Natanael Copa committed
57
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
58
	${CHMOD} +x $@
Natanael Copa's avatar
Natanael Copa committed
59

Natanael Copa's avatar
Natanael Copa committed
60
%: %.in
Natanael Copa's avatar
Natanael Copa committed
61
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
62
	${CHMOD} +x $@
Natanael Copa's avatar
Natanael Copa committed
63

64
P=$(PACKAGE)-$(VERSION)
Natanael Copa's avatar
Natanael Copa committed
65

66
all:	$(USR_BIN_FILES) functions.sh
Natanael Copa's avatar
Natanael Copa committed
67

68
clean:
69
	@rm -f $(USR_BIN_FILES) functions.sh
Natanael Copa's avatar
Natanael Copa committed
70

Natanael Copa's avatar
Natanael Copa committed
71
%.o: %.c
Timo Teräs's avatar
Timo Teräs committed
72
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -c $<
73

Natanael Copa's avatar
Natanael Copa committed
74 75 76 77 78 79 80
abuild-sudo: abuild-sudo.o
	$(LINK)

abuild-tar: abuild-tar.o
	$(LINK)

abuild-tar.static: abuild-tar.o
Timo Teräs's avatar
Timo Teräs committed
81
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -static $(LIBS-$@) $^
Natanael Copa's avatar
Natanael Copa committed
82

Natanael Copa's avatar
Natanael Copa committed
83 84 85 86
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"

Natanael Copa's avatar
Natanael Copa committed
87
install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh aports.lua
Natanael Copa's avatar
Natanael Copa committed
88
	install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
89
		$(DESTDIR)/$(datadir)
90
	for i in $(USR_BIN_FILES); do\
Natanael Copa's avatar
Natanael Copa committed
91 92 93 94 95
		install -m 755 $$i $(DESTDIR)/$(bindir)/$$i;\
	done
	chmod 4111 $(DESTDIR)/$(prefix)/bin/abuild-sudo
	for i in adduser addgroup apk; do \
		ln -fs abuild-sudo $(DESTDIR)/$(bindir)/abuild-$$i; \
96
	done
97
	if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
98 99
		cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
	fi
100 101
	cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild/
	cp $(AUTOTOOLS_TOOLCHAIN_FILES) $(DESTDIR)/$(prefix)/share/abuild/
102
	cp functions.sh $(DESTDIR)/$(datadir)/
Natanael Copa's avatar
Natanael Copa committed
103 104
	mkdir -p $(DESTDIR)$(LUA_SHAREDIR)
	cp aports.lua $(DESTDIR)$(LUA_SHAREDIR)/
Natanael Copa's avatar
Natanael Copa committed
105

106 107 108 109 110 111 112
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


Dubiousjim's avatar
Dubiousjim committed
113
.PHONY: install