Skip to content

Commit

Permalink
Add cross/firebird SynoCommunity#5795
Browse files Browse the repository at this point in the history
Build FirebirdSQL database using native/libtommath and
native/libtomcrypt as dependencies.
Link against these native libraries during first step of cross build
process.

The build works for x64 architecture and DSM 7.1

- Use configure --with-cross-build as used by firebird build itself
  • Loading branch information
vitkabele authored and Vít Kabele committed Aug 1, 2023
1 parent c7fde92 commit 9d517b6
Show file tree
Hide file tree
Showing 6 changed files with 844 additions and 0 deletions.
79 changes: 79 additions & 0 deletions cross/firebird/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
PKG_NAME = firebird
PKG_VERS = 4.0.2
PKG_EXT = tar.gz
PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/FirebirdSQL/firebird/archive/refs/tags/
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS = cross/zlib native/libicu native/libtomcrypt native/libtommath

UNSUPPORTED_ARCHS = $(ARMv5_ARCHS) $(OLD_PPC_ARCHS) $(ARMv7_ARCHS)

include ../../mk/spksrc.common.mk

# Currently v4.0.2 works only with 7.1
# DSM 7.2 has issues with GLIBC version
ifeq ($(call version_lt,${TC_VERS},7.0)$(call version_gt,${TC_VERS},7.1),11)
UNSUPPORTED_ARCHS += $(ARCH)
endif

HOMEPAGE = https://www.firebirdsql.org/
COMMENT = Firebird is a relational database offering many ANSI SQL standard features that runs on Linux, Windows, MacOS and a variety of Unix platforms.
LICENSE = MPL
MAINTAINER = vitkabele

PRE_CONFIGURE_TARGET = firebird_pre_configure

INSTALL_TARGET = firebird_install

# We need both native and cross compilers for building the binary.
include ../../mk/spksrc.cross-cc.mk

# If we use --with-builtin-tomcrypt/math, the libraries are built during cross1
# phase without -fPIC and then refuse to link during cross2 phase. Further,
# they can be built for different platforms during cross1 and cross2 phase.
#
# termlib and editline are disabled because we don't provide ncurses
# and editline libraries
CONFIGURE_ARGS = --without-termlib --without-editline --with-cross-build=synology --prefix=$(INSTALL_PREFIX)

NATIVE_LIBICU_DIR := $(WORK_DIR)/../../../native/libicu/work-native/install/usr/local
NATIVE_LIBTOMCRYPT_DIR := $(WORK_DIR)/../../../native/libtomcrypt/work-native/install/usr/local
NATIVE_LIBTOMMATH_DIR := $(WORK_DIR)/../../../native/libtommath/work-native/install/usr/local

# CFLAGS and CXXFLAGS for cross1 compile stage
NATIVE_CFLAGS := -I$(NATIVE_LIBICU_DIR)/include -I$(NATIVE_LIBTOMCRYPT_DIR)/include -I$(NATIVE_LIBTOMMATH_DIR)/include \
-L$(NATIVE_LIBICU_DIR)/lib -L$(NATIVE_LIBTOMCRYPT_DIR)/lib -L$(NATIVE_LIBTOMMATH_DIR)/lib

# The cross1 phase not only compiles the binaries against the libtom libraries,
# but also executes them. We must provide the -rpath to linker so the libs
# are found during runtime
NATIVE_LDFLAGS := -Wl,-rpath,$(NATIVE_LIBTOMCRYPT_DIR)/lib -Wl,-rpath,$(NATIVE_LIBTOMMATH_DIR)/lib

# CFLAGS for the cross2 build phase
CROSS_CFLAGS=-Wno-invalid-offsetof

# This ENV is for cross1 phase where we build native target
# CROSS_ prefixed vars are for the cross2 phase and we "strip" the CROSS_ prefix
# in our provided src/makefile.xxx
ENV = CC= LD= \
CFLAGS="$(NATIVE_CFLAGS)" \
CXXFLAGS="$(NATIVE_CFLAGS)" \
LDFLAGS="$(NATIVE_LDFLAGS)" \
CROSS_TOOLCHAIN=$(TC_PATH)$(TC_PREFIX) \
CROSS_CFLAGS="$(CROSS_CFLAGS)"

