On Fri, 31 Aug 2007 19:46:05 -0400 "Brett W. McCoy" <[EMAIL PROTECTED]> wrote:
> On 8/31/07, ed <[EMAIL PROTECTED]> wrote: > > > A small project that I've been working on was buildable for > > linux/openbsd through a Makefile. The Makefile would build with one > > of two .c files. This worked fine as the same function names were > > used in both files. > > > > Now I'm wanting to add optional mysql/postgres/sqllite etc to the > > project but I don't know how I can specify these as optionals, for > > example, the libraries may not exist to link to. Is there a way to > > set a define value in the Makefile that can be passed to the > > compiler? > > > > Ideally in the code, I would have something like: > > > > #ifdef DATABASE > > call_database_routeine(); > > #enfif > > > > .. at bit of a loss here! > > Well, gcc uses the -D option for setting pre-processor values... Thanks very much, that does the trick beautifully :-) > If you are doing stuff on Linux or one of the BSD flavors, I recommend > look into something that does dynamic configuration management that > can do building and linking based on the specs of your system. > > 1) The most common option used is the GNU Autotools... you build a > metascript that specifies required libraries, build environment, etc, > and this generates a 'configure' script that you (or other users > compiling your software) can run that builds your makefile. This is > the familiar 'configure && make && make install' command for building > software. Your system may already have this stuff installed. If you > use an IDE like Anjuta on Linux, it uses the autotools stuff > underneath. I find configure scripts do the job well, but for a small project I really don't want to make people spend a few minutes watching the configure script check for things like the size of int... > 2) Another option that is getting popular is scons -- it's a similar > kind of thing but is based entirely on Python. You create a Python > script that defines required libraries, customized build algorithms, > etc. I like this one because it's much easier to use than the > autotools stuff (which can be pretty daunting for a newbie not > familiar with Unix shell scripting); plus you get the benefit of using > a programming language that can be debugged and doesn't generate a lot > of hidden scripts and config files. > > http://www.scons.org/ I will look into this, but I know that openbsd does not include python in the default install, although python does a lot of things more efficiently than perl. > 3) And then there is CMake, is which is a cross-compiler build > environment that can be used on many different systems. It is similar > to the autotools but much easier to use and, being cross-platform, can > be used to target many different compiler environments. > > http://www.cmake.org/HTML/Index.html > > Since your project is small, I'd go with SCons, it's the easiest to > start with. But I have seen some huge projects on Linux build with > SCons (like Ardour and Rosegarden, two GUI-based high-end audio > applications written in C++). So it's quite powerful. Thanks for the sound advice. -- The 14.4 dialup to www.tatooine.net is going off like a car alarm because of unscheduled testing of the battery backup system. Barbarella is eating 24 free dinners at Sweet Tomatoes. :: http://www.s5h.net/ :: http://www.s5h.net/gpg [Non-text portions of this message have been removed]
