Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier support for cross compiled GCC tools under Windows #325

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 18 additions & 34 deletions common.mk
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimize the differences between Windows and Linux. The .exe extension isn't needed.

Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,34 @@

BIN := $(GDK)/bin
LIB := $(GDK)/lib
export PATH := $(BIN):$(PATH)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the path to include the SGDK/bin directory.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather avoid to modify the PATH variable as it may cause troubles for an user who already has a GCC toolchain in its path (it was the case before and we got many issues with that). The way SGDK is working currently is convenient as it doesn't need any environment vars nor PATH modification. The $(BIN) var contains full SGDK bin path and the -B$(BIN) option allow to set the path for GCC binaries, libs... so it works out of the box :)


SRC_LIB := $(GDK)/src
RES_LIB := $(GDK)/res
INCLUDE_LIB := $(GDK)/inc
MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(subst \,/,$(MAKEFILE_DIR))

ifeq ($(OS),Windows_NT)
# Native Windows
SHELL := $(BIN)/sh.exe
RM := $(BIN)/rm.exe
CP := $(BIN)/cp.exe
MKDIR := $(BIN)/mkdir.exe

AR := $(BIN)/ar.exe
CC := $(BIN)/gcc.exe
LD:= $(BIN)/ld.exe
NM:= $(BIN)/nm.exe
OBJCPY := $(BIN)/objcopy.exe
ASMZ80 := $(BIN)/sjasm.exe
MACCER := $(BIN)/mac68k.exe
BINTOS := $(BIN)/bintos.exe
LTO_PLUGIN := --plugin=liblto_plugin-0.dll
LIBGCC := $(LIB)/libgcc.a
else
# Native Linux and Docker
ifneq ($(OS),Windows_NT)
PREFIX ?= m68k-elf-
SHELL = sh
RM = rm
CP = cp
MKDIR = mkdir

AR := $(PREFIX)ar
CC := $(PREFIX)gcc
LD := $(PREFIX)ld
NM := $(PREFIX)nm
OBJCPY := $(PREFIX)objcopy
ASMZ80 := sjasm
MACCER := mac68k
BINTOS := bintos
LTO_PLUGIN :=
LIBGCC := -lgcc
endif

SHELL = sh
RM = rm
CP = cp
MKDIR = mkdir

AR := $(PREFIX)ar
CC := $(PREFIX)gcc
LD := $(PREFIX)ld
NM := $(PREFIX)nm
OBJCPY := $(PREFIX)objcopy
ASMZ80 := sjasm
MACCER := mac68k
BINTOS := bintos
LTO_PLUGIN :=
LIBGCC := -lgcc

Comment on lines +17 to +32
Copy link
Owner

@Stephane-D Stephane-D May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in previous comment I prefer to not path PATH and use full path and so keep both $(BIN) and $(LIB) prefixes here. I think that should work for Linux system too.

JAVA := java
ECHO := echo
SIZEBND := $(JAVA) -jar $(BIN)/sizebnd.jar
Expand Down
Binary file modified lib/libmd.a
Binary file not shown.
Binary file modified lib/libmd_debug.a
Binary file not shown.
2 changes: 1 addition & 1 deletion makefile.gen
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ $(OUT)/symbol.txt: $(OUT)/rom.out

$(OUT)/rom.out: $(OUT)/sega.o $(OUT)/cmd_ $(LIBMD)
$(MKDIR) -p $(dir $@)
$(CC) -m68000 -B$(BIN) -n -T $(GDK)/md.ld -nostdlib $(OUT)/sega.o @$(OUT)/cmd_ $(LIBMD) $(LIBGCC) -o $(OUT)/rom.out -Wl,--gc-sections -flto
$(CC) -m68000 -B$(BIN) -n -T $(GDK)/md.ld -nostdlib $(OUT)/sega.o @$(OUT)/cmd_ -L$(LIB) $(LIBMD) $(LIBGCC) -o $(OUT)/rom.out -Wl,--gc-sections -flto
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use -L to set the library path. This allows libgcc.a to be picked up from the SGDK/lib directory if it exists or the default GCC lib directory if it doesn't.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use -L to set the library path. This allows libgcc.a to be picked up from the SGDK/lib directory if it exists or the default GCC lib directory if it doesn't.

See previous comment (use full path for lib) so the option is not needed.

$(RM) $(OUT)/cmd_

$(OUT)/cmd_: $(OBJS)
Expand Down