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.

Makefile to build several files in different folders

Status
Not open for further replies.

pashok84

Member level 4
Joined
Apr 11, 2011
Messages
71
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
India
Activity points
1,831
Hi

I have been trying to use MSP GCC compiler. I have written a makefile for single file and able to compile and flash in the MSP430 device.

I don't know how to write makefile for many source files in different folder inter dependent with each other.

I am developing a serial deriver folder and file structure is as follows
serial_driver/App
serial_driver/App/inc/app.h
serial_driver/App/inc/app.c
serial_driver/controller
serial_driver/controller/inc/hardware.h
serial_driver/controller/inc/globaldef.h
serial_driver/controller/src/ctrl.c
serial_driver/UART
serial_driver/UART/inc/uart.h
serial_driver/UART/src/uart.c

Can any give some ideas to write make files for this project and how to expand in future bigger projects.

Thanks and Regards,
Ashok Kumar P
 

CC=gcc-msp430

DIR1=serial_driver/App
DIR2=serial_driver/controller
DIR2=serial_driver/UART

INCLUDES=$(DIR1)/inc \
$(DIR2)/inc \
$(DIR3)/inc

SRCS=$(DIR1)/src/app.c \
$(DIR2)/src/controller.c \
$(DIR3)/src/UART.c

#fillup your library directory and libs
LIBDIR=
LIBS=


xxx.exe:
$(CC) $(INCLUDES) \
$(SRCS) -o xxx.exe $(LIBDIR) $(LIBS)

use 'tabs' apropriately.

is your OS windows or linux?
 

Hi srizbf,

Thanks for your help. i will try this now.

I am using linux.

Thanks and Regards,
Ashok Kumar P

---------- Post added at 21:27 ---------- Previous post was at 20:23 ----------

Hi,

I getting the following error. Having problem with including the header file.


msp430-gcc -mmcu=msp430xG4618 -o mcu/inc/hardware.h mcu/inc/led.h mcu/inc/serial.h mcu/inc/mcu.h app/inc/app.h app/src/app.c main/main.c mcu/src/mcu.c mcu/src/serial.c
app/src/app.c:2:30: error: mcu/inc/hardware.h: No such file or directory
app/src/app.c:3:20: error: serial.h: No such file or directory
main/main.c:2:22: error: hardware.h: No such file or directory
main/main.c:3:17: error: mcu.h: No such file or directory
main/main.c:4:17: error: app.h: No such file or directory
main/main.c:5:17: error: led.h: No such file or directory
mcu/src/mcu.c:2:22: error: hardware.h: No such file or directory
mcu/src/mcu.c:3:20: error: serial.h: No such file or directory
mcu/src/mcu.c:6:17: error: led.h: No such file or directory

Makefile snipets

INCLUDES = ${MCUDIR}/inc/hardware.h\
${MCUDIR}/inc/led.h\
${MCUDIR}/inc/serial.h\
${MCUDIR}/inc/mcu.h\
${APPDIR}/inc/app.h

SRCS = ${APPDIR}/src/app.c\
${MAINDIR}/main.c\
${MCUDIR}/src/mcu.c\
${MCUDIR}/src/serial.c

${NAME}.elf: ${OBJECTS}
${CC} -mmcu=${CPU} -o ${INCLUDES} ${SRCS}

Any help please.

Thanks and Regards,
Ashok Kumar P

Attached the full makefile.
 
Last edited:

Attached ythe makefile txt format
 

Attachments

  • Makefile.txt
    1.4 KB · Views: 52

one possibility is , the directory 'mcu' is not completely specified.

say , "./mcu" , or "/home/mcu".

another one is error in final line.

insted of:
${NAME}.elf: ${OBJECTS}
${CC} -mmcu=${CPU} -o ${INCLUDES} ${SRCS}

it should be:
${NAME}.elf: ${OBJECTS}
-->note this line: ${CC} -mmcu " ??what is this--->${CPU}" -o $(NAME.elf ${INCLUDES} ${SRCS}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top