##################### GENERAL ##################### 
GARNAME = firebird
GARVERSION = 3.0.4.33054.0
ORIGNAME = Firebird
ORIGVERSION = 3.0.4.33054-0
GARELEASE = 3
HOME_URL = https://firebirdsql.org/
CATEGORIES = app/database
MASTER_SITES += https://github.com/FirebirdSQL/firebird/releases/download/R3_0_4/
DISTFILES = Firebird-$(ORIGVERSION).tar.bz2
PATCHFILES = 
MAINTAINER = Felipe Sanchez <izto@asic-linux.com.mx>
LICENSE = Interbase Public License (Modified Mozilla Public License V1.1)

DESCRIPTION = An open source, multiplatform RDBMS
define BLURB

Firebird is a relational database offering many ANSI SQL standard
features that runs on Linux, Windows, MacOS and a variety of Unix
platforms. Firebird offers excellent concurrency, high performance,
and powerful language support for stored procedures and triggers.
It has been used in production systems, under a variety of names,
since 1981.

The Firebird Project is a commercially independent project of
C/C++ programmers, technical advisors and supporters developing
and enhancing a multi-platform relational database management
system based on the source code released by Inprise Corporation
on 25 July, 2000.
endef

##################### PACKAGING #####################


#IZTACI_PACKAGE_PATH =

# Users and groups the binary package will create
# WHEN INSTALLED ON THE DESTINATION SYSTEM
CREATE_GROUPS = firebird:84
CREATE_USERS  = firebird:84:84

# This is to be appended to the package's installation script
# Use it to set file owners, permissions, DB initialization, etc.
# Remember any shell variables (Such as $ROOT) have to be escaped
# like this: \$$ROOT

define DOINST_APPEND

chown -v firebird:firebird $(sysconfdir)/security3.fdb

mkdir -vp /var/log/firebird/server
chown -R log:log /var/log/firebird

echo ------------------------------------------------------------------
echo s6-rc services installed:
echo
echo \"    firebird-server\"
echo \"    firebird-log\"
echo \"    fbserver-log\"
echo \"    firebird\"
echo
echo Run \'rc update\' to add them to the live services database.
echo
echo ------------------------------------------------------------------
echo If this is a new installation you should change the default SYSDBA password:
echo
echo  /usr/bin/gsec -user sysdba -password 'newpassword' -di
echo
echo Afterwards, start the FirebirdSQL service with \'rc up firebird\'
echo ------------------------------------------------------------------
echo
endef

# Required dependencies
define SLACK_REQUIRED
gcc-so | gcc
libtommath
ncurses
icu4c
endef

# Suggested dependencies
define SLACK_SUGGESTS
endef

# Package conflicts (lprng vs cups for example)
define SLACK_CONFLICTS
firebird25
endef



##################### BUILDING #####################


CONFIGURE_SCRIPTS = $(WORKSRC)/configure
BUILD_SCRIPTS = $(WORKSRC)/Makefile
INSTALL_SCRIPTS = custom

CONFIGURE_ARGS = $(DIRPATHS)
NODIRPATHS = 

# Directories to be created as part of the install process.
# Can be inside the final package or just transient dirs we need
# while building it.
INSTALL_DIRS += $(DESTDIR)/etc/sysconfig
INSTALL_DIRS += $(DESTDIR)/etc/s6-rc/source
INSTALL_DIRS += $(DESTDIR)/srv/firebird
INSTALL_DIRS += $(DESTDIR)/$(libdir)/firebird
INSTALL_DIRS += $(DESTDIR)/$(bindir)
INSTALL_DIRS += $(DESTDIR)/$(docdir)

# If some dirs are trying to install into /, list their names
# here, such as: prefix bindir mandir
INSTALL_OVERRIDE_DIRS = 


# Dependencies are of the form categorydir/packagedir
# LIBDEPS are for libraries, and DEPENDS are for everything else
DEPENDS =
LIBDEPS =
DEPENDS =
# Builddeps are installed in the build DESTIMG
BUILDDEPS =

##################### GAR #####################

# This should go before any hand-made rules.
include config.mk
include ../level.mk

##################### CUSTOMIZING #####################

test:
	cd $(WORKSRC); $(MAKE) check
	$(MAKECOOKIE)

# Firebird does not support DESTDIR and its "install" target
# looks loke an overly convoluted mess to me, so we'll just 
# take the "dist" target which creates something a bit
# like a DESTDIR and then we move everything in place from
# there.

install-custom:
	$(MAKE) -C $(WORKSRC) gen dist
	cp -av $(WORKSRC)/gen/buildroot/* $(DESTDIR)
#	cd $(WORKSRC)/gen/buildroot/usr/;     \
#	mv -v plugins UDF $(DESTDIR)$(libdir)/firebird && \
#	mv -v misc/upgrade $(DESTDIR)/$(docdir) && \
#	mv -v doc examples misc *License.txt README WhatsNew $(DESTDIR)/$(docdir) && \
#	mv -v *.conf intl help firebird.msg security3.fdb $(DESTDIR)/srv/firebird &&          \
#	mv -v bin/*   $(DESTDIR)/$(bindir) && \
#	mv -v lib/*   $(DESTDIR)/$(libdir) && \
#	mv -v include $(DESTDIR)/$(prefix)
	$(MAKECOOKIE)


post-install:
	$(MAKE) s6rc
	$(MAKE) sysconfig
	rm -vr $(DESTDIR)/var
	rm -vr $(DESTDIR)/run
	$(MAKE) strip
	$(MAKE) gzip-man
	$(MAKECOOKIE)

