makfile general structure

Jul 17, 2008 at 7:47pm
Hi,
I am currently building a makefile for my C++ project.
I am trying to find a general structure for a makefile. Is there any documentation which explain each possible entry.
For example can somebody explain the below

INCS = -I. ( . is the current directory)

LIBDIR = -L. ( ditto)

LIBS = -lBD ( BD is a directory)


Regards,
Alan Mehio
London, UK

Jul 17, 2008 at 7:53pm
BD shouldn't be a directory. It should be a file. Depending on your compiler it maybe named libbd.a (GCC style).
Jul 17, 2008 at 8:10pm
The Gnu Make documentation is a good place to start.
http://www.gnu.org/software/make/manual/make.html

All those things are variables people tend to use to make modifying the makefile easy.

INCS is the list of directories to search for include files (headers, etc)

LIBDIR is the list of directories to search for lib files (libbd.a, libm.a, etc)

LIBS is the list of libraries to link into your application's executable (bd, m, etc)

CC is the name of the compiler

CFLAGS is the list of compilation flags (things like -Wall, etc) used to compile object files

LFLAGS is the list of linker flags (often used instead of LIBS)

Hmm... I can't think of others... But I'm sure the Make docs list common variable names.


None of these are written in stone. But they are common.

Hope this helps.
Jul 18, 2008 at 7:48am
There are several alternative names for some of the above depending on which platform/make you are using

The default environment variables, targets and rules are usually in a make.rules file. On my system the file is in /usr/share/lib/make
Jul 18, 2008 at 10:40am
Many thanks for you quick responses. Highly appreciated

Regards,
Alan Mehio
London, UK
Topic archived. No new replies allowed.