Before launching make for a raw build, Postgres does some preprocessing with configure to setup the installation based on the environment and the different options given by user. If you don’t do that before trying a make, your build will fail with a critical hit of this type:
$ make
You need to run the 'configure' program first. See the file
'INSTALL' for installation instructions.
make: *** [all] Error 1

It is important to get familiar with this way of doing before actually working or developing Postgres, so be sure to go through the notes of this post to learn one thing or two, or even complete those notes with comments at the bottom.

This process is launched with ./configure, located at the root of the code path (it can even be called outside of code folder in the case of a vpath installation) and generated directly from configure.in using autoconf. A couple of scripts located in config/ containing additional methods not in autoconf are also used when generating ./configure from ./configure.in for many things:

  • Check presence of necessary library dependencies, some of them being optional (documentation) and others mandatory as core process need them (flex, bison)
  • Check availability of some languages (perl.m4, python.m4)
  • Test C-related functionalities (c-compiler.m4, c-library.m4)
  • etc.

Note that those files are included through ./aclocal.m4 like that:
m4_include([config/c-compiler.m4])
./aclocal.m4 is included itself automatically by autoconf as default.

If you are a PostgreSQL developer, you might at some point create a fork of Postgres for a private project. In this case, you should definitely modify your project to be a maximum consistent with Postgres itself in order to facilitate merges with future versions. The preprocessing Postgres uses has few chances to change but it usually includes fixes that may be platform dependent, so be sure to fetch the fixes when they are here. Here are also some advices about how you should manage a fork regarding configure:

  • Modify in priority configure.in and not configure. Generate configure based on your modifications of configure.in.
  • When extra preprocessing is needed, add your own m4 procedures in config/ in separate files, except if they overlap with existing checks, so as if a fix happens on Postgres itself you will be able to at least detect easily if there is a conflict with what your own stuff.
  • Declare additional m4 files in ./aclocal.m4
  • Similarly, do not forget to update Makefile.global.in when adding some new variables, and use them!

Here is a short example of how you could add your own .in file with some code dedicated to configure.in understandable by autoconf.
#Some initialization
AC_INIT([mypgfork], [1.0devel], [joe@example.com])
AC_CONFIG_AUX_DIR(config)
 
# Setup a default prefix
AC_PREFIX_DEFAULT(/usr/local/psql)
 
# Addition of my own customized file
AC_CONFIG_FILES([foo.cfg.in])
 
# Option to enforce optimize to a wanted flag
PGAC_ARG_BOOL(enable, optimize, no,
  [build with optimize symbol (-O2)])
 
# supply -g if --enable-super-debug
if test "$enable_optimize" = yes; then
 CFLAGS="-O2"
fi
 
# Substitute CFLAGS value in .in files
AC_SUBST(CFLAGS)
 
# Generate the output to files
AC_OUTPUT

In this case a file called foo.cfg *is* generated… Feel free to play with this piece of code btw.

For a vanilla Postgres build, two files that are used for code make and installation are generated: src/Makefile.global.in (containing all the variables that are environment-dependent as well as all the configuration parameters that user has set when launching ./configure) and GNUMakefile.in.

When generating Postgres from raw code, there are some options in ./configure you should absolutely know about if you are a developer:

  • –prefix to define the folder where library and binaries will be installed (bin, share, lib, include).
  • –enable-cassert, to enable assertions inside a build (avoid that for a production build, this option is good only or development).
  • –enable-debug, making the code to compile with -g in CFLAGS, the default being -O2 for production builds.
  • –enable-depend, to enable automatic dependency tracking, useful to recompile all the objects affected by a header modification.

There are also some options that you might need if you develop an application based on Postgres:

  • –with-perl, to enable PL/Perl on server side
  • –with-python, to enable PL/Python on server side
  • –with-blocksize, defining the default block size used by table pages, default begin 8kB. Note that using binaries compiled with a given block size is not compatible with a existing server that has been initialized with a different block size.

Do not forget to have a look at all the options available here, configure might have many things that remained hidden to you until now.

In one word, Arch Linux is AWESOME. It is the first distribution of Linux that I use giving me the feeling that I control everything in my environment. Among its strengths, its package manager pacman makes everything very flexible and once you migrate to it, you don’t need to worry about support time or anything like for Ubuntu distributions or most of the major distributions.

However setting up an Arch environment is honestly a pain for noobs.
So, based on my *painful* experience, I created some manuals that can be used to install an ArchLinux environment using XFCE as Desktop.
So here is the list of manuals.

Those manuals are not perfect, but give good guidelines of my migration experience. Enjoy!

Here is a memo about RPM building in Linux environment.
First is necessary an RPM-based distribution. The most famous are Fedora and CentOS.

Let’s suppose you want to build your RPMs in the folder $RPMREPO.
You need first the correct folder tree for package creation.
mkdir $RPMREPO
cp -r /usr/src/redhat/* $RPMREPO

Then what is necessary is a spec file (Ex: spec_file.spec). It contains all the directives necessary to create the package.
You may find examples of spec files in RedHat SVN repositories like the one of PostgreSQL 9.0 package.
With a spec file, you may need a PAM file (Ex: file.pam), containing data like:
#%PAM-1.0
auth include password-auth
account include password-auth

Don’t forget that you also need a tarball (Ex: foo.tar.gz) or something equivalent containing the code.
Then copy the PAM file and the tarball inside $RPMREPO/SOURCES.
cp file.pam foo.tar.gz $RPMREPO/SOURCES
Copy the spec file to the correct folder.
cp spec_file.spec $RPMREPO/SPECS

Before building an RPM, it is necessary to set a file called .rpmmacros located in $HOME directory.
echo "%_topdir $RPMREPO" > $HOME/.rpmmacros

Then you can create the RPM with this command, assuming spec, pam and tarball files are correct.
rpmbuild -ba spec_file.spec

If no error occurred, SRPM file is located in $RPMREPO/SRPMS, RPM packages are located in $RPMREPO/RPMS/x86_64.

Here are some additional useful commands.
You can also build a RPM package from a SRPM file.
rpmbuild --rebuild $SRPM_FILE

Check content of an RPM file.
rpm -qpl $RPM_FILE

Export files of an RPM package.
rpm2cpio $RPM_FILE | cpio -idv

Sometimes you have to face some formats that are not installed by default in Ubuntu environments.
And it may be a problem if you cannot extract such archives.

Fortunately, there are some free applications provided with your distribution.
If you are not using Ubuntu, you can find debian or rpm packages easily.
In order to do that, there is this useful RPM package searcher
or this Debian package searcher.

For Ubuntu, which is well… Debian based… (But it uses an APT system to manage its distribution packages)
Here is how to install those packages with commands (geek-mode).
To install rar format manager:
sudo apt-get install unrar-free
To install 7z format manager:
sudo apt-get install p7zip

Or for beginners you can find the packages in the software package center.
For that you have just to make a research with p7zip and unrar-free for each application in the Ubuntu Software Center in the Application tab of your menu bar.

To decompress a file with p7zip, you have to do the following command:
7z x $FILE_NAME
$FILE_NAME being the name of your 7z file.

To decompress a file with unrar-free, you have to do the following command:
unrar-free x $FILE_NAME
$FILE_NAME being the name of your rar file.

©2010-2013 Michael Paquier All content is ©Copyright of Otacoo.com 2010-2013. Privacy Policy - Terms of Use