Makefile 2.77 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.14.3
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 12 13
LUA_VERSION	= 5.1
LUA_SHAREDIR	?= $(prefix)/share/lua/$(LUA_VERSION)/

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

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

31
CHMOD		:= chmod
Natanael Copa's avatar
Natanael Copa committed
32 33
SED		:= sed
TAR		:= tar
Natanael Copa's avatar
Natanael Copa committed
34
LINK		= $(CC) $(OBJS-$@) -o $@ $(LDFLAGS) $(LDFLAGS-$@) $(LIBS-$@)
Natanael Copa's avatar
Natanael Copa committed
35 36 37 38

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

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

45
LDFLAGS ?=
Natanael Copa's avatar
Natanael Copa committed
46 47 48 49 50 51

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

OBJS-abuild-sudo = abuild-sudo.o
52

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

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

62
P=$(PACKAGE)-$(VERSION)
Natanael Copa's avatar
Natanael Copa committed
63

64
all:	$(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
65

66 67
clean:
	@rm -f $(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
68

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

Natanael Copa's avatar
Natanael Copa committed
72 73 74 75 76 77 78
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
79
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -static $(LIBS-$@) $^
Natanael Copa's avatar
Natanael Copa committed
80

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

Natanael Copa's avatar
Natanael Copa committed
85
install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh aports.lua
Natanael Copa's avatar
Natanael Copa committed
86
	install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
87
		$(DESTDIR)/$(datadir)
88
	for i in $(USR_BIN_FILES); do\
Natanael Copa's avatar
Natanael Copa committed
89 90 91 92 93
		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; \
94
	done
95
	if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
96 97
		cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
	fi
98 99
	cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild/
	cp $(AUTOTOOLS_TOOLCHAIN_FILES) $(DESTDIR)/$(prefix)/share/abuild/
100
	cp functions.sh $(DESTDIR)/$(datadir)/
Natanael Copa's avatar
Natanael Copa committed
101 102
	mkdir -p $(DESTDIR)$(LUA_SHAREDIR)
	cp aports.lua $(DESTDIR)$(LUA_SHAREDIR)/
Natanael Copa's avatar
Natanael Copa committed
103

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


Dubiousjim's avatar
Dubiousjim committed
111
.PHONY: install