Hi guys!
This is my first ever post, so I apologise for anything I mess up! But here are some scripts I've created to help me build and package C::B under Mac OSX Snow Leopard. They pull together a whole bunch of stuff from various bits of the Wiki and forums.
(1) Builds WxWidgets.
(2) Checks out/updates C::B and builds it.
(3) Bundles C::B into a proper Snow Leopard application.
The scripts make a few assumptions:
- You want to build C::B for 32 bit Mac OSX Snow Leopard with WxWidgets 2.8.12, for Unicode, with all plugins.
- You run all the scripts from the same directory.
- Script (1) creates a subdirectory "Dependencies" and builds WxWidgets there.
- Script (2) creates a subdirectory "Source" and checks out/updates and builds C::B there.
- Script (3) creates a subdirectory "Output" and bundles the app there.
- You download the file wxMac-2.8.12.tar.gz and put it in the same directory as the scripts before you start.
- You know the password for root (sudo is used for make install).
The scripts aren't perfect, there are a couple of hacks:
- There is a pause in the building of C::B to add a line to the configure.in file for m4_include[wxwin.m4].
- Maybe this should be checked into Subversion?
- All the plugins are built and not all of them always compile properly.
- FileManager, NassiShneiderman and Hunspell all seem to be broken on mine, so you might have to comment some stuff out.
If you have any comments/suggestions for improvement, please let me know! I'm hoping to do a bit of development on Mac in the coming few months, so any advice is very welcome. :-)
Cheers,
- Paul.
Script 1 (1_BuildAndInstallWxWidgets.sh):#!/bin/sh
if [ ! -d ./Dependencies ]
then
mkdir Dependencies
mv wxMac-2.8.12.tar.gz ./Dependencies
fi
cd Dependencies
tar xvf wxMac-2.8.12.tar.gz
cd wxMac-2.8.12
# For Mac OS X 10.5 or older or with a 32-bit processor, build Carbon like this:
mkdir build-carbon-debug
cd build-carbon-debug
arch_flags="-arch i386"
../configure --enable-shared --enable-monolithic --enable-unicode --with-mac --with-opengl --with-png=builtin --with-jpeg=builtin --with-tiff=builtin --with-expat=builtin CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags"
make;
sudo make install
Script 2 (2_GetAndBuildCodeBlocks.sh):#!/bin/sh
if [ ! -d ./Source ]
then
mkdir Source
fi
cd Source
if [ ! -d ./trunk ]
then
# Checkout SVN
svn checkout svn://svn.berlios.de/codeblocks/trunk
cd trunk
else
# Update SVN
cd trunk
svn update
fi
cp ../../Dependencies/wxMac-2.8.12/wxwin.m4 .
echo -----------------------------------------------------------
echo "Please add the following to your trunk/configure.in file:"
echo
echo " - After the line m4_include([revision.m4]), add:"
echo " m4_include([wxwin.m4])"
echo
echo "Once you have added this, press any key to continue..."
read
# Add m4_include[wxwin.m4] to configure.in.
ACLOCAL_FLAGS="-I /usr/share/aclocal"
./bootstrap
arch_flags="-arch i386"
./configure --with-contrib-plugins=all --enable-shared --enable-monolithic --enable-unicode --with-mac --with-opengl --with-png=builtin --with-jpeg=builtin --with-tiff=builtin --with-expat=builtin CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags"
make
sudo make install
Script 3 (3_BundleCodeBlocks.sh):#!/bin/sh
echo ===== Making Bundle Directories =====
mkdir ./Output
cd Output
mkdir ./CodeBlocksSVN.app
mkdir ./CodeBlocksSVN.app/Contents
mkdir ./CodeBlocksSVN.app/Contents/MacOS
mkdir ./CodeBlocksSVN.app/Contents/Resources
mkdir ./CodeBlocksSVN.app/Contents/Resources/share
mkdir ./CodeBlocksSVN.app/Contents/Resources/share/codeblocks
mkdir ./CodeBlocksSVN.app/Contents/Resources/lib
mkdir ./CodeBlocksSVN.app/Contents/Resources/lib/codeblocks
mkdir ./CodeBlocksSVN.app/Contents/Resources/English.lproj
echo ===== Copying Built Files =====
cp /usr/local/bin/codeblocks ./CodeBlocksSVN.app/Contents/MacOS/CodeBlocks
cp /usr/local/bin/cb_share_config ./CodeBlocksSVN.app/Contents/MacOS
cp /usr/local/bin/cb_console_runner ./CodeBlocksSVN.app/Contents/MacOS
cp /usr/local/bin/codesnippets ./CodeBlocksSVN.app/Contents/MacOS
cp /usr/local/lib/libwxsmithlib.0.dylib ./CodeBlocksSVN.app/Contents/MacOS
cp /usr/local/lib/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS
cp /usr/local/lib/libcodeblocks.0.dylib ./CodeBlocksSVN.app/Contents/MacOS
echo ===== Copying Resources From Source =====
# Most of this section has been copied from the Wiki:http://wiki.wxwidgets.org/WxMac_Issues#Building_a_MacOSX_application_bundle
# I don't know how much of it is necessary though.
#cp /Applications/CodeBlocks.app/Contents/Info.plist ./CodeBlocksSVN.app/Contents/
cp ../Source/trunk/codeblocks.plist ./CodeBlocksSVN.app/Contents/Info.plist
# cp version.plist YourApp.app/Contents/
# cp InfoPlist.strings YourApp.app/Contents/Resources/English.lproj/
# echo -n 'APPL????' > YourApp.app/Contents/PkgInfo
# cp YourApp YourApp.app/Contents/MacOS/YourApp
cp ../Source/trunk/src/src/resources/icons/* ./CodeBlocksSVN.app/Contents/Resources/
echo ===== Doing install_name_tool stuff =====
install_name_tool -id @executable_path/libcodeblocks.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/libcodeblocks.0.dylib
install_name_tool -id @executable_path/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/libwx_macu-2.8.0.dylib
install_name_tool -id @executable_path/libwxsmithlib.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/libwxsmithlib.0.dylib
install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/CodeBlocks
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/CodeBlocks
install_name_tool -change /usr/local/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/CodeBlocks
install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/codesnippets
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/codesnippets
install_name_tool -change /usr/local/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/codesnippets
install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/cb_share_config
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/cb_share_config
install_name_tool -change /usr/local/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/cb_share_config
install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/cb_console_runner
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/cb_console_runner
install_name_tool -change /usr/local/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/cb_console_runner
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/libcodeblocks.0.dylib
install_name_tool -change /usr/local/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/libcodeblocks.0.dylib
install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/libwxsmithlib.0.dylib
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib ./CodeBlocksSVN.app/Contents/MacOS/libwxsmithlib.0.dylib
echo ===== Finished install_name_tool stuff =====
cp -R /usr/local/share/codeblocks/ ./CodeBlocksSVN.app/Contents/Resources/share/codeblocks
cp -R /usr/local/lib/codeblocks/ ./CodeBlocksSVN.app/Contents/Resources/share/codeblocks
for dotso in ./CodeBlocksSVN.app/Contents/Resources/share/codeblocks/plugins/*.so
do
#echo $dotso
install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib $dotso
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib $dotso
install_name_tool -change /usr/local/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib $dotso
done