Try the makefile script. Let file1.c include file.h. Then use touch file.h to change the date of your header file to a newer date than the dependent .c files. Now issue make -f myMakefile and you should see gcc recompile file.c and create the executable myprogram.
make -f myMakefile gcc -Wall -c file1.c gcc -Wall -c file2.c gcc -o myprogram file1.o file2.o make myprogram make: 'myprogram' is up to date. touch file.h make myprogram gcc -Wall -c file1.c gcc -o myprogram file1.o file2.o