Build a program with Make.gfxtools.rules

These steps describe how to compile a hello world program with the $G makefiles. For now, we will walk you through doing this in your home directory. Normally, once you have a file or two to work with, you will then take this source and put it in CVS under $G/src, then continue to develop in that directory. You will find out how to import the simple program you make here into the $G/src tree in the next tutorial.
  1. cd
  2. mkdir testprog
  3. cd testprog
  4. edit main.cpp to contain the following example program:
    #include <stdio.h>
    
    int main(int argc, char **argv)
    {
      printf("hello world\n");
      return 0;
    }
    
  5. edit Makefile to contain the following
    PROJECT_NAME=testprog
    OBJDIR=obj
    
    SRC=main.cpp
    
    # by default, compile just the debug version
    all:   progg
    
    # rule to compile the debug version
    debug: progg
    
    # rule to compile the optimized version
    opt:   progo
    
    # rule to compile the profiling version
    prof:  progp
    
    include $(G)/lib/Make.gfxtools.rules
    -include Makefile.depend
    
  6. make all
  7. try running it with: "obj/testprog-d"
  8. try making an optimized version: make opt
  9. try running it: "obj/testprog"
  10. you can also run "make clean" to delete all the compiled sources
Notes: The -d is appened automatically to debug version of programs and libraries. A -p is appended for the profiling versions. The name for the optimized version is taken directly from the PROJECT_NAME Makefile variable.