Firebird Documentation Index → Firebird MacOSX Whitepaper → Building Firebird from Source on MacOSX |
The next three sections record how I have built various models and versions of Firebird on MacOSx (eMac).
To build from source, you will have to have the XCode Tools (which includes GCC) installed on your Mac. These are freely available from the Apple Developer Connection site. Create a free membership account in order to download the developer tools.
My current build environment is:
Mac OSX Panther (10.3.7)
XCode 1.5
gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671)
In order to build Firebird Classic1.5.1 from Source Code on MacOSX, the following steps are required:
Download the latest source code package from the SourceForge Firebird page. In this example, we have downloaded firebird-1.5.1.4481.tar.bz2
Create a work directory and copy the source package into it. Our work directory is called firebird151
Open a Terminal window and change to our work directory
Unpack the source code archive using the following command
$ tar -jxvf firebird-1.5.1.4481.tar.bz2
This will unpack the contents into a subdirectory called firebird-1.5.1.4481. Change to the source directory using cd firebird-1.5.1.4481 before continuing.
You need to set a couple of environment variables before proceeding as the default
build process looks for the programs libtoolize
and
libtool
. Under OSX, the gnu versions of these programs, glibtoolize and
glibtool must be used instead:
$ export LIBTOOLIZE=glibtoolize $ export LIBTOOL=glibtool
Now run the autogen.sh shell script which automagically creates and runs the configure script to generate the required Makefile.
$ ./autogen.sh
This will take a wee while to complete. Once it is finished, you should see something like this at the end of the output:
The Firebird2 package has been configured with the following options: Architecture : ClassicServer Debug : disabled 64 bit I/O : enabled Raw devices : disabled Lock manager : enabled Service name : gds_db Service port : 3050 GPRE modules : c_cxx.cpp Install Dir : /usr/local/firebird Now type `make' to compile Firebird2
As the last line in the previous step says, run make to build the software:
$ make
The build takes a while to run ... make a cup of coffee. At the completion of the build process, you should see ...
********************************************************** Build Successful!! You can find the installer packages in gen/firebird, and the raw frameworks in gen/firebird/frameworks Run "make install" as root (or via sudo) to install your binary. Enjoy
If you look in the gen/firebird directory, you should see something like the following:
ahost:~/projects/Firebird/firebird-1.5.1.4481 $ ls -l gen/firebird/ total 2880 drwxr-xr-x 20 dwp dwp 680 28 Dec 17:27 . drwxr-xr-x 60 dwp dwp 2040 28 Dec 17:13 .. drwxr-xr-x 3 dwp dwp 102 28 Dec 17:27 Firebird-CS-1.5.pkg drwxr-xr-x 6 dwp dwp 204 28 Dec 17:21 Firebird.framework drwxr-xr-x 4 dwp dwp 136 28 Dec 17:27 UDF drwxr-xr-x 28 dwp dwp 952 28 Dec 17:26 bin -rw-rw-rw- 1 dwp dwp 145272 28 Dec 17:21 de_DE.msg drwxr-xr-x 3 dwp dwp 102 28 Dec 17:12 examples -rw-rw-rw- 1 dwp dwp 132796 28 Dec 17:21 firebird.msg -rw-rw-rw- 1 dwp dwp 144216 28 Dec 17:21 fr_FR.msg drwxr-xr-x 3 dwp dwp 102 28 Dec 17:27 frameworks drwxr-xr-x 3 dwp dwp 102 28 Dec 17:20 help drwxr-xr-x 8 dwp dwp 272 28 Dec 17:21 include drwxr-xr-x 3 dwp dwp 102 28 Dec 17:21 intl -rw-rw-rw- 1 dwp dwp 0 28 Dec 17:20 isc_init1.PBBear.local -rw-rw-rw- 1 dwp dwp 262144 28 Dec 17:20 isc_lock1.PBBear.local -rw-rw-rw- 1 dwp dwp 135656 28 Dec 17:21 ja_JP.msg drwxr-xr-x 12 dwp dwp 408 28 Dec 17:27 lib drwxr-xr-x 3 dwp dwp 102 28 Dec 17:21 misc -rw-rw-rw- 1 dwp dwp 643072 28 Dec 17:27 security.fdb
The first entry shows that we have successfully built a MacOSX Installer Package called Firebird-CS-1.5.pkg.
You can install this package either by double-clicking it in the Finder, or from the commandline by typing
open gen/firebird/Firebird-CS-1.5.pkg
My initial attempts to build FB 1.5.2 failed with a variety of error messages. After hacking around a bit, the following steps worked for me.
Unpack the source tarball and then change into the firebird source directory.
$ tar -jxvf firebird-1.5.2.4731.tar.bz2 $ cd firebird-1.5.2.4731
Run the clean script to ensure we start from the base build tree.
$ yes | . ./clean.sh
Export these environment variables so that the build uses the gnu libtools installed on OSX:
$ export LIBTOOLIZE=glibtoolize $ export LIBTOOL=glibtool
Now, edit the builds/posix/make.defaults and configure.in.
The Darwin Linker does not recognize the --version-script flag for attaching symbols to generated libs. To prevent errors, edit the builds/posix/prefix.darwin file and add the following lines to the end of the file:
LIB_LINK_MAPFILE= LINK_FIREBIRD_SYMBOLS= LINK_FBINTL_SYMBOLS=
Next, some OS-specific directories are not created by the supplied configure file. This will cause the build to fail.
You should edit the configure file and add the following lines at approximately line number 21277 in the appropriate sections:
mkdir -p temp/client.qli/jrd/os/darwin mkdir -p temp/client.util/jrd/os/darwin mkdir -p temp/client.gdef/jrd/os/darwin mkdir -p temp/embed.util/jrd/os/darwin mkdir -p temp/embed.gdef/jrd/os/darwin mkdir -p temp/embed.qli/jrd/os/darwin
The configure file is a generated file. If you run autogen.sh again, this file will be overwritten. To make this change permanent, add the lines to the configure.in file before running autogen.sh.
Now run the configure script to produce the platform-specific Makefile(s):
$ ./configure
When the script completes, you will see the following output:
The Firebird2 package has been configured with the following options: Architecture : ClassicServer Debug : disabled 64 bit I/O : enabled Raw devices : disabled Lock manager : enabled Service name : gds_db Service port : 3050 GPRE modules : c_cxx.cpp Install Dir : /usr/local/firebird Now type `make' to compile Firebird2
So, now do as it says and run make:
$ make
The build will chug away for a while before displaying the completion message:
********************************************************** Build Successful!! You can find the installer packages in gen/firebird, and the raw frameworks in gen/firebird/frameworks Run "make install" as root (or via sudo) to install your binary. Enjoy
You will find the Firebird-CS-1.5.pkg OSX Installer Package in the gen/firebird directory.
On a couple of occasions, the build failed with an error relating to ranlib and the libeditline.a being out of date. If you receive this error, you need to run the ranlib program against the libeditline.a file, then continue the make process as follows:
$ ranlib gen/firebird/lib/libeditline.a $ make
To build the SuperServer Installer Package, you should first successfully build the CS version as described above. Then,
In the firebird source directory, run the configure script with the superserver switch as follows:
$ ./configure --enable-superserver
At the end of the script execution, you will see the following output:
The Firebird2 package has been configured with the following options: Architecture : SuperServer Debug : disabled 64 bit I/O : enabled Raw devices : disabled Service name : gds_db Service port : 3050 GPRE modules : c_cxx.cpp Install Dir : /usr/local/firebird
Now run the make command to build the package:
$ make
When the build is complete, you should have a new Installer Package in the gen/firebird directory called Firebird-SS-1.5.pkg:
$ ls gen/firebird/F* Firebird-CS-1.5.pkg Firebird-SS-1.5.pkg Firebird.framework
Now, run the installer package, either by locating it in the Finder and double-clicking, or by using the open utility from the commandline as follows:
$ open gen/firebird/Firebird-SS-1.5.pkg
Upon completion of the installation, a StartupItem for the Firebird SuperServer daemon has been installed in /System/Library/StartupItems/Firebird.
Start the Firebird SuperServer using the following commandline:
$ sudo SystemStarter start "Firebird Server"
You can check that it is running using the ps command as follows:
$ ps aux | grep fb root ... ... /path/to/bin/fbguard -f root ... ... /path/to/bin/fbserver
The string "/path/to/bin/ should appear as "/Library/Frameworks/Firebird.framework/Resources/English.lproj/var/bin" and you should see running processes called fbguard and fbserver.
From now on, whenever you restart your machine, the Firebird Superserver will be started automatically.
You can manually stop, start and restart the Firebird Superserver using the SystemStarter command in a Terminal as follows:
$ sudo SystemStarter stop "Firebird Server" $ sudo SystemStarter start "Firebird Server" $ sudo SystemStarter restart "Firebird Server"
If you have already installed either the Classic or Superserver package, running the installer again will 'Upgrade' it. Whilst this should be safe, I recommend that you backup your existing installation by copying the /Library/Frameworks/Firebird.framework directory tree to another location before proceeding with installation.
I have safely flipped between Classic/SuperServer operation just by 'upgrading' with the required package. Note that during an upgrade, the Firebird Security database is preserved, so any users/password changes you have made remain in effect.
Installation of both the Classic and Superserver packages is not a problem. However, operationally, only the last installed version will be used at runtime.
For instance, when you install Classic, Firebird is configured to listen for database connections on port 3050 via the xinetd daemon. If you later install Superserver, Firebird is removed from the xinetd configuration. You must use SystemStarter (or restart your machine) to start the Firebird SuperServer daemon, which will then listen for database connections on port 3050.
To cleanup before a totally fresh install (ie. during development or testing), the following directories must be removed:
/Library/Frameworks/Firebird.framework /System/Library/StartupItems/Firebird /Library/Receipts/Firebird-XX-1.5.pkg
The next installation of the package will then ask you to Install instead of Upgrade.
In order for other machines to connect to your Firebird databases, in your System Preferences, go to the Sharing/Firewall page and open port 3050 to inbound connections. Assess your own security policy before doing this.
The SuperServer installation installs a SystemStarter script in the location /System/Library/StartupItems/Firebird/. According to the docs I have read, the /System/Library/StartupItems directory is reserved for use by Mac OSX startup processing. User daemons should instead be installed in /Library/StartupItems directory.
The SuperServer startup script /System/Library/StartupItems/Firebird/Firebird contains the SYSDBA password hard-coded in it to enable the Firebird shutdown command to succeed.
This may be regarded by some as a security hole
If you change the default SYSDBA password (masterkey) as recommended in the install docs, then you will also have to edit the startup script and replace the default password with your new SYSDBA password.
The SuperServer startup script runs the Firebird SuperServer processes under the root profile.
This may be regarded by some as a security risk
During installation of the Firebird package, a user called firebird was created, however, this user profile is not used.
You can modify the startup script to run the SuperServer under the firebird profile as follows:
Edit the script /System/Library/StartupItems/Firebird/Firebird
Change the StartService code to use the su -c command as follows:
Note, the command should not be broken up as it appears in the illustrations below.
su firebird -c "/Library/Frameworks/Firebird.framework/Res ources/bin/fbmgr.bin -start"
Change StopService, so:
su firebird -c "/Library/Frameworks/Firebird.framework/Res ources/bin/fbmgr.bin -shut -password masterkey"
and RestartService, so:
su firebird -c "/Library/Frameworks/Firebird.framework/Res ources/bin/fbmgr.bin -shut -password masterkey" su firebird -c "/Library/Frameworks/Firebird.framework/Res ources/bin/fbmgr.bin -start"
Save your changes.
Then you must ensure that the contents of /Library/Frameworks/Firebird.framework are owned by the user firebird:
$ sudo chown -R firebird:firebird /Library/Frameworks/Fire bird.framework/
Finally, you must ensure that any database you wish to create and/or access must be in a location to which the firebird user has read/write privileges. The easiest way to do this is to create a special directory to hold all your Firebird databases and assign its ownership to the firebird user.
$ cd ~ $ mkdir fbdata $ sudo chown firebird:firebird fbdata $ isql -u SYSDBA -p masterkey Use CONNECT or CREATE DATABASE to specify a database SQL> CREATE DATABASE '/Users/dwp/fbdata/testdb.fdb'; SQL> quit;
If we now look in the fbdata directory, we will see our new database has been created by the Firebird Superserver process and that it is owned by the firebird user (ie. the user who owns the Superserver process):
$ ls -l fbdata total 1168 drwxr-xr-x 3 firebird firebird 102 2 Jan 20:26 . drwxr-xr-x 77 dwp dwp 2618 2 Jan 20:25 .. -rw------- 1 firebird firebird 598016 2 Jan 20:28 testdb.fdb
Firebird Documentation Index → Firebird MacOSX Whitepaper → Building Firebird from Source on MacOSX |