Skip to content
Snippets Groups Projects
Makefile 2.77 KiB
Newer Older
Natanael Copa's avatar
Natanael Copa committed

Natanael Copa's avatar
Natanael Copa committed
PACKAGE		:= abuild
Natanael Copa's avatar
Natanael Copa committed
VERSION		:= 2.14.3
Natanael Copa's avatar
Natanael Copa committed

prefix		?= /usr
Natanael Copa's avatar
Natanael Copa committed
bindir		?= $(prefix)/bin
sysconfdir	?= /etc
datadir		?= $(prefix)/share/$(PACKAGE)
abuildrepo	?= ~/.cache/abuild
Natanael Copa's avatar
Natanael Copa committed

LUA_VERSION	= 5.1
LUA_SHAREDIR	?= $(prefix)/share/lua/$(LUA_VERSION)/

SCRIPTS		:= abuild buildrepo abuild-keygen abuild-sign newapkbuild \
Natanael Copa's avatar
Natanael Copa committed
		   abump apkgrel ap buildlab apkbuild-cpan checkapk
Natanael Copa's avatar
Natanael Copa committed
USR_BIN_FILES	:= $(SCRIPTS) abuild-tar abuild-sudo
Natanael Copa's avatar
Natanael Copa committed
SAMPLES		:= sample.APKBUILD sample.initd sample.confd \
		sample.pre-install sample.post-install
AUTOTOOLS_TOOLCHAIN_FILES := config.sub config.guess
Natanael Copa's avatar
Natanael Copa committed

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

Natanael Copa's avatar
Natanael Copa committed
SED		:= sed
TAR		:= tar
Natanael Copa's avatar
Natanael Copa committed
LINK		= $(CC) $(OBJS-$@) -o $@ $(LDFLAGS) $(LDFLAGS-$@) $(LIBS-$@)
Natanael Copa's avatar
Natanael Copa committed

SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
			-e 's:@prefix@:$(prefix):g' \
			-e 's:@sysconfdir@:$(sysconfdir):g' \
			-e 's:@datadir@:$(datadir):g' \
			-e 's:@abuildrepo@:$(abuildrepo):g'
Natanael Copa's avatar
Natanael Copa committed
SSL_CFLAGS	= $(shell pkg-config --cflags openssl)
SSL_LIBS	= $(shell pkg-config --libs openssl)

Natanael Copa's avatar
Natanael Copa committed

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

OBJS-abuild-sudo = abuild-sudo.o
Natanael Copa's avatar
Natanael Copa committed
.SUFFIXES:	.sh.in .in
Natanael Copa's avatar
Natanael Copa committed
%.sh: %.sh.in
Natanael Copa's avatar
Natanael Copa committed
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
Natanael Copa's avatar
Natanael Copa committed
%: %.in
Natanael Copa's avatar
Natanael Copa committed
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
P=$(PACKAGE)-$(VERSION)
clean:
	@rm -f $(USR_BIN_FILES)
Natanael Copa's avatar
Natanael Copa committed
%.o: %.c
Timo Teräs's avatar
Timo Teräs committed
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -c $<
Natanael Copa's avatar
Natanael Copa committed
abuild-sudo: abuild-sudo.o
	$(LINK)

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

abuild-tar.static: abuild-tar.o
Timo Teräs's avatar
Timo Teräs committed
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -static $(LIBS-$@) $^
Natanael Copa's avatar
Natanael Copa committed
help:
	@echo "$(P) makefile"
	@echo "usage: make install [ DESTDIR=<path> ]"

install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh aports.lua
Natanael Copa's avatar
Natanael Copa committed
	install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
		$(DESTDIR)/$(datadir)
	for i in $(USR_BIN_FILES); do\
Natanael Copa's avatar
Natanael Copa committed
		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; \
	if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
		cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
	fi
	cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild/
	cp $(AUTOTOOLS_TOOLCHAIN_FILES) $(DESTDIR)/$(prefix)/share/abuild/
	cp functions.sh $(DESTDIR)/$(datadir)/
	mkdir -p $(DESTDIR)$(LUA_SHAREDIR)
	cp aports.lua $(DESTDIR)$(LUA_SHAREDIR)/
Natanael Copa's avatar
Natanael Copa committed

.gitignore: Makefile
	echo "*.tar.bz2" > $@
	for i in $(USR_BIN_FILES); do\
		echo $$i >>$@;\
	done


Jim Pryor's avatar
Jim Pryor committed
.PHONY: install