I’m writing a program C and tracking my source with git.
Every time I run my makefile I need to commit my build.
(Yes, I know this isn’t an ideal thing to do or ‘smart’ idea but I have to do this for school.)
How would I commit myprogram to my git repo with the comment of date from my make file?
Should I use a shell script instead?
Here is my Makefile below
BUILDID=$(shell date +%Y%m%d-%H:%M:%S)
CFLAGS=-Wall -g
all: myprogram
clean:
rm -f *.o
rm -f myprogram
There are lots of ways in which doing this doesn’t make sense, as you acknowledge in your question. However, assuming that what you want is to make your git repository reflect all the changes in your working tree (apart from ignored files), you could do the following:
(The
.PHONYis GNU make specific, meaning that its dependencies aren’t real targets.)