build: enable building of development package
- always create .so and .a with the apk libary code - create .pc file - install headers and above mentioned files Maintainers edit: merged commits, cleaned up sed script logic, and few other minor fixes.cute-signatures
parent
8b2efdd272
commit
4966bc5ede
|
@ -11,7 +11,8 @@ libfetch/*err.h
|
||||||
*.o
|
*.o
|
||||||
*.d
|
*.d
|
||||||
*.cmd
|
*.cmd
|
||||||
*.so
|
*.so*
|
||||||
*.5
|
*.5
|
||||||
*.8
|
*.8
|
||||||
|
*.pc
|
||||||
config.mk
|
config.mk
|
||||||
|
|
32
Make.rules
32
Make.rules
|
@ -69,7 +69,9 @@ CROSS_COMPILE ?=
|
||||||
CC := $(CROSS_COMPILE)gcc
|
CC := $(CROSS_COMPILE)gcc
|
||||||
AR := $(CROSS_COMPILE)ar
|
AR := $(CROSS_COMPILE)ar
|
||||||
LD := $(CROSS_COMPILE)ld
|
LD := $(CROSS_COMPILE)ld
|
||||||
|
LN := ln -sf
|
||||||
SCDOC := scdoc
|
SCDOC := scdoc
|
||||||
|
SED := sed
|
||||||
INSTALL := install
|
INSTALL := install
|
||||||
INSTALLDIR := $(INSTALL) -d
|
INSTALLDIR := $(INSTALL) -d
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ CFLAGS_ALL += $(CFLAGS)
|
||||||
LDFLAGS ?= -g
|
LDFLAGS ?= -g
|
||||||
LDFLAGS_ALL += $(LDFLAGS)
|
LDFLAGS_ALL += $(LDFLAGS)
|
||||||
|
|
||||||
export CC AR LD SCDOC INSTALL INSTALLDIR CFLAGS_ALL LDFLAGS_ALL
|
export CC AR LD LN SCDOC SED INSTALL INSTALLDIR CFLAGS_ALL LDFLAGS_ALL
|
||||||
|
|
||||||
build :=
|
build :=
|
||||||
|
|
||||||
|
@ -94,8 +96,8 @@ endif
|
||||||
ifneq ($(origin targets),file)
|
ifneq ($(origin targets),file)
|
||||||
targets :=
|
targets :=
|
||||||
endif
|
endif
|
||||||
ifneq ($(origin docs),file)
|
ifneq ($(origin nontargets),file)
|
||||||
docs :=
|
nontargets :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
src :=
|
src :=
|
||||||
|
@ -274,11 +276,29 @@ quiet_cmd_scdoc = SCDOC $@
|
||||||
cmd_scdoc = $(SCDOC) < $< > $@
|
cmd_scdoc = $(SCDOC) < $< > $@
|
||||||
|
|
||||||
__scdocs := $(addprefix $(obj)/,$(sort $(scdocs-y)))
|
__scdocs := $(addprefix $(obj)/,$(sort $(scdocs-y)))
|
||||||
|
nontargets += $(__scdocs)
|
||||||
docs += $(__scdocs)
|
docs += $(__scdocs)
|
||||||
|
|
||||||
$(__scdocs): $(obj)/%: $(src)/%.scd FORCE
|
$(__scdocs): $(obj)/%: $(src)/%.scd FORCE
|
||||||
$(call if_changed,scdoc)
|
$(call if_changed,scdoc)
|
||||||
|
|
||||||
|
####
|
||||||
|
# Template (.in) files
|
||||||
|
|
||||||
|
quiet_cmd_sed = SED $@
|
||||||
|
cmd_sed = $(SED) \
|
||||||
|
-e "s|@EXEC_DIR@|$(SBINDIR)|" \
|
||||||
|
-e "s|@LIB_DIR@|$(LIBDIR)|" \
|
||||||
|
-e "s|@INCLUDE_DIR@|$(INCLUDEDIR)|" \
|
||||||
|
-e "s|@VERSION@|$(VERSION)|" \
|
||||||
|
$< > $@
|
||||||
|
|
||||||
|
$(obj)/%: $(src)/%.in FORCE
|
||||||
|
$(call if_changed,sed)
|
||||||
|
|
||||||
|
|
||||||
|
nontargets += $(addprefix $(obj)/,$(sort $(generate-y)))
|
||||||
|
|
||||||
###
|
###
|
||||||
# why - tell why a a target got build
|
# why - tell why a a target got build
|
||||||
ifeq ($(VERBOSE),2)
|
ifeq ($(VERBOSE),2)
|
||||||
|
@ -288,9 +308,9 @@ why = \
|
||||||
$(if $(strip $(any-prereq)),- due to: $(any-prereq), \
|
$(if $(strip $(any-prereq)),- due to: $(any-prereq), \
|
||||||
$(if $(arg-check), \
|
$(if $(arg-check), \
|
||||||
$(if $(cmd_$@),- due to command line change: $(arg-check), \
|
$(if $(cmd_$@),- due to command line change: $(arg-check), \
|
||||||
$(if $(filter $@, $(targets) $(docs)), \
|
$(if $(filter $@, $(targets) $(nontargets)), \
|
||||||
- due to missing .cmd file, \
|
- due to missing .cmd file, \
|
||||||
- due to $(notdir $@) not in $$(targets) or $$(docs) \
|
- due to $(notdir $@) not in $$(targets) or $$(nontargets) \
|
||||||
) \
|
) \
|
||||||
) \
|
) \
|
||||||
) \
|
) \
|
||||||
|
@ -351,7 +371,7 @@ FORCE:
|
||||||
|
|
||||||
targets := $(wildcard $(sort $(targets)))
|
targets := $(wildcard $(sort $(targets)))
|
||||||
docs := $(wildcard $(sort $(docs)))
|
docs := $(wildcard $(sort $(docs)))
|
||||||
cmd_files := $(wildcard $(foreach f,$(targets) $(docs),$(dir $(f)).$(notdir $(f)).cmd))
|
cmd_files := $(wildcard $(foreach f,$(targets) $(nontargets),$(dir $(f)).$(notdir $(f)).cmd))
|
||||||
|
|
||||||
ifneq ($(cmd_files),)
|
ifneq ($(cmd_files),)
|
||||||
include $(cmd_files)
|
include $(cmd_files)
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -6,6 +6,8 @@
|
||||||
PACKAGE := apk-tools
|
PACKAGE := apk-tools
|
||||||
VERSION := 2.10.4
|
VERSION := 2.10.4
|
||||||
|
|
||||||
|
export VERSION
|
||||||
|
|
||||||
##
|
##
|
||||||
# Default directories
|
# Default directories
|
||||||
|
|
||||||
|
@ -15,8 +17,10 @@ LIBDIR := /lib
|
||||||
CONFDIR := /etc/apk
|
CONFDIR := /etc/apk
|
||||||
MANDIR := /usr/share/man
|
MANDIR := /usr/share/man
|
||||||
DOCDIR := /usr/share/doc/apk
|
DOCDIR := /usr/share/doc/apk
|
||||||
|
INCLUDEDIR := /usr/include/apk
|
||||||
|
PKGCONFIGDIR := /usr/lib/pkgconfig
|
||||||
|
|
||||||
export DESTDIR SBINDIR LIBDIR CONFDIR MANDIR DOCDIR
|
export DESTDIR SBINDIR LIBDIR CONFDIR MANDIR DOCDIR INCLUDEDIR PKGCONFIGDIR
|
||||||
|
|
||||||
##
|
##
|
||||||
# Top-level subdirs
|
# Top-level subdirs
|
||||||
|
@ -33,9 +37,9 @@ include Make.rules
|
||||||
|
|
||||||
install:
|
install:
|
||||||
$(INSTALLDIR) $(DESTDIR)$(DOCDIR)
|
$(INSTALLDIR) $(DESTDIR)$(DOCDIR)
|
||||||
$(INSTALL) README $(DESTDIR)$(DOCDIR)
|
$(INSTALL) README.md $(DESTDIR)$(DOCDIR)
|
||||||
|
|
||||||
check test: FORCE
|
check test: FORCE src/
|
||||||
$(Q)$(MAKE) TEST=y
|
$(Q)$(MAKE) TEST=y
|
||||||
$(Q)$(MAKE) -C test
|
$(Q)$(MAKE) -C test
|
||||||
|
|
||||||
|
|
106
src/Makefile
106
src/Makefile
|
@ -7,21 +7,50 @@ OPENSSL_LIBS := $(shell $(PKG_CONFIG) --libs openssl)
|
||||||
ZLIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags zlib)
|
ZLIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags zlib)
|
||||||
ZLIB_LIBS := $(shell $(PKG_CONFIG) --libs zlib)
|
ZLIB_LIBS := $(shell $(PKG_CONFIG) --libs zlib)
|
||||||
|
|
||||||
# lua module
|
# Dynamic library
|
||||||
|
libapk.so.$(VERSION)-objs := \
|
||||||
|
common.o database.o package.o commit.o solver.o \
|
||||||
|
version.o blob.o hash.o print.o \
|
||||||
|
io.o io_url.o io_gunzip.o io_archive.o
|
||||||
|
|
||||||
|
libapk.so.$(VERSION)-libs := libfetch/libfetch.a
|
||||||
|
|
||||||
|
libapk_soname := $(VERSION)
|
||||||
|
shlibs-y += libapk.so.$(VERSION)
|
||||||
|
LDFLAGS_libapk.so.$(VERSION) += -Wl,-soname,libapk.so.$(libapk_soname)
|
||||||
|
|
||||||
|
libapk_so := $(obj)/libapk.so.$(VERSION)
|
||||||
|
install-libapk_so := $(INSTALLDIR) $(DESTDIR)$(LIBDIR) && \
|
||||||
|
$(INSTALL) $(libapk_so) $(DESTDIR)$(LIBDIR)/libapk.so.$(VERSION) && \
|
||||||
|
$(INSTALL) $(obj)/libapk.so.$(libapk_soname) $(DESTDIR)$(LIBDIR) && \
|
||||||
|
$(INSTALL) $(obj)/libapk.so $(DESTDIR)$(LIBDIR)
|
||||||
|
|
||||||
|
# Static library
|
||||||
|
libapk.a-objs := $(libapk.so.$(VERSION)-objs)
|
||||||
|
libapk.a-libs := $(libapk.so.$(VERSION)-libs)
|
||||||
|
|
||||||
|
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
|
||||||
ifneq ($(LUAAPK),)
|
ifneq ($(LUAAPK),)
|
||||||
LUA_VERSION ?= 5.3
|
LUA_VERSION ?= 5.3
|
||||||
LUA_PC ?= lua$(LUA_VERSION)
|
LUA_PC ?= lua$(LUA_VERSION)
|
||||||
LUA_LIBDIR ?= /usr/lib/lua/$(LUA_VERSION)
|
LUA_LIBDIR ?= /usr/lib/lua/$(LUA_VERSION)
|
||||||
LIBAPK := YesPlease
|
|
||||||
shlibs-y += apk.so
|
shlibs-y += apk.so
|
||||||
apk.so-objs := lua-apk.o
|
apk.so-objs := lua-apk.o
|
||||||
CFLAGS_lua-apk.o := -DAPK_VERSION=\"$(FULL_VERSION)\" \
|
CFLAGS_lua-apk.o := -DAPK_VERSION=\"$(FULL_VERSION)\" \
|
||||||
$(shell $(PKG_CONFIG) $(LUA_PC) --cflags)
|
$(shell $(PKG_CONFIG) $(LUA_PC) --cflags)
|
||||||
LUA_LIB-y := $(obj)/apk.so
|
apklua_so := $(obj)/apk.so
|
||||||
install-LUA_LIB-y := $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) && \
|
install-apklua_so := $(INSTALLDIR) $(DESTDIR)$(LUA_LIBDIR) && \
|
||||||
$(INSTALL) $(LUA_LIB-y) $(DESTDIR)$(LUA_LIBDIR)
|
$(INSTALL) $(apklua_so) $(DESTDIR)$(LUA_LIBDIR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Apk utility
|
||||||
progs-y += apk
|
progs-y += apk
|
||||||
apk-objs := apk.o \
|
apk-objs := apk.o \
|
||||||
app_add.o app_del.o app_fix.o app_update.o app_upgrade.o \
|
app_add.o app_del.o app_fix.o app_update.o app_upgrade.o \
|
||||||
|
@ -31,37 +60,9 @@ apk-objs := apk.o \
|
||||||
app_index.o app_fetch.o app_verify.o app_dot.o \
|
app_index.o app_fetch.o app_verify.o app_dot.o \
|
||||||
app_audit.o
|
app_audit.o
|
||||||
|
|
||||||
libapk.so-objs := common.o database.o package.o commit.o solver.o \
|
|
||||||
version.o blob.o hash.o print.o \
|
|
||||||
io.o io_url.o io_gunzip.o io_archive.o
|
|
||||||
|
|
||||||
libapk.so-libs := libfetch/libfetch.a
|
|
||||||
|
|
||||||
ifeq ($(TEST),y)
|
|
||||||
progs-y += apk-test
|
|
||||||
apk-test-objs := apk-test.o $(filter-out apk.o, $(apk-objs))
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(SHARED_LIBAPK),)
|
|
||||||
apk-objs += $(libapk.so-objs)
|
|
||||||
apk-test-objs += $(libapk.so-objs)
|
|
||||||
apk.so-objs += $(libapk.so-objs)
|
|
||||||
apk-libs += $(libapk.so-libs)
|
|
||||||
apk-test-libs += $(libapk.so-libs)
|
|
||||||
apk.so-libs += $(libapk.so-libs)
|
|
||||||
else
|
|
||||||
LIBAPK := YesPlease
|
|
||||||
LIBS_apk := -lapk
|
LIBS_apk := -lapk
|
||||||
LIBS_apk-test := -lapk
|
LIBS_apk-test := -lapk
|
||||||
LIBS_apk.so := -L$(obj) -lapk
|
LIBS_apk.so := -L$(obj) -lapk
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(SHARED_LIBAPK),)
|
|
||||||
shlibs-y += libapk.so
|
|
||||||
LIBAPK-y := $(obj)/libapk.so
|
|
||||||
install-LIBAPK-y := $(INSTALLDIR) $(DESTDIR)$(LIBDIR) && \
|
|
||||||
$(INSTALL) $(LIBAPK-y) $(DESTDIR)$(LIBDIR)
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS_ALL += -D_ATFILE_SOURCE -Ilibfetch
|
CFLAGS_ALL += -D_ATFILE_SOURCE -Ilibfetch
|
||||||
CFLAGS_apk.o := -DAPK_VERSION=\"$(FULL_VERSION)\"
|
CFLAGS_apk.o := -DAPK_VERSION=\"$(FULL_VERSION)\"
|
||||||
|
@ -70,7 +71,7 @@ CFLAGS_apk-test.o := -DAPK_VERSION=\"$(FULL_VERSION)\" -DOPENSSL_NO_ENGINE -DTES
|
||||||
|
|
||||||
progs-$(STATIC) += apk.static
|
progs-$(STATIC) += apk.static
|
||||||
apk.static-objs := $(filter-out apk.o,$(apk-objs)) apk-static.o
|
apk.static-objs := $(filter-out apk.o,$(apk-objs)) apk-static.o
|
||||||
apk.static-libs := $(apk-libs)
|
apk.static-libs := $(apk-static-libs)
|
||||||
LDFLAGS_apk.static := -static
|
LDFLAGS_apk.static := -static
|
||||||
LIBS_apk.static := -Wl,--as-needed -ldl -Wl,--no-as-needed
|
LIBS_apk.static := -Wl,--as-needed -ldl -Wl,--no-as-needed
|
||||||
LDFLAGS_apk += -L$(obj)
|
LDFLAGS_apk += -L$(obj)
|
||||||
|
@ -81,13 +82,40 @@ LIBS := -Wl,--as-needed \
|
||||||
$(OPENSSL_LIBS) $(ZLIB_LIBS) \
|
$(OPENSSL_LIBS) $(ZLIB_LIBS) \
|
||||||
-Wl,--no-as-needed
|
-Wl,--no-as-needed
|
||||||
|
|
||||||
$(obj)/apk: $(LIBAPK-y)
|
# Test build
|
||||||
|
ifeq ($(TEST),y)
|
||||||
|
progs-y += apk-test
|
||||||
|
apk-test-objs := apk-test.o $(filter-out apk.o, $(apk-objs))
|
||||||
|
endif
|
||||||
|
|
||||||
$(obj)/apk.so: $(LIBAPK-y)
|
$(obj)/apk: $(libapk_so)
|
||||||
|
|
||||||
install: $(obj)/apk $(LIBAPK-y) $(LUA_LIB-y)
|
$(obj)/apk-test: $(libapk_so)
|
||||||
|
|
||||||
|
$(obj)/apk.so: $(libapk_so)
|
||||||
|
|
||||||
|
ifneq ($(libapk_soname), $(VERSION))
|
||||||
|
generate-y += libapk.so.$(libapk_soname)
|
||||||
|
|
||||||
|
$(obj)/libapk.so.$(libapk_soname):
|
||||||
|
$(LN) libapk.so.$(VERSION) $(obj)/libapk.so.$(libapk_soname)
|
||||||
|
endif
|
||||||
|
|
||||||
|
generate-y += libapk.so
|
||||||
|
|
||||||
|
$(obj)/libapk.so:
|
||||||
|
$(LN) libapk.so.$(libapk_soname) $(obj)/libapk.so
|
||||||
|
|
||||||
|
generate-y += apk.pc
|
||||||
|
|
||||||
|
install: $(obj)/apk $(libapk_so) $(libapk_a) $(apklua_so)
|
||||||
$(INSTALLDIR) $(DESTDIR)$(SBINDIR)
|
$(INSTALLDIR) $(DESTDIR)$(SBINDIR)
|
||||||
$(INSTALL) $(obj)/apk $(DESTDIR)$(SBINDIR)
|
$(INSTALL) $(obj)/apk $(DESTDIR)$(SBINDIR)
|
||||||
$(install-LIBAPK-y)
|
$(install-libapk_so)
|
||||||
$(install-LUA_LIB-y)
|
$(install-libapk_a)
|
||||||
|
$(install-apklua_so)
|
||||||
|
$(INSTALLDIR) $(DESTDIR)$(INCLUDEDIR)
|
||||||
|
$(INSTALL) -m644 src/*.h $(DESTDIR)$(INCLUDEDIR)
|
||||||
|
$(INSTALLDIR) $(DESTDIR)$(PKGCONFIGDIR)
|
||||||
|
$(INSTALL) -m644 $(obj)/apk.pc $(DESTDIR)$(PKGCONFIGDIR)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue