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

Getting Windows cross-compilation to work on my Mac #1630

Merged
merged 11 commits into from
Feb 23, 2025
25 changes: 20 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Gregorio. If not, see <http://www.gnu.org/licenses/>.

SUBDIRS = src examples tex contrib fonts doc
SUBDIRS = src examples tex contrib fonts doc macosx

ACLOCAL_AMFLAGS = -I m4

Expand All @@ -25,22 +25,26 @@ EXTRA_DIST = README.md CHANGELOG.md CONTRIBUTING.md CONTRIBUTORS.md \

MAINTAINERCLEANFILES = gregoriotex.ctan.zip

VERSION := $(shell ./VersionManager.py --get-current)
TOP := $(shell pwd)
export TOP

export TOP_LEVEL_MAKE = true

gregorio:
make -C src all
$(MAKE) -C src all

fonts: make-fonts
make-fonts:
make -C fonts fonts
$(MAKE) -C fonts fonts

clean-fonts:
make -C fonts clean-fonts
$(MAKE) -C fonts clean-fonts

doc: pdf
clean-pdf: clean-doc
clean-doc:
make -C doc clean-doc
$(MAKE) -C doc clean-doc

gregoriotex.tds.zip: dist-zip install-gtex.sh
./install-gtex.sh tds
Expand All @@ -50,3 +54,14 @@ ctan: gregoriotex.tds.zip build-ctan.sh

dist-hook:
rm -rf $(distdir)/windows

if MACOSX
dist-macosx: gregorio doc fonts
$(MAKE) -C macosx dist-macosx
else
dist-macosx:
@echo "macOS packages can only be built on Mac systems."
endif

clean-macosx:
$(MAKE) -C macosx clean-local
4 changes: 4 additions & 0 deletions VersionManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
"tex/gregoriotex-signs.lua",
"tex/gregoriotex-symbols.tex",
"contrib/TeXShop/Makefile.am",
"contrib/vim/Makefile.am",
"contrib/vim/ftdetect/Makefile.am",
"contrib/vim/syntax/Makefile.am",
"contrib/900_gregorio.xml",
"contrib/Makefile.am",
"contrib/gabc.lang",
Expand Down Expand Up @@ -165,6 +168,7 @@
"windows/gregorio.iss",
"windows/install.lua",
"windows/uninstall.lua",
"macosx/Makefile.am",
]

def strtobool(val):
Expand Down
27 changes: 20 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
# --jobs= : the number of jobs to run simultaneously in the make step
# --force= : force autoreconf
# {other) : anything else is passed to configure verbatim


# Before we do anything we make sure our working directory is the top level of the
# repository (where this script is located). This allows us to call this script from
# other folders and still have it work.
cd "${0%/*}"


# try to find bash, in case the standard shell is not capable of
# handling the generated configure's += variable assignments
if which bash >/dev/null
Expand All @@ -33,7 +39,7 @@ then
export MAKE
echo "You have a GNU-make installed as gmake; I will use that"
else
echo "I can't find a GNU-make; I'll try to use make and hope that works."
echo "I can't find a GNU-make; I'll try to use make and hope that works."
echo "If it doesn't, please install GNU-make."
fi

