Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #7 from Follpvosten/freebsd
Browse files Browse the repository at this point in the history
Make framebot build on FreeBSD
  • Loading branch information
h4child committed May 16, 2018
2 parents df1ac6b + 3d96919 commit d049784
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 25 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This is the official repository for Framebot.

## Building from source

### Ubuntu/Debian
First you need to install the dependencies

```
Expand All @@ -23,6 +24,29 @@ make
make install
```

### FreeBSD
The required packages can be installed using either ports:

```
make -C /usr/ports/{cmake,jansson,openssl,curl} install clean
```

Or binary packages:

```
pkg install cmake jansson openssl curl
```

After that, cd into the framebot repository continue the same way as above:

```
mkdir build
cd build
cmake ..
make
make install
```

## Usage

See our [Examples](examples/) folder.
Expand Down
15 changes: 13 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ project(ExampleBots)

include_directories (${PROJECT_SOURCE_DIR}/../include)

add_definitions("-g")
add_definitions("-g")

set(OS_FREEBSD CMAKE_SYSTEM_NAME STREQUAL FreeBSD)

if(${OS_FREEBSD})
# Add /usr/local/lib so we can find the libs on FreeBSD
link_directories(/usr/local/lib /usr/lib /lib)
endif()

add_executable(echo echo.c)
target_link_libraries(echo jansson libcurl.so framebot)

add_executable(inline inline_bot.c)
target_link_libraries(inline jansson libcurl.so framebot)
target_link_libraries(inline jansson libcurl.so framebot)

if(${OS_FREEBSD})
target_compile_options(echo PUBLIC -I/usr/local/include)
target_compile_options(inline PUBLIC -I/usr/local/include)
endif()
4 changes: 2 additions & 2 deletions include/framebot/framebot.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@
#include <errno.h>


#ifdef __linux__
#if defined __linux__ || defined __FreeBSD__
#include <unistd.h>
#include <sys/stat.h>
#include <time.h>
#elif _WIN32
#include <Windows.h>
#include <io.h>
#else
# error "Only windows or Linux"
# error "Only Windows, Linux and FreeBSD are supported at the moment."
#endif

#include <limits.h>
Expand Down
25 changes: 15 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
cmake_minimum_required (VERSION 3.7)
project(framebotLibrary)

FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

include_directories (${PROJECT_SOURCE_DIR}/../include)

add_definitions("-g")
add_definitions("-g")

set(OS_LINUX CMAKE_SYSTEM_NAME STREQUAL Linux)
set(OS_FREEBSD CMAKE_SYSTEM_NAME STREQUAL FreeBSD)

if(${OS_LINUX} OR ${OS_FREEBSD})
if(${OS_FREEBSD})
# Add /usr/local/lib so we can find the libs on FreeBSD
link_directories(/usr/local/lib /usr/lib /lib)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
add_library(framebot_ SHARED framebot.c memory.c objects.c json.c network.c format.c util.c)
target_link_libraries(framebot_ jansson libcurl.so)

add_library(framebot STATIC framebot.c memory.c objects.c json.c network.c format.c util.c)
target_link_libraries(framebot jansson libcurl.so)

if(${OS_FREEBSD})
# The default FreeBSD include path
target_compile_options(framebot_ PUBLIC -I/usr/local/include)
target_compile_options(framebot PUBLIC -I/usr/local/include)
endif()

install(TARGETS framebot_ LIBRARY DESTINATION lib)
install(TARGETS framebot ARCHIVE DESTINATION lib)

Expand Down
36 changes: 25 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
cmake_minimum_required (VERSION 3.7)
project(framebotTest)

FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

include_directories (${PROJECT_SOURCE_DIR}/../include)

add_definitions("-g")

set(OS_LINUX CMAKE_SYSTEM_NAME STREQUAL Linux)
set(OS_FREEBSD CMAKE_SYSTEM_NAME STREQUAL FreeBSD)

if(${OS_FREEBSD})
# Add /usr/local/lib so we can find the libs on FreeBSD
link_directories(/usr/local/lib /usr/lib /lib)
endif()

add_executable(methods_chat test_chat.c)
add_executable(update test_update.c)
add_executable(file test_file.c)
Expand All @@ -26,7 +25,22 @@ add_executable(sendvoice test_sendvoice.c)
add_executable(sendvideonote test_sendvideonote.c)
add_executable(sendmessage test_sendmessage.c)

if (CMAKE_SYSTEM_NAME STREQUAL Linux)
if(${OS_FREEBSD})
# The default FreeBSD include path
target_compile_options(methods_chat PUBLIC -I/usr/local/include)
target_compile_options(update PUBLIC -I/usr/local/include)
target_compile_options(file PUBLIC -I/usr/local/include)
target_compile_options(userprofilephotos PUBLIC -I/usr/local/include)
target_compile_options(sendphotos PUBLIC -I/usr/local/include)
target_compile_options(sendaudio PUBLIC -I/usr/local/include)
target_compile_options(senddocument PUBLIC -I/usr/local/include)
target_compile_options(sendvideo PUBLIC -I/usr/local/include)
target_compile_options(sendvoice PUBLIC -I/usr/local/include)
target_compile_options(sendvideonote PUBLIC -I/usr/local/include)
target_compile_options(sendmessage PUBLIC -I/usr/local/include)
endif()

if (${OS_LINUX} OR ${OS_FREEBSD})
target_link_libraries(methods_chat jansson libcurl.so framebot)
target_link_libraries(update jansson libcurl.so framebot)
target_link_libraries(file jansson libcurl.so framebot)
Expand All @@ -38,7 +52,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL Linux)
target_link_libraries(sendvoice jansson libcurl.so framebot)
target_link_libraries(sendvideonote jansson libcurl.so framebot)
target_link_libraries(sendmessage jansson libcurl.so framebot)
endif (CMAKE_SYSTEM_NAME STREQUAL Linux)
endif ()

if (WIN32)
target_link_libraries(methods_chat jansson libcurl_a framebot)
Expand Down

0 comments on commit d049784

Please sign in to comment.