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

4 5 6
# lua module
ifneq ($(LUAAPK),)
LIBAPK			:= YesPlease
7
PKGDEPS			+= lua
Natanael Copa's avatar
Natanael Copa committed
8 9 10
shlibs-y		+= apk.so
apk.so-objs		:= lua-apk.o
CFLAGS_lua-apk.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\"
11
LIBS_apk.so		:= -L$(obj) -lapk
12 13 14 15
LUA_LIB-y		:= $(obj)/apk.so
install-LUA_LIB-y	:= $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) \
			   $(INSTALL) $(LUA_LIB-y) $(DESTDIR)$(LUA_LIBDIR)
endif
Natanael Copa's avatar
Natanael Copa committed
16

17
ifeq ($(shell $(PKG_CONFIG) --print-errors --exists $(PKGDEPS) || echo fail),fail)
18 19 20
$(error Build dependencies are not met)
endif

21
progs-y			+= apk
Natanael Copa's avatar
Natanael Copa committed
22 23
apk-objs		:= apk.o add.o del.o fix.o update.o info.o \
			   search.o upgrade.o cache.o ver.o index.o fetch.o \
24
			   audit.o verify.o dot.o
Natanael Copa's avatar
Natanael Copa committed
25

26
libapk.so-objs		:= common.o state.o database.o package.o archive.o \
27 28 29 30 31 32 33
			   version.o io.o url.o gunzip.o blob.o hash.o print.o \
			   solver.o topology.o

ifeq ($(TEST),y)
progs-y			+= apk_test
apk_test-objs		:= apk.o test.o $(libapk.so-objs)
endif
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

ifeq ($(SHARED_LIBAPK),)
apk-objs		+= $(libapk.so-objs)
else
LIBAPK			:= YesPlease
LIBS_apk		:= -lapk
endif

ifneq ($(LIBAPK),)
shlibs-y		+= libapk.so
LIBAPK-y		:= $(obj)/libapk.so
install-LIBAPK-y	:= $(INSTALLDIR) $(DESTDIR)$(LIBDIR) \
			   $(INSTALL) $(LIBAPK-y) $(DESTDIR)$(LIBDIR)
endif

49
CFLAGS_ALL		+= -D_ATFILE_SOURCE
50
CFLAGS_apk.o		:= -DAPK_VERSION=\"$(FULL_VERSION)\"
51
CFLAGS_apk-static.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE
52

53
progs-$(STATIC)		+= apk.static
54
apk.static-objs		:= $(filter-out apk.o,$(apk-objs)) apk-static.o
55
LDFLAGS_apk.static	:= -static
Natanael Copa's avatar
Natanael Copa committed
56
LDFLAGS_apk		+= -nopie -L$(obj)
57
LDFLAGS_apk_test	+= -nopie -L$(obj)
58

59
CFLAGS_ALL		+= $(shell $(PKG_CONFIG) --cflags $(PKGDEPS))
60
LIBS			:= -Wl,--as-needed \
61
				$(shell $(PKG_CONFIG) --libs $(PKGDEPS)) \
62
			   -Wl,--no-as-needed
63

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

66
$(obj)/apk.so: $(obj)/libapk.so
Natanael Copa's avatar
Natanael Copa committed
67

68 69
install: $(obj)/apk $(LIBAPK-y) $(LUA_LIB-y)
	$(INSTALLDIR) $(DESTDIR)$(SBINDIR)
70
	$(INSTALL) $(obj)/apk $(DESTDIR)$(SBINDIR)
71 72
	$(install-LIBAPK-y)
	$(install-LUA_LIB-y)
Natanael Copa's avatar
Natanael Copa committed
73