Next Previous Contents

5. Examples

5.1 Basic example

Here is a very simple example Smakefile that can be used with smake. It is meant as a quick demonstration only, not as a proof of smake's power. It assumes the C files hello.c and hello.h exist.

target hello.o { 
  depend {foo.h main.c} {
    compile main.c 
  }
}
target foo.o {
  depend {foo.c foo.h} {
    compile foo.c
  }
}
target testiprg {
  depend {foo.o main.o} {
    link testiprg {foo.o main.o} Tcl8.0
  }
}
target all {
  depend testiprg {}
}

5.2 Extended example

Here is another simple example Smakefile that demonstrates how smake can be extended.


set Compile "g++"
set COptions "-c -g"
set Linker "g++"
set LOptions "-execute -r"

target hello.o {
  depend {foo.h main.c} {
    compile main.c \
      -Wall \
      -I/usr/include/ \
      -I..
  }
}
target testiprg {
  depend {main.o} {
    link testiprg {foo.o main.o \
      -L/usr/lib} {tcl8.0 tk8.0}
  }
}
# Note the position of the curly braces for link!
target all {
  depend testiprg {}
}
target clean {
  set LObjFiles [glob *.o]
  foreach it $LObjFiles {
    file delete $it
  }
  file delete testiprg
}


Next Previous Contents