Makefile 1.95 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
LUA_LIB-y		:= $(obj)/apk.so
12
install-LUA_LIB-y	:= $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) && \
13 14
			   $(INSTALL) $(LUA_LIB-y) $(DESTDIR)$(LUA_LIBDIR)
endif
Natanael Copa's avatar
Natanael Copa committed
15

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

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

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

ifeq ($(TEST),y)
progs-y			+= apk_test
apk_test-objs		:= apk.o test.o $(libapk.so-objs)
endif
33 34 35

ifeq ($(SHARED_LIBAPK),)
apk-objs		+= $(libapk.so-objs)
36
apk.so-objs		+= $(libapk.so-objs)
37 38 39
else
LIBAPK			:= YesPlease
LIBS_apk		:= -lapk
40
LIBS_apk.so		:= -L$(obj) -lapk
41 42
endif

43
ifneq ($(SHARED_LIBAPK),)
44 45
shlibs-y		+= libapk.so
LIBAPK-y		:= $(obj)/libapk.so
46
install-LIBAPK-y	:= $(INSTALLDIR) $(DESTDIR)$(LIBDIR) && \
47 48 49
			   $(INSTALL) $(LIBAPK-y) $(DESTDIR)$(LIBDIR)
endif

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

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

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

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

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

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