Makefile 2.44 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
FETCH_LIBS		:= $(shell $(CC) -print-file-name=libfetch.a)
11

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

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

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

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

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

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

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

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

71 72 73
CFLAGS_ALL		+= $(OPENSSL_CFLAGS) $(ZLIB_CFLAGS)
LIBS			:= -Wl,--as-needed \
				$(FETCH_LIBS) $(OPENSSL_LIBS) $(ZLIB_LIBS) \
74
			   -Wl,--no-as-needed
75

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

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

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