Do I need a makefile?

If your program is relatively simple and doesn't require anything particularly special, makepp may already know how to build it without your explicitly giving instructions. For example, suppose you have a program in a single source file, called test.c. You can just type makepp test and your program will build like this:

% makepp test
makepp: Entering directory `/somewhere/or/other'
gcc -g -Wall -c test.c -o test.o
gcc -g -Wall test.o     -o test
Warning: on unix, to run a program called 'test', you must type
   ./test
rather than just 'test'.

These are the basic commands needed to compile a program on unix. If these commands don't make any sense to you, that's ok--you can just rely on makepp's builtin rules, or you can see the primer on unix compilation commands on the next page.

Makepp contains builtin rules for C, C++, and Fortran. Java support will probably come as soon as I learn Java.

Makepp can sometimes figure out how to compile programs that are contained in more than one source file, or programs that must be linked with various system libraries. It does this by guessing which source files and libraries you need based on the files that you include. The actual algorithm is too complicated to discuss here in a tutorial (but see the section on builtin rules in the reference manual); you can try it, and if it doesn't work automatically for you, you need to write your own makefile.

By default, for C and C++, makepp compiles the program with debug information and without optimization. If you want to turn on optimization so that your program runs faster, change the command line to:

makepp CFLAGS=-O2 test

If you're compiling C++ instead of C, use CXXFLAGS=-O2 instead of CFLAGS=-O2. For a complete list of other options you can configure, see the reference manual.

Makepp's builtin rules are somewhat more powerful than the standard unix make, but if you write programs of any complexity, it's likely that you'll need a makefile eventually to tell makeppq what to do. The next page explains simply what all those cryptic unix compilation commands actually do, and how to write them; following that, I explain how you tell makepp to use these commands.


Tutorial index | Next (compile commands on unix) | Previous (what's in a makefile)
Last modified: Wed Dec 27 13:10:04 PST 2000