xDra
xDra

Reputation: 1

Makefile doesn't find the rule

I have to do a makefile to compile something, but I got a problem : when I type the make command, I got an error message saying that there is no rules for one of the targets. The problem is about the path to the target, using an environment var.

Here is the given start of the Makefile :

    CC = mipsel-unknown-elf-gcc
AS = mipsel-unknown-elf-as
LD = mipsel-unknown-elf-ld
DU = mipsel-unknown-elf-objdump

SYS_OBJS = reset.o \
           giet.o \
           common.o \
           ctx_handler.o \
           drivers.o \
           exc_handler.o \
           irq_handler.o \
           sys_handler.o

APP_OBJS = stdio.o main.o

GIET ?= /(my path)/giet

SYS_PATH = $(GIET)/sys
APP_PATH = $(GIET)/app

SYS_CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -I$(SYS_PATH) -I.
APP_CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -I$(APP_PATH) -I.

all: sys.bin app.bin

(I am supposed to finish it)

What I tried to do (rule for sys.bin works fine) :

common.o: common.c
    mipsel-unknown-elf-gcc $(SYS_CFLAGS) common.o $(SYS_PATH)/common.c

The command I'm using to compile myself is : mipsel-unknown-elf-gcc -ffreestanding -mno-gpopt -mips32 -I$GIET/sys -I. -c -o common.o $GIET/sys/common.c Could you help me to fix this ? Thanks :)

Upvotes: 0

Views: 115

Answers (1)

paxdiablo
paxdiablo

Reputation: 881423

I don't see a -o (output file specifier) at the end of $(SYS_CFLAGS) or before the common.o in the command for your rule. That's the important difference between your makefile and your manual command.

Without that specifier, it will try to act on common.o rather than produce it, attempting to combine both common.o and $(SYS_PATH)/common.c into (most likely) a.out.

To fix it, change the rule to:

common.o: common.c
    mipsel-unknown-elf-gcc $(SYS_CFLAGS) -o common.o $(SYS_PATH)/common.c
    #                                    ^^
    #              Add this bit here (but not these two comment lines).

Upvotes: 1

Related Questions