From 98a13624a1559c201bb96ca9db71dc74324396b1 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Mon, 13 Jun 2016 07:19:44 +0000 Subject: 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. --- src/Makefile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Makefile b/src/Makefile index 250d2f0..72450f2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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) -- cgit v1.2.3