objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
edit : $(objects)
cc -o edit $(objects)
main.o : defs.h
kbd.o : defs.h command.h
command.o : defs.h command.h
display.o : defs.h buffer.h
insert.o : defs.h buffer.h
search.o : defs.h buffer.h
files.o : defs.h buffer.h command.h
utils.o : defs.h
.PHONY : clean
clean :
rm edit $(objects)
This is an example makefile from GNU make. It says that make will use simple rules to generate *.o files with *.c files of the matching name.
However, on my mac make default use clang and I want it default to use gcc-7, in case there are some projects that give error when compiling in clang.
1 Answer 1
First, you would need to install gcc. I would do that by installing Homebrew, then running:
brew install gcc
That should give you /usr/local/bin/gcc-7 or similar. You can check with:
ls /usr/local/bin/gcc*
Then you should be able to do:
make CC=/usr/local/bin/gcc-7
If you always want that compiler, edit your login profile and add a line:
export CC=/usr/local/bin/gcc-7
and log out and back in for it to take effect.