setting up msys2 to build the FB manual

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

setting up msys2 to build the FB manual

Post by srvaldez »

I was going to post a script that would setup the msys2 toolchain to build both FB and the FB manual, all was going well, after installing msys2 and then installing some needed packages using pacman the script would download and extract the winlibs-gcc-9.3.0 toolchain to the appropriate folder then it would do the same for fbc-1.09 and then download the fbc gitrepo and build FB, the problem was that to build the FB manual you need libcurl and libpcre, pacman would fail to install the needed packages due to conflicting file versions
it would probably been ok if I didn't want to use the winlibs toolchain but I wanted to conform with the official distribution
it easy enough to have a clean minimal toolchain with the required packages to build the FB manual but that defeats my goal of an easy all-in-one solution
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: setting up msys2 to build the FB manual

Post by srvaldez »

so my efforts won't be a complete waste here are instructions on how to setup msys2, very simple
here are 2 scripts that will do almost all the work

make-fb32.txt

Code: Select all

set -e
cd /
# the following creates a dummy file in /tmp so that rm -r /tmp/* won't give an error due to empty directory
echo 'dummy'>/tmp/dummy.txt
rm -r /tmp/*
if !(test -f /mingw32/bin/gcc.exe) then
	cd /tmp
	wget https://github.com/brechtsanders/winlibs_mingw/releases/download/9.3.0-7.0.0-sjlj-r3/winlibs-mingw-w64-i686-9.3.0-7.0.0-r3-sjlj.7z
	7z x -o/ /tmp/winlibs-mingw-w64-i686-9.3.0-7.0.0-r3-sjlj.7z
	cd /
	rm /tmp/*
fi

if !(test -f /mingw64/bin/gcc.exe) then
	cd /tmp
	wget https://github.com/brechtsanders/winlibs_mingw/releases/download/9.3.0-7.0.0-sjlj-r3/winlibs-mingw-w64-x86_64-9.3.0-7.0.0-r3-sjlj.7z
	7z x -o/ /tmp/winlibs-mingw-w64-x86_64-9.3.0-7.0.0-r3-sjlj.7z
	cd /
	rm -r /tmp/*
fi

if !(test -f /mingw32/bin/fbc.exe) then
	cd /tmp
	wget https://downloads.sourceforge.net/fbc/fbc-1.09.0-win32-winlibs-gcc-9.3.0.7z?download
	7z x fbc-1.09.0-win32-winlibs-gcc-9.3.0.7z@download
	cp -r fbc-1.09.0-win32-winlibs-gcc-9.3.0/bin/* /mingw32/bin
	cp -r fbc-1.09.0-win32-winlibs-gcc-9.3.0/lib/* /mingw32/lib
	cp -r fbc-1.09.0-win32-winlibs-gcc-9.3.0/include/* /mingw32/include
	cd /
	rm -r /tmp/*
fi

if !(test -f /mingw64/bin/fbc.exe) then
	cd /tmp
	wget https://downloads.sourceforge.net/fbc/fbc-1.09.0-win64-winlibs-gcc-9.3.0.7z?download
	7z x fbc-1.09.0-win64-winlibs-gcc-9.3.0.7z?download
	cp -r fbc-1.09.0-win64-winlibs-gcc-9.3.0/bin/* /mingw64/bin
	cp -r fbc-1.09.0-win64-winlibs-gcc-9.3.0/lib/* /mingw64/lib
	cp -r fbc-1.09.0-win64-winlibs-gcc-9.3.0/include/* /mingw64/include
	cd /
	rm -r /tmp/*
fi

if (test -d /mingw32/i686-w64-mingw32/lib) then
	if !(test -f /mingw32/i686-w64-mingw32/lib/libffi.a) then
		cd /tmp
		wget https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz
		tar xzvf libffi-3.4.2.tar.gz
		cd libffi-3.4.2
		./configure --build=i686-pc-mingw32 --host=i686-pc-mingw32 --target=i686-pc-mingw32
		make
		cd i686-pc-mingw32/.libs
		cp *.* /mingw32/i686-w64-mingw32/lib
		cd ../include
		cp *.h /mingw32/i686-w64-mingw32/include
		cd /
		rm -r /tmp/*
	fi
fi

cd /tmp
wget https://github.com/freebasic/fbc/archive/refs/heads/master.zip
7z x master.zip
cd fbc-master
make compiler
cp bin/fbc.exe /mingw32/bin
make
rm /mingw32/lib/freebasic/win32/*
cp lib/freebasic/win32/* /mingw32/lib/freebasic/win32
make clean
make compiler
cp bin/fbc.exe /mingw32/bin
make clean
echo 'ENABLE_STANDALONE=1'>config.mk
make
mkdir -p bin/win32
cd lib/win32
make
cd ../..
make mingw-libs
if !(test -f GoRC.exe) then
	wget http://www.godevtool.com/Gorc.zip
	7z e Gorc.zip
fi
cp GoRC.exe bin/win32
cp '/mingw32/bin/ar.exe' bin/win32
cp '/mingw32/bin/as.exe' bin/win32
cp '/mingw32/bin/dlltool.exe' bin/win32
cp /mingw32/bin/gcc.exe bin/win32
cp '/mingw32/bin/gprof.exe' bin/win32
cp '/mingw32/bin/ld.exe' bin/win32
cp '/mingw32/bin/libintl-8.dll' bin/win32
cp '/mingw32/bin/zlib1.dll' bin/win32
cp '/mingw32/bin/libdl.dll' bin/win32
cp '/mingw32/bin/libiconv-2.dll' bin/win32
cp '/mingw32/bin/libwinpthread-1.dll' bin/win32
cp '/mingw32/bin/libgcc_s_sjlj-1.dll' bin/win32
cp -R /mingw32/libexec bin
# you could run the tests suits before making bindist
make bindist
make-fb64.txt

Code: Select all

set -e
cd /
# the following creates a dummy file in /tmp so that rm -r /tmp/* won't give an error due to empty directory
echo 'dummy'>/tmp/dummy.txt
rm -r /tmp/*
if (test -d /mingw64/x86_64-w64-mingw32/lib) then
	if !(test -f /mingw64/x86_64-w64-mingw32/lib/libffi.a) then
		cd /tmp
		wget https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz
		tar xzvf libffi-3.4.2.tar.gz
		cd libffi-3.4.2
		./configure
		make
		cd x86_64-w64-mingw32/.libs
		cp *.* /mingw64/x86_64-w64-mingw32/lib
		cd ../include
		cp *.h /mingw64/x86_64-w64-mingw32/include
		cd /
		rm -r /tmp/*
	fi
fi
cd /tmp
wget https://github.com/freebasic/fbc/archive/refs/heads/master.zip
7z x master.zip
cd fbc-master
make compiler
cp bin/fbc.exe /mingw64/bin
make
rm /mingw64/lib/freebasic/win64/*
cp lib/freebasic/win64/* /mingw64/lib/freebasic/win64
make clean
make compiler
cp bin/fbc.exe /mingw64/bin
make clean
echo 'ENABLE_STANDALONE=1'>config.mk
make
mkdir -p bin/win64
make mingw-libs
if !(test -f GoRC.exe) then
	wget http://www.godevtool.com/Gorc.zip
	7z e Gorc.zip
fi
cp GoRC.exe bin/win64
cp '/mingw64/bin/ar.exe' bin/win64
cp '/mingw64/bin/as.exe' bin/win64
cp '/mingw64/bin/dlltool.exe' bin/win64
cp /mingw64/bin/gcc.exe bin/win64
cp '/mingw64/bin/gprof.exe' bin/win64
cp '/mingw64/bin/ld.exe' bin/win64
cp '/mingw64/bin/libintl-8.dll' bin/win64
cp '/mingw64/bin/zlib1.dll' bin/win64
cp '/mingw64/bin/libdl.dll' bin/win64
cp '/mingw64/bin/libiconv-2.dll' bin/win64
cp '/mingw64/bin/libwinpthread-1.dll' bin/win64
cp -R /mingw64/libexec bin
# you could run the tests suits before making bindist
make bindist
1: download and install msys2 https://www.msys2.org/
2: launch mingw32.exe and issue the following command: pacman -S wget git p7zip zip make
3: type sh followed by a space then drag&drop make-fb32.txt onto the shell window, press return
after it's finished you will have the freshly built fb, it will be in C:\msys64\tmp\fbc-master
4: move your build out of the tmp folder to get ready to build the 64-bit version, if you don't move it out it will be deleted
5: exit/close the msys32 shell, then launch mingw64.exe
6: type sh followed by a space then drag&drop make-fb64.txt onto the shell window, press return
that will build the 64-bit version
the only thing that the script didn't do is to cleanup libexec, just go there and delete the unneeded files/folders keep cc1.exe and all the dlls except the lto-plugin stuff

mk-fb-manual.txt

Code: Select all

set -e
if !(test -d /tmp/fbc-master) then
	cd /
	echo 'dummy'>/tmp/dummy.txt
	rm -r /tmp/*
	cd /tmp
	wget https://github.com/freebasic/fbc/archive/refs/heads/master.zip
	7z x master.zip
fi
cd /tmp/fbc-master
cd doc/fbdoc
make
cd ../makefbhelp
make
cd ../manual
make clean
../fbdoc/fbdoc -refresh -useweb -chm -fbhelp -txt
make HHC=/c/htmlhelp/hhc.exe
to setup the system to build the manual I did from a clean msys2 install, that is before any of the above
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-i686-curl
pacman -S mingw-w64-i686-pcre
copy libmySQL.dll.a to msys64/mingw32/lib
copy libmysql.dll msys64/mingw32/bin
copy the 32-bit version of FreeBasic into the appropriate folders in msys64/mingw32
install htmlhelp.exe in c:\htmlhelp
then to make the manual launch mingw32.exe and type sh a space then drag&drop mk-fb-manual.txt onto the shell window, press return
the manual will be created in fbc-master\doc\manual
after that I would rename msys64/mingw32 and msys64/mingw64 to something else and then run the scripts to build FB
to rebuild the manual again I would rename msys64/mingw32 and msys64/mingw64 to mingw32-930 and mingw64-930 and undo the previous rename
I hope that makes sense
Last edited by srvaldez on Jul 19, 2022 13:42, edited 1 time in total.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: setting up msys2 to build the FB manual

Post by paul doe »

Very useful info! Thanks, srvaldez 8)
Post Reply