Mahmoud Saad
Mahmoud Saad

Reputation: 145

GNU make doesn't include headerfile

I have been searching for 6 hours and I can't seem to find the issue with this GNU make file, everytime I try to compile by main.o by the order

make main.o

it gives me this error:

arm-none-eabi-gcc -c main.c -mcpu=cortex-m4 -mthumb -- 
specs=nosys.specs  -Wall -Werror -g -O0  -std=c99 -o main.o
main.c:23:22: fatal error: platform.h: No such file or directory
#include "platform.h"
                     ^
compilation terminated.
Makefile:52: recipe for target 'main.o' failed
make: *** [main.o] Error 1

makefile:

include sources.mk

# Platform Overrides
PLATFORM = MSP432

# Architectures Specific Flags
LINKER_FILE = msp432p401r.lds
CPU = cortex-m4
ARCH = thumb
SPECS = nosys.specs

# Compiler Flags and Defines
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
TARGET = c1m1
LDFLAGS = -Wl,-Map=$(TARGET).map -T $(LINKER_FILE)
CFLAGS = -mcpu=$(CPU) -m$(ARCH) --specs=$(SPECS)  -Wall -Werror -g -O0  -std=c99
CPPFLAGs =


.PHONY: all
all: $(TARGET).out

.PHONY: clean
clean:  
    rm -f $(OBJS) $(TARGET).out $(TARGET).map

%.o : %.c
    $(CC) -c $< $(CFLAGS) -o $@

OBJS = $(SOURCES:.c=.o)

$(TARGET).out: $(OBJS)
    $(CC) $(OBJS) $(CFLAGS) $(LDFLAGS) -o $@

sources.mk:

# Add your Source files to this variable
SOURCES =./main.c \
    ./memory.c \
    ./startup_msp432p401r_gcc.c \
    ./system_msp432p401r.c  \
    ./interrupts_msp432p401r_gcc.c  



# Add your include paths to this variable
INCLUDES =-I./include/CMSIS \
    -I./include/common \
    -I./include/msp432

here's my code on github:

github repository

Upvotes: 1

Views: 141

Answers (1)

Clifford
Clifford

Reputation: 93476

You have not used the INCLUDES macro in makefile's CFLAGS macro. Consequently the arm-none-eabi-gcc ... command line does not specify the include paths to the compiler (or strictly the pre-processor).

CFLAGS = -mcpu=$(CPU) -m$(ARCH) --specs=$(SPECS) $(INCLUDES) -Wall -Werror -g -O0  -std=c99
                                                 ^^^^^^^^^^^

Upvotes: 1

Related Questions