Makefile 3.3 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		:= 3.4.0
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)
A. Wilcox's avatar
A. Wilcox committed
9
mandir		?= $(prefix)/share/man
Natanael Copa's avatar
Natanael Copa committed
10

Natanael Copa's avatar
Natanael Copa committed
11
SCRIPTS		:= abuild abuild-keygen abuild-sign newapkbuild \
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
12 13
		   abump apkgrel buildlab apkbuild-cpan checkapk \
		   apkbuild-gem-resolver
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
14
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar abuild-gzsplit abuild-sudo abuild-fetch abuild-rmtemp
A. Wilcox's avatar
A. Wilcox committed
15 16
MAN_1_PAGES	:= newapkbuild.1
MAN_5_PAGES	:= APKBUILD.5
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' \
Natanael Copa's avatar
Natanael Copa committed
40

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

120 121 122 123 124 125 126
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


Dubiousjim's avatar
Dubiousjim committed
127
.PHONY: install