Makefile 如下:
引用:main: null.out
null.out:
./compile.sh
clean:
rm *.out
compile.sh 就是实际执行 make 命令的了:
引用:#!/bin/bash
for cpp in *.cpp
do
out="${cpp%.cpp}.out"
if test ${cpp} -nt ${out}
then
printf "g++ -o %s %s\n" "${out}" "${cpp}"
g++ -o ${out} ${cpp}
fi
done