]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/docs/Building.md
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / docs / Building.md
CommitLineData
7c673cae
FG
1Building CivetWeb
2=========
3
4This guide covers the build instructions for the stand-alone web server.
5See [Embedding.md](https://github.com/civetweb/civetweb/blob/master/docs/Embedding.md) for information on extending an existing C or C++ application. A brief overview of the source code files can be found in [Embedding.md](https://github.com/civetweb/civetweb/blob/master/docs/Embedding.md) as well.
6
7#### Where to get the source code?
8
9The latest version can be found at
10https://github.com/civetweb/civetweb
11
12Released versions can be found at
13https://github.com/civetweb/civetweb/releases
14
15
16Building for Windows
17---------
18
19#### Using Visual Studio
20
21Open the *VS/civetweb.sln* in Visual Studio.
22To include SSL support, you may have to add an extra library for the cryptography support. You might wish to use yaSSL. However, it is GPL licensed or uses a commercial license. See [yaSSL.md](https://github.com/civetweb/civetweb/blob/master/docs/yaSSL.md) for more information.
23Alternatively, you might wish to use OpenSSL. See [OpenSSL.md](https://github.com/civetweb/civetweb/blob/master/docs/OpenSSL.md) for more information.
24
25#### Using MinGW-w64 or TDM-GCC
26In the start menu locate and run the "Run terminal" batch file. For TDM-GCC this is named "MinGW Command Prompt".
27Navigate to the civetweb sources directory and run:
28```
29mingw32-make CC=gcc
30```
31
32#### Using Qt Creator
33Open the Qt Designer project in the Qt folder
34
35#### Using CMake
36Except for the components in the `third_party` folder (e.g., Lua and Duktape), CivetWeb can also be built with CMake.
37CMake can be used for all supported operating systems.
38
39
40Building for Linux, BSD, and OSX
41---------
42
43## Using Make
44
45```
46make help
47```
48Get a list of all supported make option
49
50```
51make build
52```
53compile the code
54
55```
56make install
57```
58Install on the system, Linux only.
59
60```
61make lib WITH_CPP=1 WITH_IPV6=1
62make clean slib WITH_CPP=1 WITH_LUA=1 WITH_WEBSOCKET=1
63```
64Build the static and shared libraries.
65The *WITH_CPP* make option is to include the CivetServer class.
66The additional make options configure the library just as it would the application.
67
68The *slib* option should be done on a separate clean build as position
69independent code (PIC) is required for it. Trying to run it after
70building the static library or the server will result in a link error.
71
72```
73make clean
74```
75Clean up files generated during the build
76
77## Setting build options
78
79Make options can be set on the command line with the make command like so.
80```
81make build WITH_LUA=1
82```
83
84
11fdf7f2
TL
85| Make Options | Description |
86| ------------------------- | ----------------------------------------- |
87| WITH_LUA=1 | build with Lua support |
88| WITH_DUKTAPE=1 | build with server-side JavaScript support |
89| WITH_DEBUG=1 | build with GDB debug support |
90| WITH_IPV6=1 | with IPV6 support |
91| WITH_WEBSOCKET=1 | build with web socket support |
92| WITH_SERVER_STATS=1 | build with support for server statistics |
93| WITH_CPP=1 | build libraries with c++ classes |
94| CONFIG_FILE=file | use 'file' as the config file |
95| CONFIG_FILE2=file | use 'file' as the backup config file |
96| HTMLDIR=/path | place to install initial web pages |
97| DOCUMENT_ROOT=/path | HTMLDIR override, config option, install |
98| | nothing is installed here. |
99| PORTS=8080 | listening ports override when installing |
100| SSL_LIB=libssl.so.0 | use versioned SSL library |
101| CRYPTO_LIB=libcrypto.so.0 | system versioned CRYPTO library |
102| PREFIX=/usr/local | sets the install directory |
103| COPT='-DNO_SSL' | method to insert compile flags |
7c673cae
FG
104
105Note that the WITH_* options used for *make* are not identical to the
106preprocessor defines in the source code - usually USE_* is used there.
107
11fdf7f2
TL
108## Changing PREFIX
109
110To change the target destination pass the `PREFIX` option to the command `make install` (not `make build`). Example usage:
111
112```
113$ make build
114$ make -n install PREFIX=/opt/civetweb
115```
116Note: The `-n` corresponds to the `--dry-run` option (it does not make any changes): You can see where `make install` would install. Example output of the above command:
117
118```
119$ make -n install PREFIX=/opt/civetweb
120install -d -m 755 "/opt/civetweb/share/doc/civetweb"
121install -m 644 resources/itworks.html /opt/civetweb/share/doc/civetweb/index.html
122install -m 644 resources/civetweb_64x64.png /opt/civetweb/share/doc/civetweb/
123install -d -m 755 "/opt/civetweb/etc"
124install -m 644 resources/civetweb.conf "/opt/civetweb/etc/"
125sed -i 's#^document_root.*$#document_root /opt/civetweb/share/doc/civetweb#' "/opt/civetweb/etc/civetweb.conf"
126sed -i 's#^listening_ports.*$#listening_ports 8080#' "/opt/civetweb/etc/civetweb.conf"
127install -d -m 755 "/opt/civetweb/share/doc/civetweb"
128install -m 644 *.md "/opt/civetweb/share/doc/civetweb"
129install -d -m 755 "/opt/civetweb/bin"
130install -m 755 civetweb "/opt/civetweb/bin/"
131```
132
133If the output looks good: Just remove the `-n` option to actually install the software on your system.
134
7c673cae
FG
135## Setting compile flags
136
137Compile flags can be set using the *COPT* make option like so.
138```
139make build COPT="-DNDEBUG -DNO_CGI"
140```
141
142| Compile Flags | Description |
143| ------------------------- | ------------------------------------ |
144| NDEBUG | strip off all debug code |
145| DEBUG | build debug version (very noisy) |
146| NO_CGI | disable CGI support |
147| NO_CACHING | disable caching functionality |
148| NO_SSL | disable SSL functionality |
149| NO_SSL_DL | link against system libssl library |
150| NO_FILES | do not serve files from a directory |
151| SQLITE_DISABLE_LFS | disables large files (Lua only) |
152| SSL_ALREADY_INITIALIZED | do not initialize libcrypto |
153
154## Cross Compiling
155
156Take total control with *CC*, *COPT* and *TARGET_OS* as make options.
157TARGET_OS is used to determine some compile details as will as code function.
158TARGET_OS values should be be one found in *resources/Makefile.in-os*.
159
160```
161make CC=arm-none-linux-gnueabi-gcc COPT="-march=armv7-a -mfpu=vfp -mfloat-abi=softfp" TARGET_OS=FROG
162```
163
164## Cocoa DMG Packaging (OSX Only)
165
166Use the alternate *Makefile.osx* to do the build. The entire build has
167to be done using *Makefile.osx* because additional compile and link options
168are required. This Makefile has all the same options as the other one plus
169one additional *package* rule.
170
171```
172make -f Makefile.osx package
173```
174
175Building with Buildroot
176---------
177
178[Buildroot](http://buildroot.uclibc.org/) is a tool for creating cross compiled file systems. Including Civetweb in buildroot is fairly easy. There is even support for various build options.
179
1801. First, check if it already there.
181 - In buildroot, make menuconfig
182 - Package Selection for the target --->
183 - Networking applications --->
184 - civetweb
1852. If not there, just add it
186 - copy *Config.in* and *civetweb.mk* from Civetweb's *contrib/buildroot/* to Buildroot's *package/civetweb/* directory.
187 - In Buildroot's *package/Config.in, insert the following line in were you will know how to find it in the menu.
188 > ``` source "package/civetweb/Config.in" ```
189
190
191Building on Android
192---------
193
11fdf7f2
TL
194This is a small guide to help you run civetweb on Android, originally
195tested on the HTC Wildfire.
7c673cae
FG
196Note: You do not need root access to run civetweb on Android.
197
198- Download the source from the Downloads page.
199- Download the Android NDK from [http://developer.android.com/tools/sdk/ndk/index.html](http://developer.android.com/tools/sdk/ndk/index.html)
200- Run `/path-to-ndk/ndk-build -C /path-to-civetweb/resources`
201 That should generate civetweb/lib/armeabi/civetweb
202- Using the adb tool (you need to have Android SDK installed for that),
203 push the generated civetweb binary to `/data/local` folder on device.
204- From adb shell, navigate to `/data/local` and execute `./civetweb`.
205- To test if the server is running fine, visit your web-browser and
206 navigate to `http://127.0.0.1:8080` You should see the `Index of /` page.
207
7c673cae
FG
208
209Notes:
210
211- `jni` stands for Java Native Interface. Read up on Android NDK if you want
212 to know how to interact with the native C functions of civetweb in Android
213 Java applications.
11fdf7f2 214
7c673cae
FG
215
216