Initial commit
[yaffs-website] / node_modules / node-sass / src / libsass / docs / build-with-mingw.md
1 ## Building LibSass with MingGW (makefiles)
2
3 First grab the latest [MinGW for windows] [1] installer. Once it is installed, you can click on continue or open the Installation Manager via `bin\mingw-get.exe`.
4
5 You need to have the following components installed:
6 ![](https://cloud.githubusercontent.com/assets/282293/5525466/947bf396-89e6-11e4-841d-4aa916f14de1.png)
7
8 Next we need to install [git for windows] [2]. You probably want to check the option to add it to the global path, but you do not need to install the unix tools.
9
10 If you want to run the spec test-suite you also need [ruby] [3] and a few gems available. Grab the [latest installer] [3] and make sure to add it the global path. Then install the missing gems:
11
12 ```bash
13 gem install minitest
14 ```
15
16 ### Mount the mingw root directory
17
18 As mentioned in the [MinGW Getting Started](http://www.mingw.org/wiki/Getting_Started#toc5) guide, you should edit `C:\MinGW\msys\1.0\etc\fstab` to contain the following line:
19
20 ```
21 C:\MinGW   /mingw
22 ```
23
24 ### Starting a "MingGW" console
25
26 Create a batch file with this content:
27 ```bat
28 @echo off
29 set PATH=C:\MinGW\bin;%PATH%
30 REM only needed if not already available
31 set PATH=%PROGRAMFILES%\git\bin;%PATH%
32 REM C:\MinGW\msys\1.0\msys.bat
33 cmd
34 ```
35
36 Execute it and make sure these commands can be called: `git`, `mingw32-make`, `rm` and `gcc`! Once this is all set, you should be ready to compile `libsass`!
37
38 ### Get the sources
39
40 ```bash
41 # using git is preferred
42 git clone https://github.com/sass/libsass.git
43 # only needed for sassc and/or testsuite
44 git clone https://github.com/sass/sassc.git libsass/sassc
45 git clone https://github.com/sass/sass-spec.git libsass/sass-spec
46 ```
47
48 ### Decide for static or shared library
49
50 `libsass` can be built and linked as a `static` or as a `shared` library. The default is `static`. To change it you can set the `BUILD` environment variable:
51
52 ```bat
53 set BUILD="shared"
54 ```
55
56 ### Compile the library
57 ```bash
58 mingw32-make -C libsass
59 ```
60
61 ### Results can be found in
62 ```bash
63 $ ls libsass/lib
64 libsass.a  libsass.dll  libsass.so
65 ```
66
67 ### Run the spec test-suite
68 ```bash
69 mingw32-make -C libsass test_build
70 ```
71
72 ## Building via MingGW 64bit (makefiles)
73 Building libass to dll on window 64bit.
74
75 Download [MinGW64 for windows7 64bit](http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z/download) and unzip to "C:\mingw64".
76
77 Create a batch file with this content:
78
79 ```bat
80 @echo off
81 set PATH=C:\mingw64\bin;%PATH%
82 set CC=gcc
83 REM only needed if not already available
84 set PATH=%PROGRAMFILES%\Git\bin;%PATH%
85 REM C:\MinGW\msys\1.0\msys.bat
86 cmd
87 ```
88
89 By default, mingw64 dll will depends on "​m​i​n​g​w​m​1​0​.​d​l​l​、​ ​l​i​b​g​c​c​_​s​_​d​w​2​-​1​.​d​l​l​", we can modify Makefile to fix this:(add "-static")
90
91 ``` bash
92 lib/libsass.dll: $(COBJECTS) $(OBJECTS) $(RCOBJECTS)
93         $(MKDIR) lib
94         $(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(RCOBJECTS) $(LDLIBS) -s -static -Wl,--subsystem,windows,--out-implib,lib/libsass.a
95 ```
96
97 Compile the library
98
99 ```bash
100 mingw32-make -C libsass
101 ```
102
103 By the way, if you are using java jna, [JNAerator](http://jnaerator.googlecode.com/) is a good tool.
104
105 [1]: http://sourceforge.net/projects/mingw/files/latest/download?source=files
106 [2]: https://msysgit.github.io/
107 [3]: http://rubyinstaller.org/