Makefile 2.34 KB
Newer Older
1
PKGDEPS := openssl zlib
2
PKG_CONFIG ?= pkg-config
3
LUAAPK ?= yes
Timo Teräs's avatar
Timo Teräs committed
4

5 6
# lua module
ifneq ($(LUAAPK),)
Natanael Copa's avatar
Natanael Copa committed
7 8 9
LUA_VERSION		?= 5.2
LUA_PC			?= lua$(LUA_VERSION)
LUA_LIBDIR		?= /usr/lib/lua/$(LUA_VERSION)
10
LIBAPK			:= YesPlease
Natanael Copa's avatar
Natanael Copa committed
11 12
shlibs-y		+= apk.so
apk.so-objs		:= lua-apk.o
Natanael Copa's avatar
Natanael Copa committed
13 14
CFLAGS_lua-apk.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" \
			   $(shell $(PKG_CONFIG) $(LUA_PC) --cflags)
15
LUA_LIB-y		:= $(obj)/apk.so
16
install-LUA_LIB-y	:= $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) && \
17 18
			   $(INSTALL) $(LUA_LIB-y) $(DESTDIR)$(LUA_LIBDIR)
endif
Natanael Copa's avatar
Natanael Copa committed
19

20
ifeq ($(shell $(PKG_CONFIG) --print-errors --exists $(PKGDEPS) || echo fail),fail)
21 22 23
$(error Build dependencies are not met)
endif

24
progs-y			+= apk
25
apk-objs		:= apk.o add.o del.o fix.o update.o info.o \
Natanael Copa's avatar
Natanael Copa committed
26
			   search.o upgrade.o cache.o ver.o index.o fetch.o \
Timo Teräs's avatar
Timo Teräs committed
27
			   audit.o verify.o dot.o policy.o stats.o
Natanael Copa's avatar
Natanael Copa committed
28

Timo Teräs's avatar
Timo Teräs committed
29
libapk.so-objs		:= common.o database.o package.o archive.o \
30
			   version.o io.o url.o gunzip.o blob.o hash.o print.o \
31
			   commit.o solver.o
32 33

ifeq ($(TEST),y)
34 35
progs-y			+= apk-test
apk-test-objs		:= apk-test.o $(filter-out apk.o, $(apk-objs))
36
endif
37 38 39

ifeq ($(SHARED_LIBAPK),)
apk-objs		+= $(libapk.so-objs)
40
apk-test-objs		+= $(libapk.so-objs)
41
apk.so-objs		+= $(libapk.so-objs)
42 43 44
else
LIBAPK			:= YesPlease
LIBS_apk		:= -lapk
45
LIBS_apk-test		:= -lapk
46
LIBS_apk.so		:= -L$(obj) -lapk
47 48
endif

49
ifneq ($(SHARED_LIBAPK),)
50 51
shlibs-y		+= libapk.so
LIBAPK-y		:= $(obj)/libapk.so
52
install-LIBAPK-y	:= $(INSTALLDIR) $(DESTDIR)$(LIBDIR) && \
53 54 55
			   $(INSTALL) $(LIBAPK-y) $(DESTDIR)$(LIBDIR)
endif

56
CFLAGS_ALL		+= -D_ATFILE_SOURCE
57
CFLAGS_apk.o		:= -DAPK_VERSION=\"$(FULL_VERSION)\"
58
CFLAGS_apk-static.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE
59
CFLAGS_apk-test.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE -DTEST_MODE
60

61
progs-$(STATIC)		+= apk.static
62
apk.static-objs		:= $(filter-out apk.o,$(apk-objs)) apk-static.o
63
LDFLAGS_apk.static	:= -static
64
LIBS_apk.static		:= -Wl,--as-needed -ldl -Wl,--no-as-needed
65 66
LDFLAGS_apk		+= -L$(obj)
LDFLAGS_apk-test	+= -L$(obj)
67

68
CFLAGS_ALL		+= $(shell $(PKG_CONFIG) --cflags $(PKGDEPS))
69 70
LIBS			:=  /usr/lib/libfetch.a \
			   -Wl,--as-needed \
71
				$(shell $(PKG_CONFIG) --libs $(PKGDEPS)) \
72
			   -Wl,--no-as-needed
73

74
$(obj)/apk: $(LIBAPK-y)
Natanael Copa's avatar
Natanael Copa committed
75

76
$(obj)/apk.so: $(LIBAPK-y)
Natanael Copa's avatar
Natanael Copa committed
77

78 79
install: $(obj)/apk $(LIBAPK-y) $(LUA_LIB-y)
	$(INSTALLDIR) $(DESTDIR)$(SBINDIR)
80
	$(INSTALL) $(obj)/apk $(DESTDIR)$(SBINDIR)
81 82
	$(install-LIBAPK-y)
	$(install-LUA_LIB-y)
Natanael Copa's avatar
Natanael Copa committed
83