makefile m68k-amiga-elf-gcc w. vasm -Felf.txt

(6 KB) Pobierz
# to generate assembler listing with LTO, add to LDFLAGS: -Wa,-adhln=$@.listing,--listing-rhs-width=200
# for better annotations add -dA -dP
# to generate assembler source with LTO, add to LDFLAGS: -save-temps=cwd

forward-to-backward = $(subst /,\,$1)

subdirs := src/ shared/ shared/tools/ shared/image/ shared/math/ src/roots_rotator/ src/copper_stretch/ src/tunnel/ src/copper_voxel/ src/image_viewer/ src/title/ src/greetings/ src/logos/ src/wbscreen/ src/playfield/ src/end/
data_subdirs := data/tunnel/ 
VPATH = $(subdirs) 
cpp_sources := $(wildcard *.cpp) $(wildcard $(addsuffix *.cpp,$(subdirs)))
cpp_objects := $(addprefix obj/,$(patsubst %.cpp,%.o,$(notdir $(cpp_sources))))
c_sources := $(wildcard *.c) $(wildcard $(addsuffix *.c,$(subdirs))) 
c_objects := $(addprefix obj/,$(patsubst %.c,%.o,$(notdir $(c_sources))))
s_sources := shared/tools/gcc8_a_support.s shared/tools/depacker_doynax.s src/roots_rotator/artezoom.s src/tunnel/tunnel.s
s_objects := $(addprefix obj/,$(patsubst %.s,%.o,$(notdir $(s_sources))))
iff_sources := 
iff_objects := $(addprefix obj/,$(patsubst %.iff,%.lzw,$(notdir $(iff_sources))))
vasm_sources := shared/reset.s shared/tools/wos_overlay.s src/copper_stretch/drawscanline.s src/copper_voxel/voxeldrawcolumn.s src/kpl14-mod.s src/wbscreen/coppercustom.s src/playfield/playfield_asm.s
# removed from vasm_sources src/LightSpeedPlayer_cia.s
vasm_objects := $(addprefix obj/,$(patsubst %.s,%.o,$(notdir $(vasm_sources))))
vasm_sources_bin := src/tunnel/tunnel_routine.s
vasm_objects_bin := $(patsubst %.s, %.bin, $(addprefix data/,$(vasm_sources_bin:src/%=%)))
lzw_sources := 
lzw_objects := $(addprefix obj/,$(patsubst %.bin,%.lzw,$(notdir $(lzw_sources))))

lzw_sources1 := data/tunnel/tunnel.bmp data/tunnel/tunnel1.bmp data/tunnel/tunnel_routine.bin data/tunnel/tab.bin data/tunnel/tab1.bin \
				data/copper_voxel/color3_256x128.bmp data/copper_voxel/height3_512x128.bmp data/copper_voxel/height3_256x128.bmp data/copper_voxel/rays-new.bin data/copper_voxel/rays_1024.bin data/copper_voxel/divtablearray-converted-180.bin data/copper_voxel/divtablearray-converted-new.bin data/copper_voxel/color3_512x128_v6.bmp data/copper_voxel/credit_1.iff data/copper_voxel/credit_2.iff data/copper_voxel/credit_3.iff data/copper_voxel/credit_4.iff data/copper_voxel/credit_5.iff \
				data/roots_rotator/arte_zoom.iff data/roots_rotator/arte_zoom_logo.iff data/roots_rotator/GodIsAnAstronaut.iff \
				data/copper_stretch/texture.bmp data/copper_stretch/credits.iff data/copper_stretch/tunnel_logo.iff \
				data/image_viewer/NeonRain.iff \
				data/title/TheLoop.iff \
				data/greetings/layer0.iff data/greetings/layer1.iff data/greetings/layer2.iff data/greetings/gradient.bmp \
				data/logos/Ghostown_logo_320x180.iff data/logos/Haujobb_logo_320x180.iff \
				data/playfield/playfields_off_v4.iff data/playfield/mask.iff \
				data/end/end_320x180.iff data/ascii.ansi
				
lzw_objects1 := $(addsuffix .lz,$(lzw_sources1))

objects := $(vasm_objects) $(cpp_objects) $(c_objects) $(s_objects) 

# https://stackoverflow.com/questions/4036191/sources-from-subdirectories-in-makefile/4038459
# http://www.microhowto.info/howto/automatically_generate_makefile_dependencies.html

OUT = a.mingw
CC = m68k-amiga-elf-gcc

INCLUDES = -Ishared

SHELL = c:/windows/system32/cmd.exe

