2020-05-19 07:50:57 +00:00
|
|
|
PKG_CONFIG ?= pkg-config
|
2020-04-24 08:49:14 +00:00
|
|
|
LUA ?= $(firstword $(wildcard /usr/bin/lua5.3 /usr/bin/lua5.2))
|
|
|
|
|
2020-05-19 07:50:57 +00:00
|
|
|
ifeq ($(LUA),no)
|
|
|
|
LUAAPK ?= no
|
|
|
|
else ifneq ($(LUA),)
|
|
|
|
LUAAPK ?= yes
|
|
|
|
else
|
|
|
|
$(error Lua interpreter not found. Please specify LUA interpreter, or use LUA=no to build without help.)
|
|
|
|
endif
|
|
|
|
|
2016-06-13 07:19:44 +00:00
|
|
|
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)
|
|
|
|
|
2020-03-16 13:25:02 +00:00
|
|
|
# Dynamic library
|
2020-08-25 12:35:46 +00:00
|
|
|
libapk_soname := 3.12.0
|
|
|
|
libapk_so := $(obj)/libapk.so.$(libapk_soname)
|
|
|
|
libapk.so.$(libapk_soname)-objs := \
|
2020-09-30 11:11:37 +00:00
|
|
|
adb.o adb_trust.o \
|
2020-10-05 15:52:51 +00:00
|
|
|
common.o context.o database.o package.o commit.o solver.o \
|
2020-05-19 08:39:21 +00:00
|
|
|
version.o atom.o blob.o hash.o print.o \
|
2020-03-16 13:25:02 +00:00
|
|
|
io.o io_url.o io_gunzip.o io_archive.o
|
|
|
|
|
2020-08-25 12:35:46 +00:00
|
|
|
libapk.so.$(libapk_soname)-libs := libfetch/libfetch.a
|
2020-03-16 13:25:02 +00:00
|
|
|
|
2020-08-25 12:35:46 +00:00
|
|
|
shlibs-y += libapk.so.$(libapk_soname)
|
|
|
|
LDFLAGS_libapk.so.$(libapk_soname) += -Wl,-soname,libapk.so.$(libapk_soname)
|
2020-03-16 13:25:02 +00:00
|
|
|
|
|
|
|
install-libapk_so := $(INSTALLDIR) $(DESTDIR)$(LIBDIR) && \
|
2020-08-25 12:35:46 +00:00
|
|
|
$(INSTALL) $(libapk_so) $(DESTDIR)$(LIBDIR) && \
|
|
|
|
$(LN) libapk.so.$(libapk_soname) $(DESTDIR)$(LIBDIR)/libapk.so
|
2020-03-16 13:25:02 +00:00
|
|
|
|
|
|
|
# Static library
|
2020-08-25 12:35:46 +00:00
|
|
|
libapk.a-objs := $(libapk.so.$(libapk_soname)-objs)
|
|
|
|
libapk.a-libs := $(libapk.so.$(libapk_soname)-libs)
|
2020-03-16 13:25:02 +00:00
|
|
|
|
|
|
|
libs-y += libapk.a
|
|
|
|
libapk_a := $(obj)/libapk.a
|
|
|
|
|
|
|
|
install-libapk_a := $(INSTALLDIR) $(DESTDIR)$(LIBDIR) && \
|
|
|
|
$(INSTALL) $(libapk_a) $(DESTDIR)$(LIBDIR)
|
|
|
|
apk-static-libs := $(libapk.a-libs) $(obj)/libapk.a
|
|
|
|
|
|
|
|
# Lua module
|
2020-05-19 13:55:33 +00:00
|
|
|
ifeq ($(LUAAPK),yes)
|
2019-12-30 14:15:44 +00:00
|
|
|
LUA_VERSION ?= 5.3
|
2013-06-26 14:42:10 +00:00
|
|
|
LUA_PC ?= lua$(LUA_VERSION)
|
|
|
|
LUA_LIBDIR ?= /usr/lib/lua/$(LUA_VERSION)
|
2010-03-06 19:07:38 +00:00
|
|
|
shlibs-y += apk.so
|
|
|
|
apk.so-objs := lua-apk.o
|
2013-06-26 14:42:10 +00:00
|
|
|
CFLAGS_lua-apk.o := -DAPK_VERSION=\"$(FULL_VERSION)\" \
|
|
|
|
$(shell $(PKG_CONFIG) $(LUA_PC) --cflags)
|
2020-03-16 13:25:02 +00:00
|
|
|
apklua_so := $(obj)/apk.so
|
|
|
|
install-apklua_so := $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) && \
|
|
|
|
$(INSTALL) $(apklua_so) $(DESTDIR)$(LUA_LIBDIR)
|
2010-06-14 09:41:06 +00:00
|
|
|
endif
|
2010-03-06 19:07:38 +00:00
|
|
|
|
2020-03-16 13:25:02 +00:00
|
|
|
# Apk utility
|
2009-04-16 10:49:16 +00:00
|
|
|
progs-y += apk
|
2020-10-05 15:52:51 +00:00
|
|
|
apk-objs := apk.o applet.o \
|
2020-02-14 11:49:41 +00:00
|
|
|
app_add.o app_del.o app_fix.o app_update.o app_upgrade.o \
|
|
|
|
app_info.o app_list.o app_search.o app_manifest.o \
|
|
|
|
app_policy.o app_stats.o \
|
|
|
|
app_cache.o app_version.o \
|
|
|
|
app_index.o app_fetch.o app_verify.o app_dot.o \
|
|
|
|
app_audit.o
|
2010-03-05 08:13:25 +00:00
|
|
|
|
2020-09-30 11:11:37 +00:00
|
|
|
ifeq ($(ADB),y)
|
|
|
|
libapk.so.$(libapk_soname)-objs += apk_adb.o
|
|
|
|
apk-objs += app_adbdump.o app_adbsign.o app_mkndx.o \
|
|
|
|
app_convdb.o app_convndx.o
|
|
|
|
endif
|
|
|
|
|
2010-06-14 09:41:06 +00:00
|
|
|
LIBS_apk := -lapk
|
2012-02-23 20:02:11 +00:00
|
|
|
LIBS_apk-test := -lapk
|
2011-09-14 14:16:19 +00:00
|
|
|
LIBS_apk.so := -L$(obj) -lapk
|
2010-06-14 09:41:06 +00:00
|
|
|
|
2017-10-05 07:57:45 +00:00
|
|
|
CFLAGS_ALL += -D_ATFILE_SOURCE -Ilibfetch
|
2009-04-16 10:49:16 +00:00
|
|
|
CFLAGS_apk.o := -DAPK_VERSION=\"$(FULL_VERSION)\"
|
2010-06-30 13:53:56 +00:00
|
|
|
CFLAGS_apk-static.o := -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE
|
2012-02-23 20:02:11 +00:00
|
|
|
CFLAGS_apk-test.o := -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE -DTEST_MODE
|
2008-04-17 14:09:13 +00:00
|
|
|
|
2009-04-16 10:49:16 +00:00
|
|
|
progs-$(STATIC) += apk.static
|
2010-06-30 13:53:56 +00:00
|
|
|
apk.static-objs := $(filter-out apk.o,$(apk-objs)) apk-static.o
|
2020-03-16 13:25:02 +00:00
|
|
|
apk.static-libs := $(apk-static-libs)
|
2009-04-16 10:49:16 +00:00
|
|
|
LDFLAGS_apk.static := -static
|
2012-03-28 08:28:41 +00:00
|
|
|
LIBS_apk.static := -Wl,--as-needed -ldl -Wl,--no-as-needed
|
2014-05-12 16:42:32 +00:00
|
|
|
LDFLAGS_apk += -L$(obj)
|
|
|
|
LDFLAGS_apk-test += -L$(obj)
|
2008-04-17 14:09:13 +00:00
|
|
|
|
2016-06-13 07:19:44 +00:00
|
|
|
CFLAGS_ALL += $(OPENSSL_CFLAGS) $(ZLIB_CFLAGS)
|
|
|
|
LIBS := -Wl,--as-needed \
|
2017-10-05 07:57:45 +00:00
|
|
|
$(OPENSSL_LIBS) $(ZLIB_LIBS) \
|
2009-07-08 07:46:38 +00:00
|
|
|
-Wl,--no-as-needed
|
2008-04-17 14:09:13 +00:00
|
|
|
|
2020-04-24 08:49:14 +00:00
|
|
|
# Help generation
|
|
|
|
quiet_cmd_genhelp = GENHELP $@
|
2020-05-19 07:50:57 +00:00
|
|
|
ifneq ($(LUA),no)
|
2020-04-24 08:49:14 +00:00
|
|
|
cmd_genhelp = $(LUA) $(src)/genhelp.lua $(filter %.scd, $^) > $@
|
2020-05-19 07:50:57 +00:00
|
|
|
else
|
|
|
|
cmd_genhelp = echo \\\#define NO_HELP > $@
|
|
|
|
endif
|
2020-04-24 08:49:14 +00:00
|
|
|
|
2020-05-19 07:50:57 +00:00
|
|
|
$(obj)/help.h: $(src)/genhelp.lua $(wildcard doc/apk*.8.scd) FORCE
|
|
|
|
$(call if_changed,genhelp)
|
2020-04-24 08:49:14 +00:00
|
|
|
|
|
|
|
CFLAGS_help.o := -I$(obj)
|
|
|
|
|
|
|
|
generate-y += help.h
|
|
|
|
|
2020-03-16 13:25:02 +00:00
|
|
|
# Test build
|
|
|
|
ifeq ($(TEST),y)
|
|
|
|
progs-y += apk-test
|
|
|
|
apk-test-objs := apk-test.o $(filter-out apk.o, $(apk-objs))
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(obj)/apk: $(libapk_so)
|
|
|
|
|
|
|
|
$(obj)/apk-test: $(libapk_so)
|
|
|
|
|
|
|
|
$(obj)/apk.so: $(libapk_so)
|
|
|
|
|
|
|
|
generate-y += libapk.so
|
|
|
|
|
|
|
|
$(obj)/libapk.so:
|
|
|
|
$(LN) libapk.so.$(libapk_soname) $(obj)/libapk.so
|
2010-03-05 08:13:25 +00:00
|
|
|
|
2020-03-16 13:25:02 +00:00
|
|
|
generate-y += apk.pc
|
2010-03-06 19:07:38 +00:00
|
|
|
|
2020-03-16 13:25:02 +00:00
|
|
|
install: $(obj)/apk $(libapk_so) $(libapk_a) $(apklua_so)
|
2010-06-14 09:41:06 +00:00
|
|
|
$(INSTALLDIR) $(DESTDIR)$(SBINDIR)
|
2009-04-16 10:49:16 +00:00
|
|
|
$(INSTALL) $(obj)/apk $(DESTDIR)$(SBINDIR)
|
2020-03-16 13:25:02 +00:00
|
|
|
$(install-libapk_so)
|
|
|
|
$(install-libapk_a)
|
|
|
|
$(install-apklua_so)
|
2020-04-01 14:37:46 +00:00
|
|
|
$(INSTALLDIR) $(DESTDIR)$(INCLUDEDIR)/apk
|
|
|
|
$(INSTALL) -m644 src/*.h $(DESTDIR)$(INCLUDEDIR)/apk
|
2020-03-16 13:25:02 +00:00
|
|
|
$(INSTALLDIR) $(DESTDIR)$(PKGCONFIGDIR)
|
|
|
|
$(INSTALL) -m644 $(obj)/apk.pc $(DESTDIR)$(PKGCONFIGDIR)
|
2010-03-05 08:13:25 +00:00
|
|
|
|