Version 8 of smake

Updated 2003-09-02 12:59:45

Philipp Roessler

The small smake[L1 ] program by Kristoffer Lawson proved immensely useful for me; but it took me some while to figure out how to tweak it that it suited my needs perfectly - just put Tcl commands in the right place.

One thing that the author obviously forgot when he wrote smake was the LOptions variable for linking; if you want to handily give options to the linker the original proc needs to be modified as follows:

       proc link {target objs libs} {
         global Linker LOptions

         set opt_libs ""
         foreach lib $libs {
           set opt_libs "$opt_libs -l$lib"
         }

         eval "exec $Linker $LOptions -o $target $objs $opt_libs"
       }

So here is my addition to the original man page:

       Here is an example Smakefile that demonstrates how
       smake can be extended using Tcl syntax.

       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} {stdc++ tcl8.0 tk8.0}
         }
       }
       # note the position of the curly braces for link!

       target all {
         global Compiler COptions Linker LOptions
         set Compiler "g++"
         set COptions "-c -g"
         set Linker "g++"
         set LOptions "-execute -r"
         depend testiprg {}
       }

       target clean {
         set LObjFiles [glob *.o]
         foreach it $LObjFiles {
           exec rm $it
         }
       }

See also: A Little Make Replacement