diff options
| author | lloydh <lloydh@e775cfb5-b74b-0410-aad5-5bebe4a96390> | 2007-12-22 14:17:11 +0000 |
|---|---|---|
| committer | lloydh <lloydh@e775cfb5-b74b-0410-aad5-5bebe4a96390> | 2007-12-22 14:17:11 +0000 |
| commit | 8aed20e97375cd1e1adf8e8692f1b9fab7032111 (patch) | |
| tree | 78fac78ecd849b986f464200c18f4975cc8227a3 | |
| parent | 89d90dd72421844e29cb1bdc7addfd0ebaa487ec (diff) | |
| download | yajl-8aed20e97375cd1e1adf8e8692f1b9fab7032111.tar.gz | |
add lightweight build system wrapper, fix shared lib symlinks, add
familiar top level make targets.
git-svn-id: http://yajl-c.googlecode.com/svn/yajl/trunk@87 e775cfb5-b74b-0410-aad5-5bebe4a96390
| -rw-r--r-- | BUILDING | 18 | ||||
| -rw-r--r-- | CMakeLists.txt | 6 | ||||
| -rwxr-xr-x | configure | 86 | ||||
| -rw-r--r-- | reformatter/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 27 | ||||
| -rw-r--r-- | test/CMakeLists.txt | 4 |
6 files changed, 124 insertions, 23 deletions
@@ -1,9 +1,13 @@ -CMake (http://www.cmake.org) is used to build yajl. Steps to build are: +Short story (If you already have ruby and cmake): -1. attain cmake (tested against cmake 2.4.5 and 2.4.6 -2. mkdir build -3. cd build -4. cmake .. -5. make +./configure && make install -build output is left in dist/ +When things go wrong: + +CMake (http://www.cmake.org) is used to build yajl, and a small configure +ruby script is provided to emulate an autotools environment. + +1. attain cmake (tested against cmake 2.4.5 and 2.4.6) + +best, +lloyd diff --git a/CMakeLists.txt b/CMakeLists.txt index 4899355..ff1dab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,12 @@ PROJECT(YetAnotherJSONParser) +SET (YAJL_MAJOR 1) +SET (YAJL_MINOR 0) +SET (YAJL_MICRO 0) + +SET (YAJL_DIST_NAME "yajl-${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}") + SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1) IF (NOT CMAKE_BUILD_TYPE) diff --git a/configure b/configure new file mode 100755 index 0000000..5725096 --- /dev/null +++ b/configure @@ -0,0 +1,86 @@ +#!/usr/bin/env ruby +# Copyright 2007, Lloyd Hilaiel. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# 3. Neither the name of Lloyd Hilaiel nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +require 'fileutils' +require 'optparse' + +prefix = "/usr/local" +options = {} +OptionParser.new do |opts| + opts.banner = "Usage: configure [options]" + opts.on("-p", "--prefix PATH", "Set installation prefix") do |p| + prefix = p + end + opts.on_tail("-h", "--help", "Output usage summary") do + puts opts + exit + end + + opts.parse!(ARGV) +end + +puts "== removing old build files" +FileUtils.rm_rf("build") +FileUtils.rm_f("Makefile") +puts "== running CMake in build directory" +FileUtils.mkdir("build") +FileUtils.cd("build") do + if (!system("cmake ..")) + puts "The \"cmake\" program is required to configure yajl. It's" + puts "available from most ports/packaging systems and http://cmake.org" + exit 1 + end +end + +# now generate a Makefile +puts "== Generating Makefile" +File.open("Makefile", "w+") do |f| + f.puts ".PHONY: all clean distclean install package" + f.puts "all:" + f.puts " @cd build && make" + f.puts + f.puts "clean:" + f.puts " @cd build && make clean" + f.puts + f.puts "distclean:" + f.puts " @rm -rf Makefile build" + f.puts " @rm yajl-*.tgz" + f.puts + f.puts "install: all" + f.puts " @echo oops, install target not yet implemented" + f.puts + f.puts "package: all" + f.puts " @echo \"compressing to `basename build/yajl-*`.tgz\"" + f.puts " @cd build && tar czf ../`basename yajl-*`.tgz yajl-*" +end + +puts "== Configured with installation prefix: #{prefix}" + diff --git a/reformatter/CMakeLists.txt b/reformatter/CMakeLists.txt index 1476e4c..aa96f43 100644 --- a/reformatter/CMakeLists.txt +++ b/reformatter/CMakeLists.txt @@ -29,7 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. # set up a paths -SET (binDir ${CMAKE_CURRENT_BINARY_DIR}/../dist/bin) +SET (binDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/bin) # create a directories FILE(MAKE_DIRECTORY ${binDir}) @@ -37,8 +37,8 @@ FILE(MAKE_DIRECTORY ${binDir}) SET (SRCS json_reformat.c) # use the library we build, duh. -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../dist/include) -LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../dist/lib) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include) +LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) ADD_EXECUTABLE(json_reformat ${SRCS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f740253..7652f5a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,33 +35,38 @@ SET (PUB_HDRS api/yajl_parse.h api/yajl_gen.h api/yajl_common.h) # useful when fixing lexer bugs. #ADD_DEFINITIONS(-DYAJL_LEXER_DEBUG) +# set up some paths +SET (libDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) +SET (incDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include/yajl) + +# set the output path for libraries +SET(LIBRARY_OUTPUT_PATH ${libDir}) + ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS}) ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS}) #### setup shared library version number -SET_TARGET_PROPERTIES(yajl PROPERTIES SOVERSION 1 VERSION 1.0) +SET_TARGET_PROPERTIES(yajl PROPERTIES + SOVERSION ${YAJL_MAJOR} + VERSION ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}) #### build up an sdk as a post build step -# set up some paths -SET (libDir ${CMAKE_CURRENT_BINARY_DIR}/../dist/lib) -SET (incDir ${CMAKE_CURRENT_BINARY_DIR}/../dist/include/yajl) - # create some directories FILE(MAKE_DIRECTORY ${libDir}) FILE(MAKE_DIRECTORY ${incDir}) # copy in the library -GET_TARGET_PROPERTY(libPath yajl_s LOCATION) +#GET_TARGET_PROPERTY(libPath yajl_s LOCATION) -ADD_CUSTOM_COMMAND(TARGET yajl_s POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${libPath} ${libDir}) +#ADD_CUSTOM_COMMAND(TARGET yajl_s POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${libPath} ${libDir}) -GET_TARGET_PROPERTY(libPath yajl LOCATION) +#GET_TARGET_PROPERTY(libPath yajl LOCATION) -ADD_CUSTOM_COMMAND(TARGET yajl POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${libPath} ${libDir}) +#ADD_CUSTOM_COMMAND(TARGET yajl POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${libPath} ${libDir}) FOREACH (header ${PUB_HDRS}) SET (header ${CMAKE_CURRENT_SOURCE_DIR}/${header}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 73a9754..c6d65e9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -31,8 +31,8 @@ SET (SRCS yajl_test.c) # use the library we build, duh. -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../dist/include) -LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../dist/lib) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include) +LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) ADD_EXECUTABLE(yajl_test ${SRCS}) |
