Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Understanding makefile

Status
Not open for further replies.

lignin

Junior Member level 2
Joined
Apr 27, 2013
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,436
Hello;
I am trying to understand makefiles. So I can write a simple makefile code. I want to ask questions for better understanding.
so here is my code :
Code:
CC = gcc
CFLAGS = -g -Wall
FILE = main
EXECUTABLE_FILE = out_executable 

all : $(FILE)
	$(CC) -O2 $(CFLAGS) -o $(EXECUTABLE_FILE) $(FILE).c
clean : 
	$(RM) *~ $(FILE) *~ $(EXECUTABLE_FILE) *.o

what does -o mean in this example ?

thank you.

I understand.
gcc [options] [source files] [object files] -o output file
and -o is gcc option flag and it write the build output to an output file.

$(CC) -O2 $(CFLAGS) $(FILE).c -o $(EXECUTABLE_FILE) is also work.
but why $(CC) -O2 $(CFLAGS) -o $(EXECUTABLE_FILE) $(FILE).c is work ?
 
Last edited:

The line calls gcc. -o is a gcc command line option, you'll review the gcc user manual to know what it means.

-o file
Place output in file file. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.
 

Also at the end line(clean) it removes /deletes all the object files created (with .o extension for a clean build or compile)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top