Makefile 2.74 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.25.0_rc1
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
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
14
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar abuild-sudo abuild-fetch
Natanael Copa's avatar
Natanael Copa committed
15 16
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install
Natanael Copa's avatar
Natanael Copa committed
17
AUTOTOOLS_TOOLCHAIN_FILES := config.sub
Natanael Copa's avatar
Natanael Copa committed
18 19 20 21 22 23 24 25 26 27 28

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

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

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

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

43
LDFLAGS ?=
Natanael Copa's avatar
Natanael Copa committed
44 45 46 47 48 49

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

OBJS-abuild-sudo = abuild-sudo.o
50
OBJS-abuild-fetch = abuild-fetch.o
51

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

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

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

63
all:	$(USR_BIN_FILES) functions.sh
Natanael Copa's avatar
Natanael Copa committed
64

65
clean:
66
	@rm -f $(USR_BIN_FILES) functions.sh
Natanael Copa's avatar
Natanael Copa committed
67

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

Natanael Copa's avatar
Natanael Copa committed
71 72 73 74 75 76
abuild-sudo: abuild-sudo.o
	$(LINK)

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

77 78 79
abuild-fetch: abuild-fetch.o
	$(LINK)

Natanael Copa's avatar
Natanael Copa committed
80
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
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"

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