//CCFLAGS = -g -MP -MMD -m68000 -nostdlib -Wextra -Wno-unused-function -Wno-volatile-register-var -fomit-frame-pointer -fno-tree-loop-distribution -flto -fwhole-program -fno-exceptions -D__BIG_ENDIAN__ -D__LOAD_DATA__  $(INCLUDES)
CCFLAGS = -g -MP -MMD -m68000 -Ofast -nostdlib -Wextra -Wno-unused-function -Wno-volatile-register-var -fomit-frame-pointer -fno-tree-loop-distribution -flto -fwhole-program -fno-exceptions -D__BIG_ENDIAN__ -D__LOAD_DATA__  $(INCLUDES)
CPPFLAGS= $(CCFLAGS) -fno-rtti -fcoroutines -fno-use-cxa-atexit
ASFLAGS = -Wa,-g,--register-prefix-optional
LDFLAGS = -Wl,--emit-relocs,-Ttext=0,-Map=$(OUT).map


VBCCDIR= $(realpath $(VBCC))
$(info $(lzw_objects1))
$(info $(VBCCDIR))
$(info $(c_sources))
$(info $(vasm_sources_bin))
$(info $(vasm_objects_bin))

# hjb
#VASM = $(VBCCDIR)/bin/vasmm68k_mot
#VASMFLAGS = -m68000 -quiet -Felf -opt-speed -showopt -I$(VBCCDIR)/NDK39/Include/include_i
VASM = vasmm68k_mot
VASMFLAGS = -m68000 -quiet -Felf -opt-speed -showopt -I$(VBCCDIR)/NDK39/Include/include_i
VASMFLAGS_ = -m68000 -Fbin -opt-speed -showopt -I$(VBCCDIR)/NDK39/Include/include_i
LZW = tools/lzw.exe
CRANKER = tools/cranker.exe


$(info $(lzw_sources))
$(info $(lzw_objects))
$(info $(s_sources))
$(info $(s_objects))

all: $(OUT).exe

$(OUT).exe: $(OUT).elf
	$(info Elf2Hunk $(OUT).exe)
	@elf2hunk $(OUT).elf $(OUT).exe -s
# cranker release version
	python whdf.py -n "The Loop Final" -f whdf-filelist.txt -a overlaydata.bin
	copy /b shared\tools\ovl.bin + overlaydata.bin markedoverlaydata.bin
	@$(CRANKER) -f $(OUT).exe -a markedoverlaydata.bin -tf data\cranker.txt -ed decranker_userdata.bin -o $(OUT).exe
	copy $(OUT).exe loop.exe
#	@$(CRANKER) -f $(OUT).exe -a markedoverlaydata.bin -tf data\ascii.ansi -ed decranker_userdata.bin -o $(OUT).exe
# normal debug version	
#	python whdf.py -f whdf-filelist.txt -a overlaydata.bin -e $(OUT).exe -o loop.exe	
#	copy loop.exe $(OUT).exe
# deprecated old approach	
#	copy /b $(OUT).exe + shared\tools\ovl.bin + overlaydata.bin $(OUT).exe

$(OUT).elf: $(objects)
	$(info Linking a.mingw.elf)
	$(info $(objects))
	@$(CC) $(CCFLAGS) $(LDFLAGS) $(objects) -o $@
	@m68k-amiga-elf-objdump --disassemble --no-show-raw-ins --visualize-jumps -S $@ >$(OUT).s 

clean:
	$(info Cleaning...)
	@del /q obj $(OUT).* 2>nul || rmdir obj 2>nul || ver>nul

-include $(objects:.o=.d)

$(iff_objects): obj/%.lzw : $(iff_sources)
	$(info IFF $<)
	@$(LZW) -o $@ $(CURDIR)/$<

$(cpp_objects) : obj/%.o : %.cpp $(lzw_objects) $(iff_objects)
	@if not exist "$(call forward-to-backward,$(dir $@))" mkdir $(call forward-to-backward,$(dir $@))
	$(info Compiling $<)
	@$(CC) $(CPPFLAGS) -c -o $@ $(CURDIR)/$<

$(c_objects) : obj/%.o : %.c $(lzw_objects)
	@if not exist "$(call forward-to-backward,$(dir $@))" mkdir $(call forward-to-backward,$(dir $@))
	$(info Compiling $<)
	@$(CC) $(CCFLAGS) -c -o $@ $(CURDIR)/$<

$(s_objects): obj/%.o : %.s
	$(info Assembling $<)
	@$(CC) $(CCFLAGS) $(ASFLAGS) -c -o $@ $(CURDIR)/$<

$(vasm_objects): obj/%.o : %.s
	$(info Assembling (VASM) $<)
	@$(VASM) $(VASMFLAGS) -o $@ $(CURDIR)/$<

data: $(vasm_objects_bin)
$(vasm_objects_bin): $(vasm_sources_bin)
	$(info Assembling (VASM) $< , $@)
	@$(VASM) -m68000 -Fbin -opt-speed -showopt -o $@ $(CURDIR)/$<

compress: $(lzw_objects1)
$(lzw_objects1):
	$(info Compressing (LZW) $@ , $(basename $@))
	@$(LZW) -o $@ $(basename $@) 
Zgłoś jeśli naruszono regulamin