Could the example be extended to include an assembly source file as well as C? I've changed to the makefile to do this myself, but I'm not comfortable with makefiles / gnu make and don't know how to work around the a.mingw.s file that keeps appearing and wanting to be assembled.
Code:
# to generate assembler sources: -Wa,-ahl=$@.s
forward-to-backward = $(subst /,\,$1)
subdirs := $(wildcard */)
VPATH = $(subdirs)
csources := $(wildcard *.c) $(wildcard $(addsuffix *.c,$(subdirs)))
asmsources := $(wildcard *.s) $(wildcard $(addsuffix *.s,$(subdirs)))
cobjects := $(addprefix obj8mingw/,$(patsubst %.c,%.o,$(notdir $(csources))))
asmobjects := $(addprefix obj8mingw/,$(patsubst %.s,%.o,$(notdir $(asmsources))))
objects := $(cobjects) $(asmobjects)
# 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
CCFLAGS = -g -MP -MMD -m68000 -Ofast -nostdlib -Wall -Wno-pointer-sign -Wno-unused-function -Wno-volatile-register-var -Wno-discarded-qualifiers -fomit-frame-pointer -fno-tree-loop-distribution -flto -fwhole-program
ASFLAGS = -Wa,-g,--register-prefix-optional
LDFLAGS = -Wl,--emit-relocs,-Ttext=0,-Map=$(OUT).map
all: $(OUT).exe
$(OUT).exe: $(OUT).elf
$(info Elf2Hunk $(OUT).exe)
@elf2hunk $(OUT).elf $(OUT).exe
$(OUT).elf: $(objects)
$(info Linking a.mingw.elf)
@$(CC) $(CCFLAGS) $(LDFLAGS) $(objects) -o $@
@m68k-amiga-elf-objdump --disassemble -S $@ >$(OUT).s
clean:
$(info Cleaning...)
@del /q obj8mingw $(OUT).* 2>nul || rmdir obj8mingw 2>nul || ver>nul
-include $(objects:.o=.d)
$(cobjects) : obj8mingw/%.o : %.c
@if not exist "$(call forward-to-backward,$(dir $@))" mkdir $(call forward-to-backward,$(dir $@))
$(info Compiling $<)
@$(CC) $(CCFLAGS) -c -o $@ $(CURDIR)/$<
$(asmobjects) : obj8mingw/%.o : %.s
@if not exist "$(call forward-to-backward,$(dir $@))" mkdir $(call forward-to-backward,$(dir $@))
$(info Assembling $<)
@$(CC) $(CCFLAGS) $(ASFLAGS) -xassembler-with-cpp -c -o $@ $(CURDIR)/$<
And could clean be added to tasks.json?
Code:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"type": "shell",
"command": "${command:amiga.bin-path}\\gnumake.exe",
"args": [
"-f", "Makefile8mingw", "-j4",
],
"options": {
"cwd": "${workspaceRoot}",
"env": {
"PATH": "${command:amiga.bin-path}\\opt\\bin;${command:amiga.bin-path}"
}
},
"problemMatcher": [
{
"base": "$gcc",
"fileLocation": "absolute"
}
],
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "clean",
"type": "shell",
"command": "${command:amiga.bin-path}\\gnumake.exe",
"args": [
"-f", "Makefile8mingw", "-j4", "clean"
],
"options": {
"cwd": "${workspaceRoot}",
"env": {
"PATH": "${command:amiga.bin-path}\\opt\\bin;${command:amiga.bin-path}"
}
},
"problemMatcher": [
{
"base": "$gcc",
"fileLocation": "absolute"
}
],
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"build"
}
]
}
Also, could the --register-prefix-optional option allow most of the first 28 lines of gcc8_a_support.s to be removed, or is there more to it than that?