Building Ruby on AIX

Requisite Installation

  1. OPTIONAL: Install the IBM Visual Age for C Compiler suitable for your release of AIX. The installable package is in standard AIX installp format on the CD. For Visual Age C 6.0 you will also need to license the compiler with the iFor License Manager, which is a HOWTO topic in and of itself.

  2. Download GCC (if you are not using VaC), zlib, make, and OpenSSL RPM binaries and development files from IBM's AIX Toolbox for Linux page. Note that OpenSSL is on the Cryptographic Tools link on the right side of the site. Don't forget to grab the prngd binary if you are using AIX 4.3.3 or AIX 5.1.

  3. Install the RPMs using the following commands as root. If your AIX does not have the rpm binary download the installp package and install it per IBM's site. The RPMs will install into /opt/freeware so make sure you have enough space there.

    • If you are using GCC, install/upgrade to the correct release from the downloaded RPM files:

      # rpm -Uvh gcc*.rpm libgcc*.rpm libstdcplusplus*.rpm
  4. Regardless of compiler, install the necessary library files:

    # rpm -Uvh zlib*.rpm openssl*.rpm make*.rpm readline*.rpm
  5. OPTIONAL: Install the prngd RPM the same way if your system is AIX 5.1 or AIX 4.3.3.

    # rpm -Uvh prngd*.rpm
  6. Download and extract the Ruby 1.8.4 source distribution. Once downloaded, extract it into a suitable directory with the following:

    # gunzip -c ruby-1.8.4.tar.gz | tar xf -

Environment Preparation

Prior to building the Ruby source code, the following environment changes must be enabled for the user who is building the Ruby Source:

  1. GCC should already be in your PATH if you installed them from the RPM files. You only need to update your path if your GCC is installed in a non-standard location.

  2. If you are using IBM's Visual Age for C Compilers change your PATH so that the Visual Age for C Compiler is checked before anything else (i.e. gcc). On my system I have GCC and VaC so it is vital that the cc command comes from /usr/vac/bin or /usr/ibmcxx/bin.

    • For VaC 6.0 and 7.0:

      # export PATH=/usr/vac/bin:$PATH
    • For VaC 5.0 or lower:

      # export PATH=/usr/ibmcxx/bin:$PATH
  3. Set the CPPFLAGS environment variable with:

    • For GCC:

      # export CPPFLAGS="-D_LINUX_SOURCE_COMPAT"
    • For IBM's VaC:

      # export CPPFLAGS="-qalloca -D_LINUX_SOURCE_COMPAT -qlonglong"
  4. Set the CC environment variable to use the correct compiler:

    • For GCC:

      # export CC=gcc
    • For IBM's VaC:

      # export CC=cc

Starting the Ruby Build

Before starting this section be sure to correctly set your PATH, CC, and CPPFLAGS as described in the previous sections, especially if using IBM's Visual Age for C Compiler. Once you have verified your environment settings proceed with the following steps.

  1. OPTIONAL: For AIX 4.3.3 you will have to add custom macros that are missing in the sys/socket.h header file. AIX 5.1 and higher have these defined correctly.

    The socket extension for Ruby is in directory: <build directory>/ruby-1.8.4/ext/socket. The file that needs the extra macro definitions is socket.c, so add the following macros anywhere after the #include lines in this file:

    #ifndef CMSG_SPACE
    #define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
    #endif
    #ifndef CMSG_LEN
    #define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
    #endif
  2. Build the Makefiles with the configure script:

    • For GCC:

      # ./configure --prefix=/usr/local/ruby \
      --with-openssl-dir=/opt/freeware \
      --with-zlib-dir=/opt/freeware \
      --with-readline-dir=/opt/freeware
    • For IBM's VaC:

      # ./configure --prefix=/usr/local/ruby --without-gcc \
      --disable-ipv6 \
      --with-openssl-dir=/opt/freeware \
      --with-zlib-dir=/opt/freeware \
      --with-readline-dir=/opt/freeware
  3. Before invoking any builds, and after the configure script has been run, certain *.c source files need to me modified by having their #include <unistd.h> lines commented out with /* */. Simply edit each of the files listed below, search for unistd.h, and comment it out.

    • <build directory>/ext/openssl/ossl_ssl.c

    • <build directory>/ext/openssl/ossl_bio.c

    • <build directory>/ext/readline/readline.c

  4. If you are building with GCC, the top-level Makefile specifies an extra -brtl for LDFLAGS. Edit the Makefile and change the line that reads:

    LDFLAGS = $(CFLAGS) -brtl

    So that it reads:

    LDFLAGS = $(CFLAGS)
  5. Build the ruby.imp file that is missing from the Makefile as a dependency.

    # gmake ruby.imp
  6. Invoke the main build with GNU Make. Be warned, it is not the cleanest build as there are a lot of warnings but it should complete successfully.

    # gmake
  7. After successful compilation, test the Ruby build with:

    # gmake test

Installing Ruby after the Build

Installation of the Ruby binaries is fairly straightforward; however, one thing that is often overlooked is the Ruby Documentation install for usage with ri. I have found several pre-packaged Linux Rubies that do not include it and it drives me nuts, so be good to yourself and install it.

  1. Install your newly compiled Ruby binaries with the following:

    # gmake install
  2. Be sure to install the Ruby Documentation (RDoc) files with:

    # gmake install-doc