repo2/firmware/Makefile @ 78
| 46 | markw | BASE	= zpu-elf
  | 
      |
CC      = $(BASE)-gcc
  | 
      |||
LD      = $(BASE)-gcc
  | 
      |||
AS      = $(BASE)-as
  | 
      |||
CP      = $(BASE)-objcopy
  | 
      |||
DUMP    = $(BASE)-objdump
  | 
      |||
# we use mincrt0.s from here
  | 
      |||
STARTUP_DIR = .
  | 
      |||
# we fetch ROM prologue / epilogue from here
  | 
      |||
RTL_DIR = $(ZPUFLEXDIR)/RTL/
  | 
      |||
BUILD_DIR=zpu_obj
  | 
      |||
#MINSTARTUP_SRC = mincrt0.s
  | 
      |||
MINSTARTUP_SRC = mycrt0.s
  | 
      |||
MINSTARTUP_OBJ = $(patsubst $(STARTUP_DIR)/%.s,$(BUILD_DIR)/%.o,$(MINSTARTUP_SRC))
  | 
      |||
| 78 | markw | DE1_PRJ = DE1
  | 
      |
DE1_SRC = main.c regs.c freeze.c joystick.c fileutils.c fileselector.c atari_drive_emulator.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c sd_direct/diskio_mmc.c sd_direct/spi.c sd_direct/mmc.c de1/dirs.c
  | 
      |||
DE1_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(DE1_SRC))
  | 
      |||
| 69 | markw | MCC_PRJ = MCC216
  | 
      |
MCC_SRC = main.c regs.c freeze.c joystick.c fileutils.c fileselector.c atari_drive_emulator.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c sd_direct/diskio_mmc.c sd_direct/spi.c sd_direct/mmc.c mcc/dirs.c
  | 
      |||
MCC_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(MCC_SRC))
  | 
      |||
| 46 | markw | ||
| 69 | markw | MIST_PRJ = MIST
  | 
      |
MIST_SRC = main.c regs.c freeze.c joystick.c fileutils.c fileselector.c atari_drive_emulator.c pokey/uart.c hexdump.c printf/printf.c fat/pff_file.c fat/pff.c common/utils.c mist/diskio_sectorrequest.c mist/dirs.c
  | 
      |||
MIST_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(MIST_SRC))
  | 
      |||
| 46 | markw | LINKMAP  = ./standalone_simple.ld
  | 
      |
# Commandline options for each tool.
  | 
      |||
#ZPUOPTS= -mno-poppcrel -mno-pushspadd -mno-callpcrel -mno-shortop -mno-neg # No-neg requires bugfixed toolchain
  | 
      |||
#Include everything -> need to include emulation rom...
  | 
      |||
ZPUOPTS =
  | 
      |||
CFLAGS  = -I. -Isd_direct -Iprintf -Ifat -Icommon -c -g -Os $(ZPUOPTS) -DDISABLE_UART_RX
  | 
      |||
LFLAGS  = -nostartfiles -Wl,--relax -g -Os
  | 
      |||
#LFLAGS  = -nostartfiles -Os
  | 
      |||
# Our target.
  | 
      |||
| 78 | markw | all: mcc mist de1
  | 
      |
| 46 | markw | ||
| 69 | markw | install:
  | 
      |
	cd ../common/romgen && ./createall && cd ../../firmware
  | 
      |||
| 78 | markw | de1: $(BUILD_DIR) $(DE1_PRJ).bin $(DE1_PRJ).rpt
  | 
      |
| 69 | markw | mcc: $(BUILD_DIR) $(MCC_PRJ).bin $(MCC_PRJ).rpt
  | 
      |
mist: $(BUILD_DIR) $(MIST_PRJ).bin $(MIST_PRJ).rpt
  | 
      |||
| 46 | markw | clean:
  | 
      |
| 78 | markw | 	rm -f $(BUILD_DIR)/*.o *.hex *.elf *.map *.lst *.srec $(MIST_PRJ).rom $(MCC_PRJ).rom ${DE1_PRJ).rom *~ */*.o *.bin
  | 
      |
| 46 | markw | ||
# Convert ELF binary to bin file.
  | 
      |||
%.bin: %.elf
  | 
      |||
	$(CP) -O binary $< $@
  | 
      |||
%.rpt: %.elf
  | 
      |||
	echo >$@ -n "End of code:\t"
  | 
      |||
	$(DUMP) -x $< | grep >>$@ _romend
  | 
      |||
	echo >>$@ -n "Start of BSS:\t"
  | 
      |||
	$(DUMP) -x $< | grep  >>$@ __bss_start__
  | 
      |||
	echo >>$@ -n "End of BSS:\t"
  | 
      |||
	$(DUMP) -x $< | grep >>$@ __bss_end__
  | 
      |||
	cat $@
  | 
      |||
# Link - this produces an ELF binary.
  | 
      |||
| 78 | markw | $(DE1_PRJ).elf: $(MINSTARTUP_OBJ) $(DE1_OBJ)
  | 
      |
	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
  | 
      |||
| 69 | markw | $(MCC_PRJ).elf: $(MINSTARTUP_OBJ) $(MCC_OBJ)
  | 
      |
| 46 | markw | 	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
  | 
      |
| 69 | markw | $(MIST_PRJ).elf: $(MINSTARTUP_OBJ) $(MIST_OBJ)
  | 
      |
	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
  | 
      |||
| 46 | markw | $(BUILD_DIR)/%.o: %.c Makefile
  | 
      |
	mkdir -p `dirname $@`
  | 
      |||
	$(CC) $(CFLAGS)  -o $@ -c $<
  | 
      |||
$(BUILD_DIR)/%.o: %.s
  | 
      |||
	$(AS) -o $@ $<
  | 
      |||
$(BUILD_DIR)/%.o: $(STARTUP_DIR)/%.s
  | 
      |||
	$(AS) -o $@ $<
  | 
      |||
$(BUILD_DIR):
  | 
      |||
	mkdir $(BUILD_DIR)
  |