Linux, make device: no rule to make 'pdex.bin'

I'm trying to build the examples provided in the C_API folder in the SDK on Linux. When I run, make, I get this errors:

make: *** No rule to make target 'build/pdex.bin', needed by 'device'. Stop.

I fixed this by editing common.mk as follows:

$(OBJDIR)/%elf: $(OBJS) $(LDSCRIPT)
	$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@

$(OBJDIR)/%hex: $(OBJDIR)/%elf
	$(HEX) $< $@

$(OBJDIR)/%bin: $(OBJDIR)/%elf
	$(BIN) $< $@

becomes

$(OBJDIR)/pdex.elf: $(OBJS) $(LDSCRIPT)
	$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@

$(OBJDIR)/pdex.hex: $(OBJDIR)/pdex.elf
	$(HEX) $< $@

$(OBJDIR)/pdex.bin: $(OBJDIR)/pdex.elf
	$(BIN) $< $@

I also needed to install this packages on ubuntu:

sudo apt install gcc-arm-none-eabi

This made significant progress, but then was stopped with this error message:

make: *** No rule to make target 'build/setup.o', needed by 'build/pdex.elf'.  Stop.

I see there is a setup.c in the C_API folder but I am not sure how to proceed exactly...

Ok, I had to edit common.mk a little bit more to get it to work. It also had a problem where it couldn't deal with an non-flat source tree. Attached is my new common.mk. Please note that it may require that $PLAYDATE_SDK_PATH begins with a ~ in order to work. (Makefiles are a bit hard for me still.) If you can fix this quirky behaviour, please let me know!

common.mk has been zipped in order to allow it to be uploaded.
common.mk.zip (1.6 KB)

Can confirm this fixes the error for me

Same! This is great, had no idea why it was giving that error. Er.. not that I have any better idea now, but I'm really glad to have something that works better! Like most people I build makefiles by copying random examples from the web until it sort of does what I want.

1 Like

I'll be honest, I have no understanding of why this fix worked for me either. I just messed around with things until it worked. I was not able to understand the "right" way to copy files into a build tree from an absolute path -- so I'm pretty sure this fix does not work if $PLAYDATE_SDK_PATH is absolute but doesn't start with ~.

This seems like a possible incompatibility with the syntax we're using. What version of make are you using? (make -v).

GNU Make 4.2.1
Built for x86_64-pc-linux-gnu

Can you explain what you mean about incompatible syntax?

The %elf syntax instead of explicitly defining it as pdex.elf as you have, for example. The makefile works as-is with 4.3 so I am trying to figure out what the possible differences are.