Makefile: no rule to make target (sdcc)

Advertisements

I’m trying to do my first Makefile for a sdcc C program I start.

For now, I get this error:

make: *** No rule to make target ‘out/main.rel’, needed by ‘a.bin’. Stop.

This is my Makefile:

SRC = src/main.c src/include/vdu.c src/include/func.c
INC = include/common.h include/mos.h src/include/vdu.h src/include/func.h
MOSLIBSRC = lib/mos.s crt/crt0.s

CRT = out/crt0.rel
MOSLIB = out/mos.rel
OBJ = out/main.rel out/vdu.rel out/func.rel

EXEC = a.bin
CC = sdcc
LD = sdcc
AS = sdasz80
CLD = sdldz80
OBJCPY = sdobjcopy

ASFLAGS=-plosgff
CFLAGS=-mez80_z80 -Iinclude/ -Isrc/include/ --reserve-regs-iy --std-c11 --fno-omit-frame-pointer
CLINK=--no-std-crt0 -mez80_z80 --code-loc 100

all : $(EXEC)

$(EXEC) : $(OBJ) $(CRT) $(MOSLIB)
    $(CC) -o $(EXEC) $(OBJ) $(CRT) $(MOSLIB) $(CFLAGS)
    $(LD) -o $(OBJ) $(CRT) $(MOSLIB) $(CLINK)
    $(CLD) -nf out/a.lk
    $(OBJCPY) -I ihex -O binary out/a.rel miniGraf.bin

main.rel : src/main.c
    $(CC) -o out/main.rel -c src/main.c $(CFLAGS)

vdu.rel : src/include/vdu.c
    $(CC) -o out/vdu.rel -c src/include/vdu.c $(CFLAGS)

func.rel : src/include/func.c
    $(CC) -o out/func.rel -c src/include/func.c $(CFLAGS)
    
$(CRT) : crt/crt0.s
    $(AS) $(ASFLAGS) -o $(CRT) crt/crt0.s

$(MOSLIB) : $(MOSLIBSRC)
    $(AS) $(ASFLAGS) -o $(MOSLIB) lib/mos.s

clean :
        rm -rf out/*.* out/*  main.bin

I’ve tried a lot of changes, but without success.

>Solution :

Assuming you used tabs instead of spaces in the original file:

$OBJ contains out/main.rel which is given as requirement for $EXEC (= a.bin), but there is no rule for out/main.rel. There is ”just” one for main.rel. That’s what the error message is trying to tell you, quite literally.

Change the targets to match the requirements or vice versa. 😎

Leave a ReplyCancel reply