#!/bin/sh set -ev rm -rf $0.dir mkdir $0.dir cd $0.dir cat > top.fac < main.out | mkdir -p lib.out > lib.out | python main.py > main.out/main.fac < main.out < main > main.out/main.fac | python lib.py > lib.out/lib.fac < lib.out < lib > lib.out/lib.fac EOF cat > lib.py < %s ''' % (src, obj, src, obj)) print('''| ar rcs lib.a %s < %s > lib.a ''' % (' '.join(objs), '\n< '.join(objs))) EOF cat > main.py < %s ''' % (src, obj, src, obj)) print('''| gcc -o main %s ../lib.out/lib.a < %s < ../lib.out/lib.a > main ''' % (' '.join(objs), '\n< '.join(objs))) EOF mkdir inc cat > inc/lib.h < lib/foo.c < int foo = 1; EOF mkdir main cat > main/main.c < #include int main() { printf("success\n"); return 0; } EOF git init git add . ${FAC:-../../fac} ${FAC:-../../fac} cat >> inc/lib.h < lib/bar.c < int bar = 2; EOF git add lib/bar.c ${FAC:-../../fac} ${FAC:-../../fac} main.out/main exit 0