Makefile 3.45 KB
Newer Older
Natanael Copa's avatar
Natanael Copa committed
1
PACKAGE		:= abuild
Natanael Copa's avatar
Natanael Copa committed
2
VERSION		:= 3.4.0
Natanael Copa's avatar
Natanael Copa committed
3

4
prefix		?= /usr
Natanael Copa's avatar
Natanael Copa committed
5
bindir		?= $(prefix)/bin
6
sysconfdir	?= /etc
Natanael Copa's avatar
Natanael Copa committed
7
sharedir		?= $(prefix)/share/$(PACKAGE)
A. Wilcox's avatar
A. Wilcox committed
8
mandir		?= $(prefix)/share/man
Natanael Copa's avatar
Natanael Copa committed
9

Natanael Copa's avatar
Natanael Copa committed
10
SCRIPTS		:= abuild abuild-keygen abuild-sign newapkbuild \
11
		   abump apkgrel buildlab apkbuild-cpan apkbuild-pypi checkapk \
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
12
		   apkbuild-gem-resolver
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
13
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar abuild-gzsplit abuild-sudo abuild-fetch abuild-rmtemp
A. Wilcox's avatar
A. Wilcox committed
14 15
MAN_1_PAGES	:= newapkbuild.1
MAN_5_PAGES	:= APKBUILD.5
Natanael Copa's avatar
Natanael Copa committed
16 17
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install
18
AUTOTOOLS_TOOLCHAIN_FILES := config.sub config.guess
Natanael Copa's avatar
Natanael Copa committed
19 20 21 22 23 24 25 26 27 28 29

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

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

SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
			-e 's:@prefix@:$(prefix):g' \
			-e 's:@sysconfdir@:$(sysconfdir):g' \
Natanael Copa's avatar
Natanael Copa committed
38
			-e 's:@sharedir@:$(sharedir):g' \
Natanael Copa's avatar
Natanael Copa committed
39

40 41 42
SSL_CFLAGS	?= $(shell pkg-config --cflags openssl)
SSL_LDFLAGS	?= $(shell pkg-config --cflags openssl)
SSL_LIBS	?= $(shell pkg-config --libs openssl)
43
ZLIB_LIBS	?= $(shell pkg-config --libs zlib)
Natanael Copa's avatar
Natanael Copa committed
44 45

OBJS-abuild-tar  = abuild-tar.o
46 47
CFLAGS-abuild-tar.o = $(SSL_CFLAGS)
LDFLAGS-abuild-tar = $(SSL_LDFLAGS)
Natanael Copa's avatar
Natanael Copa committed
48
LIBS-abuild-tar = $(SSL_LIBS)
49
LIBS-abuild-tar.static = $(LIBS-abuild-tar)
Natanael Copa's avatar
Natanael Copa committed
50

51 52 53
OBJS-abuild-gzsplit = abuild-gzsplit.o
LDFLAGS-abuild-gzsplit = $(ZLIB_LIBS)

Natanael Copa's avatar
Natanael Copa committed
54
OBJS-abuild-sudo = abuild-sudo.o
55
OBJS-abuild-fetch = abuild-fetch.o
56

Natanael Copa's avatar
Natanael Copa committed
57
.SUFFIXES:	.sh.in .in
Natanael Copa's avatar
Natanael Copa committed
58
%.sh: %.sh.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

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

66
P=$(PACKAGE)-$(VERSION)
Natanael Copa's avatar
Natanael Copa committed
67

68
all:	$(USR_BIN_FILES) functions.sh
Natanael Copa's avatar
Natanael Copa committed
69

70
clean:
Natanael Copa's avatar
Natanael Copa committed
71
	@rm -f $(USR_BIN_FILES) *.o functions.sh
Natanael Copa's avatar
Natanael Copa committed
72

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

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

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

82 83 84
abuild-fetch: abuild-fetch.o
	$(LINK)

85 86 87
abuild-gzsplit: abuild-gzsplit.o
	$(LINK)

Natanael Copa's avatar
Natanael Copa committed
88
abuild-tar.static: abuild-tar.o
89
	$(CC) -static $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) $^ -o $@ $(LIBS-$@)
Natanael Copa's avatar
Natanael Copa committed
90

Natanael Copa's avatar
Natanael Copa committed
91 92 93 94
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"

Natanael Copa's avatar
Natanael Copa committed
95 96 97
check: $(USR_BIN_FILE) functions.sh
	cd tests && bats *.bats

98
install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh
Natanael Copa's avatar
Natanael Copa committed
99
	install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
Natanael Copa's avatar
Natanael Copa committed
100
		$(DESTDIR)/$(sharedir) $(DESTDIR)/$(mandir)/man1 \
A. Wilcox's avatar
A. Wilcox committed
101
		$(DESTDIR)/$(mandir)/man5
102
	for i in $(USR_BIN_FILES); do\
Natanael Copa's avatar
Natanael Copa committed
103 104 105 106 107
		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; \
108
	done
A. Wilcox's avatar
A. Wilcox committed
109 110 111 112 113 114
	for i in $(MAN_1_PAGES); do\
		install -m 644 $$i $(DESTDIR)/$(mandir)/man1/$$i;\
	done
	for i in $(MAN_5_PAGES); do\
		install -m 644 $$i $(DESTDIR)/$(mandir)/man5/$$i;\
	done
115
	if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
116 117
		cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
	fi
118 119
	cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild/
	cp $(AUTOTOOLS_TOOLCHAIN_FILES) $(DESTDIR)/$(prefix)/share/abuild/
Natanael Copa's avatar
Natanael Copa committed
120
	cp functions.sh $(DESTDIR)/$(sharedir)/
Natanael Copa's avatar
Natanael Copa committed
121

Richard Mortier's avatar
Richard Mortier committed
122 123 124
depends depend:
	sudo apk --no-cache add -U openssl-dev zlib-dev

125 126 127 128 129 130 131
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


Dubiousjim's avatar
Dubiousjim committed
132
.PHONY: install