Makefile 2.99 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

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

23
DISTFILES=$(SCRIPT_SOURCES) $(SAMPLES) Makefile abuild.conf
Natanael Copa's avatar
Natanael Copa committed
24 25 26 27 28 29 30 31 32

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

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

SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
			-e 's:@prefix@:$(prefix):g' \
			-e 's:@sysconfdir@:$(sysconfdir):g' \
41
			-e 's:@datadir@:$(datadir):g' \
42
			-e 's:@abuildrepo@:$(abuildrepo):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)
Natanael Copa's avatar
Natanael Copa committed
67

68 69
clean:
	@rm -f $(USR_BIN_FILES)
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 87
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"
	@echo "       make dist"

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

107
dist:	$(P).tar.bz2
Natanael Copa's avatar
Natanael Copa committed
108

109
$(P).tar.bz2:	$(DISTFILES)
Natanael Copa's avatar
Natanael Copa committed
110 111 112
	rm -rf $(P)
	mkdir -p $(P)
	cp $(DISTFILES) $(P)/
113
	tar -cjf $@ $(P)
Natanael Copa's avatar
Natanael Copa committed
114 115
	rm -rf $(P)

116 117 118 119 120 121 122
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


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