Makefile 2.76 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.29.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
13
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar abuild-sudo abuild-fetch
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)
Natanael Copa's avatar
Natanael Copa committed
41 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 48
LIBS-abuild-tar = $(SSL_LIBS)

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

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

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

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

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

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

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

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

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

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

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

Natanael Copa's avatar
Natanael Copa committed
82 83 84 85
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"

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

103 104 105 106 107 108 109
.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


Dubiousjim's avatar
Dubiousjim committed
110
.PHONY: install