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

some fixes in unix/Makefile #192

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
50 changes: 28 additions & 22 deletions platforms/unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,38 @@ UNAME := $(shell uname -s)
# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
# See "docs/pf_ref.htm" file for more info.

# you can set these from outside, defaults are provided otherwise.
ifndef CC
# c99 on macOS doesn't handle the command line options properly
ifeq "$(UNAME)" "Darwin"
CC=clang
endif
# c99 on FreeBSD does not accept '-x' option
ifeq "$(UNAME)" "FreeBSD"
CC=clang
endif
endif
ifndef WIDTHOPT
philburk marked this conversation as resolved.
Show resolved Hide resolved
# Set this parameter to -m32 if you want to compile a 32-bit binary. Leave empty for 64-bit binary.
WIDTHOPT=
endif
ifndef IO_SOURCE
IO_SOURCE = pf_io_posix.c pf_fileio_stdio.c
#IO_SOURCE = pf_io_stdio.c
# TODO: add demo what else is needed for this to work
endif

SRCDIR = ../..
PFORTHDIR = $(SRCDIR)
CSRCDIR = $(PFORTHDIR)/csrc
FTHDIR = $(PFORTHDIR)/fth
UNIXDIR = platforms/unix
BUILDDIR = $(shell pwd)

PFDICAPP = pforth
PFORTHDIC = pforth.dic
PFDICDAT = pfdicdat.h
PFORTHAPP = pforth_standalone

# Set this parameter to -m32 if you want to compile a 32-bit binary.
WIDTHOPT=

FULL_WARNINGS = \
--std=c89 \
-fsigned-char \
Expand Down Expand Up @@ -53,20 +71,8 @@ else
ASANOPTS =
endif

IO_SOURCE = pf_io_posix.c pf_fileio_stdio.c
#IO_SOURCE = pf_io_stdio.c

EMBCCOPTS = -DPF_STATIC_DIC #-DPF_NO_FILEIO

# c99 on macOS doesn't handle the command line options properly
ifeq "$(UNAME)" "Darwin"
CC=clang
endif
# c99 on FreeBSD does not accept '-x' option
ifeq "$(UNAME)" "FreeBSD"
CC=clang
endif

#######################################
PFINCLUDES = pf_all.h pf_cglue.h pf_clib.h pf_core.h pf_float.h \
pf_guts.h pf_host.h pf_inc1.h pf_io.h pf_mem.h pf_save.h \
Expand Down Expand Up @@ -157,12 +163,12 @@ help:
@echo " It allows pForth to work as a standalone image that does not need to load a dictionary file."

test: $(PFORTHAPP)
cd $(FTHDIR) && ../$(UNIXDIR)/$(PFORTHAPP) -q t_corex.fth
cd $(FTHDIR) && ../$(UNIXDIR)/$(PFORTHAPP) -q t_strings.fth
cd $(FTHDIR) && ../$(UNIXDIR)/$(PFORTHAPP) -q t_locals.fth
cd $(FTHDIR) && ../$(UNIXDIR)/$(PFORTHAPP) -q t_alloc.fth
cd $(FTHDIR) && ../$(UNIXDIR)/$(PFORTHAPP) -q t_floats.fth
cd $(FTHDIR) && ../$(UNIXDIR)/$(PFORTHAPP) -q t_file.fth
cd $(FTHDIR) && $(BUILDDIR)/$(PFORTHAPP) -q t_corex.fth
cd $(FTHDIR) && $(BUILDDIR)/$(PFORTHAPP) -q t_strings.fth
cd $(FTHDIR) && $(BUILDDIR)/$(PFORTHAPP) -q t_locals.fth
cd $(FTHDIR) && $(BUILDDIR)/$(PFORTHAPP) -q t_alloc.fth
cd $(FTHDIR) && $(BUILDDIR)/$(PFORTHAPP) -q t_floats.fth
cd $(FTHDIR) && $(BUILDDIR)/$(PFORTHAPP) -q t_file.fth
@echo "PForth Tests PASSED"

clean:
Expand Down
15 changes: 15 additions & 0 deletions platforms/zig-crossbuild/cross-compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
guberathome marked this conversation as resolved.
Show resolved Hide resolved

# example for crosscompiling
# note-1: Please make sure zig is available on the path!
# depending on the target you may need to set IO_SOURCE as well:
# target="x86_64-windows-gnu" IO_SOURCE="pf_fileio_stdio.c pf_io_win32.c" ./cross-compile.sh pforth
# note-2: above compiles a Windows executable which may fail at runtime!

if test -z "$target"
then
# this builds a static executable with MUSL
target=x86_64-linux-musl
fi

CC="zig cc --target=$target" make -f ../unix/Makefile "$@"
5 changes: 5 additions & 0 deletions platforms/zig-crossbuild/default.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# note: Please make sure zig is available on the path!

CC="zig cc" make -f ../unix/Makefile "$@"
Loading