Browse Source

Added support of conditional builds

master
Artyom Beilis 16 years ago
parent
commit
fdca64889c
6 changed files with 58 additions and 10 deletions
  1. +11
    -3
      Makefile.am
  2. +2
    -0
      autogen.sh
  3. +22
    -3
      configure.in
  4. +22
    -3
      manager.cpp
  5. +1
    -0
      manager.h
  6. +0
    -1
      worker_thread.h

+ 11
- 3
Makefile.am View File

@@ -4,14 +4,22 @@ hello_world_fcgi_LDADD = libcppcms.la
hello_world_fcgi_CXXFLAGS=-Wall

lib_LTLIBRARIES = libcppcms.la
libcppcms_la_SOURCES = fcgi.cpp global_config.cpp manager.cpp \
libcppcms_la_SOURCES = global_config.cpp manager.cpp \
url.cpp worker_thread.cpp text_tool.cpp\
cache_interface.cpp base_cache.cpp thread_cache.cpp scgi.cpp process_cache.cpp
cache_interface.cpp base_cache.cpp thread_cache.cpp scgi.cpp

if EN_FORK_CACHE
libcppcms_la_SOURCES += process_cache.cpp
endif

if EN_FCGI_BACKEND
libcppcms_la_SOURCES += fcgi.cpp
endif

libcppcms_la_CXXFLAGS=-Wall

nobase_pkginclude_HEADERS = global_config.h text_tool.h url.h cppcms_error.h \
manager.h worker_thread.h fcgi.h cache_interface.h archive.h base_cache.h \
thread_cache.h cgicc_connection.h scgi.h cgi_api.h process_cache.h \
shmem_allocator.h posix_mutex.h
shmem_allocator.h posix_mutex.h config.h


+ 2
- 0
autogen.sh View File

@@ -3,3 +3,5 @@ aclocal
libtoolize --force
automake --add-missing
autoconf
autoheader


+ 22
- 3
configure.in View File

@@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)

AC_INIT([cppcms], [0.0.1], [artyomtnk@yahoo.com])
AC_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([1.9 foreign])

AC_PROG_CXX
@@ -12,8 +12,27 @@ AC_SUBST(LIBTOOL_DEPS)

AC_LANG_CPLUSPLUS
AC_CONFIG_FILES([Makefile])
AC_CHECK_LIB(mm,main,[],[echo "OSSP mm library (libmm) not installed" ; exit -1])
AC_CHECK_LIB(fcgi++,main,[],[echo "Fast CGI library not installed" ; exit -1])


AC_CHECK_LIB(mm,main,[
have_mm=yes
LIBS="-lmm $LIBS"
AC_DEFINE([EN_FORK_CACHE],[],["Enable fork cache"])
],
[ echo "OSSP mm library (libmm) not installed"
echo "============== The fork cache backend will be disabled ===============" ])
AC_CHECK_LIB(fcgi++,main,[
have_fcgi=yes
LIBS="-lfcgi++ $LIBS"
AC_DEFINE([EN_FCGI_BACKEND],[],["Enable fastcgi backend"])
],
[ echo "Fast CGI library not installed"
echo "============== FastCGI API will be disabled =========================="
echo "You still have scgi and cgi API" ])

AM_CONDITIONAL(EN_FORK_CACHE,[test "x$have_mm" == "xyes" ])
AM_CONDITIONAL(EN_FCGI_BACKEND,[test "x$have_fcgi" == "xyes" ])

AC_CHECK_LIB(cgicc,main,[],[echo "cgicc not found" ; exit -1])
AC_CHECK_LIB(boost_regex,main,[],[AC_CHECK_LIB(boost_regex-gcc-mt,main,[],[ echo "boost::regex not found" ; exit -1])])
AC_CHECK_LIB(boost_iostreams,main,[],[AC_CHECK_LIB(boost_iostreams-gcc-mt,main,[],[ echo "boost::iostreams not found" ; exit -1])])


+ 22
- 3
manager.cpp View File

@@ -1,9 +1,12 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "manager.h"
#include "cgicc_connection.h"
#include <poll.h>
#include <signal.h>
#include <errno.h>
#include "scgi.h"
#include <unistd.h>
#include <stdlib.h>
#include <semaphore.h>
@@ -11,7 +14,15 @@
#include <sys/wait.h>
#include <sys/types.h>
#include "thread_cache.h"
#include "process_cache.h"
#include "scgi.h"

#ifdef EN_FORK_CACHE
# include "process_cache.h"
#endif

#ifdef EN_FCGI_BACKEND
# include "fcgi.h"
#endif

namespace cppcms {
namespace details {
@@ -387,11 +398,13 @@ static cache_factory *get_cache_factory()
int n=global_config.lval("cache.limit",100);
return new thread_cache_factory(n);
}
#ifdef EN_FORK_CACHE
else if(backend=="fork") {
size_t s=global_config.lval("cache.memsize",64);
string f=global_config.sval("cache.file","");
return new process_cache_factory(s*1024U,f=="" ? NULL: f.c_str());
}
#endif
else {
throw cppcms_error("Unkown cache backend:" + backend);
}
@@ -414,12 +427,18 @@ void run_application(int argc,char *argv[],base_factory const &factory)
else
{
auto_ptr<cgi_api> capi;
if(api=="fastcgi" || api=="scgi" ) {
if(
#ifdef EN_FCGI_BACKEND
api=="fastcgi" ||
#endif
api=="scgi" ) {
string socket=global_config.sval("server.socket","");
int backlog=global_config.lval("server.buffer",1);
#ifdef EN_FCGI_BACKEND
if(api=="fastcgi")
capi=auto_ptr<cgi_api>(new fcgi_api(socket.c_str(),backlog));
else
#endif
capi=auto_ptr<cgi_api>(new scgi_api(socket.c_str(),backlog));
}
else {


+ 1
- 0
manager.h View File

@@ -9,6 +9,7 @@
#include "worker_thread.h"
#include "global_config.h"
#include "cache_interface.h"
#include "cgi_api.h"

#include <boost/shared_ptr.hpp>



+ 0
- 1
worker_thread.h View File

@@ -12,7 +12,6 @@
#include <boost/noncopyable.hpp>
#include <memory>

#include "fcgi.h"
#include "cppcms_error.h"
#include "url.h"
#include "cache_interface.h"


Loading…
Cancel
Save