In this tutorial we will go through the entire process of building CUBRID CCI API on Mac OS X. In this tutorial I will be using Snow Leopard.
Apple's Xcode Developer Tools version 4.1 or later for Lion, 3.2 or later for Snow Leopard, or 3.1 or later for Leopard is required to build Macports (see below). Choose and download Xcode from Apple Developer Center. When installing ensure that the optional components for command line development are checked to be installed ("System Tools", "UNIX Development", or "Command Line Tools" in newer versions, or "Command Line Support" in older ones). The following is a screenshot of Xcode 3.2.6 on Snow Leopard.
Macports is a great, convenient package manager for Mac OS X. It simplifies many steps by automatically managing dependencies between packages. Some Linux-only packages have been ported to Mac and are available through Macports. To build CCI API we need some of those GNU packages available on Linux. So, we need Macports.
Macports is available in "pkg" installer. You can download it from http://www.macports.org/install.php/. Once downloaded, simply double click on the package to start the installation process.
Now install the tools required to build CUBRID source code.
sudo port install autoconf automake libtool sudo port install coreutils
CUBRID Source Code is available at SF.net. Checkout the latest version using the following command. In this tutorial we will download version 8.4.1.
svn co http://cubrid.svn.sourceforge.net/svnroot/cubrid/cubrid/branches/RB-8.4.1 cubrid-8.4.1
We need to create symlinks to two GNU libs because Mac OS X version of these libs are not compatible with CUBRID source code as we use GNU version. So let's link them.
cd cubrid-8.4.1 ln -s /opt/local/bin/greadlink readlink ln –s /opt/local/bin/glibtoolize libtoolize
these will create readlink and libtoolize symlinks in the root directory of CUBRID source code. Now we need to force the builder to use them instead of the Mac OS X version by appending the current directory path to $PATH.
user$ export PATH=/Users/user/Downloads/cubrid-8.4.1/:$PATH user$ $PATH -bash: /Users/user/Downloads/cubrid-8.4.1/:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin: No such file or directory
Some files in CUBRID source code need to be executable while for some reason they are not. So we will fix this.
chmod +x cubrid-8.4.1/external/libregex38a/configure chmod +x cubrid-8.4.1/external/libregex38a/configure.gnu chmod +x cubrid-8.4.1/external/libregex38a/install-sh
For CUBRID 8.4.3 the following file also needs to be executable.
chmod +x cubrid-8.4.3/external/expat-2.0.1/configure chmod +x cubrid-8.4.3/external/expat-2.0.1/configure.gnu
Since CUBRID supports Java Stored Procedures during this CCI API compilation process we need JDK to compile the source responsible for Java Stored Procedures. So let's set these variables.
In Snow Leopard simply export the following path to JAVA_HOME variable. The Home directory already contains /include and /lib directories necessary for building CCI API. So we are good.
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
For some reason Apple has decided to put jni_md.h file into a separate directory under $JAVA_HOME/include/darwin/ instead of just $JAVA_HOME/include/. Since this file is required to build Java Stored Procedure feature in CUBRID, we need to hard copy (not symlink) this file to $JAVA_HOME/include/.
sudo cp $JAVA_HOME/include/darwin/jni_md.h $JAVA_HOME/include/
We need to edit CUBRID source code so that it correctly compiles under OS X.
Edit ./external/gc6.7/darwin_stop_word.c file.
Edit ./src/cci/cci_net_buf.h file.
Around the line 57 you will see the following code. Add the code marked in red:
#if (defined(SOLARIS) && !defined(SOLARIS_X86)) || defined(HPUX) || defined(AIX)
#define BYTE_ORDER_BIG_ENDIAN
#elif defined(WINDOWS) || defined(LINUX) || defined(SOLARIS_X86) || defined(MAC_OS)
#ifdef BYTE_ORDER_BIG_ENDIAN
#error BYTE_ORDER_BIG_ENDIAN defined
Edit ./src/broker/cas_net_buf.h file.
Around the line 45 you will see the following code. Add the code marked in red:
#if (defined(SOLARIS) && !defined(SOLARIS_X86)) || defined(HPUX) || defined(AIX) || defined(PPC_LINUX)
#define BYTE_ORDER_BIG_ENDIAN
#elif defined(WINDOWS) || defined(LINUX) || defined(OSF1) || defined(ALPHA_LINUX) || defined(UNIXWARE7) || defined(SOLARIS_X86) || defined(MAC_OS)
#ifdef BYTE_ORDER_BIG_ENDIAN
#error BYTE_ORDER_BIG_ENDIAN defined
Edit ./configure.ac file.
Around the line 54 you will see the following code. Add the code marked in red:
case $SYSTEM_TYPE in
*linux*) SYS_DEFS="-DGCC -DLINUX -D_GNU_SOURCE -DI386"
SYS_LIBS="" ;;
*) SYS_DEFS="-DMAC_OS"
SYS_LIBS="" ;;
esac
If you are building CUBRID 8.4.3, you also need to edit ./src/cci/cci_common.h.
Line 71: #define gettid() syscall(__NR_gettid)
change to
#define gettid() getpid()
cd cubrid-8.4.1 mkdir build ./autogen.sh
Now configure the source code. Notice the --prefix path /usr/local/cubrid. This is where we will place CUBRID CCI API once we compile so that other dependent APIs like PHP, Python, etc. could link to our CCI API. At this moment we do not need to created that directory.
cd build ../configure --prefix=/usr/local/cubrid
If you are building CUBRID 8.4.3, before moving to the next final step, you need to make external libraries. In 8.4.1 this step was not required.
cd build/external make
cd cubrid-8.4.1/build/cci make -j
Congratulations! You can find the compiled CUBRID CCI API in cubrid-8.4.1/build/cci/.lib/. Below is a list of CCI API files you need to keep together if you want to further compile other APIs based on CCI.
Copy them to /usr/loca/cubrid directory as shown below.
mkdir /usr/local/cubrid mkdir /usr/local/cubrid/include mkdir /usr/local/cubrid/lib cd cubrid-8.4.1 sudo cp build/cci/.libs/libcascci.8.dylib /usr/local/cubrid/lib sudo cp build/cci/.libs/libcascci.a /usr/local/cubrid/lib sudo cp src/broker/cas_error.h /usr/local/cubrid/include sudo cp src/cci/cas_cci.h /usr/local/cubrid/include sudo ln -s /usr/local/cubrid/lib/libcascci.8.dylib /usr/local/cubrid/lib/libcascci.so
Done!