Expand Down Expand Up @@ -67,22 +73,29 @@ if [ "$MINGWCROSS" = "TRUE" ]
then
MINGWBUILD=$HOSTTYPE-$OSTYPE
MINGWSTR=mingw32
PREFIX=/usr/
if [ -d /usr/mingw32 ]; then
MINGWSTR=mingw32
PREFIX=/usr/
elif [ -d /usr/i386-mingw32msvc ]; then
MINGWSTR=i386-mingw32msvc
MINGWSTR=i386-mingw32msvc
PREFIX=/usr/
elif [ -d /usr/i586-mingw32msvc ]; then
MINGWSTR=i586-mingw32msvc
MINGWSTR=i586-mingw32msvc
PREFIX=/usr/
elif [ -d /opt/local/i686-w64-mingw32 ]; then
MINGWSTR=i686-w64-mingw32
PREFIX=/opt/local/
fi
OLDPATH=$PATH
PATH=/usr/$MINGWSTR/bin:$PATH
CFLAGS="-mtune=pentiumpro -msse2 -g -O2 $CFLAGS"
LDFLAGS="-Wl,--large-address-aware $CFLAGS"
LDFLAGS="-static -Wl,--large-address-aware $CFLAGS"
ARCHFLAGS="--target=\"$MINGWSTR\" \
--with-gnu-ld \
--host=$MINGWSTR \
--build=$MINGWBUILD \
--prefix=/usr/$MINGWSTR"
--prefix=$PREFIX$MINGWSTR"
elif [ "$MACCROSS" = "TRUE" ]
then
# make sure that architecture parameter is valid
Expand All @@ -92,7 +105,7 @@ then
esac
ARCHFLAGS="$ARCHFLAGS"
CFLAGS="-arch $ARCH -g -O2 $CFLAGS"
LDFLAGS="-arch $ARCH $LDFLAGS"
LDFLAGS="-arch $ARCH $LDFLAGS"
fi


Expand Down
31 changes: 29 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS+=" -Wl,-z,now"])
AX_CHECK_LINK_FLAG([-fPIE], [LDFLAGS+=" -fPIE"])
AX_CHECK_LINK_FLAG([-pie], [LDFLAGS+=" -pie"])

AC_HEADER_STDC

gl_FUNC_REALPATH_WORKS

dnl linux has integer types in stdint.h, solaris, vms in inttypes.h
Expand Down Expand Up @@ -116,6 +114,34 @@ AC_ARG_ENABLE([version-in-exe], AS_HELP_STRING([--disable-version-in-exe], [Disa
])
AC_SUBST(GREGORIO_EXE_SUFFIX)

# AC_CANONICAL_HOST is needed to access the 'host_os' variable
AC_CANONICAL_HOST

build_linux=no
build_windows=no
build_mac=no

# Detect the target system
case "${host_os}" in
linux*)
build_linux=yes
;;
cygwin*|mingw*)
build_windows=yes
;;
darwin*)
build_mac=yes
;;
*)
AC_MSG_ERROR(["OS $host_os is not supported"])
;;
esac

# Pass the conditionals to automake
AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
AM_CONDITIONAL([MACOSX], [test "$build_mac" = "yes"])

