Makefile 3.26 KB
Newer Older
Natanael Copa's avatar
Natanael Copa committed
1

2
PACKAGE		:= abuild
3
VERSION		:= 3.3.0_pre2
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 \
12 13
		   abump apkgrel buildlab apkbuild-cpan checkapk \
		   apkbuild-gem-resolver
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
17 18
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install
19
AUTOTOOLS_TOOLCHAIN_FILES := config.sub config.guess
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
32 33
SED		:= sed
TAR		:= tar
Natanael Copa's avatar
Natanael Copa committed
34
LINK		= $(CC) $(OBJS-$@) -o $@ $(LDFLAGS) $(LDFLAGS-$@) $(LIBS-$@)
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' \
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 50
LIBS-abuild-tar = $(SSL_LIBS)

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

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

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

66
P=$(PACKAGE)-$(VERSION)
67

68
all:	$(USR_BIN_FILES) functions.sh
69

70
clean:
71
	@rm -f $(USR_BIN_FILES) functions.sh
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
Timo Teräs's avatar
Timo Teräs committed
89
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -static $(LIBS-$@) $^
90

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

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

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


Dubiousjim's avatar
Dubiousjim committed
126
.PHONY: install