Makefile 2.94 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.0.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)
Natanael Copa's avatar
Natanael Copa committed
9

Natanael Copa's avatar
Natanael Copa committed
10
SCRIPTS		:= abuild abuild-keygen abuild-sign newapkbuild \
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
11 12
		   abump apkgrel buildlab apkbuild-cpan checkapk \
		   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
Natanael Copa's avatar
Natanael Copa committed
14 15
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install
16
AUTOTOOLS_TOOLCHAIN_FILES := config.sub config.guess
Natanael Copa's avatar
Natanael Copa committed
17 18 19 20 21 22 23 24 25 26 27

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

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

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

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

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

48 49 50
OBJS-abuild-gzsplit = abuild-gzsplit.o
LDFLAGS-abuild-gzsplit = $(ZLIB_LIBS)

Natanael Copa's avatar
Natanael Copa committed
51
OBJS-abuild-sudo = abuild-sudo.o
52
OBJS-abuild-fetch = abuild-fetch.o
53

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

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

63
P=$(PACKAGE)-$(VERSION)
Natanael Copa's avatar
Natanael Copa committed
64

65
all:	$(USR_BIN_FILES) functions.sh
Natanael Copa's avatar
Natanael Copa committed
66

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

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

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

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

79 80 81
abuild-fetch: abuild-fetch.o
	$(LINK)

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

Natanael Copa's avatar
Natanael Copa committed
85
abuild-tar.static: abuild-tar.o
Timo Teräs's avatar
Timo Teräs committed
86
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -static $(LIBS-$@) $^
Natanael Copa's avatar
Natanael Copa committed
87

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

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

109 110 111 112 113 114 115
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


Dubiousjim's avatar
Dubiousjim committed
116
.PHONY: install