.PHONY: firebird_pre_configure
firebird_pre_configure:
cp src/make.synology $(WORK_DIR)/$(PKG_DIR)/builds/posix/
cp src/cross_config/* $(WORK_DIR)/$(PKG_DIR)/src/include/cross/
$(RUN) NOCONFIGURE=1 ./autogen.sh

.PHONY: firebird_install
firebird_install:
$(RUN) make dist
# We assume there is just one buildroot.tar.gz file in the build tree
# This is a little hack since we don't know the exact path where it is
# produced and it is easier than patching the firebird Makefiles
cd $(WORK_DIR)/install && tar xf $$(find ../ -name buildroot.tar.gz)

48 changes: 48 additions & 0 deletions cross/firebird/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
rsc:CHANGELOG.md
rsc:IDPLicense.txt
rsc:IPLicense.txt
rsc:README.md
rsc:bin/FirebirdUninstall.sh
rsc:bin/changeServerMode.sh
rsc:bin/fb_config
bin:bin/fb_lock_print
bin:bin/fbguard
bin:bin/fbsvcmgr
bin:bin/fbtracemgr
bin:bin/firebird
bin:bin/gbak
bin:bin/gfix
bin:bin/gpre
bin:bin/gsec
bin:bin/gsplit
bin:bin/gstat
bin:bin/isql
bin:bin/nbackup
bin:bin/qli
rsc:bin/registerDatabase.sh
rsc:databases.conf
rsc:fbtrace.conf
rsc:firebird.conf
rsc:help/help.gbak
rsc:intl/fbintl
rsc:intl/fbintl.conf
lnk:lib/libfbclient.so
lnk:lib/libfbclient.so.2
lib:lib/libfbclient.so.4.0.2
lib:lib/libib_util.so
rsc:misc/intl.sql
rsc:misc/rc.config.firebird
rsc:misc/upgrade/udf/udf_replace.sql
rsc:misc/upgrade/udf/udf_replace.txt
rsc:plugins.conf
lib:plugins/libChaCha.so
lib:plugins/libEngine13.so
lib:plugins/libLegacy_Auth.so
lib:plugins/libLegacy_UserManager.so
lib:plugins/libSrp.so
lib:plugins/libfbtrace.so
lib:plugins/libudr_engine.so
lib:plugins/udr/libudf_compat.so
rsc:plugins/udr/udf_compat.sql
rsc:plugins/udr_engine.conf
rsc:replication.conf
3 changes: 3 additions & 0 deletions cross/firebird/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
v4.0.2.tar.gz SHA1 c0ba59179feb4ee3068403fe3a0e1d5e6f046cb1
v4.0.2.tar.gz SHA256 756428b86bb9a20f0117e0ea4cf499c79214c5c15a3a31ebddd8c95ded66db3d
v4.0.2.tar.gz MD5 4fd0b0726752545605e6297857bc0106
14 changes: 14 additions & 0 deletions cross/firebird/patches/0001-remove-extauth-plugin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Do not build the extauth plugin, because it cannot refer to native/libtomcrypt
# It can only work with the builtin tomcrypt or the system-wide.
# There is no way how to pass CFLAGS with -I to this makefile as it overrides them
--- Makefile.in.examples 2023-07-25 09:09:56.598749645 +0000
+++ builds/posix/Makefile.in.examples 2022-08-08 00:08:06.000000000 +0000
@@ -90,7 +90,7 @@ EXTAUTH_PLUGIN= $(EXAMPLES_FB)/prebuilt/
all: examples

# examples: $(EMPLOYEE_DB) $(INTLEMP_DB) $(EXAMPLES_FB)/README
-examples: $(FINAL_EMPDB) $(EXAMPLES_FB)/README $(EXTAUTH_PLUGIN)
+examples: $(FINAL_EMPDB) $(EXAMPLES_FB)/README

$(EXTAUTH_PLUGIN): $(EXAMPLES_FB)/extauth/Makefile
$(MAKE) -C $(EXAMPLES_FB)/extauth OUT=$(EXAMPLES_FB)/prebuilt INTERMED=$(TMP_ROOT)/examples/extauth
Loading

0 comments on commit 9d517b6

Please sign in to comment.