In Git, I have a master branch (release) and a dev branch (development) for a
In the master branch, I want
gcc to only be passed the compiler flag
-Os (optimize for speed) and not
-ftest-coverage -fprofile-arcs (when compiled, a
.gcno file is created, when run, a
.gcda file is created and when
gcov executable, a
.gcov file is created).
In the release branch, I only want the compiler to be passed the flag
I can add
.gitignore for 1 branch, but I would need to manually check everytime if
Makefile has been changed after each push on the other branch.
I can also do nothing and be notified of a change in the
Makefile when merging, but I would need to manually merge the file (keep one line of
CFLAG+=... and discard the other), but this is error-prone.
How can I keep two separate versions of a
Makefile on different branches with different requirements?
BASE=notepad # NEEDED FOR BOTH RELEASE AND TESTING CFLAGS=-Wall # ONLY NEEDED IF RELEASE CFLAGS+=-Os # ONLY NEEDED IF TESTING COVERAGE AND PROFILING CFLAGS+=-ftest-coverage -fprofile-arcs all: $(BASE).exe $(BASE).exe: $(BASE).o $(BASE).o: $(BASE).c gcc $(CFLAGS) -c $(BASE).c clean: rm -f $(BASE).o $(BASE).exe # ALWAYS NEEDED rm -f *.gcda *.gcno *.gcov # ONLY NEEDED IF -ftest-coverage -fprofile-arcs