AC_CONFIG_HEADERS([src/config_.h])
AC_CONFIG_FILES([
Makefile
Expand All @@ -129,5 +155,6 @@ AC_CONFIG_FILES([
doc/Makefile
tex/Makefile
fonts/Makefile
macosx/Makefile
])
AC_OUTPUT
5 changes: 5 additions & 0 deletions install-gtex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
# uninstall script generation and any existing uninstall script will be left
# alone.

# Before we do anything we make sure our working directory is the top level of the
# repository (where this script is located). This allows us to specify the files to be
# installed by their relative locations in the repository.
cd "${0%/*}"

VERSION=`head -1 .gregorio-version`
FILEVERSION=`echo $VERSION | sed 's/\./_/g'`

Expand Down
85 changes: 85 additions & 0 deletions macosx/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright (C) 2006-2025 The Gregorio Project (see CONTRIBUTORS.md)
#
# This file is part of Gregorio.
#
# Gregorio is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Gregorio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gregorio. If not, see <http://www.gnu.org/licenses/>.

MACOSX_TOP := $(shell pwd)
MACOSX_BUILD := $(MACOSX_TOP)/build
MACOSX_RESOURCES := $(MACOSX_TOP)/Resources
HTMLPREFIX := "https://github.com/gregorio-project/gregorio/blob/v"$(VERSION)"/"

$(MACOSX_BUILD) :
mkdir -p $(MACOSX_BUILD)

Gregorio : $(MACOSX_BUILD)
mkdir -p $(MACOSX_BUILD)/Gregorio
cp $(TOP)/*.md $(MACOSX_BUILD)/Gregorio

$(MACOSX_RESOURCES) :
mkdir -p $(MACOSX_RESOURCES)

Resources/COPYING.html : $(MACOSX_RESOURCES)
pandoc -s $(TOP)/COPYING.md -f markdown -t html --metadata title="COPYING" -o $(MACOSX_RESOURCES)/COPYING.html
sed -i -E "s|(href=.)([A-Z]+.md.)|\1$(HTMLPREFIX)\2|g" $(MACOSX_RESOURCES)/COPYING.html
sed -i -E "s|\(C\)|\&copy;|g" $(MACOSX_RESOURCES)/COPYING.html
sed -i -E "s|©|\&copy;|g" $(MACOSX_RESOURCES)/COPYING.html
sed -i -E "s|--|\&#8212;|g" $(MACOSX_RESOURCES)/COPYING.html
sed -i -E "s|“|\&#8220;|g" $(MACOSX_RESOURCES)/COPYING.html
sed -i -E "s|”|\&#8221;|g" $(MACOSX_RESOURCES)/COPYING.html

Resources/README.html : $(MACOSX_RESOURCES)
pandoc -s $(TOP)/README.md -f markdown -t html --metadata title="README" -o $(MACOSX_RESOURCES)/README.html
sed -i -E "s|(href=.)([A-Z]+.md.)|\1$(HTMLPREFIX)\2|g" $(MACOSX_RESOURCES)/README.html
sed -i -E "s|\(C\)|\&copy;|g" $(MACOSX_RESOURCES)/README.html
sed -i -E "s|©|\&copy;|g" $(MACOSX_RESOURCES)/README.html
sed -i -E "s|--|\&#8212;|g" $(MACOSX_RESOURCES)/README.html
sed -i -E "s|“|\&#8220;|g" $(MACOSX_RESOURCES)/README.html
sed -i -E "s|”|\&#8221;|g" $(MACOSX_RESOURCES)/README.html

resources : Resources/COPYING.html Resources/README.html

examples : Gregorio
mkdir -p $(MACOSX_BUILD)/Gregorio/examples
cp $(TOP)/examples/*.tex $(MACOSX_BUILD)/Gregorio/examples/
cp $(TOP)/examples/*.gabc $(MACOSX_BUILD)/Gregorio/examples/

mac-doc : Gregorio
mkdir -p $(MACOSX_BUILD)/Gregorio/doc
cp $(TOP)/doc/*.tex $(MACOSX_BUILD)/Gregorio/doc/
cp $(TOP)/doc/*.lua $(MACOSX_BUILD)/Gregorio/doc/
cp $(TOP)/doc/*.gabc $(MACOSX_BUILD)/Gregorio/doc/
cp $(TOP)/doc/*.pdf $(MACOSX_BUILD)/Gregorio/doc/
cp $(TOP)/doc/doc_README.md $(MACOSX_BUILD)/Gregorio/doc/
cp -r $(TOP)/contrib/ $(MACOSX_BUILD)/Gregorio/contrib
find $(MACOSX_BUILD)/Gregorio/contrib -name 'Makefile*' -delete

payload : $(MACOSX_BUILD) mac-doc examples
$(MAKE) -C .. DESTDIR=$(MACOSX_BUILD) install
AUTO_UNINSTALL=true $(TOP)/install-gtex.sh dir:$(MACOSX_BUILD)/tmp/gregorio
rm $(MACOSX_BUILD)/tmp/gregorio/fonts/source/gregoriotex/gregorio-base.sfd
rm $(MACOSX_BUILD)/tmp/gregorio/fonts/source/gregoriotex/granapadano-base.sfd

%.pkg : %.pkgproj payload resources
packagesbuild $<
mv $(MACOSX_BUILD)/$@ $(MACOSX_TOP)

dist-macosx : Gregorio.pkg Uninstall-Gregorio.pkg
mv Gregorio.pkg Gregorio-$(VERSION).pkg
mv Uninstall-Gregorio.pkg Uninstall-Gregorio-$(VERSION).pkg

clean-local :
rm -rf $(MACOSX_BUILD)
rm -rf $(MACOSX_RESOURCES)
rm -f *.pkg
Loading