Saturday, January 13, 2007

簡單的 bash build script

這個 script 用 test 比對檔案的版本,如果有更新就重新編譯。為什麼不用 Makefile?因為我比較習慣 bash……有時間會認真學 make 的語法啦……

#!/bin/sh
# A simple building script

# target file names separated with " "
targets="foo bar"

for i in $targets; do
# EDIT the matching conditions and prefix/suffix
    if [ $i.c -nt $i ]; then
# EDIT following commands while matching
        echo "[C] $i"
        gcc -g $i.c NanoTime.o -o $i -lpthread
    fi
done

No comments: