Here’s a handy Makefile I use:
me@debian:~/lcthw/code/ex13$ cat Makefile
CFLAGS = -Wall -g
all: create run
clear:
rm copy
create:
make copy
run:
./copy
in each exercise I copy the Ex.c file to copy.c and just run make.
me@debian:~/lcthw/code/ex13$ cp ex13.c copy.c
me@debian:~/lcthw/code/ex13$ make
make copy
make[1]: Entering directory '/home/me/lcthw/code/ex13'
cc -Wall -g copy.c -o copy
make[1]: Leaving directory '/home/me/lcthw/code/ex13'
./copy
state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas
after each change to copy.c I run make to update the file
and the original stays intact
What’s your Makefile?