Optimize build for example
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>main
parent
c38a36ec19
commit
c9252d78e4
|
@ -7,3 +7,4 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
|||
#set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(example)
|
||||
|
|
20
README.md
20
README.md
|
@ -41,22 +41,11 @@ See which configuration are supported
|
|||
# Build and install
|
||||
|
||||
~/libuhttpd/build$ make && sudo make install
|
||||
|
||||
# Build Example
|
||||
|
||||
~/libuhttpd/build$ cd ../example
|
||||
~/libuhttpd/example$ mkdir build && cd build
|
||||
~/libuhttpd/example/build$ cmake .. && make
|
||||
|
||||
# Run Example
|
||||
First generate the SSL certificate file
|
||||
|
||||
~/libuhttpd/example/build$ cd ..
|
||||
~/libuhttpd/example$ ./gen_cert.sh
|
||||
|
||||
# Run Example
|
||||
Run
|
||||
|
||||
~/libuhttpd/example$ ./build/helloworld
|
||||
~/libuhttpd/build$ ./example/helloworld
|
||||
|
||||
Then use the command curl or browser to test
|
||||
|
||||
|
@ -85,6 +74,8 @@ Select package libuhttpd in menuconfig and compile new image.
|
|||
```
|
||||
#include <uhttpd.h>
|
||||
|
||||
//#define EXAMPLE_SSL
|
||||
|
||||
#define port "8000"
|
||||
|
||||
static void hello_action(struct uh_client *cl)
|
||||
|
@ -118,11 +109,12 @@ int main(int argc, char **argv)
|
|||
|
||||
uh_log_debug("Listen on: *:%s", port);
|
||||
|
||||
#ifdef EXAMPLE_SSL
|
||||
#if (UHTTPD_SSL_SUPPORT)
|
||||
if (srv->ssl_init(srv, "server-key.pem", "server-cert.pem") < 0)
|
||||
goto done;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
srv->add_action(srv, "/hello", hello_action);
|
||||
|
||||
uloop_run();
|
||||
|
|
18
README_ZH.md
18
README_ZH.md
|
@ -43,21 +43,10 @@
|
|||
|
||||
~/libuhttpd/build$ make && sudo make install
|
||||
|
||||
# 编译示例程序
|
||||
|
||||
~/libuhttpd/build$ cd ../example
|
||||
~/libuhttpd/example$ mkdir build && cd build
|
||||
~/libuhttpd/example/build$ cmake .. && make
|
||||
|
||||
# 运行示例程序
|
||||
首先生成SSL证书文件
|
||||
|
||||
~/libuhttpd/example/build$ cd ..
|
||||
~/libuhttpd/example$ ./gen_cert.sh
|
||||
|
||||
运行
|
||||
|
||||
~/libuhttpd/example$ ./build/helloworld
|
||||
~/libuhttpd/build$ ./example/helloworld
|
||||
|
||||
然后使用命令curl或者浏览器进行测试
|
||||
|
||||
|
@ -86,6 +75,8 @@ Select package libuhttpd in menuconfig and compile new image.
|
|||
```
|
||||
#include <uhttpd.h>
|
||||
|
||||
//#define EXAMPLE_SSL
|
||||
|
||||
#define port "8000"
|
||||
|
||||
static void hello_action(struct uh_client *cl)
|
||||
|
@ -119,11 +110,12 @@ int main(int argc, char **argv)
|
|||
|
||||
uh_log_debug("Listen on: *:%s", port);
|
||||
|
||||
#ifdef EXAMPLE_SSL
|
||||
#if (UHTTPD_SSL_SUPPORT)
|
||||
if (srv->ssl_init(srv, "server-key.pem", "server-cert.pem") < 0)
|
||||
goto done;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
srv->add_action(srv, "/hello", hello_action);
|
||||
|
||||
uloop_run();
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(libuhttpd-example C)
|
||||
|
||||
#set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake/Modules/")
|
||||
|
||||
add_definitions(-O -Wall -Werror --std=gnu99 -D_GNU_SOURCE -Wno-misleading-indentation)
|
||||
|
||||
find_package(Libuhttpd REQUIRED)
|
||||
find_package(Libubox REQUIRED)
|
||||
|
||||
include_directories(${LIBUHTTPD_INCLUDE_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src)
|
||||
|
||||
add_executable(helloworld helloworld.c)
|
||||
target_link_libraries(helloworld ${LIBUHTTPD_LIBRARY} ${LIBUBOX_LIBRARY})
|
||||
target_link_libraries(helloworld uhttpd ${LIBUBOX_LIBRARY})
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <uhttpd/uhttpd.h>
|
||||
#include <uhttpd.h>
|
||||
|
||||
//#define EXAMPLE_SSL
|
||||
|
||||
#define port "8000"
|
||||
|
||||
|
@ -51,9 +53,11 @@ int main(int argc, char **argv)
|
|||
|
||||
uh_log_debug("Listen on: *:%s", port);
|
||||
|
||||
#ifdef EXAMPLE_SSL
|
||||
#if (UHTTPD_SSL_SUPPORT)
|
||||
if (srv->ssl_init(srv, "/etc/wifidog/wifidog.key", "/etc/wifidog/wifidog.crt") < 0)
|
||||
goto done;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
srv->add_action(srv, "/hello", hello_action);
|
||||
|
|
Loading…
Reference in New Issue