Makefile 2.12 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 7
# lua module
ifneq ($(LUAAPK),)
LIBAPK			:= YesPlease
8
PKGDEPS			+= lua
Natanael Copa's avatar
Natanael Copa committed
9 10 11
shlibs-y		+= apk.so
apk.so-objs		:= lua-apk.o
CFLAGS_lua-apk.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\"
12
LUA_LIB-y		:= $(obj)/apk.so
13
install-LUA_LIB-y	:= $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) && \
14 15
			   $(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
22
apk-objs		:= apk.o add.o del.o fix.o update.o info.o \
Natanael Copa's avatar
Natanael Copa committed
23
			   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

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

ifeq ($(TEST),y)
31 32
progs-y			+= apk-test
apk-test-objs		:= apk-test.o $(filter-out apk.o, $(apk-objs))
33
endif
34 35 36

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

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

53
CFLAGS_ALL		+= -D_ATFILE_SOURCE
54
CFLAGS_apk.o		:= -DAPK_VERSION=\"$(FULL_VERSION)\"
55
CFLAGS_apk-static.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE
56
CFLAGS_apk-test.o	:= -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE -DTEST_MODE
57

58
progs-$(STATIC)		+= apk.static
59
apk.static-objs		:= $(filter-out apk.o,$(apk-objs)) apk-static.o
60
LDFLAGS_apk.static	:= -static
Natanael Copa's avatar
Natanael Copa committed
61
LDFLAGS_apk		+= -nopie -L$(obj)
62
LDFLAGS_apk-test	+= -nopie -L$(obj)
63

64
CFLAGS_ALL		+= $(shell $(PKG_CONFIG) --cflags $(PKGDEPS))
65
LIBS			:= -Wl,--as-needed \
66
				$(shell $(PKG_CONFIG) --libs $(PKGDEPS)) \
67
			   -Wl,--no-as-needed
68

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

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

73 74
install: $(obj)/apk $(LIBAPK-y) $(LUA_LIB-y)
	$(INSTALLDIR) $(DESTDIR)$(SBINDIR)
75
	$(INSTALL) $(obj)/apk $(DESTDIR)$(SBINDIR)
76 77
	$(install-LIBAPK-y)
	$(install-LUA_LIB-y)
Natanael Copa's avatar
Natanael Copa committed
78