Makefile 1.56 KB
Newer Older
1 2 3 4 5 6 7 8 9
# Makefile - one file to rule them all, one file to bind them
#
# Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi>
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it 
# under the terms of the GNU General Public License version 3 as published
# by the Free Software Foundation. See http://www.gnu.org/ for details.

10
PACKAGE := apk-tools
Timo Teräs's avatar
Timo Teräs committed
11
VERSION := 2.0_pre10
12

13 14 15 16 17 18 19
GIT_REV := $(shell git describe || echo exported)
ifneq ($(GIT_REV), exported)
ifneq ($(filter apk-tools-$(VERSION)%, $(GIT_REV)),)
FULL_VERSION := $(patsubst apk-tools-%,%,$(GIT_REV))
else
FULL_VERSION := $(GIT_REV)
endif
20 21 22 23 24 25 26 27
else
FULL_VERSION := $(VERSION)
endif

CC=gcc
INSTALL=install
INSTALLDIR=$(INSTALL) -d

28 29 30 31
CFLAGS?=-g -Werror -Wall -Wstrict-prototypes
CFLAGS+=-D_GNU_SOURCE -std=gnu99 -DAPK_VERSION=\"$(FULL_VERSION)\"

LDFLAGS?=-g
Natanael Copa's avatar
Natanael Copa committed
32
LDFLAGS+=-nopie
33
LIBS=/usr/lib/libz.a
34 35 36 37 38

ifeq ($(STATIC),yes)
CFLAGS+=-fno-stack-protector
LDFLAGS+=-static
endif
39 40

DESTDIR=
41
SBINDIR=/sbin
42 43 44 45
CONFDIR=/etc/apk
MANDIR=/usr/share/man
DOCDIR=/usr/share/doc/apk

46
SUBDIRS=src
47

48
.PHONY: compile install clean all static
49 50 51

all: compile

52 53 54
static:
	$(MAKE) $(MFLAGS) -C src apk.static

55 56 57 58 59 60 61
compile install clean::
	@for i in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$i $(MAKECMDGOALS); done

install::
	$(INSTALLDIR) $(DESTDIR)$(DOCDIR)
	$(INSTALL) README $(DESTDIR)$(DOCDIR)

Natanael Copa's avatar
Natanael Copa committed
62 63 64
clean::
	rm -rf $(TARBALL)

65
TARBALL := $(PACKAGE)-$(VERSION).tar.bz2
Natanael Copa's avatar
Natanael Copa committed
66 67
dist:	$(TARBALL)
$(TARBALL):
68 69 70 71 72
	rm -rf $(PACKAGE)
	git clone . $(PACKAGE)
	cd $(PACKAGE) && (cd .. && git diff) | patch -p1
	tar -cjf $@ $(PACKAGE)
	rm -rf $(PACKAGE)
73 74

.EXPORT_ALL_VARIABLES: