Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12746 Discussions

How to write a makefile to compile C project ?

Altera_Forum
Honored Contributor II
1,261 Views

Hi all ! 

 

I'm using Cyclone 1c12 eval, Microtronix uCLinux 1.4, NIOS II IDE 5.0 

 

I have a C project (which will run on uCLinux) as following: 

 

header files: 

 

libA.h 

libB.h 

 

c files:  

 

a.c 

b.c 

c.c 

main.c // <-- this file contains function main() 

 

 

 

How can I write a makefile ( makefile & rule.mak ) for above project or edit the Microtronix template ? 

 

 

Thank you 

 

OneNet
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
555 Views

Hi OneNet, 

 

> How can I write a makefile ( makefile & rule.mak ) for above project 

 

First read the Linux Reference Guide section, "Creating a Makefile" ... basically, you just need 

to include the Rules.mak and pretty much do what you would always do. 

E.g.:TARGET  = foo.exe CSRC    =  foo.c bar.c OBJS    = $(CSRC:.c=.o)                  # All object files LDFLAGS += # ################################################################# .PHONY: default install clean realclean distclean depend default: deps $(TARGET) install:     cp -pf $(TARGET) $(BIN_INSTALL) clean:     rm -rf $(OBJS) core distclean: clean     rm -f deps     rm -rf $(TARGET) depend: deps sinclude deps include Rules.mak 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
555 Views

Sorry, I must have fat fingered the following (missing from above): 

deps: Makefile $(CSRC)     $(CC) -M $(CFLAGS) $(CSRC) > deps 

 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
555 Views

Dear scott ! 

 

Your solution is very clear ! 

 

thank you so much 

 

OneNet
0 Kudos
Reply