Skip to content

Commit 5c06ced

Browse files
committed
Merge pull request #212 from anthonygego/master
Improved package distribution and Windows compilation process
2 parents 4b0d043 + 0410de8 commit 5c06ced

File tree

29 files changed

+529
-62
lines changed

29 files changed

+529
-62
lines changed

CMakeLists.txt

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,36 @@ set(MOZART_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
1212
set(MOZART_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}")
1313

1414
# Some helpers when using MinGW
15-
1615
if(MINGW)
1716
get_filename_component(CMAKE_MAKE_PROGRAM_PATH "${CMAKE_MAKE_PROGRAM}" PATH)
1817
get_filename_component(CMAKE_MAKE_PROGRAM_PATH_PARENT "${CMAKE_MAKE_PROGRAM_PATH}" PATH)
1918

2019
set(MINGW_ROOT "${CMAKE_MAKE_PROGRAM_PATH_PARENT}"
2120
CACHE PATH "Path where MinGW is installed")
22-
set(MINGW_COMPILER_VERSION "4.7.2"
21+
set(MINGW_COMPILER_VERSION "4.9.1"
2322
CACHE STRING "Version of GCC in your MinGW installation")
2423

2524
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format -Wno-format-extra-args")
26-
set(CMAKE_CXX_STANDARD_LIBRARIES "-lwsock32 -lws2_32 ${CMAKE_CSS_STANDARD_LIBRARIES}")
27-
set(DEFAULT_MOZART_GENERATOR_FLAGS
28-
"-I${MINGW_ROOT}/include/c++/${MINGW_COMPILER_VERSION}"
29-
"-I${MINGW_ROOT}/include/c++/${MINGW_COMPILER_VERSION}/i686-pc-mingw32")
25+
set(CMAKE_CXX_STANDARD_LIBRARIES "-static -lwsock32 -lws2_32 ${CMAKE_CSS_STANDARD_LIBRARIES}")
26+
27+
# Check for gcc target architecture
28+
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE GCC_ARCH)
29+
string(STRIP "${GCC_ARCH}" GCC_ARCH_TRIPLE)
30+
message(STATUS "Target architecture : ${GCC_ARCH_TRIPLE}")
3031

32+
set(DEFAULT_MOZART_GENERATOR_FLAGS
33+
"-I${MINGW_ROOT}/${GCC_ARCH_TRIPLE}/include/c++"
34+
"-I${MINGW_ROOT}/${GCC_ARCH_TRIPLE}/include/c++/${GCC_ARCH_TRIPLE}"
35+
"-I${MINGW_ROOT}/${GCC_ARCH_TRIPLE}/include")
36+
3137
set(BOOST_ROOT "${MINGW_ROOT}"
3238
CACHE PATH "Path where Boost is installed")
39+
40+
# Configuration for resources files
41+
set(CMAKE_RC_COMPILER_INIT windres)
42+
enable_language(RC)
43+
set(CMAKE_RC_COMPILE_OBJECT
44+
"<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
3345
else()
3446
set(DEFAULT_MOZART_GENERATOR_FLAGS "")
3547
endif()
@@ -52,6 +64,11 @@ add_subdirectory(wish)
5264
add_subdirectory(stdlib)
5365
add_subdirectory(platform-test)
5466

67+
# Add launcher and icons
68+
if(UNIX)
69+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/distrib/share/" DESTINATION share)
70+
endif()
71+
5572
# General CPack configuration
5673

5774
string(TOLOWER "${CMAKE_SYSTEM_NAME}" MOZART_SYSTEM_NAME)
@@ -86,6 +103,46 @@ string(REGEX REPLACE "-(alpha|beta|rc)\\." "~\\1"
86103
CPACK_DEBIAN_PACKAGE_VERSION "${MOZART_PROP_OZ_VERSION}")
87104
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
88105
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
106+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "tcl8.5, tk8.5, emacs")
107+
108+
# Configuration of the RPM generator
109+
110+
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${MOZART_PROP_PLATFORM_ARCH}")
111+
set(CPACK_RPM_PACKAGE_REQUIRES "tcl >= 8.5, tk >= 8.5, emacs")
112+
set(CPACK_RPM_PACKAGE_GROUP "Development/Languages")
113+
114+
# Configuration of Inno Setup files
115+
116+
if(WIN32)
117+
find_program(ISS_COMPILER NAMES iscc ISCC
118+
HINTS "C:/Program Files (x86)/Inno Setup 5" "C:/Program Files/Inno Setup 5")
119+
120+
if(NOT ISS_COMPILER)
121+
message(WARNING "Inno Setup Compiler not found. You won't be able to build setup files.")
122+
else()
123+
message(STATUS "Using Inno Setup Compiler from: ${ISS_COMPILER}")
124+
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/distrib/windows"
125+
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/distrib")
126+
127+
# Compute Tcl/Tk install path
128+
get_filename_component(ISS_TCL_EXEC_PARENT "${ISS_TCL_EXEC}" DIRECTORY)
129+
get_filename_component(ISS_TCL_PATH "${ISS_TCL_EXEC_PARENT}" DIRECTORY)
130+
131+
# Compute emacs install path
132+
get_filename_component(ISS_EMACS_EXEC_PARENT "${ISS_EMACS_EXEC}" DIRECTORY)
133+
get_filename_component(ISS_EMACS_PATH "${ISS_EMACS_EXEC_PARENT}" DIRECTORY)
134+
135+
# Parse Inno Setup config file
136+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/distrib/windows/MozartConfig.iss"
137+
"${CMAKE_CURRENT_BINARY_DIR}/distrib/windows/MozartConfig.iss")
138+
139+
# Add installer target
140+
add_custom_target(installer
141+
COMMAND ${CMAKE_MAKE_PROGRAM} install
142+
COMMAND ${ISS_COMPILER} "${CMAKE_CURRENT_BINARY_DIR}/distrib/windows/MozartSetup.iss"
143+
VERBATIM)
144+
endif()
145+
endif()
89146

