diff options
| author | Beoran <[email protected]> | 2012-05-01 20:13:09 +0200 |
|---|---|---|
| committer | Jon <[email protected]> | 2012-05-22 09:11:13 -0400 |
| commit | b5dcb7128d7d235b66b4d9be879d26364dd1e3e9 (patch) | |
| tree | c58c7ccfa87d4cdd9c9f8a503356f5e2d142ea16 | |
| parent | abacbf667241ff4919b14007ef1a704f321de96d (diff) | |
| download | mruby-b5dcb7128d7d235b66b4d9be879d26364dd1e3e9.tar.gz mruby-b5dcb7128d7d235b66b4d9be879d26364dd1e3e9.zip | |
First cmake build system. Works on Linux.
| -rw-r--r-- | CMakeLists.txt | 124 | ||||
| -rw-r--r-- | INSTALL | 14 | ||||
| -rw-r--r-- | Makefile.orig (renamed from Makefile) | 0 | ||||
| -rw-r--r-- | build/.gitkeep | 0 | ||||
| -rw-r--r-- | mrblib/CMakeLists.txt | 35 | ||||
| -rw-r--r-- | mrblib/Makefile.orig (renamed from mrblib/Makefile) | 0 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 23 | ||||
| -rw-r--r-- | src/Makefile.orig (renamed from src/Makefile) | 0 | ||||
| -rw-r--r-- | tools/mrbc/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | tools/mrbc/Makefile.orig (renamed from tools/mrbc/Makefile) | 0 | ||||
| -rw-r--r-- | tools/mruby/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | tools/mruby/Makefile.orig (renamed from tools/mruby/Makefile) | 0 |
12 files changed, 205 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..752222db0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,124 @@ +# +# Cmake build system for muby by [email protected], 2012. +# Released under the same license as mruby. +# +# NOTE: the original Makefile build system had a few hacks in them, +# whch I didn't duplicate. In stead the build logic is like this: +# 1) First libritevm_object is built +# 2) From this libritevm_static.a is built. +# 2) Then mrbc is built and linked with libritevm_static.a . +# 4) Then libmrblib_object is builtfrom are built from the rb files in +# the mrblib subdirectory +# 5) Then libmrblib_object & libritevm_object are linked together into +# a single library libmrubylib_static.a +# 6) Finally, mruby is built and linked with libmrubylib_static.a +# +# As a result, applications that embed mruby will have to link against +# libmrubylib_static.a only.. +# +# TODO: make this work on windows too, support build options to generate +# mrbconf.h, etc... +# + +# Setup +# Need at least cmake version 2.8.8 +cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) +if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + cmake_policy(SET CMP0015 NEW) +endif(COMMAND cmake_policy) + +# Set the project name, we use only plain C. +project(MRUBY C) + +# C compiler flags. +set(CMAKE_C_FLAGS "-Wall -g") +# should use -O3 if it's a release build.bin/mrb + + +# Version of mruby, useful for versoning .so and .dll files. +set(MRUBY_VERSION 1.0.0) +string(REGEX MATCH "^[0-9]+[.][0-9]+" MRUBY_SOVERSION ${MRUBY_VERSION}) +string(REPLACE "." "" MRUBY_DLL_SHORTVER ${MRUBY_SOVERSION}) + +# Search in the `cmake' directory for additional CMake modules if needed. +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + +# Search for C header files in these directories. +include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) + +# Search for libaries too link tools with here: +link_directories("lib") +link_directories("mrblib") + +# put binaries that get built in bin +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) +# Put libraries that get built into `lib'. +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) + +if(NOT IPHONE) +option(SHARED "Build shared libraries" on) +set(BUILD_SHARED_LIBS ${SHARED}) # actual CMake variable +endif(NOT IPHONE) + +# On some 64-bit platforms, libraries should be installed into `lib64' +# instead of `lib'. Set this to 64 to do that. +set(LIB_SUFFIX "" CACHE STRING "Suffix for 'lib' directories, e.g. '64'") + +set(FRAMEWORK_INSTALL_PREFIX "/Library/Frameworks" CACHE STRING + "Directory in which to install Mac OS X frameworks") + +# Options (none yet). + +# Set up compilers. + +include(CheckCSourceCompiles) + +# Begin tests + +include(CheckFunctionExists) +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(CheckSymbolExists) +include(CheckTypeSize) +include(FindPkgConfig) +include(TestBigEndian) + + +# lib Libraries that mruby uses itself (just libm) +set(MRUBY_LIBS m) + +# Compile the sources to make libritevm +add_subdirectory("src") + +# compile the compiler tool +add_subdirectory("tools/mrbc") + +# compile libmrblib +add_subdirectory("mrblib") + +# generate final library +add_library(mrubylib_static STATIC + $<TARGET_OBJECTS:ritevm_object> $<TARGET_OBJECTS:mrblib_object>) +add_library(mrubylib SHARED + $<TARGET_OBJECTS:ritevm_object> $<TARGET_OBJECTS:mrblib_object>) + +install(TARGETS mrubylib mrubylib_static + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + +# compile the interpreter tool +add_subdirectory("tools/mruby") + +# for make install, install the header files +install(FILES include/mruby.h DESTINATION include) +install(FILES include/mrbconf.h DESTINATION include) +install(DIRECTORY include/mruby DESTINATION include) +# For now, also install header files in src dir to ${PREFIX}include/mruby +file(GLOB SRC_HEADERS src/*.h) +install (FILES ${SRC_HEADERS} DESTINATION include/mruby) + + + + + @@ -1,17 +1,21 @@ * Prerequisites 1. Make sure you have bison (http://www.gnu.org/software/bison/) installed in your system. + 2 Make sure you have cmake (http://www.cmake.org version 2.8.8 or + later installed). + * Compilation and Installation - 1. Run make in the top directory. - + 1. Run cmake . ; make ; make install in the top directory. + + This command will create the following directories and store libraries and binaries files into them. - * bin - * lib - * include + * /usr/local/bin + * /usr/local/lib + * /usr/local/include If an error occurs when compiling mruby, it will be helpful for others if you send a detailed report to the developers that includes the error log, machine, diff --git a/Makefile b/Makefile.orig index fc22089a9..fc22089a9 100644 --- a/Makefile +++ b/Makefile.orig diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/build/.gitkeep diff --git a/mrblib/CMakeLists.txt b/mrblib/CMakeLists.txt new file mode 100644 index 000000000..30881c611 --- /dev/null +++ b/mrblib/CMakeLists.txt @@ -0,0 +1,35 @@ +# build mrblib +# need custom commands +# Compile C source from merged mruby source + +file(GLOB MRBLIB_SRC_RB "*.rb") + +# generate the a single rubu file from all the existing ones. +add_custom_command(OUTPUT mrblib.rbtmp +COMMAND cat ${MRBLIB_SRC_RB} > mrblib.rbtmp +DEPENDS ${MRBLIB_SRC_RB} +) + +# generate the intermediate representation in C +add_custom_command(OUTPUT mrblib_irep.c +COMMAND echo -B mrblib_irep -o mrblib_irep.c mrblib.rbtmp +COMMAND mrbc -Bmrblib_irep -omrblib_irep.c mrblib.rbtmp +DEPENDS mrblib.rbtmp +) + +# finally generate the library's c file +add_custom_command(OUTPUT mrblib.c +COMMAND cat init_mrblib.c mrblib_irep.c > mrblib.c +DEPENDS init_mrblib.c mrblib_irep.c +) + +# only use this C file to generate mrblib. +set(MRBLIB_SRC_C mrblib.c) +# add_library(mrblib_static STATIC ${MRBLIB_SRC_C}) +add_library(mrblib_object OBJECT ${MRBLIB_SRC_C}) +# target_link_libraries(mrblib ritevm ${MRUBY_LIBS}) +# target_link_libraries(mrblib_static ritevm_static ${MRUBY_LIBS}) +# install(TARGETS mrblib mrblib_static +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib) + diff --git a/mrblib/Makefile b/mrblib/Makefile.orig index d22c4509f..d22c4509f 100644 --- a/mrblib/Makefile +++ b/mrblib/Makefile.orig diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..b25711ae3 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,23 @@ +# Build the C files in the mruby src directory + +cmake_minimum_required(VERSION 2.6) +if(CMAKE_VERSION VERSION_GREATER "2.8.0") + cmake_policy(SET CMP0012 OLD) +endif() + +find_package(BISON) +BISON_TARGET(mruby parse.y ${CMAKE_CURRENT_BINARY_DIR}/parse.c) + +# configure_file("config.in.h" "config.h") +file(GLOB MRUBY_SRC_C "*.c") +add_library(ritevm_object OBJECT ${MRUBY_SRC_C}) +add_library(ritevm_static STATIC $<TARGET_OBJECTS:ritevm_object>) +add_library(ritevm SHARED $<TARGET_OBJECTS:ritevm_object>) + + +# target_link_libraries(ritevm ${MRUBY_LIBS}) +# target_link_libraries(ritevm_static ${MRUBY_LIBS}) +# install(TARGETS ritevm ritevm_static +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib) + diff --git a/src/Makefile b/src/Makefile.orig index 14485041d..14485041d 100644 --- a/src/Makefile +++ b/src/Makefile.orig diff --git a/tools/mrbc/CMakeLists.txt b/tools/mrbc/CMakeLists.txt new file mode 100644 index 000000000..073ac1743 --- /dev/null +++ b/tools/mrbc/CMakeLists.txt @@ -0,0 +1,7 @@ +# builds tools/mrbc +file(GLOB MRBC_SRC_C "*.c") +add_executable(mrbc ${MRBC_SRC_C}) +target_link_libraries(mrbc ritevm_static ${MRUBY_LIBS}) +install(TARGETS mrbc RUNTIME DESTINATION bin) + + diff --git a/tools/mrbc/Makefile b/tools/mrbc/Makefile.orig index 9ecda4a59..9ecda4a59 100644 --- a/tools/mrbc/Makefile +++ b/tools/mrbc/Makefile.orig diff --git a/tools/mruby/CMakeLists.txt b/tools/mruby/CMakeLists.txt new file mode 100644 index 000000000..ab0e3acc1 --- /dev/null +++ b/tools/mruby/CMakeLists.txt @@ -0,0 +1,7 @@ +# builds tools/mrbc +file(GLOB MRUBYBIN_SRC_C "*.c") +add_executable(mruby ${MRUBYBIN_SRC_C}) +target_link_libraries(mruby mrubylib_static ${MRUBY_LIBS}) +install(TARGETS mruby RUNTIME DESTINATION bin) + + diff --git a/tools/mruby/Makefile b/tools/mruby/Makefile.orig index 052aa93d6..052aa93d6 100644 --- a/tools/mruby/Makefile +++ b/tools/mruby/Makefile.orig |
