Skip to content

Conversation

bartoldeman
Copy link
Collaborator

  1. Get most cross asm tools via autoconf instead of the make logic.
  2. We need -x assembler-with-cpp instead of -x assembler, otherwise with a .s file preprocessor #ifdef's are ignored (and for .S we already have a cross rule, not good for tmp.s)
  3. -rpath=xx needs to be -rpath xx, so from compiler -Wl,-rpath,xx
  4. .section in asm is different on MacOS

@bartoldeman bartoldeman force-pushed the macos-dj64-mk-fixes branch from f55b507 to cdbb215 Compare July 26, 2025 03:03
@stsp
Copy link
Owner

stsp commented Jul 26, 2025

I think such design is problematic.
Basically what you assume is
that user's configuration
(installed tool-chains etc)
matches the build one, which
is LP. This is simply not true,
so I don't think we can generate
dj64.mk this way.
But I am not saying there is
no problem with current design.
I fully agree that dj64.mk is
over-convoluted.
But we need another solution.

stsp added a commit that referenced this pull request Jul 26, 2025
This is a change on top of Bart's work to run configure directly
on client's build session.
@stsp
Copy link
Owner

stsp commented Jul 26, 2025

I added #41 with some
idea on top of your patch.

@bartoldeman
Copy link
Collaborator Author

yes, I thought there was a catch somewhere! I think dj64.mk can be simplified a bit by grouping some things together, it's so it's more clear what the if/endif belong too, but yes it's a bit of emulation of configure in a sense, whether comcom64 would then also run this configure I'm not sure...

ifeq ($(filter clean install,$(MAKECMDGOALS)),)
MACH = $(subst -, ,$(shell $(CC) -dumpmachine))
ifeq ($(MACH),)
$(error unknown target architecture)
endif
OS = $(shell uname -s)
NATIVE=0
ifneq ($(filter x86_64 amd64 i686 i386,$(MACH)),)
ifneq ($(OS), Darwin)
NATIVE = 1
endif
endif

# find the suitable cross-assembler
DJ64AS = $(CROSS_PREFIX)as
DJ64ASFLAGS = --32 --defsym _DJ64=1
XSTRIP = $(CROSS_PREFIX)strip --strip-debug
XLD = $(CROSS_PREFIX)ld
XLD_IMB = -Ttext-segment

ifeq ($(CROSS_PREFIX),)
CROSS_PREFIX := i686-linux-gnu-
ifeq ($(shell $(DJ64AS) --version 2>/dev/null),)
CROSS_PREFIX := x86_64-linux-gnu-
ifeq ($(shell $(DJ64AS) --version 2>/dev/null),)
CROSS_PREFIX :=
endif
endif
else ifeq ($(shell $(DJ64AS) --version 2>/dev/null),)
# CROSS_PREFIX already set
$(error invalid CROSS_PREFIX)
endif

ifeq ($(CROSS_PREFIX),)
ifeq ($(NATIVE), 1)

# natively-compiling, as not found
ifeq ($(shell $(DJ64AS) --version 2>/dev/null),)
# found nothing, try built-in assembler
DJ64AS = $(CC) -x assembler
DJ64ASFLAGS = -m32 -Wa,-defsym,_DJ64=1 -c
endif

else

# cross-compiling, as not found
ifeq ($(shell clang --version 2>/dev/null),)
$(error cross-binutils not installed)
endif
DJ64AS = clang -x assembler -target i686-unknown-linux-gnu
DJ64ASFLAGS = -Wa,-defsym,_DJ64=1 -c
XSTRIP = llvm-strip --strip-debug
ifeq ($(shell $(XSTRIP) --version 2>/dev/null),)
XSTRIP = /usr/local/opt/llvm/bin/llvm-strip --strip-debug
ifeq ($(shell $(XSTRIP) --version 2>/dev/null),)
$(error llvm-strip not found)
endif
endif
XLD = ld.lld
XLD_IMB = --image-base

endif
endif

endif # filter clean install

up to you if you want #41 or the above.

@stsp
Copy link
Owner

stsp commented Jul 26, 2025

I don't really care at that point.
Be it just configure alone - fine,
I would prefer that.
But there is also config.sub,
config.guess, install-sh and all
the alike! Almost 0.5Mb of
the trash code for nothing.
So feel free to push your
cleanup patch.

@stsp
Copy link
Owner

stsp commented Jul 26, 2025

So if you don't add the
patch, I'll take that as an
approval of #41 :)

@bartoldeman bartoldeman force-pushed the macos-dj64-mk-fixes branch from cdbb215 to ec9d20a Compare July 26, 2025 19:39
@bartoldeman
Copy link
Collaborator Author

I did now, just did something else in the mean time :)

1. Reorder some make logic to make it a little easier to follow
2. We need -x assembler-with-cpp instead of -x assembler, otherwise
with a .s file preprocessor #ifdef's are ignored (and for .S we
already have a cross rule, not good for tmp.s)
3. -rpath=xx needs to be -rpath xx, so from compiler -Wl,-rpath,xx
4. .section in asm is different on MacOS
@bartoldeman bartoldeman force-pushed the macos-dj64-mk-fixes branch from ec9d20a to 25a0e49 Compare July 28, 2025 00:46
@stsp stsp merged commit cd5b7b0 into stsp:master Jul 28, 2025
1 check passed
@stsp
Copy link
Owner

stsp commented Jul 28, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants