Skip to content

Instantly share code, notes, and snippets.

@kikairoya
Created June 21, 2010 11:40
Show Gist options
  • Save kikairoya/446735 to your computer and use it in GitHub Desktop.
Save kikairoya/446735 to your computer and use it in GitHub Desktop.
INCLUDES=src src_api src_sys src_usb
CC=h8300-elf-gcc -std=gnu99 -msx -mint32 -c $(addprefix -I, $(INCLUDES))
CFLAGS=-O0 -g3 -Wall
CXX=h8300-elf-g++ -msx -mint32 -c $(addprefix -I, $(INCLUDES))
CXXFLAGS=$(CFLAGS) -fno-rtti -fno-exceptions
AS=h8300-elf-gcc -msx -mint32 -Xassembler $(addprefix -I, $(INCLUDES))
ASFLAGS=-g3
LINK=h8300-elf-gcc -msx -mint32 -nostartfiles -nodefaultlibs
LINKFLAGS=-g3
OBJCOPY=h8300-elf-objcopy
TARGET=PROG.mot
SYS_OBJS=src/main.o\
src_api/analog.o src_api/bsc.o src_api/cpg.o src_api/dmac.o src_api/dtc.o src_api/fat16.o\
src_api/gpio.o src_api/graphics.o src_api/key.o src_api/lcd1602.o src_api/lcdpanel.o src_api/rtc.o\
src_api/sdcard.o src_api/spi.o src_api/tmr.o src_api/touch.o\
src_sys/console.o src_sys/exception_handler.o src_sys/irq.o\
src_sys/malloc.o src_sys/retarget.o src_sys/start.o src_sys/stub.o src_sys/switch.o src_sys/uart.o\
src_sys/usb.o src_sys/vects.o\
src_usb/DoBulk.o src_usb/DoControl.o src_usb/DoRequest.o src_usb/DoRequestComCommand.o\
src_usb/DoRequestVenderCommand.o src_usb/DoSerial.o src_usb/StartUp.o src_usb/UsbMain.o
USER_OBJS=
LIBS=-lc -lgcc
LDSCRIPT=ldscript/H8SX_1655.link
OUTDIR=Debug
SED=sed
MAKEDEP.c=$(CC) $(CFLAGS) -MM
MAKEDEP.cc=$(CXX) $(CXXFLAGS) -MM
MAKEDEP.cpp=$(MAKEDEP.cc)
MAKEDEP.S=$(AS) $(ASFLAGS) -MM
.PHONY:
.PHONY: all clean mkdirs
all: mkdirs $(OUTDIR)/$(TARGET)
mkdirs:
ifneq ($(MAKECMDGOALS),clean)
MKDIR___:=$(shell mkdir -p $(addprefix $(OUTDIR)/, src src_api src_sys src_usb))
-include $(addprefix $(OUTDIR)/, $(SYS_OBJS:.o=.dep) $(USER_OBJS:.o=.dep))
endif
%.mot: %.elf
$(OBJCOPY) -O srec $< $@
$(OUTDIR)/$(basename $(TARGET)).elf: $(addprefix $(OUTDIR)/, $(SYS_OBJS) $(USER_OBJS)) $(LDSCRIPT)
$(LINK) -T$(LDSCRIPT) -Wl,-Map,$(OUTDIR)/$(basename $(TARGET)).map -o$@ $(addprefix $(OUTDIR)/, $(SYS_OBJS) $(USER_OBJS)) $(LIBS)
$(OUTDIR)/%.o: %.c
$(CC) -c $(CFLAGS) -o$@ $<
$(OUTDIR)/%.o: %.cc
$(CXX) -c $(CXXFLAGS) -o$@ $<
$(OUTDIR)/%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -o$@ $<
$(OUTDIR)/%.o: %.S
$(AS) -c $(ASFLAGS) -o$@ $<
define makedep
@echo Generating dependency information for $<
@$(MAKEDEP$(suffix $<)) -MT '$@ $(@:.dep=.o)' $< -MF $@
endef
$(OUTDIR)/%.dep: %.c
$(makedep)
$(OUTDIR)/%.dep: %.cpp
$(makedep)
$(OUTDIR)/%.dep: %.cc
$(makedep)
$(OUTDIR)/%.dep: %.S
$(makedep)
clean:
-$(RM) $(addprefix $(OUTDIR)/, $(foreach suff, .dep .o, $(addsuffix $(suff), $(basename $(SYS_OBJS) $(USER_OBJS)))) $(foreach suff, .mot .map .elf, $(addsuffix $(suff), $(basename $(TARGET)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment