mirror of
https://github.com/semerad/gt3b.git
synced 2026-02-19 19:11:23 +01:00
122 lines
3.0 KiB
Makefile
122 lines
3.0 KiB
Makefile
|
|
# paths
|
|
|
|
|
|
INCDIR = $(TOOLSET)/Hstm8
|
|
LIBDIR = $(TOOLSET)/Lib
|
|
# in linux, use wine to call compiler
|
|
ifdef WINEPREFIX
|
|
export WINEPREFIX
|
|
WINE = wine
|
|
else
|
|
WINE =
|
|
endif
|
|
|
|
|
|
# flags
|
|
|
|
CFLAGS = +warn +proto +mods$(SMODE)0 $(DEBUG) -i. -i$(INCDIR) -l $(VERBOSE) -pxp -ac
|
|
AFLAGS = -xx -xp -l $(VERBOSE) -c -i. -i$(INCDIR)
|
|
LDFLAGS = -l$(LIBDIR)
|
|
|
|
ifdef CHANNELS
|
|
CFLAGS += -dMAX_CHANNELS=$(CHANNELS)
|
|
endif
|
|
|
|
# used programs
|
|
|
|
AS = $(WINE) $(TOOLSET)/castm8
|
|
CC = $(WINE) $(TOOLSET)/cxstm8
|
|
LD = $(WINE) $(TOOLSET)/clnk
|
|
TOELF = $(WINE) $(TOOLSET)/cvdwarf
|
|
BIN = $(WINE) $(TOOLSET)/chex
|
|
RM = rm -f
|
|
|
|
|
|
# object files
|
|
|
|
OBJ = $(SRCC:.c=.o) $(INTRS:.c=.o)
|
|
|
|
|
|
# common compile
|
|
|
|
%.o: %.c
|
|
$(CC) $(CFLAGS) $<
|
|
|
|
%.s: %.c
|
|
$(CC) -s $(CFLAGS) $<
|
|
|
|
%.o: %.s
|
|
$(AS) $(AFLAGS) $<
|
|
|
|
|
|
# program
|
|
|
|
all: $(PROGRAM).elf $(PROGRAM).s19
|
|
|
|
|
|
$(PROGRAM).sm8: $(OBJ)
|
|
@echo "+seg .const -b 0x8080 -m 0x7f80 -n .const -it" >$(PROGRAM).lkf
|
|
@echo "+seg .text -a .const -n .text" >>$(PROGRAM).lkf
|
|
@echo "+seg .eeprom -b 0x4000 -m 0x400 -n .eeprom" >>$(PROGRAM).lkf
|
|
@echo "+seg .bsct -b 0x0 -m 0x100 -n .bsct" >>$(PROGRAM).lkf
|
|
@echo "+seg .ubsct -a .bsct -n .ubsct" >>$(PROGRAM).lkf
|
|
@echo "+seg .bit -a .ubsct -n .bit -id" >>$(PROGRAM).lkf
|
|
@echo "+seg .share -a .bit -n .share -is" >>$(PROGRAM).lkf
|
|
@echo "+seg .data -b 0x100 -m "$(ENDMEMORY)"+1-0x100 -n .data" >>$(PROGRAM).lkf
|
|
@echo "+seg .bss -a .data -n .bss" >>$(PROGRAM).lkf
|
|
@echo "crtsi0.sm8" >>$(PROGRAM).lkf
|
|
@echo $(SRCC:.c=.o) >>$(PROGRAM).lkf
|
|
@echo $(LIBS) >>$(PROGRAM).lkf
|
|
@echo "libis"$(SMODE)"0.sm8" >>$(PROGRAM).lkf
|
|
@echo "libm0.sm8" >>$(PROGRAM).lkf
|
|
@echo "+seg .const -b 0x8000 -k" >>$(PROGRAM).lkf
|
|
@echo $(INTRS:.c=.o) >>$(PROGRAM).lkf
|
|
@echo "+def __endzp=@.ubsct" >>$(PROGRAM).lkf
|
|
@echo "+def __memory=@.bss" >>$(PROGRAM).lkf
|
|
@echo "+def __stack="$(STACK) >>$(PROGRAM).lkf
|
|
@echo "+def __startmem=@.bss" >>$(PROGRAM).lkf
|
|
@echo "+def __endmem="$(ENDMEMORY) >>$(PROGRAM).lkf
|
|
$(LD) $(LDFLAGS) -o $@ -m$(PROGRAM).map $(PROGRAM).lkf
|
|
|
|
$(PROGRAM).elf: $(PROGRAM).sm8
|
|
$(TOELF) $<
|
|
|
|
$(PROGRAM).s19: $(PROGRAM).sm8
|
|
$(BIN) -o $@ $<
|
|
|
|
|
|
|
|
|
|
clean:
|
|
$(RM) $(OBJ) $(OBJ:.o=.s) $(OBJ:.o=.ls) $(PROGRAM).sm8 $(PROGRAM).elf $(PROGRAM).s19 $(PROGRAM).map $(PROGRAM).lkf
|
|
|
|
|
|
|
|
depend:
|
|
$(CC) -sm $(CFLAGS) $(SRCC) $(INTRS) \
|
|
| sed -e 's/\<\(mods[^.]*\|iostm8s\|string\)\.h\>//g' \
|
|
-e 's/\r//' >.depend
|
|
|
|
# include dependences if they exists
|
|
|
|
ifeq (.depend, $(wildcard .depend))
|
|
include .depend
|
|
endif
|
|
|
|
|
|
|
|
compile.bat: Makefile Makefile.stm8
|
|
make clean
|
|
echo '@if "%TOOLSET%"=="" goto NoToolset' > $@
|
|
echo -e '@if not "%CHANNELS%"=="" goto ChannelOK\n@set CHANNELS=8\n:ChannelOK' >>$@
|
|
make CHANNELS=8 | grep /c | grep -v ^make | tee -a $@
|
|
sed -i -e "s|^\(wine \)\?$(TOOLSET)|%TOOLSET%|" \
|
|
-e "s|-\([il]\)$(TOOLSET)|-\1%TOOLSET%|" \
|
|
-e "s|-dMAX_CHANNELS=.|-dMAX_CHANNELS=%CHANNELS%|" $@
|
|
cp -p $(PROGRAM).lkf compile.lkf
|
|
sed -i -e "s|$(PROGRAM)\.lkf|compile.lkf|" $@
|
|
echo -e '@goto:EOF\n\n:NoToolset\n@echo TOOLSET variable is not set, set it with "set TOOLSET=path"' >>$@
|
|
sed -i -e 's|\(.*\)|\1
|
|
|' $@
|
|
|