2
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.

asked Nov 1, 2017 at 9:10

1 Answer 1

7

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.

answered Nov 1, 2017 at 10:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.