Makefile 2.55 KB
Newer Older
1
PKG_CONFIG ?= pkg-config
2
LUAAPK ?= yes
Timo Teräs's avatar
Timo Teräs committed
3

4 5 6 7 8 9
OPENSSL_CFLAGS		:= $(shell $(PKG_CONFIG) --cflags openssl)
OPENSSL_LIBS		:= $(shell $(PKG_CONFIG) --libs openssl)

ZLIB_CFLAGS		:= $(shell $(PKG_CONFIG) --cflags zlib)
ZLIB_LIBS		:= $(shell $(PKG_CONFIG) --libs zlib)

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

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

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

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

ifeq ($(SHARED_LIBAPK),)
apk-objs		+= $(libapk.so-objs)
42
apk-test-objs		+= $(libapk.so-objs)
43
apk.so-objs		+= $(libapk.so-objs)
44 45 46
apk-libs		+= $(libapk.so-libs)
apk-test-libs		+= $(libapk.so-libs)
apk.so-libs		+= $(libapk.so-libs)
47 48 49
else
LIBAPK			:= YesPlease
LIBS_apk		:= -lapk
50
LIBS_apk-test		:= -lapk
51
LIBS_apk.so		:= -L$(obj) -lapk
52 53
endif

54
ifneq ($(SHARED_LIBAPK),)
55 56
shlibs-y		+= libapk.so
LIBAPK-y		:= $(obj)/libapk.so
57
install-LIBAPK-y	:= $(INSTALLDIR) $(DESTDIR)$(LIBDIR) && \
58 59 60
			   $(INSTALL) $(LIBAPK-y) $(DESTDIR)$(LIBDIR)
endif

61
CFLAGS_ALL		+= -D_ATFILE_SOURCE -Ilibfetch
62
CFLAGS_apk.o		:= -DAPK_VERSION=\"$(FULL_VERSION)\"
63
CFLAGS_apk-static.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE
64
CFLAGS_apk-test.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE -DTEST_MODE
65

66
progs-$(STATIC)		+= apk.static
67
apk.static-objs		:= $(filter-out apk.o,$(apk-objs)) apk-static.o
68
apk.static-libs		:= $(apk-libs)
69
LDFLAGS_apk.static	:= -static
70
LIBS_apk.static		:= -Wl,--as-needed -ldl -Wl,--no-as-needed
71 72
LDFLAGS_apk		+= -L$(obj)
LDFLAGS_apk-test	+= -L$(obj)
73

74 75
CFLAGS_ALL		+= $(OPENSSL_CFLAGS) $(ZLIB_CFLAGS)
LIBS			:= -Wl,--as-needed \
76
				$(OPENSSL_LIBS) $(ZLIB_LIBS) \
77
			   -Wl,--no-as-needed
78

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

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

83 84
install: $(obj)/apk $(LIBAPK-y) $(LUA_LIB-y)
	$(INSTALLDIR) $(DESTDIR)$(SBINDIR)
85
	$(INSTALL) $(obj)/apk $(DESTDIR)$(SBINDIR)
86 87
	$(install-LIBAPK-y)
	$(install-LUA_LIB-y)
Natanael Copa's avatar
Natanael Copa committed
88