90147
# Finally include CPack
91148
include(CPack)

README.Windows.md

Lines changed: 107 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,134 @@
11
# Windows-specific notes
22

33
General information can be found in the [main Readme](README.md). Unless
4-
othewise specified here, instructions found in the main Readme apply.
5-
6-
## Required software
4+
otherwise specified here, instructions found in the main Readme apply.
75

6+
## Global configuration
7+
### Development tools
88
Download and install the following tools:
99

10-
* TortoiseSVN and TortoiseGit
11-
* The [MinGW distro](http://nuwen.net/mingw.html) of nuwen.net,
12-
which includes a C++11 enabled GCC and Boost
10+
* Java (required for building the boot compiler)
11+
* Python (required for building LLVM)
12+
* Git for Windows
1313
* CMake >= 2.8.6
14-
* Emacs
15-
* [Active TCL](http://www.activestate.com/activetcl/downloads)
16-
_32 bits_ (even if you are running a 64-bit Windows), preferably v8.5
14+
* [Inno Setup](http://www.jrsoftware.org/isdl.php) (with preprocessor, required for building setup files)
15+
* A recent 32-bit (i686) or 64-bit (x86_64) targeting [MinGW-64 distro](http://mingw-w64.sourceforge.net/download.php#mingw-builds) with gcc >= 4.7.1.
1716

18-
We will refer to the installation directories of MinGW, CMake and Emacs by
19-
`<mingw>`, `<cmake>` and `<emacs>`, respectively.
17+
These tools won't be needed at run time. We will refer to the installation directory of MinGW (in which the first `bin` subdirectory is found) by `<mingw>`.
18+
All commands in this file are to be done in the MinGW terminal (shortcut available from the start menu).
2019

21-
Also, each time we mention "4.7.2", we are referring to the version of GCC
22-
that accompanies MinGW. Make sure to adapt this to your version.
20+
### Mozart requirements
21+
Download and install :
2322

24-
## Global configuration
23+
* Emacs for Windows
24+
* 32-bit or 64-bit (depending on MinGW) [Active Tcl](http://www.activestate.com/activetcl/downloads) or self-compiled Tcl/Tk >= 8.5
25+
26+
We will refer to the installation directory of Emacs and Tcl/Tk by `<emacs>` and `<tcl>`, respectively.
27+
28+
### Suggested directory layout
29+
30+
We suggest that you use the following directory layout, starting from a
31+
directory `<projects>` :
32+
33+
<projects>
34+
+ mozart2 // cloned from this repo
35+
+ externals
36+
+ boost // source of Boost (see below)
37+
+ gtest // source of GTest (see below)
38+
+ llvm // source of LLVM (see below)
39+
+ builds
40+
+ gtest // build of GTest
41+
+ llvm // build of LLVM
42+
+ mozart2 // build of Mozart
43+
+ redist // export dir of Mozart (see below)
44+
45+
Throughout the following instructions, we will assume this layout.
46+
47+
## Compilation of Boost
48+
1. Download [Boost **>= 1.53**](http://www.boost.org/users/download/) and extract the archive in `<projects>\externals\boost`.
49+
1. In your MinGW terminal, type (`<arch>` depends on building 32-bit or 64-bit target) :
50+
51+
C:> cd <projects>\externals\boost\tools\build\src\engine
52+
C:> build.bat mingw
53+
C:> cp bin.nt<arch>\*.* ..\..\..\..\
54+
C:> cd ..\..\..\..\
55+
C:> bjam --toolset=gcc
56+
57+
1. From `<projects>\externals\boost`, copy `boost` subdirectory in your `<mingw>\<arch>-w64-mingw32\include` directory and merge `stage\lib` subdirectory with your `<mingw>\<arch>-w64-mingw32\lib` directory.
58+
59+
## Compilation of GTest
60+
61+
1. Download [GTest](https://code.google.com/p/googletest/downloads/list) and extract the archive in `<projects>\externals\gtest`.
62+
1. In your MinGW terminal, type :
63+
64+
C:> cd <projects>\builds\gtest
65+
C:> cmake -G"MinGW Makefiles" ..\..\externals\gtest
66+
C:> mingw32-make
67+
68+
## Compilation of LLVM
69+
1. Download [LLVM and Clang **3.3**](http://llvm.org/releases/download.html#3.3) source code.
70+
1. Extract the content of LLVM source archive in `<projects>\externals\llvm` and the content of Clang source archive in `<projects>\externals\llvm\tools\clang`.
71+
1. If you are targeting 64-bit builds, patch the files `<projects>\externals\llvm\lib\ExecutionEngine\JIT\JIT.cpp` and `<projects>\externals\llvm\lib\ExecutionEngine\MCJIT\SectionMemoryManager.cpp` by replacing :
72+
73+
// Determine whether we can register EH tables.
74+
#if (defined(__GNUC__) && !defined(__ARM_EABI__) && \
75+
!defined(__USING_SJLJ_EXCEPTIONS__))
76+
#define HAVE_EHTABLE_SUPPORT 1
77+
#else
78+
#define HAVE_EHTABLE_SUPPORT 0
79+
#endif
80+
81+
by :
2582

26-
Put the following directories in your PATH:
83+
// Determine whether we can register EH tables.
84+
#if (defined(__GNUC__) && !defined(__ARM_EABI__) && \
85+
!(defined(__USING_SJLJ_EXCEPTIONS__) || defined(_WIN64)))
86+
#define HAVE_EHTABLE_SUPPORT 1
87+
#else
88+
#define HAVE_EHTABLE_SUPPORT 0
89+
#endif
2790

28-
* `<mingw>\bin`
29-
* `<cmake>\bin`
30-
* `<emacs>\bin`
31-
* `<projects>\builds\llvm-release\bin`
91+
1. In your MinGW terminal, type :
3292

33-
Patch the file `<mingw>\include\c++\4.7.2\i686-pc-mingw32\bits\c++config.h` by
34-
replacing
93+
C:> cd <projects>\builds\llvm
94+
C:> cmake -G"MinGW Makefiles" -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release ..\..\externals\llvm
95+
C:> mingw32-make
3596

36-
/* Define if __float128 is supported on this host. */
37-
#define _GLIBCXX_USE_FLOAT128 1
97+
## Compilation of Mozart 2
98+
1. In your MinGW terminal, type :
3899

39-
by
100+
C:> set PATH=%PATH%;<projects>\builds\llvm\bin;<emacs>\bin;<tcl>\bin
101+
C:> cd <projects>
102+
C:> git clone --recursive https://github.com/mozart/mozart2.git
103+
C:> cd <projects>\builds\mozart2
104+
C:> cmake -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_DIR=..\llvm -DGTEST_BUILD_DIR=..\gtest -DGTEST_SRC_DIR=..\..\externals\gtest -DLLVM_SRC_DIR=..\..\externals\llvm -DBOOST_ROOT=..\..\externals\boost\ -DCMAKE_INSTALL_PREFIX=..\..\redist\ ..\..\mozart2
105+
C:> mingw32-make
40106

41-
/* Define if __float128 is supported on this host. */
42-
#ifndef __clang__
43-
#define _GLIBCXX_USE_FLOAT128 1
44-
#endif
107+
If the script does not detect correctly where MinGW is installed, you can tell
108+
it using the option `-DMINGW_ROOT=<mingw>`. Similarly, if the version of GCC in
109+
your MinGW is not 4.9.1, you can tell it with
110+
`-DMINGW_COMPILER_VERSION=4.8.2`, e.g.
45111

46-
## GTest and LLVM
112+
1. To copy all the binaries in the `redist` folder, type :
47113

48-
Download them as specified in the main Readme.
114+
C:> mingw32-make install
49115

50-
Configure and build GTest:
116+
## Running Mozart 2
51117

52-
gtest-debug>cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=<mingw>/bin/make.exe -DCMAKE_BUILD_TYPE=Debug ../../externals/gtest
53-
gtest-debug>make
118+
For Mozart to run properly, you need to ensure :
54119

55-
Configure and build LLVM with:
120+
* Tcl/Tk is in your PATH or its `lib` and `bin` subfolders are merged with Mozart ones
121+
* An environment variable `OZEMACS` is set to `<emacs>\bin\runemacs.exe`
56122

57-
llvm-release>cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=<mingw>/bin/make.exe -DCMAKE_BUILD_TYPE=Release ../../externals/llvm
58-
llvm-release>make
123+
## Making Mozart 2 packages
59124

60-
## Configuration and build of Mozart2
125+
If you want to build setup files for Mozart, just type in your terminal :
61126

62-
The "build" version (not "installed") of Mozart2 is very tedious to run on
63-
Windows. We suggest that you always `make install` (we do that ourselves).
64-
You can use the configuration option `-DCMAKE_INSTALL_PREFIX=C:/Where/You/Want`
65-
of CMake to specify in which directory you want it to be installed.
127+
C:> mingw32-make installer
66128

67-
Configure and build Mozart with the following incantation. It might be
68-
necessary to open your command prompt with administrator privileges.
129+
The new setup file will be located in your build directory. Two more CMake options are then available :
69130

70-
mozart2-release>cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=<mingw>/bin/make.exe -DCMAKE_BUILD_TYPE=Release -DGTEST_SRC_DIR=../../externals/gtest -DGTEST_BUILD_DIR=../gtest-debug -DLLVM_SRC_DIR=../../externals/llvm -DLLVM_BUILD_DIR=../llvm-release ../../mozart2
71-
mozart2-release>make
72-
mozart2-release>make install
131+
* `-DISS_INCLUDE_EMACS=ON` will include your Emacs files in the package.
132+
* `-DISS_INCLUDE_TCL=ON` will include your Tcl/Tk files in the package.
73133

74-
If the script does not detect correctly where MinGW is installed, you can tell
75-
it using the option `-DMINGW_ROOT=<mingw>`. Similarly, if the version of GCC in
76-
your MinGW is not 4.7.2, you can tell it with
77-
`-DMINGW_COMPILER_VERSION=4.7.1`, e.g.
134+
Please note that ActiveTcl is not redistributable without an OEM license.

boosthost/emulator/emulator.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ int main(int argc, char** argv) {
162162
std::string ozSearchPath, ozSearchLoad, appURL;
163163
std::vector<std::string> appArgs;
164164
size_t minMemoryMega = 32;
165+
#if defined(_WIN32) && !defined(_WIN64)
166+
size_t maxMemoryMega = 512;
167+
#else
165168
size_t maxMemoryMega = 768;
169+
#endif
166170
bool appGUI;
167171

168172
// DEFINE OPTIONS
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Desktop Entry]
2+
Version=1.0
3+
Name=Mozart Programming System
4+
Exec=oz %u
5+
Terminal=false
6+
Type=Application
7+
Icon=oz
8+
Categories=Development;
9.05 KB
Loading
949 Bytes
Loading
14 KB
Loading
1.47 KB
Loading
1.58 KB
Loading
15.9 KB
Loading

0 commit comments

Comments
 (0)