]> git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/docs/Building.md
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / civetweb / docs / Building.md
1 Building CivetWeb
2 =========
3
4 This guide covers the build instructions for the stand-alone web server.
5 See [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
9 The latest version can be found at
10 https://github.com/civetweb/civetweb
11
12 Released versions can be found at
13 https://github.com/civetweb/civetweb/releases
14
15
16 Building for Windows
17 ---------
18
19 #### Using Visual Studio
20
21 Open the *VS/civetweb.sln* in Visual Studio.
22 To 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.
23 Alternatively, 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
26 In the start menu locate and run the "Run terminal" batch file. For TDM-GCC this is named "MinGW Command Prompt".
27 Navigate to the civetweb sources directory and run:
28 ```
29 mingw32-make CC=gcc
30 ```
31
32 #### Using Qt Creator
33 Open the Qt Designer project in the Qt folder
34
35 #### Using CMake
36 Except for the components in the `third_party` folder (e.g., Lua and Duktape), CivetWeb can also be built with CMake.
37 CMake can be used for all supported operating systems.
38
39
40 Building for Linux, BSD, and OSX
41 ---------
42
43 ## Using Make
44
45 ```
46 make help
47 ```
48 Get a list of all supported make option
49
50 ```
51 make build
52 ```
53 compile the code
54
55 ```
56 make install
57 ```
58 Install on the system, Linux only.
59
60 ```
61 make lib WITH_CPP=1 WITH_IPV6=1
62 make clean slib WITH_CPP=1 WITH_LUA=1 WITH_WEBSOCKET=1
63 ```
64 Build the static and shared libraries.
65 The *WITH_CPP* make option is to include the CivetServer class.
66 The additional make options configure the library just as it would the application.
67
68 The *slib* option should be done on a separate clean build as position
69 independent code (PIC) is required for it. Trying to run it after
70 building the static library or the server will result in a link error.
71
72 ```
73 make clean
74 ```
75 Clean up files generated during the build
76
77 ## Setting build options
78
79 Make options can be set on the command line with the make command like so.
80 ```
81 make build WITH_LUA=1
82 ```
83
84
85 | Make Options | Description |
86 | ------------------------- | ---------------------------------------- |
87 | WITH_LUA=1 | build with Lua support |
88 | WITH_DEBUG=1 | build with GDB debug support |
89 | WITH_IPV6=1 | with IPV6 support |
90 | WITH_WEBSOCKET=1 | build with web socket support |
91 | WITH_CPP=1 | build libraries with c++ classes |
92 | CONFIG_FILE=file | use 'file' as the config file |
93 | CONFIG_FILE2=file | use 'file' as the backup config file |
94 | HTMLDIR=/path | place to install initial web pages |
95 | DOCUMENT_ROOT=/path | HTMLDIR override, config option, install |
96 | | nothing is installed here. |
97 | PORTS=8080 | listening ports override when installing |
98 | SSL_LIB=libssl.so.0 | use versioned SSL library |
99 | CRYPTO_LIB=libcrypto.so.0 | system versioned CRYPTO library |
100 | PREFIX=/usr/local | sets the install directory |
101 | COPT='-DNO_SSL' | method to insert compile flags |
102
103 Note that the WITH_* options used for *make* are not identical to the
104 preprocessor defines in the source code - usually USE_* is used there.
105
106 ## Setting compile flags
107
108 Compile flags can be set using the *COPT* make option like so.
109 ```
110 make build COPT="-DNDEBUG -DNO_CGI"
111 ```
112
113 | Compile Flags | Description |
114 | ------------------------- | ------------------------------------ |
115 | NDEBUG | strip off all debug code |
116 | DEBUG | build debug version (very noisy) |
117 | NO_CGI | disable CGI support |
118 | NO_CACHING | disable caching functionality |
119 | NO_SSL | disable SSL functionality |
120 | NO_SSL_DL | link against system libssl library |
121 | NO_FILES | do not serve files from a directory |
122 | SQLITE_DISABLE_LFS | disables large files (Lua only) |
123 | SSL_ALREADY_INITIALIZED | do not initialize libcrypto |
124
125 ## Cross Compiling
126
127 Take total control with *CC*, *COPT* and *TARGET_OS* as make options.
128 TARGET_OS is used to determine some compile details as will as code function.
129 TARGET_OS values should be be one found in *resources/Makefile.in-os*.
130
131 ```
132 make CC=arm-none-linux-gnueabi-gcc COPT="-march=armv7-a -mfpu=vfp -mfloat-abi=softfp" TARGET_OS=FROG
133 ```
134
135 ## Cocoa DMG Packaging (OSX Only)
136
137 Use the alternate *Makefile.osx* to do the build. The entire build has
138 to be done using *Makefile.osx* because additional compile and link options
139 are required. This Makefile has all the same options as the other one plus
140 one additional *package* rule.
141
142 ```
143 make -f Makefile.osx package
144 ```
145
146 Building with Buildroot
147 ---------
148
149 [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.
150
151 1. First, check if it already there.
152 - In buildroot, make menuconfig
153 - Package Selection for the target --->
154 - Networking applications --->
155 - civetweb
156 2. If not there, just add it
157 - copy *Config.in* and *civetweb.mk* from Civetweb's *contrib/buildroot/* to Buildroot's *package/civetweb/* directory.
158 - In Buildroot's *package/Config.in, insert the following line in were you will know how to find it in the menu.
159 > ``` source "package/civetweb/Config.in" ```
160
161
162 Building on Android
163 ---------
164
165 This is a small guide to help you run civetweb on Android. Currently it is
166 tested on the HTC Wildfire. If you have managed to run it on other devices
167 as well, please comment or drop an email in the mailing list.
168 Note: You do not need root access to run civetweb on Android.
169
170 - Download the source from the Downloads page.
171 - Download the Android NDK from [http://developer.android.com/tools/sdk/ndk/index.html](http://developer.android.com/tools/sdk/ndk/index.html)
172 - Run `/path-to-ndk/ndk-build -C /path-to-civetweb/resources`
173 That should generate civetweb/lib/armeabi/civetweb
174 - Using the adb tool (you need to have Android SDK installed for that),
175 push the generated civetweb binary to `/data/local` folder on device.
176 - From adb shell, navigate to `/data/local` and execute `./civetweb`.
177 - To test if the server is running fine, visit your web-browser and
178 navigate to `http://127.0.0.1:8080` You should see the `Index of /` page.
179
180 ![screenshot](https://a248.e.akamai.net/camo.github.com/b88428bf009a2b6141000937ab684e04cc8586af/687474703a2f2f692e696d6775722e636f6d2f62676f6b702e706e67)
181
182
183 Notes:
184
185 - `jni` stands for Java Native Interface. Read up on Android NDK if you want
186 to know how to interact with the native C functions of civetweb in Android
187 Java applications.
188 - TODO: A Java application that interacts with the native binary or a
189 shared library.
190
191