my code lab
README.md

ss #

A couple differences from redo:

  • build files not tightly coupled to output files
  • stdout does not get captured by default - you always have to write something to ${outfile}

hello world #

target hello
needs hello.c

hello() {
  cc -o hello hello.c
}

hello world: vars #

target hello
needs hello.c

hello() {
  cc -o ${outfile} ${deps}
}

hello world: named build function #

target hello.out build_hello
needs hello.c

build_hello() {
  cc -o ${outfile} ${deps}
}

hello world: implicit deps #

target hello
needs hello.c : hello.h

hello() {
  cc -o ${outfile} ${deps}
}

hello world: stamp #

stamp build_date

target hello
needs hello.c : build_date

build_date() {
  date +%Y-%m-%d > ${outfile}
}

hello() {
  cc -o ${outfile} ${deps}
}

hello world: multiple targets #

target hello
needs hello.c libhello.o

target libhello.o libhello
needs libhello.c

libhello() {
  cc -c -o ${outfile} ${deps}
}

hello() {
  cc -o ${outfile} ${deps}
}

hello world: produces #

target hello
needs hello.c
produces bin/hello lib/libhello.so

hello() {
  cc -shared -o lib/libhello.so hello.c
  cc -o bin/hello hello.c
}

hello world: named needs and produces #

target hello
needs src=hello.c
produces bin=bin/hello lib=lib/libhello.so

hello() {
  cc -shared -o ${lib} ${src}
  cc -o ${bin} ${src}
}

hello world: named transitive deps #

target libhello
needs hello.c : hello.h
produces lib=libhello.so

target hello
needs src=main.c libhello

libhello() {
  cc -shared -o ${lib} ${deps}
}

hello() {
  cc -o ${outfile} ${src} ${libhello__lib}
}

hello world: transitive deps #

target libhello
needs hello.c : hello.h
produces libhello.so

target hello
needs main.c libhello

libhello() {
  cc -shared -o ${target}.so ${deps}
}

hello() {
  cc -o ${outfile} ${deps}
}

hello world: dynamic needs #

target libhello
needs hello.c
produces so=libhello.so

target hello
needs hello.c

libhello() {
  cc -shared -o ${so} ${deps}
}

hello() {
  needs : lib=lib${target}
  cc -o ${outfile} ${deps} ${lib__so}
}

hello world: dynamic produces #

target libhello
needs hello.c

target hello
needs hello.c : libhello

libhello() {
  produces so=${target}.so
  cc -shared -o ${so} ${deps}
}

hello() {
  cc -o ${outfile} ${deps} ${libhello__so}
}