bsd-games: fix cross-compile

This commit is contained in:
Đoàn Trần Công Danh 2020-04-03 16:42:39 +07:00 committed by Juan RP
parent 2b9be04823
commit a71f080e38
2 changed files with 117 additions and 4 deletions

View file

@ -0,0 +1,86 @@
diff --git a/adventure/Makefrag b/adventure/Makefrag
index 64bc7e2..ee02de8 100644
--- a/adventure/Makefrag
+++ b/adventure/Makefrag
@@ -28,11 +28,12 @@
adventure_CLEANFILES := data.c
adventure_DIRS := $(GAMESDIR) $(MAN6DIR)
+ADVENTURE_SETUP = adventure/setup
adventure_all: adventure/adventure adventure/adventure.6
adventure/data.c: adventure/glorkz adventure/setup
- adventure/setup $< >$@
+ $(ADVENTURE_SETUP) $< >$@
adventure_install: adventure_all
$(INSTALL_BINARY) adventure/adventure $(INSTALL_PREFIX)$(GAMESDIR)/adventure
diff --git a/boggle/mkdict/Makefrag b/boggle/mkdict/Makefrag
index 3e27969..1556e72 100644
--- a/boggle/mkdict/Makefrag
+++ b/boggle/mkdict/Makefrag
@@ -34,9 +34,10 @@ boggle_mkdict_DICTSRC := $(DICTIONARY_SRC)
boggle_mkdict_DIRS := $(BOGGLE_DIR)
boggle_mkdict_INCS := -Iboggle/boggle
+BOGGLE_MKDICT_MKDICT = boggle/mkdict/mkdict
boggle/mkdict/dictionary: boggle/mkdict/mkdict $(boggle_mkdict_DICTSRC)
- $< <$(boggle_mkdict_DICTSRC) >$@
+ $(BOGGLE_MKDICT_MKDICT) <$(boggle_mkdict_DICTSRC) >$@
boggle_mkdict_all: boggle/mkdict/dictionary
diff --git a/boggle/mkindex/Makefrag b/boggle/mkindex/Makefrag
index 5d406b3..08afad7 100644
--- a/boggle/mkindex/Makefrag
+++ b/boggle/mkindex/Makefrag
@@ -29,9 +29,10 @@
boggle_mkindex_CLEANFILES := dictindex
boggle_mkindex_DIRS := $(BOGGLE_DIR)
boggle_mkindex_INCS := -Iboggle/boggle
+BOGGLE_MKINDEX_MKINDEX = boggle/mkindex/mkindex
boggle/mkindex/dictindex: boggle/mkindex/mkindex boggle/mkdict/dictionary
- $< <boggle/mkdict/dictionary >$@
+ $(BOGGLE_MKINDEX_MKINDEX) <boggle/mkdict/dictionary >$@
boggle_mkindex_all: boggle/mkindex/dictindex
diff --git a/hack/Makefrag b/hack/Makefrag
index eabbd2a..bc4388b 100644
--- a/hack/Makefrag
+++ b/hack/Makefrag
@@ -29,11 +29,12 @@
hack_DIRS := $(GAMESDIR) $(MAN6DIR)
hack_CLEANFILES := hack.onames.h
+HACK_MAKEDEFS = hack/makedefs
hack_all: hack/hack hack/hack.6
hack/hack.onames.h: hack/def.objects.h hack/makedefs
- hack/makedefs $< >$@
+ $(HACK_MAKEDEFS) $< >$@
hack/alloc.d hack/hack.Decl.d hack/hack.apply.d hack/hack.bones.d \
hack/hack.d hack/hack.cmd.d hack/hack.do.d hack/hack.do_name.d \
diff --git a/phantasia/Makefrag b/phantasia/Makefrag
index 96c3e6a..a041d45 100644
--- a/phantasia/Makefrag
+++ b/phantasia/Makefrag
@@ -30,11 +30,12 @@ phantasia_DIRS := $(GAMESDIR) $(MAN6DIR) $(PHANTASIA_DIR)
phantasia_VFILES1 := gold lastdead mess monsters motd void
phantasia_VFILES2 := scoreboard characs
phantasia_CLEANFILES := $(phantasia_VFILES1) $(phantasia_VFILES2) scorefiles.stamp
+PHANTASIA_SETUP = ./setup
phantasia_all: phantasia/phantasia phantasia/phantasia.6 phantasia/scorefiles.stamp
phantasia/scorefiles.stamp: phantasia/setup phantasia/monsters.asc
- cd phantasia && ./setup -m monsters.asc
+ cd phantasia && $(PHANTASIA_SETUP) -m monsters.asc
touch phantasia/scorefiles.stamp
phantasia_install: phantasia_all

View file

@ -7,8 +7,8 @@ make_dirs="
/var/games/bsdgames/hack 0775 root users
/var/games/bsdgames/hack/save 0775 root users
/var/games/bsdgames/phantasia 0775 root users"
hostmakedepends="flex words-en"
makedepends="ncurses-devel"
hostmakedepends="flex words-en ncurses-devel"
makedepends="ncurses-devel libfl-devel"
depends="words-en"
short_desc="Linux port for a collection of BSD command line games"
maintainer="Leah Neukirchen <leah@vuxu.org>"
@ -36,7 +36,22 @@ mutable_files="/var/games/bsdgames/atc_score
/var/games/bsdgames/hack/record
/var/games/bsdgames/hack/perm"
patch_args="-Np1"
nocross=yes
if [ "$CROSS_BUILD" ]; then
local _file _var
_native_target="adventure/setup boggle/mkdict/mkdict boggle/mkindex/mkindex
hack/makedefs"
for _file in $_native_target; do
_var=${_file//\//_}
make_build_args+=" ${_var^^}=native/$_file"
done
_native_target+=" phantasia/setup"
make_build_args+=" PHANTASIA_SETUP=../native/phantasia/setup"
fi
if [ "$XBPS_LIBC" = musl ]; then
hostmakedepends+=" musl-legacy-compat"
fi
if [ "$XBPS_TARGET_LIBC" = musl ]; then
makedepends+=" musl-legacy-compat"
@ -59,6 +74,18 @@ post_extract() {
pre_configure() {
cp ${FILESDIR}/config.params .
if [ "$CROSS_BUILD" ]; then
mkdir -p native
cp -a * native 2>/dev/null || true
pushd native
echo "bsd_games_cfg_cc='$CC_FOR_BUILD'" >>config.params
echo "bsd_games_cfg_cxx='$CXX_FOR_BUILD'" >>config.params
echo "bsd_games_cfg_other_cflags='$CFLAGS_FOR_BUILD'" >>config.params
echo "bsd_games_cfg_other_ldflags='$LDFLAGS_FOR_BUILD'" >>config.params
./configure
make $_native_target
popd
fi
echo "bsd_games_cfg_cc='$CC'" >>config.params
echo "bsd_games_cfg_cxx='$CXX'" >>config.params
echo "bsd_games_cfg_other_cflags='$CFLAGS'" >>config.params
@ -68,7 +95,7 @@ pre_configure() {
do_install() {
echo >install-score
make install
make $make_build_args install
# Remove conflict with fish-shell
mv "${DESTDIR}/usr/bin/fish" "${DESTDIR}/usr/bin/go-fish"