build: allow override compiler/linker flags for external libs

Make it possible to individually override openssl, zlib and libfetch
cflags and linker flags. This makes it possible to build apk-tools
without having pkg-config installed.
cute-signatures
Natanael Copa 2016-06-13 07:19:44 +00:00
parent 5906aef695
commit 98a13624a1
1 changed files with 11 additions and 9 deletions

View File

@ -1,7 +1,14 @@
PKGDEPS := openssl zlib
PKG_CONFIG ?= pkg-config
LUAAPK ?= yes
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)
FETCH_LIBS := /usr/lib/libfetch.a
# lua module
ifneq ($(LUAAPK),)
LUA_VERSION ?= 5.2
@ -17,10 +24,6 @@ install-LUA_LIB-y := $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) && \
$(INSTALL) $(LUA_LIB-y) $(DESTDIR)$(LUA_LIBDIR)
endif
ifeq ($(shell $(PKG_CONFIG) --print-errors --exists $(PKGDEPS) || echo fail),fail)
$(error Build dependencies are not met)
endif
progs-y += apk
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 \
@ -65,10 +68,9 @@ LIBS_apk.static := -Wl,--as-needed -ldl -Wl,--no-as-needed
LDFLAGS_apk += -L$(obj)
LDFLAGS_apk-test += -L$(obj)
CFLAGS_ALL += $(shell $(PKG_CONFIG) --cflags $(PKGDEPS))
LIBS := /usr/lib/libfetch.a \
-Wl,--as-needed \
$(shell $(PKG_CONFIG) --libs $(PKGDEPS)) \
CFLAGS_ALL += $(OPENSSL_CFLAGS) $(ZLIB_CFLAGS)
LIBS := -Wl,--as-needed \
$(FETCH_LIBS) $(OPENSSL_LIBS) $(ZLIB_LIBS) \
-Wl,--no-as-needed
$(obj)/apk: $(LIBAPK-y)