2016-05-15 14:00:40 +02:00
|
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
# INCLUDE CONFIGURATION
|
2017-01-07 21:07:10 +01:00
|
|
|
|
include $(CURDIR)/Makefile.config
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
# DEDUCED VARS
|
|
|
|
|
ALLOBJ = $(SRC:%=$(OBJDIR)/%.o)
|
2016-05-15 15:03:51 +02:00
|
|
|
|
ALLINC = $(INC:%=$(INCDIR)/%.h)
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
# RULES
|
|
|
|
|
## Make it all (default rule)
|
|
|
|
|
all: $(NAME).g1a
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Make the object directory
|
|
|
|
|
$(OBJDIR):
|
|
|
|
|
mkdir -p $(OBJDIR)
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Make an object file out of an ASM source file
|
|
|
|
|
$(OBJDIR)/%.o: $(SRCDIR)/%.s
|
|
|
|
|
$(AS) -c -o $@ $<
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Make an object file out of a C source file
|
2016-05-15 15:03:51 +02:00
|
|
|
|
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(ALLINC)
|
2017-01-07 21:07:10 +01:00
|
|
|
|
$(CC) -c -o $@ $< $(CFLAGS)
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Make the ELF file
|
|
|
|
|
$(NAME).elf: $(OBJDIR) $(ALLOBJ)
|
|
|
|
|
$(LD) -o $@ $(ALLOBJ) $(LFLAGS)
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Make the BIN file
|
|
|
|
|
$(NAME).bin: $(NAME).elf
|
2017-01-07 21:07:10 +01:00
|
|
|
|
$(OBJCPY) -R .comment -R .bss -R '$$iop' -O binary $< $@
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Make the G1A file
|
|
|
|
|
$(NAME).g1a: $(NAME).bin
|
|
|
|
|
$(WRAPR) $< -o $(NAME).g1a
|
|
|
|
|
@stat -c "Build finished -- output size is %s bytes." $(NAME).g1a
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Clean up your mess
|
|
|
|
|
clean:
|
|
|
|
|
$(RM) $(ALLOBJ)
|
|
|
|
|
$(RM) $(NAME).elf
|
|
|
|
|
$(RM) $(NAME).bin
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Clean up everything
|
|
|
|
|
mrproper: clean
|
|
|
|
|
$(RM) $(NAME).g1a
|
|
|
|
|
fclean: mrproper
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Remake
|
|
|
|
|
re: fclean all
|
2016-05-14 22:19:51 +02:00
|
|
|
|
|
2016-05-15 14:00:40 +02:00
|
|
|
|
## Send to calc
|
|
|
|
|
send:
|
|
|
|
|
@if [ ! -f $(NAME).g1a ]; then \
|
2016-05-17 19:49:11 +02:00
|
|
|
|
echo "Please make before sending."; \
|
2017-01-07 21:07:10 +01:00
|
|
|
|
else $(SENDR) send $(NAME).g1a \
|
2016-05-15 14:00:40 +02:00
|
|
|
|
fi
|
|
|
|
|
## Phuneral phuture ?
|
|
|
|
|
.PHONY: all clean fclean mrproper re send
|
|
|
|
|
# END OF FILE
|