Tools

Compilers, build systems and other applications that support programming

Building and Installing PostgreSQL on Mac OS X

Here are instructions for building and installing the PostgreSQL database server on a Mac OS X system. This includes instructions for using dscl to create a special user account to manage the database processes and data, and a sample launchd script to automatically launch the database server on system startup.

Introduction

Tags:

If you write C/C++ code on a Unix system you probably have used GNU Make at some point. Even if you have used it for years, you may not be aware of some of its simpler and yet powerful features. Here are a handful of what I suspect are lesser-known capabilities of GNU Make that make me more productive.

Summary

Tags:

I have described the handful of GNU Make features that I employ to greatest effect in my work (mostly C/C++ programming). By adhering to a few simple conventions when you initially structure your project you can employ these techniques to create a few simple building-block Makefiles that you can then reuse throughout your work. Ultimately, even a complex and dynamic project can be maintained by a Makefile that is just a few lines long.

Identifying Dependencies Automatically

Tags:

GCC has a set of preprocessor options intended for use with GNU Make, the -M options. The gcc -M options generate a set of include-file names on which a source file depends, in the form of a GNU Make rule. I use g++ -MM in a Makefile rule to identify dependencies for my .cpp files. The -MM option omits system header files from the dependency list.

# Add .d to Make's recognized suffixes.
SUFFIXES += .d

Extending GNU Make's Logic

Tags:

You can set variables to change how GNU Make does what it does, you can define new rules to change what GNU Make can do. The general form of a rule is:

target : prerequisites...
        commands

Keeping Things Modular With include

Tags:

The GNU Make include directive lets you include one Makefile in another. One benefit of this is you can more easily re-use your configurations. If you have common behavior patterns that you employ in many places or projects, you can use include to avoid having to rewrite the rules repeatedly.

For example, you might put the following into /usr/local/include/make.def_vars:

CPPFLAGS = -Wall -Wextra -pedantic
ifdef NDEBUG
    CPPFLAGS += -O3
else
    CPPFLAGS += -g
    CPPFLAGS += -D_GLIBCXX_DEBUG

Organizing Projects With vpath

Tags:

GNU Make's vpath directive lets me easily build a “debug” and a “release” form of my project from the same source in completely independent workspaces but using the same source code and the same Makefile.

When I start a new programming project, say a C++ class library, I typically start by creating the following directories, all of which I ultimately put under version control (e.g., CVS or Subversion):

The Makefile of No Makefile

Tags:

The simplest Makefile I use is:

That is, I use no Makefile and rely on GNU Make's built-in rules. When I first start a project, or when I have a simple piece of C/C++ code that I want to test in a stand-alone form, I write a simple main() routine in, for example, a file called prog.cpp and run:

$ make prog
g++     prog.cpp   -o prog
$ 

GNU Make Techniques

Tags:

Here are the features of GNU Make that I find provide the greatest payoff for the least effort. Using the techniques here I can maintain relatively complex C/C++ projects using just a few dozen lines of GNU Make instructions. The results are not only lean, but flexible and robust as well.

Working With DocBook XML On Mac OS X

Here is what I did to my Mac OS X 10.4 environment to work with DocBook XML.

Syndicate content