Skip to content

Commit

Permalink
Add cross/firebird SynoCommunity#5795
Browse files Browse the repository at this point in the history
Build FirebirdSQL database

The build works for x64 and aarch64 architecture and DSM 7.0 and 7.1

- Use configure --with-cross-build as used by firebird build itself
  • Loading branch information
vitkabele authored and Vít Kabele committed Aug 7, 2023
1 parent 4e02ce8 commit 648cf36
Show file tree
Hide file tree
Showing 7 changed files with 1,577 additions and 0 deletions.
115 changes: 115 additions & 0 deletions cross/firebird/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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 cross/libicu native/libicu native/libtool

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

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

# Currently v4.0.2 works only with 7.0 and 7.1
# DSM 7.2 has issues with GLIBC version
# DSM 6.x has issues with some C++ libraries versions
ifeq ($(call version_lt,$(TCVERSION),7.0)$(call version_gt,$(TCVERSION),7.1),1)
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

CONFIGURE_TARGET = firebird_configure

COMPILE_TARGET = firebird_compile

INSTALL_TARGET = firebird_install

# CXXFLAGS should be set fine by the spksrc for cross-compilation, we will
# use it in cross2 step CROSS_ENV
ADDITIONAL_CXXFLAGS = -Wno-invalid-offsetof

# Path to the libtool installed in the cross/libtool DEPENDS target
# We need the native libtool for building libommath/libtomcrypt in cross1 step
LIBTOOL_BIN = $(WORK_DIR)/../../../native/libtool/work-native/install/usr/local/bin/libtool

# 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 --with-builtin-tommath --with-builtin-tomcrypt \
--without-editline --with-cross-build=synology.$(ARCH) --prefix=$(INSTALL_PREFIX)

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

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

# Preprocessor flags
NATIVE_CPPFLAGS := -I$(NATIVE_LIBICU_DIR)/include

# This ENV is for cross1 phase where we build native target
#
# The NATIVE flags must be passed to the configure part, because the configure
# fails when it cant find the headers.
NATIVE_ENV = CC=gcc CXX=g++ AS=as AR=ar LD=ld NM=nm OBJCOPY=objcopy OBJDUMP=objdump \
PARALLEL_MAKE=max \
LIBTOOL="$(LIBTOOL_BIN)" \
CFLAGS="$(NATIVE_CFLAGS)" \
CXXFLAGS="$(NATIVE_CFLAGS)" \
CPPFLAGS="$(NATIVE_CPPFLAGS)"

NATIVE_RUN = cd $(WORK_DIR)/$(PKG_DIR) && env $(NATIVE_ENV)

# DO NOT MODIFY $(ENV) variable (too much) a.k.a. only add variables for ourselves
# and do not modify any CFLAGS or other universally recognized variable
# It breaks compilation of dependent cross/* libraries (especially cross/libicu)
#
# This ENV is for cross2 build phase where we build binaries for target platform
# CROSS_ prefixed vars are for the cross2 phase and we "strip" the CROSS_ prefix
# in our provided src/makefile.xxx
#
# The C(XX)FLAGS variables are ready by the spksrc for cross compilation, we
# just use them
ENV += CROSS_TOOLCHAIN=$(TC_PATH)$(TC_PREFIX)

.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/
$(NATIVE_RUN) NOCONFIGURE=1 ./autogen.sh

# Override the configure target, because we must pass it different env than
# ENV. We cannot modify ENV to contain -I for native/libicu, because it breaks
# compilation of native/libicu, but we must have this -I in the configure
# CFLAGS, otherwise the configure step fails with unicode headers not found.
.PHONY: firebird_configure
firebird_configure:
$(NATIVE_RUN) ./configure $(CONFIGURE_ARGS)

# Firebird itself would be compiled by simple make, but we must pass different
# environment to cross1 and cross2 step. The toolchain and CFLAGS differ
.PHONY: firebird_compile
firebird_compile:
$(NATIVE_RUN) make TARGET=Native cross1
$(RUN) make TARGET=Release CROSS_OUT=Y cross2

.PHONY: firebird_install
firebird_install:
$(RUN) make TARGET=Release CROSS_OUT=Y 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
Loading

0 comments on commit 648cf36

Please sign in to comment.