diff --git a/.gitignore b/.gitignore index 325dce1d..74d13550 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,45 @@ -Win32 -x64 -*.suo -*.user -*.ncb -*.sdf -*.opensdf -*.o -*.a -*.d *.gcno *.gcda *.gcov *.gch +*.la +*.lo +*.ncb +*.o +*.opensdf +*.sdf +*.suo +*.user *.swp -lcov* -obj* +.deps +.dirstamp +.libs +a.out.dSYM +aclocal.m4 +autom4te.cache +build +config.guess +config.h +config.h.in +config.h.in~ +config.log +config.status +config.sub +configure +depcomp html +install-sh +iphone +lcov* +libtool +ltmain.sh +Makefile +Makefile.in +missing mordor.xcodeproj/*.mode1v3 mordor.xcodeproj/*.pbxuser mordor.xcodeproj/*.perspectivev3 -build -iphone +obj* +stamp-h1 +Win32 +x64 diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..e69de29b diff --git a/LICENSE b/COPYING similarity index 100% rename from LICENSE rename to COPYING diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..e69de29b diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..7d1c323b --- /dev/null +++ b/INSTALL @@ -0,0 +1,365 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile b/Makefile deleted file mode 100644 index b2ff801b..00000000 --- a/Makefile +++ /dev/null @@ -1,506 +0,0 @@ -ifndef SRCDIR - SRCDIR=. -endif - -VPATH=$(SRCDIR) - -# make sure the 'all' target is listed first -all: - -# determine build type -ifdef NDEBUG - BUILDTYPE := nondebug - ifndef OPT - OPT := 3 - endif -else - ifdef GCOV - BUILDTYPE := gcov - else - BUILDTYPE := debug - endif -endif - -PLATFORM := $(shell uname -o 2>/dev/null) -ifneq ($(PLATFORM), Cygwin) - PLATFORM := $(shell uname) -endif - -DPKG := $(shell which dpkg 2>/dev/null) -ifdef DPKG - ARCH := $(shell dpkg --print-architecture 2>/dev/null) -endif -ifneq ($(PLATFORM), Darwin) - ifndef ARCH - ARCH := $(shell uname -m) - endif -endif - -ifeq ($(PLATFORM), Darwin) - DARWIN := 1 - BOOST_EXT := - BOOST_LIB_FLAGS := -L/opt/local/lib - PQ_LIB_FLAGS := -L/opt/local/lib/postgresql83 - GCC_ARCH := $(shell file -L `which gcc` | grep x86_64 -o | uniq) - ifndef GCC_ARCH - GCC_ARCH := $(shell file -L `which gcc` | grep ppc -o | uniq) - endif - ifndef GCC_ARCH - GCC_ARCH := i386 - endif - ifndef ARCH - ARCH := $(GCC_ARCH) - endif - ifeq ($(ARCH), x86_64) - ARCH := amd64 - endif - ifeq ($(ARCH), amd64) - ifneq ($(GCC_ARCH), x86_64) - MACH_TARGET := -arch x86_64 - endif - endif - ifeq ($(ARCH), i386) - ifneq ($(GCC_ARCH), i386) - MACH_TARGET := -arch i386 - endif - endif - ifeq ($(ARCH), ppc) - ifneq ($(GCC_ARCH), ppc) - MACH_TARGET := -arch ppc - endif - endif -endif - -# set optimization level (disable for gcov builds) -# example: 'make OPT=2' will add -O2 to the compilation options -ifdef GCOV - OPT_FLAGS := - GCOV_FLAGS += -fprofile-arcs -ftest-coverage -else - ifdef INSURE - OPT_FLAGS := - else - ifdef OPT - OPT_FLAGS += -O$(OPT) - else - OPT_FLAGS += -O0 - endif - endif -endif - -ifdef ENABLE_VALGRIND - DBG_FLAGS += -DVALGRIND -endif - -ifdef ENABLE_STACKTRACE - DBG_FLAGS += -DENABLE_STACKTRACE -rdynamic -endif - -# example: 'make NDEBUG=1' will prevent -g (add debugging symbols) to the -# compilation options and not define DEBUG -DBG_FLAGS += -g -ifndef NDEBUG - DBG_FLAGS += -DDEBUG -fno-inline -endif - -ifdef GPROF - DBG_FLAGS += -pg -endif - -# add current dir to include dir -INC_FLAGS := -I$(SRCDIR) -PCH_FLAGS := -include mordor/pch.h - -ifeq ($(PLATFORM), Darwin) - INC_FLAGS := $(INC_FLAGS) -I/opt/local/include -endif - - -# run with 'make V=1' for verbose make output -ifeq ($(V),1) - Q := -else - Q := @ -endif - -BIT64FLAGS = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE - -# Compiler options for c++ go here -CXXFLAGS += -Wall -Werror -MD $(OPT_FLAGS) $(DBG_FLAGS) $(INC_FLAGS) $(BIT64FLAGS) $(GCOV_FLAGS) $(MACH_TARGET) -fno-strict-aliasing -fPIC -CFLAGS += -Wall -MD $(OPT_FLAGS) $(DBG_FLAGS) $(INC_FLAGS) $(BIT64FLAGS) $(GCOV_FLAGS) $(MACH_TARGET) -fno-strict-aliasing -fPIC - -RLCODEGEN := $(shell which rlcodegen rlgen-cd 2>/dev/null) -RAGEL := ragel - -RAGEL_MAJOR := $(shell ragel -v | sed -n 's/.*\([0-9]\)\.[0-9].*/\1/p') - -ifeq ($(RAGEL_MAJOR), 6) - RLCODEGEN := -endif - -LIBS := $(BOOST_LIB_FLAGS) $(PQ_LIB_FLAGS) -lboost_thread$(BOOST_EXT) -lboost_program_options $(BOOST_EXT) -lboost_regex$(BOOST_EXT) -lboost_date_time$(BOOST_EXT) -lssl -lcrypto -lz -ldl -lstdc++ -lpthread - -ifeq ($(PLATFORM), Darwin) - LIBS += -framework SystemConfiguration -framework CoreFoundation -framework CoreServices -framework Security -endif - -ifeq ($(PLATFORM), Linux) - LIBS += -lrt -endif - -ifeq ($(PLATFORM), FreeBSD) - LIBS += -lexecinfo -endif - -# compile and link a binary. this *must* be defined using = and not := -# because it uses target variables -COMPLINK = $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(filter %.o %.a, $^) $(CXXLDFLAGS) $(LDFLAGS) $(LIBS) -o $@ - -# Eliminate default suffix rules -.SUFFIXES: - -# Delete target files if there is an error -.DELETE_ON_ERROR: - -# Don't delete intermediate files -.SECONDARY: - -# -# Default build rules -# - -# cpp rules -%.o: %.cpp -ifeq ($(Q),@) - @echo c++ $< -endif - $(Q)mkdir -p $(@D) - $(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(PCH_FLAGS) -c -o $@ $< - -%.o: %.c -ifeq ($(Q),@) - @echo c++ $< -endif - $(Q)mkdir -p $(@D) - $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< - -%.cpp: %.rl -ifeq ($(Q),@) - @echo ragel $< -endif - $(Q)mkdir -p $(@D) -ifndef RLCODEGEN - $(Q)$(RAGEL) $(RAGEL_FLAGS) $(RLCODEGEN_FLAGS) -o $@ $< -else - $(Q)$(RAGEL) $(RAGEL_FLAGS) $< | $(RLCODEGEN) $(RLCODEGEN_FLAGS) -o $@ -endif - -%.gch: % -ifeq ($(Q),@) - @echo c++ $< -endif - $(Q)mkdir -p $(@D) - $(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -x c++-header $< -o $@ - -# -# Include the dependency information generated during the previous compile -# phase (note that since the .d is generated during the compile, editing -# the .cpp will cause it to be regenerated for the next build.) -# -DEPS := $(shell find $(CURDIR) -name '*.d') --include $(DEPS) - -ALLBINS = mordor/examples/cat \ - mordor/examples/echoserver \ - mordor/examples/iombench \ - mordor/examples/simpleclient \ - mordor/examples/tunnel \ - mordor/examples/udpstats \ - mordor/examples/wget \ - mordor/tests/run_tests - - -# clean current build -# -.PHONY: clean -clean: - $(Q)find . -name '*.gcno' | xargs rm -f - $(Q)find . -name '*.gcda' | xargs rm -f - $(Q)find . -name '*.d' | xargs rm -f - $(Q)find . -name '*.o' | xargs rm -f - $(Q)find . -name '*.a' | xargs rm -f - $(Q)rm -f mordor/pch.h.gch - $(Q)rm -f mordor/uri.cpp mordor/http/http_parser.cpp mordor/xml/xml_parser.cpp mordor/json.cpp - $(Q)rm -f $(ALLBINS) mordor/tests/run_tests mordor/tests/pq_tests - $(Q)rm -rf lcov* html - -all: $(ALLBINS) - -.PHONY: check -check: all - $(Q)cd mordor/tests && ./run_tests - -.PHONY: lcov -lcov: - $(Q)lcov -d $(CURDIR) -z >/dev/null 2>&1 - $(Q)rm -rf lcov* - $(Q)$(MAKE) -f $(SRCDIR)/Makefile --no-print-directory $(MAKEFLAGS) check GCOV=1 - $(Q)lcov -b $(SRCDIR) -d $(CURDIR) -c -i -o lcov_base.info >/dev/null - $(Q)lcov -b $(SRCDIR) -d $(CURDIR) -c -o lcov.info >/dev/null 2>&1 - $(Q)lcov -a lcov.info -a lcov_base.info -o lcov.info >/dev/null - $(Q)lcov -r lcov.info '/usr/*' -o lcov.info >/dev/null 2>&1 - $(Q)lcov -r lcov.info mordor/uri.cpp -o lcov.info >/dev/null 2>&1 - $(Q)lcov -r lcov.info mordor/http/http_parser.cpp -o lcov.info >/dev/null 2>&1 - $(Q)lcov -r lcov.info mordor/xml/xml_parser.cpp -o lcov.info >/dev/null 2>&1 - $(Q)lcov -r lcov.info 'mordor/examples/*' -o lcov.info >/dev/null 2>&1 - $(Q)lcov -r lcov.info './*' -o lcov.info >/dev/null 2>&1 - $(Q)mkdir -p lcov && cd lcov && genhtml ../lcov.info >/dev/null && tar -czf lcov.tgz * - -TESTDATA := $(patsubst $(SRCDIR)/%,$(CURDIR)/%,$(wildcard $(SRCDIR)/mordor/tests/data/*)) - -TESTOBJECTS := \ - mordor/tests/run_tests.o \ - mordor/tests/buffer.o \ - mordor/tests/buffered_stream.o \ - mordor/tests/chunked_stream.o \ - mordor/tests/coroutine.o \ - mordor/tests/endian.o \ - mordor/tests/efs_stream.o \ - mordor/tests/fibers.o \ - mordor/tests/fibersync.o \ - mordor/tests/file_stream.o \ - mordor/tests/fls.o \ - mordor/tests/future.o \ - mordor/tests/hmac.o \ - mordor/tests/http_client.o \ - mordor/tests/http_parser.o \ - mordor/tests/http_server.o \ - mordor/tests/iomanager.o \ - mordor/tests/json.o \ - mordor/tests/log.o \ - mordor/tests/memory_stream.o \ - mordor/tests/oauth.o \ - mordor/tests/pipe_stream.o \ - mordor/tests/scheduler.o \ - mordor/tests/socket.o \ - mordor/tests/ssl_stream.o \ - mordor/tests/stream.o \ - mordor/tests/string.o \ - mordor/tests/temp_stream.o \ - mordor/tests/thread.o \ - mordor/tests/timeout_stream.o \ - mordor/tests/timer.o \ - mordor/tests/transfer_stream.o \ - mordor/tests/uri.o \ - mordor/tests/xml.o \ - mordor/tests/zlib.o - -$(TESTDATA): $(CURDIR)/%: $(SRCDIR)/% - $(Q)mkdir -p $(@D) - $(Q)cp -f $< $@ - -$(TESTOBJECTS): mordor/pch.h.gch - -mordor/tests/run_tests: \ - $(TESTOBJECTS) \ - mordor/test/libmordortest.a \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - - -EXAMPLEOBJECTS := \ - mordor/examples/cat.o \ - mordor/examples/echoserver.o \ - mordor/examples/iombench.o \ - mordor/examples/netbench.o \ - mordor/examples/simpleclient.o \ - mordor/examples/tunnel.o \ - mordor/examples/udpstats.o \ - mordor/examples/wget.o - -$(EXAMPLEOBJECTS): mordor/pch.h.gch - -mordor/examples/cat: mordor/examples/cat.o \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - -mordor/examples/echoserver: mordor/examples/echoserver.o \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - -mordor/examples/simpleclient: mordor/examples/simpleclient.o \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - -mordor/examples/iombench: mordor/examples/iombench.o \ - mordor/examples/netbench.o \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - -mordor/examples/tunnel: mordor/examples/tunnel.o \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - -mordor/examples/udpstats: mordor/examples/udpstats.o \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - -mordor/examples/wget: mordor/examples/wget.o \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) - -mordor/streams/socket_stream.o: mordor/streams/socket.cpp -ifeq ($(Q),@) - @echo c++ $< -endif - $(Q)mkdir -p $(@D) - $(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< - -mordor/streams/http_stream.o: mordor/streams/http.cpp -ifeq ($(Q),@) - @echo c++ $< -endif - $(Q)mkdir -p $(@D) - $(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< - - -LIBMORDOROBJECTS := \ - mordor/assert.o \ - mordor/config.o \ - mordor/daemon.o \ - mordor/date_time.o \ - mordor/exception.o \ - mordor/fiber.o \ - mordor/fibersynchronization.o \ - mordor/http/auth.o \ - mordor/http/basic.o \ - mordor/http/broker.o \ - mordor/http/chunked.o \ - mordor/http/client.o \ - mordor/http/connection.o \ - mordor/http/digest.o \ - mordor/http/http.o \ - mordor/http/multipart.o \ - mordor/http/oauth.o \ - mordor/http/http_parser.o \ - mordor/http/proxy.o \ - mordor/http/server.o \ - mordor/iomanager_epoll.o \ - mordor/iomanager_kqueue.o \ - mordor/json.o \ - mordor/log.o \ - mordor/parallel.o \ - mordor/ragel.o \ - mordor/scheduler.o \ - mordor/semaphore.o \ - mordor/sleep.o \ - mordor/socket.o \ - mordor/socks.o \ - mordor/statistics.o \ - mordor/streams/buffer.o \ - mordor/streams/buffered.o \ - mordor/streams/cat.o \ - mordor/streams/fd.o \ - mordor/streams/file.o \ - mordor/streams/filter.o \ - mordor/streams/hash.o \ - mordor/streams/http_stream.o \ - mordor/streams/limited.o \ - mordor/streams/memory.o \ - mordor/streams/null.o \ - mordor/streams/pipe.o \ - mordor/streams/random.o \ - mordor/streams/singleplex.o \ - mordor/streams/socket_stream.o \ - mordor/streams/ssl.o \ - mordor/streams/std.o \ - mordor/streams/stream.o \ - mordor/streams/temp.o \ - mordor/streams/timeout.o \ - mordor/streams/test.o \ - mordor/streams/throttle.o \ - mordor/streams/transfer.o \ - mordor/streams/zlib.o \ - mordor/string.o \ - mordor/thread.o \ - mordor/timer.o \ - mordor/workerpool.o \ - mordor/uri.o \ - mordor/xml/xml_parser.o \ - mordor/zip.o - -$(LIBMORDOROBJECTS): mordor/pch.h.gch - -ARFLAGS := ruc -ifdef DARWIN - ARFLAGS := -rucs -endif - -mordor/libmordor.a: $(LIBMORDOROBJECTS) -ifeq ($(Q),@) - @echo ar $@ -endif - $(Q)$(AR) $(ARFLAGS) $@ $(filter %.o,$?) - -LIBMORDORTESTOBJECTS := \ - mordor/test/antxmllistener.o \ - mordor/test/test.o \ - mordor/test/stdoutlistener.o - -$(LIBMORDORTESTOBJECTS): mordor/pch.h.gch - -mordor/test/libmordortest.a: $(LIBMORDORTESTOBJECTS) -ifeq ($(Q),@) - @echo ar $@ -endif - $(Q)$(AR) $(ARFLAGS) $@ $(filter %.o,$?) - -LIBMORDORPQOBJECTS := \ - mordor/pq.o - -$(LIBMORDORPQOBJECTS): mordor/pch.h.gch - -mordor/libmordorpq.a: $(LIBMORDORPQOBJECTS) -ifeq ($(Q),@) - @echo ar $@ -endif - $(Q)$(AR) $(ARFLAGS) $@ $(filter %.o,$?) - -PQTESTOBJECTS := \ - mordor/tests/pq.o - -$(PQTESTOBJECTS): mordor/pch.h.gch - -mordor/tests/pq_tests: \ - $(PQTESTOBJECTS) \ - mordor/libmordorpq.a \ - mordor/test/libmordortest.a \ - mordor/libmordor.a -ifeq ($(Q),@) - @echo ld $@ -endif - $(COMPLINK) -lpq diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..3f02cc53 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,90 @@ +SUBDIRS=mordor +ACLOCAL_AMFLAGS=-I m4 + +nobase_include_HEADERS= \ + mordor/anymap.h \ + mordor/assert.h \ + mordor/atomic.h \ + mordor/config.h \ + mordor/coroutine.h \ + mordor/daemon.h \ + mordor/date_time.h \ + mordor/endian.h \ + mordor/eventloop.h \ + mordor/exception.h \ + mordor/fiber.h \ + mordor/fibersynchronization.h \ + mordor/future.h \ + mordor/http/auth.h \ + mordor/http/basic.h \ + mordor/http/broker.h \ + mordor/http/chunked.h \ + mordor/http/client.h \ + mordor/http/connection.h \ + mordor/http/digest.h \ + mordor/http/http.h \ + mordor/http/multipart.h \ + mordor/http/negotiate.h \ + mordor/http/oauth.h \ + mordor/http/parser.h \ + mordor/http/proxy.h \ + mordor/http/server.h \ + mordor/iomanager_epoll.h \ + mordor/iomanager.h \ + mordor/iomanager_kqueue.h \ + mordor/json.h \ + mordor/log.h \ + mordor/main.h \ + mordor/parallel.h \ + mordor/pq.h \ + mordor/predef.h \ + mordor/ragel.h \ + mordor/scheduler.h \ + mordor/semaphore.h \ + mordor/sleep.h \ + mordor/socket.h \ + mordor/socks.h \ + mordor/statistics.h \ + mordor/streams/buffered.h \ + mordor/streams/buffer.h \ + mordor/streams/cat.h \ + mordor/streams/deflate.h \ + mordor/streams/duplex.h \ + mordor/streams/fd.h \ + mordor/streams/file.h \ + mordor/streams/filter.h \ + mordor/streams/gzip.h \ + mordor/streams/hash.h \ + mordor/streams/http.h \ + mordor/streams/limited.h \ + mordor/streams/memory.h \ + mordor/streams/notify.h \ + mordor/streams/null.h \ + mordor/streams/pipe.h \ + mordor/streams/progress.h \ + mordor/streams/random.h \ + mordor/streams/scheduler.h \ + mordor/streams/singleplex.h \ + mordor/streams/socket.h \ + mordor/streams/ssl.h \ + mordor/streams/std.h \ + mordor/streams/stream.h \ + mordor/streams/temp.h \ + mordor/streams/test.h \ + mordor/streams/throttle.h \ + mordor/streams/timeout.h \ + mordor/streams/transfer.h \ + mordor/streams/zlib.h \ + mordor/string.h \ + mordor/test/antxmllistener.h \ + mordor/test/stdoutlistener.h \ + mordor/test/test.h \ + mordor/thread.h \ + mordor/thread_local_storage.h \ + mordor/timer.h \ + mordor/uri.h \ + mordor/util.h \ + mordor/version.h \ + mordor/workerpool.h \ + mordor/xml/parser.h \ + mordor/zip.h diff --git a/NEWS b/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..754f02b1 --- /dev/null +++ b/configure.ac @@ -0,0 +1,59 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.61]) +AC_INIT(mordor, 1.3.0) +AM_INIT_AUTOMAKE +AC_CONFIG_SRCDIR([mordor/fiber.cpp]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) + +# Checks for programs. +AC_PROG_CXX +AC_DISABLE_STATIC +AC_PROG_LIBTOOL +CHECK_RAGEL([mordor/uri.cpp], [6.0]) + +# Checks for libraries. +AX_CHECK_OPENSSL +AX_CHECK_ZLIB +AX_BOOST_BASE([1.40]) +AX_BOOST_PROGRAM_OPTIONS +AX_BOOST_REGEX +AX_BOOST_THREAD +AX_CHECK_CORESERVICES_FRAMEWORK +AX_CHECK_COREFOUNDATION_FRAMEWORK +AX_CHECK_SECURITY_FRAMEWORK +AX_CHECK_SYSTEMCONFIGURATION_FRAMEWORK + +# Checks for header files. +AC_CHECK_HEADERS([fcntl.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/socket.h sys/time.h syslog.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_INT32_T +AC_TYPE_INT64_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_CHECK_TYPES([ptrdiff_t]) + +# Checks for library functions. +AC_FUNC_ERROR_AT_LINE +AC_HEADER_MAJOR +AC_FUNC_MMAP +AC_CHECK_FUNCS([clock_gettime ftruncate memchr memmove memset munmap rmdir socket strchr strstr strtoull]) + +AC_SUBST([pic_flag]) + +AC_CONFIG_FILES([Makefile mordor/Makefile mordor/examples/Makefile mordor/test/Makefile mordor/tests/Makefile]) + +AC_OUTPUT + +# Teach libtool about pre-compiled headers +#cat libtool | sed 's/\*\.cpp/*.cpp | *.gch/' > libtool2 +#rm libtool +#mv libtool2 libtool diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 00000000..38066ddf --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1,5 @@ +libtool.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 +lt~obsolete.m4 diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4 new file mode 100644 index 00000000..ec23a0ab --- /dev/null +++ b/m4/ax_boost_base.m4 @@ -0,0 +1,257 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# DESCRIPTION +# +# Test for the Boost C++ libraries of a particular version (or newer) +# +# If no path to the installed boost library is given the macro searchs +# under /usr, /usr/local, /opt and /opt/local and evaluates the +# $BOOST_ROOT environment variable. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) +# +# And sets: +# +# HAVE_BOOST +# +# LICENSE +# +# Copyright (c) 2008 Thomas Porschberg +# Copyright (c) 2009 Peter Adolphs +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 18 + +AC_DEFUN([AX_BOOST_BASE], +[ +AC_ARG_WITH([boost], + [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], + [use Boost library from a standard location (ARG=yes), + from the specified location (ARG=), + or disable it (ARG=no) + @<:@ARG=yes@:>@ ])], + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ac_boost_path="" + else + want_boost="yes" + ac_boost_path="$withval" + fi + ], + [want_boost="yes"]) + + +AC_ARG_WITH([boost-libdir], + AS_HELP_STRING([--with-boost-libdir=LIB_DIR], + [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), + [ + if test -d "$withval" + then + ac_boost_lib_path="$withval" + else + AC_MSG_ERROR(--with-boost-libdir expected directory name) + fi + ], + [ac_boost_lib_path=""] +) + +if test "x$want_boost" = "xyes"; then + boost_lib_version_req=ifelse([$1], ,1.20.0,$1) + boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` + boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` + boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` + boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` + if test "x$boost_lib_version_req_sub_minor" = "x" ; then + boost_lib_version_req_sub_minor="0" + fi + WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` + AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) + succeeded=no + + dnl On x86_64 systems check for system libraries in both lib64 and lib. + dnl The former is specified by FHS, but e.g. Debian does not adhere to + dnl this (as it rises problems for generic multi-arch support). + dnl The last entry in the list is chosen by default when no libraries + dnl are found, e.g. when only header-only libraries are installed! + libsubdirs="lib" + if test `uname -m` = x86_64; then + libsubdirs="lib64 lib lib64" + fi + + dnl first we check the system location for boost libraries + dnl this location ist chosen if boost libraries are installed with the --layout=system option + dnl or if you install boost with RPM + if test "$ac_boost_path" != ""; then + BOOST_CPPFLAGS="-I$ac_boost_path/include" + for ac_boost_path_tmp in $libsubdirs; do + if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then + BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" + break + fi + done + elif test "$cross_compiling" != yes; then + for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do + if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then + for libsubdir in $libsubdirs ; do + if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" + BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" + break; + fi + done + fi + + dnl overwrite ld flags if we have required special directory with + dnl --with-boost-libdir parameter + if test "$ac_boost_lib_path" != ""; then + BOOST_LDFLAGS="-L$ac_boost_lib_path" + fi + + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_REQUIRE([AC_PROG_CXX]) + AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if BOOST_VERSION >= $WANT_BOOST_VERSION + // Everything is okay + #else + # error Boost version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + succeeded=yes + found_system=yes + ],[ + ]) + AC_LANG_POP([C++]) + + + + dnl if we found no boost with system layout we search for boost libraries + dnl built and installed without the --layout=system option or for a staged(not installed) version + if test "x$succeeded" != "xyes"; then + _version=0 + if test "$ac_boost_path" != ""; then + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + V_CHECK=`expr $_version_tmp \> $_version` + if test "$V_CHECK" = "1" ; then + _version=$_version_tmp + fi + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` + BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" + done + fi + else + if test "$cross_compiling" != yes; then + for ac_boost_path in /usr /usr/local /opt /opt/local ; do + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + V_CHECK=`expr $_version_tmp \> $_version` + if test "$V_CHECK" = "1" ; then + _version=$_version_tmp + best_path=$ac_boost_path + fi + done + fi + done + + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` + BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" + if test "$ac_boost_lib_path" = ""; then + for libsubdir in $libsubdirs ; do + if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$best_path/$libsubdir" + fi + fi + + if test "x$BOOST_ROOT" != "x"; then + for libsubdir in $libsubdirs ; do + if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then + version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` + stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` + stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` + V_CHECK=`expr $stage_version_shorten \>\= $_version` + if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then + AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) + BOOST_CPPFLAGS="-I$BOOST_ROOT" + BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" + fi + fi + fi + fi + + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if BOOST_VERSION >= $WANT_BOOST_VERSION + // Everything is okay + #else + # error Boost version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + succeeded=yes + found_system=yes + ],[ + ]) + AC_LANG_POP([C++]) + fi + + if test "$succeeded" != "yes" ; then + if test "$_version" = "0" ; then + AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) + else + AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) + fi + # execute ACTION-IF-NOT-FOUND (if present): + ifelse([$3], , :, [$3]) + else + AC_SUBST(BOOST_CPPFLAGS) + AC_SUBST(BOOST_LDFLAGS) + AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) + # execute ACTION-IF-FOUND (if present): + ifelse([$2], , :, [$2]) + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" +fi + +]) diff --git a/m4/ax_boost_program_options.m4 b/m4/ax_boost_program_options.m4 new file mode 100644 index 00000000..d612f91d --- /dev/null +++ b/m4/ax_boost_program_options.m4 @@ -0,0 +1,108 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_boost_program_options.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_BOOST_PROGRAM_OPTIONS +# +# DESCRIPTION +# +# Test for program options library from the Boost C++ libraries. The macro +# requires a preceding call to AX_BOOST_BASE. Further documentation is +# available at . +# +# This macro calls: +# +# AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) +# +# And sets: +# +# HAVE_BOOST_PROGRAM_OPTIONS +# +# LICENSE +# +# Copyright (c) 2009 Thomas Porschberg +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 20 + +AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS], +[ + AC_ARG_WITH([boost-program-options], + AS_HELP_STRING([--with-boost-program-options@<:@=special-lib@:>@], + [use the program options library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-program-options=boost_program_options-gcc-mt-1_33_1 ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_program_options_lib="" + else + want_boost="yes" + ax_boost_user_program_options_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + export want_boost + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + AC_CACHE_CHECK([whether the Boost::Program_Options library is available], + ax_cv_boost_program_options, + [AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include + ]], + [[boost::program_options::options_description generic("Generic options"); + return 0;]])], + ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no) + AC_LANG_POP([C++]) + ]) + if test "$ax_cv_boost_program_options" = yes; then + AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,,[define if the Boost::PROGRAM_OPTIONS library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + if test "x$ax_boost_user_program_options_lib" = "x"; then + for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.a*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], + [link_program_options="no"]) + done + if test "x$link_program_options" != "xyes"; then + for libextension in `ls $BOOSTLIBDIR/boost_program_options*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.a*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], + [link_program_options="no"]) + done + fi + else + for ax_lib in $ax_boost_user_program_options_lib boost_program_options-$ax_boost_user_program_options_lib; do + AC_CHECK_LIB($ax_lib, main, + [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], + [link_program_options="no"]) + done + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the library!) + fi + if test "x$link_program_options" != "xyes"; then + AC_MSG_ERROR([Could not link against [$ax_lib] !]) + fi + fi + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/m4/ax_boost_regex.m4 b/m4/ax_boost_regex.m4 new file mode 100644 index 00000000..3aca2cfa --- /dev/null +++ b/m4/ax_boost_regex.m4 @@ -0,0 +1,111 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_regex.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_REGEX +# +# DESCRIPTION +# +# Test for Regex library from the Boost C++ libraries. The macro requires +# a preceding call to AX_BOOST_BASE. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_REGEX_LIB) +# +# And sets: +# +# HAVE_BOOST_REGEX +# +# LICENSE +# +# Copyright (c) 2008 Thomas Porschberg +# Copyright (c) 2008 Michael Tindal +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 19 + +AC_DEFUN([AX_BOOST_REGEX], +[ + AC_ARG_WITH([boost-regex], + AS_HELP_STRING([--with-boost-regex@<:@=special-lib@:>@], + [use the Regex library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-regex=boost_regex-gcc-mt-d-1_33_1 ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_regex_lib="" + else + want_boost="yes" + ax_boost_user_regex_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::Regex library is available, + ax_cv_boost_regex, + [AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include + ]], + [[boost::regex r(); return 0;]])], + ax_cv_boost_regex=yes, ax_cv_boost_regex=no) + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_regex" = "xyes"; then + AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + if test "x$ax_boost_user_regex_lib" = "x"; then + for libextension in `ls $BOOSTLIBDIR/libboost_regex*.so* $BOOSTLIBDIR/libboost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_regex.*\)\.so.*$;\1;' -e 's;^lib\(boost_regex.*\)\.a*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break], + [link_regex="no"]) + done + if test "x$link_regex" != "xyes"; then + for libextension in `ls $BOOSTLIBDIR/boost_regex*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_regex.*\)\.dll.*$;\1;' -e 's;^\(boost_regex.*\)\.a*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break], + [link_regex="no"]) + done + fi + + else + for ax_lib in $ax_boost_user_regex_lib boost_regex-$ax_boost_user_regex_lib; do + AC_CHECK_LIB($ax_lib, main, + [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break], + [link_regex="no"]) + done + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the library!) + fi + if test "x$link_regex" != "xyes"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/m4/ax_boost_thread.m4 b/m4/ax_boost_thread.m4 new file mode 100644 index 00000000..2c073b56 --- /dev/null +++ b/m4/ax_boost_thread.m4 @@ -0,0 +1,149 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_thread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_THREAD +# +# DESCRIPTION +# +# Test for Thread library from the Boost C++ libraries. The macro requires +# a preceding call to AX_BOOST_BASE. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_THREAD_LIB) +# +# And sets: +# +# HAVE_BOOST_THREAD +# +# LICENSE +# +# Copyright (c) 2009 Thomas Porschberg +# Copyright (c) 2009 Michael Tindal +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 22 + +AC_DEFUN([AX_BOOST_THREAD], +[ + AC_ARG_WITH([boost-thread], + AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], + [use the Thread library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-thread=boost_thread-gcc-mt ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_thread_lib="" + else + want_boost="yes" + ax_boost_user_thread_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::Thread library is available, + ax_cv_boost_thread, + [AC_LANG_PUSH([C++]) + CXXFLAGS_SAVE=$CXXFLAGS + + if test "x$build_os" = "xsolaris" ; then + CXXFLAGS="-pthreads $CXXFLAGS" + elif test "x$build_os" = "xming32" ; then + CXXFLAGS="-mthreads $CXXFLAGS" + else + CXXFLAGS="-pthread $CXXFLAGS" + fi + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[boost::thread_group thrds; + return 0;]])], + ax_cv_boost_thread=yes, ax_cv_boost_thread=no) + CXXFLAGS=$CXXFLAGS_SAVE + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_thread" = "xyes"; then + if test "x$build_os" = "xsolaris" ; then + BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" + elif test "x$build_os" = "xming32" ; then + BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" + else + BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" + fi + + AC_SUBST(BOOST_CPPFLAGS) + + AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + + LDFLAGS_SAVE=$LDFLAGS + case "x$build_os" in + *bsd* ) + LDFLAGS="-pthread $LDFLAGS" + break; + ;; + esac + if test "x$ax_boost_user_thread_lib" = "x"; then + for libextension in `ls $BOOSTLIBDIR/libboost_thread*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.a*$;\1;'`; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + [link_thread="no"]) + done + if test "x$link_thread" != "xyes"; then + for libextension in `ls $BOOSTLIBDIR/boost_thread*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.a*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + [link_thread="no"]) + done + fi + + else + for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do + AC_CHECK_LIB($ax_lib, exit, + [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + [link_thread="no"]) + done + + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the library!) + fi + if test "x$link_thread" = "xno"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + else + case "x$build_os" in + *bsd* ) + BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS" + break; + ;; + esac + + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/m4/ax_check_openssl.m4 b/m4/ax_check_openssl.m4 new file mode 100644 index 00000000..ea77008e --- /dev/null +++ b/m4/ax_check_openssl.m4 @@ -0,0 +1,124 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) +# +# DESCRIPTION +# +# Look for OpenSSL in a number of default spots, or in a user-selected +# spot (via --with-openssl). Sets +# +# OPENSSL_INCLUDES to the include directives required +# OPENSSL_LIBS to the -l directives required +# OPENSSL_LDFLAGS to the -L or -R flags required +# +# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately +# +# This macro sets OPENSSL_INCLUDES such that source files should use the +# openssl/ directory in include directives: +# +# #include +# +# LICENSE +# +# Copyright (c) 2009,2010 Zmanda Inc. +# Copyright (c) 2009,2010 Dustin J. Mitchell +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) +AC_DEFUN([AX_CHECK_OPENSSL], [ + found=false + AC_ARG_WITH(openssl, + AS_HELP_STRING([--with-openssl=DIR], + [root of the OpenSSL directory]), + [ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([Invalid --with-openssl value]) + ;; + *) ssldirs="$withval" + ;; + esac + ], [ + # if pkg-config is installed and openssl has installed a .pc file, + # then use that information and don't search ssldirs + AC_PATH_PROG(PKG_CONFIG, pkg-config) + if test x"$PKG_CONFIG" != x""; then + OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` + if test $? = 0; then + OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` + OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` + found=true + fi + fi + + # no such luck; use some default ssldirs + if ! $found; then + ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" + fi + ] + ) + + + # note that we #include , so the OpenSSL headers have to be in + # an 'openssl' subdirectory + + if ! $found; then + OPENSSL_INCLUDES= + for ssldir in $ssldirs; do + AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) + if test -f "$ssldir/include/openssl/ssl.h"; then + OPENSSL_INCLUDES="-I$ssldir/include" + OPENSSL_LDFLAGS="-L$ssldir/lib" + OPENSSL_LIBS="-lssl -lcrypto" + found=true + AC_MSG_RESULT([yes]) + break + else + AC_MSG_RESULT([no]) + fi + done + + # if the file wasn't found, well, go ahead and try the link anyway -- maybe + # it will just work! + fi + + # try the preprocessor and linker with our new flags, + # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS + + AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) + echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ + "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD + + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CPPFLAGS="$CPPFLAGS" + LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" + LIBS="$OPENSSL_LIBS $LIBS" + CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" + AC_LINK_IFELSE( + AC_LANG_PROGRAM([#include ], [SSL_new(NULL)]), + [ + AC_MSG_RESULT([yes]) + $1 + ], [ + AC_MSG_RESULT([no]) + $2 + ]) + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + + AC_SUBST([OPENSSL_INCLUDES]) + AC_SUBST([OPENSSL_LIBS]) + AC_SUBST([OPENSSL_LDFLAGS]) +]) diff --git a/m4/ax_check_zlib.m4 b/m4/ax_check_zlib.m4 new file mode 100644 index 00000000..8ba2f5df --- /dev/null +++ b/m4/ax_check_zlib.m4 @@ -0,0 +1,124 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_ZLIB() +# +# DESCRIPTION +# +# This macro searches for an installed zlib library. If nothing was +# specified when calling configure, it searches first in /usr/local and +# then in /usr. If the --with-zlib=DIR is specified, it will try to find +# it in DIR/include/zlib.h and DIR/lib/libz.a. If --without-zlib is +# specified, the library is not searched at all. +# +# If either the header file (zlib.h) or the library (libz) is not found, +# the configuration exits on error, asking for a valid zlib installation +# directory or --without-zlib. +# +# The macro defines the symbol HAVE_LIBZ if the library is found. You +# should use autoheader to include a definition for this symbol in a +# config.h file. Sample usage in a C/C++ source is as follows: +# +# #ifdef HAVE_LIBZ +# #include +# #endif /* HAVE_LIBZ */ +# +# LICENSE +# +# Copyright (c) 2008 Loic Dachary +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB]) +AC_DEFUN([AX_CHECK_ZLIB], +# +# Handle user hints +# +[AC_MSG_CHECKING(if zlib is wanted) +AC_ARG_WITH(zlib, +[ --with-zlib=DIR root directory path of zlib installation [defaults to + /usr/local or /usr if not found in /usr/local] + --without-zlib to disable zlib usage completely], +[if test "$withval" != no ; then + AC_MSG_RESULT(yes) + if test -d "$withval" + then + ZLIB_HOME="$withval" + else + AC_MSG_WARN([Sorry, $withval does not exist, checking usual places]) + fi +else + AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(yes)]) + +ZLIB_HOME=/usr/local +if test ! -f "${ZLIB_HOME}/include/zlib.h" +then + ZLIB_HOME=/usr +fi + +# +# Locate zlib, if wanted +# +if test -n "${ZLIB_HOME}" +then + ZLIB_OLD_LDFLAGS=$LDFLAGS + ZLIB_OLD_CPPFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + AC_LANG_SAVE + AC_LANG_C + AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no]) + AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no]) + AC_LANG_RESTORE + if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes" + then + # + # If both library and header were found, use them + # + AC_CHECK_LIB(z, inflateEnd) + AC_MSG_CHECKING(zlib in ${ZLIB_HOME}) + AC_MSG_RESULT(ok) + else + # + # If either header or library was not found, revert and bomb + # + AC_MSG_CHECKING(zlib in ${ZLIB_HOME}) + LDFLAGS="$ZLIB_OLD_LDFLAGS" + CPPFLAGS="$ZLIB_OLD_CPPFLAGS" + AC_MSG_RESULT(failed) + AC_MSG_ERROR(either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib) + fi +fi + +]) diff --git a/m4/osx.m4 b/m4/osx.m4 new file mode 100644 index 00000000..35e9b6ef --- /dev/null +++ b/m4/osx.m4 @@ -0,0 +1,92 @@ +dnl Defines COREFOUNDATION_FRAMEWORK_LIBS. +AC_DEFUN([AX_CHECK_COREFOUNDATION_FRAMEWORK], +[ + AC_CACHE_CHECK([for CFRetain], + gt_cv_func_CFRetain, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_TRY_LINK([#include ], + [CFRetain(NULL)], + [gt_cv_func_CFRetain=yes], + [gt_cv_func_CFRetain=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFRetain = yes; then + AC_DEFINE([HAVE_COREFOUNDATION_FRAMEWORK], 1, + [Define to 1 if you have the MacOS X CoreFoundation framework.]) + fi + COREFOUNDATION_FRAMEWORK_LIBS= + if test $gt_cv_func_CFRetain = yes; then + COREFOUNDATION_FRAMEWORK_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + AC_SUBST([COREFOUNDATION_FRAMEWORK_LIBS]) +]) + +dnl Defines SYSTEMCONFIGURATION_FRAMEWORK_LIBS. +AC_DEFUN([AX_CHECK_SYSTEMCONFIGURATION_FRAMEWORK], +[ + AC_CACHE_CHECK([for SCDynamicStoreCreate], + gt_cv_func_SCDynamicStoreCreate, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,SystemConfiguration" + AC_TRY_LINK([#include ], + [SCDynamicStoreCreate(NULL, NULL, NULL, NULL)], + [gt_cv_func_SCDynamicStoreCreate=yes], + [gt_cv_func_SCDynamicStoreCreate=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_SCDynamicStoreCreate = yes; then + AC_DEFINE([HAVE_SYSTEMCONFIGURATION_FRAMEWORK], 1, + [Define to 1 if you have the MacOS X SystemConfiguration framework.]) + fi + SYSTEMCONFIGURATION_FRAMEWORK_LIBS= + if test $gt_cv_func_SCDynamicStoreCreate = yes; then + SYSTEMCONFIGURATION_FRAMEWORK_LIBS="-Wl,-framework -Wl,SystemConfiguration" + fi + AC_SUBST([SYSTEMCONFIGURATION_FRAMEWORK_LIBS]) +]) + +dnl Defines CORESERVICES_FRAMEWORK_LIBS. +AC_DEFUN([AX_CHECK_CORESERVICES_FRAMEWORK], +[ + AC_CACHE_CHECK([for CFNetworkCopyProxiesForURL], + gt_cv_func_CFNetworkCopyProxiesForURL, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreServices" + AC_TRY_LINK([#include ], + [CFNetworkCopyProxiesForURL(NULL, NULL)], + [gt_cv_func_CFNetworkCopyProxiesForURL=yes], + [gt_cv_func_CFNetworkCopyProxiesForURL=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFNetworkCopyProxiesForURL = yes; then + AC_DEFINE([HAVE_CORESERVICES_FRAMEWORK], 1, + [Define to 1 if you have the MacOS X CoreServices framework.]) + fi + CORESERVICES_FRAMEWORK_LIBS= + if test $gt_cv_func_CFNetworkCopyProxiesForURL = yes; then + CORESERVICES_FRAMEWORK_LIBS="-Wl,-framework -Wl,CoreServices" + fi + AC_SUBST([CORESERVICES_FRAMEWORK_LIBS]) +]) + +dnl Defines SECURITY_FRAMEWORK_LIBS. +AC_DEFUN([AX_CHECK_SECURITY_FRAMEWORK], +[ + AC_CACHE_CHECK([for SecKeychainItemFreeContent], + gt_cv_func_SecKeychainItemFreeContent, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,Security" + AC_TRY_LINK([#include ], + [SecKeychainItemFreeContent(NULL, NULL)], + [gt_cv_func_SecKeychainItemFreeContent=yes], + [gt_cv_func_SecKeychainItemFreeContent=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_SecKeychainItemFreeContent = yes; then + AC_DEFINE([HAVE_SECURITY_FRAMEWORK], 1, + [Define to 1 if you have the MacOS X Security framework.]) + fi + SECURITY_FRAMEWORK_LIBS= + if test $gt_cv_func_SecKeychainItemFreeContent = yes; then + SECURITY_FRAMEWORK_LIBS="-Wl,-framework -Wl,Security" + fi + AC_SUBST([SECURITY_FRAMEWORK_LIBS]) +]) + diff --git a/m4/ragel.m4 b/m4/ragel.m4 new file mode 100644 index 00000000..72ce4b94 --- /dev/null +++ b/m4/ragel.m4 @@ -0,0 +1,53 @@ +dnl Check for presence of the Ragel State Machine generator. +dnl +dnl This macro checks for the presence of the ragel tool in the system, +dnl and whether the ragel tool is absolutely needed for a complete +dnl build. +dnl +dnl To check for the need for Ragel, you have to provide the relative +dnl path of a source file generated through Ragel: if the file is +dnl present in the source tree, a missing ragel command will not cause +dnl the configure to abort. + +AC_DEFUN([_RAGEL_VARS], [ + AC_ARG_VAR([RAGEL], [Ragel generator command]) + AC_ARG_VAR([RAGELFLAGS], [Ragel generator flags]) +]) + +AC_DEFUN([CHECK_RAGEL], [ + AC_REQUIRE([_RAGEL_VARS]) + AC_CHECK_PROG([RAGEL], [ragel], [ragel], [no]) + + dnl We set RAGEL to false so that it would execute the "false" + dnl command if needed. + AS_IF([test x"$RAGEL" = x"no"], + [RAGEL=false], + AS_IF([test x"$2" != "x"], + [ragel_version=`$RAGEL --version | sed -n -e '1s:.*version \(@<:@0-9@:>@\.@<:@0-9@:>@\) .*:\1:p'` + ragel_version_compare=`echo $ragel_version | tr -d .` + ragel_wanted_version=`echo $2 | tr -d .` + AS_IF([test $ragel_version_compare -lt $ragel_wanted_version], + [AC_MSG_WARN([Found Ragel $ragel_version but Ragel $2 requested]) + RAGEL=false + ]) + ])) + + dnl Only test the need if not found + AS_IF([test x"$RAGEL" = x"false"], [ + AC_MSG_CHECKING([whether we need ragel to regenerate sources]) + AS_IF([test -a "${srcdir}/$1"], [ragel_needed=no], [ragel_needed=yes]) + AC_MSG_RESULT([$ragel_needed]) + + AS_IF([test x"$ragel_needed" = x"yes"], + [AC_MSG_ERROR([dnl +You need Ragel to build from development sources. +You can find Ragel at http://www.complang.org/ragel/dnl + ])]) + ]) +]) + +AC_DEFUN([CHECK_RAGEL_AM], [ + CHECK_RAGEL([$1], [$2]) + + AM_CONDITIONAL([HAVE_RAGEL], [test x"$RAGEL" != x"false"]) +]) diff --git a/mordor/Makefile.am b/mordor/Makefile.am new file mode 100644 index 00000000..c663efdc --- /dev/null +++ b/mordor/Makefile.am @@ -0,0 +1,87 @@ +SUBDIRS=. test tests examples + +AUTOMAKE_OPTIONS=nostdinc subdir-objects +AM_CPPFLAGS=$(OPENSSL_INCLUDES) $(BOOST_CPPFLAGS) +AM_CXXFLAGS=-Wall -Werror -fno-strict-aliasing + +lib_LTLIBRARIES=libmordor.la +libmordor_la_SOURCES= \ + assert.cpp \ + config.cpp \ + daemon.cpp \ + date_time.cpp \ + exception.cpp \ + fiber.cpp \ + fibersynchronization.cpp \ + http/auth.cpp \ + http/basic.cpp \ + http/broker.cpp \ + http/chunked.cpp \ + http/client.cpp \ + http/connection.cpp \ + http/digest.cpp \ + http/http.cpp \ + http/http_parser.cpp \ + http/multipart.cpp \ + http/oauth.cpp \ + http/proxy.cpp \ + http/server.cpp \ + iomanager_epoll.cpp \ + iomanager_kqueue.cpp \ + json.cpp \ + log.cpp \ + parallel.cpp \ + ragel.cpp \ + scheduler.cpp \ + semaphore.cpp \ + sleep.cpp \ + socket.cpp \ + socks.cpp \ + statistics.cpp \ + streams/buffer.cpp \ + streams/buffered.cpp \ + streams/cat.cpp \ + streams/fd.cpp \ + streams/file.cpp \ + streams/filter.cpp \ + streams/hash.cpp \ + streams/http.cpp \ + streams/limited.cpp \ + streams/memory.cpp \ + streams/null.cpp \ + streams/pipe.cpp \ + streams/random.cpp \ + streams/singleplex.cpp \ + streams/socket.cpp \ + streams/ssl.cpp \ + streams/std.cpp \ + streams/stream.cpp \ + streams/temp.cpp \ + streams/timeout.cpp \ + streams/test.cpp \ + streams/throttle.cpp \ + streams/transfer.cpp \ + streams/zlib.cpp \ + string.cpp \ + thread.cpp \ + timer.cpp \ + uri.cpp \ + workerpool.cpp \ + xml/xml_parser.cpp \ + zip.cpp +libmordor_la_CPPFLAGS=-I$(top_srcdir) -include mordor/pch.h + +SUFFIXES=.rl + +.rl.cpp: + $(RAGEL) $(RAGELFLAGS) -C $< -o $@ + +# Objects specifically depend on the PCH +$(libmordor_la_OBJECTS): pch.h.gch + +MOSTLYCLEANFILES=pch.h.gch +CLEANFILES=http/http_parser.cpp json.cpp uri.cpp xml/xml_parser.cpp +EXTRA_DIST=http/http_parser.rl json.rl uri.rl xml/xml_parser.rl + +pch.h.gch: pch.h + $(CXXCOMPILE) $(pic_flag) -x c++-header $< -o $@ diff --git a/mordor/endian.h b/mordor/endian.h index 8f361175..71abbbd1 100644 --- a/mordor/endian.h +++ b/mordor/endian.h @@ -12,6 +12,7 @@ #ifdef WINDOWS #include #elif defined(OSX) +#include #include #include #elif defined(FREEBSD) diff --git a/mordor/examples/Makefile.am b/mordor/examples/Makefile.am new file mode 100644 index 00000000..7638d17a --- /dev/null +++ b/mordor/examples/Makefile.am @@ -0,0 +1,30 @@ +AM_CPPFLAGS=$(OPENSSL_INCLUDES) $(BOOST_CPPFLAGS) -I$(top_srcdir) +AM_LDFLAGS= \ + $(OPENSSL_LDFLAGS) \ + $(BOOST_LDFLAGS) \ + $(CORESERVICES_FRAMEWORK_LIBS) \ + $(COREFOUNDATION_FRAMEWORK_LIBS) \ + $(SECURITY_FRAMEWORK_LIBS) \ + $(SYSTEMCONFIGURATION_FRAMEWORK_LIBS) +AM_CXXFLAGS=-Wall -Werror + +noinst_PROGRAMS=cat echoserver iombench tunnel udpstats wget + +cat_SOURCES=cat.cpp +cat_LDADD=../libmordor.la $(OPENSSL_LIBS) $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) + +echoserver_SOURCES=echoserver.cpp +echoserver_LDADD=../libmordor.la $(OPENSSL_LIBS) $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) + +iombench_SOURCES=iombench.cpp netbench.cpp +iombench_LDADD=../libmordor.la $(OPENSSL_LIBS) $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) + +tunnel_SOURCES=tunnel.cpp +tunnel_LDADD=../libmordor.la $(OPENSSL_LIBS) $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) + +udpstats_SOURCES=udpstats.cpp +udpstats_LDADD=../libmordor.la $(OPENSSL_LIBS) $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) + +wget_SOURCES=wget.cpp +wget_LDADD=../libmordor.la $(OPENSSL_LIBS) $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) + diff --git a/mordor/future.h b/mordor/future.h index 62896afb..46ecbf3f 100644 --- a/mordor/future.h +++ b/mordor/future.h @@ -4,6 +4,7 @@ #include +#include #include #include diff --git a/mordor/test/Makefile.am b/mordor/test/Makefile.am new file mode 100644 index 00000000..317003b0 --- /dev/null +++ b/mordor/test/Makefile.am @@ -0,0 +1,6 @@ +lib_LTLIBRARIES=libmordortest.la +libmordortest_la_SOURCES= \ + antxmllistener.cpp \ + stdoutlistener.cpp \ + test.cpp +libmordortest_la_CPPFLAGS=-I$(top_srcdir) diff --git a/mordor/tests/Makefile.am b/mordor/tests/Makefile.am new file mode 100644 index 00000000..f2bc9209 --- /dev/null +++ b/mordor/tests/Makefile.am @@ -0,0 +1,50 @@ +AM_CPPFLAGS=$(OPENSSL_INCLUDES) $(BOOST_CPPFLAGS) -I$(top_srcdir) +AM_LDFLAGS= \ + $(OPENSSL_LDFLAGS) \ + $(BOOST_LDFLAGS) \ + $(CORESERVICES_FRAMEWORK_LIBS) \ + $(COREFOUNDATION_FRAMEWORK_LIBS) \ + $(SECURITY_FRAMEWORK_LIBS) \ + $(SYSTEMCONFIGURATION_FRAMEWORK_LIBS) +AM_CXXFLAGS=-Wall -Werror + +check_PROGRAMS=run_tests +run_tests_SOURCES= \ + run_tests.cpp \ + buffer.cpp \ + buffered_stream.cpp \ + chunked_stream.cpp \ + coroutine.cpp \ + endian.cpp \ + fibers.cpp \ + fibersync.cpp \ + file_stream.cpp \ + fls.cpp \ + future.cpp \ + hmac.cpp \ + http_client.cpp \ + http_parser.cpp \ + http_server.cpp \ + iomanager.cpp \ + json.cpp \ + log.cpp \ + memory_stream.cpp \ + oauth.cpp \ + pipe_stream.cpp \ + scheduler.cpp \ + socket.cpp \ + ssl_stream.cpp \ + stream.cpp \ + string.cpp \ + temp_stream.cpp \ + thread.cpp \ + timeout_stream.cpp \ + timer.cpp \ + transfer_stream.cpp \ + uri.cpp \ + xml.cpp \ + zlib.cpp +run_tests_LDADD=../libmordor.la ../test/libmordortest.la $(OPENSSL_LIBS) $(BOOST_REGEX_LIB) $(BOOST_THREAD_LIB) + +check: + ./run_tests diff --git a/mordor/tests/fibersync.cpp b/mordor/tests/fibersync.cpp index 9a3084cb..fa17c86c 100644 --- a/mordor/tests/fibersync.cpp +++ b/mordor/tests/fibersync.cpp @@ -1,5 +1,7 @@ // Copyright (c) 2009 - Mozy, Inc. +#include + #include "mordor/fiber.h" #include "mordor/fibersynchronization.h" #include "mordor/test/test.h" diff --git a/mordor/tests/fls.cpp b/mordor/tests/fls.cpp index eabcc18c..b5549949 100644 --- a/mordor/tests/fls.cpp +++ b/mordor/tests/fls.cpp @@ -1,5 +1,7 @@ // Copyright (c) 2009 - Mozy, Inc. +#include + #include "mordor/fiber.h" #include "mordor/scheduler.h" #include "mordor/test/test.h" diff --git a/mordor/tests/future.cpp b/mordor/tests/future.cpp index 71024054..b1c3d50d 100644 --- a/mordor/tests/future.cpp +++ b/mordor/tests/future.cpp @@ -1,5 +1,7 @@ // Copyright (c) 2009 - Mozy, Inc. +#include + #include "mordor/future.h" #include "mordor/test/test.h" #include "mordor/workerpool.h" diff --git a/mordor/tests/xml.cpp b/mordor/tests/xml.cpp index c1f8f04d..7640922f 100644 --- a/mordor/tests/xml.cpp +++ b/mordor/tests/xml.cpp @@ -1,5 +1,7 @@ // Copyright (c) 2010 - Mozy, Inc. +#include + #include "mordor/xml/parser.h" #include "mordor/test/test.h" diff --git a/vmake b/vmake deleted file mode 100755 index 51190bc4..00000000 --- a/vmake +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -`which gmake make | head -1` -f $(dirname $0)/Makefile SRCDIR=$(dirname $0) "$@"