Makefile 3.5 KB
Newer Older
Natanael Copa's avatar
Natanael Copa committed
1
PACKAGE		:= abuild
Natanael Copa's avatar
Natanael Copa committed
2
VERSION		:= 3.6.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

Natanael Copa's avatar
Natanael Copa committed
35
CFLAGS		?= -Wall -Werror -g
36

Natanael Copa's avatar
Natanael Copa committed
37 38 39
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
40
			-e 's:@sharedir@:$(sharedir):g' \
Natanael Copa's avatar
Natanael Copa committed
41

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

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

53 54 55
OBJS-abuild-gzsplit = abuild-gzsplit.o
LDFLAGS-abuild-gzsplit = $(ZLIB_LIBS)

Natanael Copa's avatar
Natanael Copa committed
56
OBJS-abuild-sudo = abuild-sudo.o
57
OBJS-abuild-fetch = abuild-fetch.o
58

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

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

68
P=$(PACKAGE)-$(VERSION)
Natanael Copa's avatar
Natanael Copa committed
69

70
all:	$(USR_BIN_FILES) functions.sh
Natanael Copa's avatar
Natanael Copa committed
71

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

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

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

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

84 85 86
abuild-fetch: abuild-fetch.o
	$(LINK)

87 88 89
abuild-gzsplit: abuild-gzsplit.o
	$(LINK)

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

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

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

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

Richard Mortier's avatar
Richard Mortier committed
124
depends depend:
125
	sudo apk --no-cache -U --virtual .abuild-depends add openssl-dev zlib-dev
Richard Mortier's avatar
Richard Mortier committed
126

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


Dubiousjim's avatar
Dubiousjim committed
134
.PHONY: install