diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-12-06 15:05:31 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-12-06 15:05:31 +0100 |
commit | ca99540270f229485e64caed4aa949e129ddf1d8 (patch) | |
tree | a7fd9f49078ceb25c6f4d01f0c8bb8505f78dd7c | |
download | eina_graph-ca99540270f229485e64caed4aa949e129ddf1d8.zip eina_graph-ca99540270f229485e64caed4aa949e129ddf1d8.tar.gz |
Initial commit
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | COPYING | 26 | ||||
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | INSTALL | 370 | ||||
-rw-r--r-- | Makefile.am | 79 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | README | 25 | ||||
-rwxr-xr-x | autogen.sh | 15 | ||||
-rw-r--r-- | configure.ac | 256 | ||||
-rw-r--r-- | eina_graph.pc.in | 12 | ||||
-rw-r--r-- | m4/efl_attribute.m4 | 83 | ||||
-rw-r--r-- | m4/efl_binary.m4 | 71 | ||||
-rw-r--r-- | m4/efl_compiler.m4 | 90 | ||||
-rw-r--r-- | m4/efl_path_max.m4 | 36 | ||||
-rw-r--r-- | m4/project_init.m4 | 115 | ||||
-rw-r--r-- | src/Makefile.am | 30 | ||||
-rw-r--r-- | src/Makefile_lib.am | 32 | ||||
-rw-r--r-- | src/lib/Eina_Graph.h | 60 | ||||
-rw-r--r-- | src/lib/eina_graph_main.c | 92 | ||||
-rw-r--r-- | src/lib/eina_graph_private.h | 63 | ||||
-rw-r--r-- | src/tests/eina_graph_suite.c | 41 |
21 files changed, 1503 insertions, 0 deletions
@@ -0,0 +1 @@ +Jérémy Zurcher <jeremy@asynk.ch> @@ -0,0 +1,26 @@ +Copyright notice for eina_graph: + +Copyright (C) 2013 Jérémy Zurcher <jeremy@asynk.ch> + and various contributors (see AUTHORS). + +All rights reserved. + +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. + +THIS SOFTWARE IS PROVIDED "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 +COPYRIGHT HOLDER OR CONTRIBUTORS 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. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..540fe18 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,3 @@ +2013-12-06 Jérémy Zurcher (jeyzu) + + * Initial commit @@ -0,0 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2013 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. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `<wchar.h>' 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 limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/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.am b/Makefile.am new file mode 100644 index 0000000..8dd446c --- /dev/null +++ b/Makefile.am @@ -0,0 +1,79 @@ +ACLOCAL_AMFLAGS = -I m4 +AM_MAKEFLAGS = --no-print-directory +AM_DISTCHECK_CONFIGURE_FLAGS = \ + --with-tests=regular + +SUBDIRS = src + +MAINTAINERCLEANFILES = \ + Makefile.in \ + $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz \ + $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 \ + aclocal.m4 \ + config.guess \ + config.cache-env \ + config.h.in \ + config.sub \ + configure \ + compile \ + depcomp \ + install-sh \ + ltconfig \ + ltmain.sh \ + missing \ + mkinstalldirs \ + stamp-h.in \ + stamp-h \ + m4/libtool.m4 \ + m4/lt~obsolete.m4 \ + m4/ltoptions.m4 \ + m4/ltsugar.m4 \ + m4/ltversion.m4 + +EXTRA_DIST = \ + README \ + AUTHORS \ + COPYING \ + autogen.sh \ + eina_graph.pc.in \ + m4/efl_attribute.m4 \ + m4/efl_compiler.m4 \ + m4/efl_path_max.m4 \ + m4/efl_binary.m4 \ + m4/project_init.m4 + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = eina_graph.pc + + +# Unit tests + +if EINA_GRAPH_ENABLE_COVERAGE + +lcov-reset: + @rm -rf $(top_builddir)/coverage + @find $(top_builddir) -name "*.gcda" -delete + @lcov --zerocounters --directory $(top_builddir) + +lcov-report: + @mkdir $(top_builddir)/coverage + lcov --capture --compat-libtool --output-file $(top_builddir)/coverage/coverage.info --directory $(top_builddir) --base-directory $(top_srcdir)/src/ + lcov --remove $(top_builddir)/coverage/coverage.info '*.h' --output-file $(top_builddir)/coverage/coverage.cleaned.info + lcov --remove $(top_builddir)/coverage/coverage.cleaned.info '*/tests/*' --output-file $(top_builddir)/coverage/coverage.cleaned2.info + genhtml --branch-coverage -t "$(PACKAGE_STRING)" -o $(top_builddir)/coverage/html $(top_builddir)/coverage/coverage.cleaned2.info + @echo "Coverage Report at $(top_builddir)/coverage/html" + +endif + +if EINA_GRAPH_ENABLE_TESTS + +lcov-check: +if EINA_GRAPH_ENABLE_COVERAGE + @$(MAKE) $(AM_MAKEFLAGS) lcov-reset +endif + @$(MAKE) $(AM_MAKEFLAGS) check +if EINA_GRAPH_ENABLE_COVERAGE + @$(MAKE) $(AM_MAKEFLAGS) lcov-report +endif + +endif @@ -0,0 +1,3 @@ +eina_graph 0.0.1 + + * Initial version @@ -0,0 +1,25 @@ +eina_graph 0.0.1 + +****************************************************************************** + + FOR ANY ISSUES PLEASE EMAIL: + jeremy@asynk.ch + +****************************************************************************** + +Requirements: +------------- + +Must: + libc + eina 1.8 (part of EFL) + +------------------------------------------------------------------------------ + +COMPILING AND INSTALLING: + + $ ./configure + $ make +(as root unless you are installing in your users directories): + $ make install + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..fe644eb --- /dev/null +++ b/autogen.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +rm -rf autom4te.cache +rm -f aclocal.m4 ltmain.sh + +echo "Running autopoint..." ; autopoint -f || : +echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1 +echo "Running autoconf..." ; autoconf || exit 1 +echo "Running autoheader..." ; autoheader || exit 1 +echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 +echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 + +if [ -z "$NOCONFIGURE" ]; then + ./configure "$@" +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..cce8589 --- /dev/null +++ b/configure.ac @@ -0,0 +1,256 @@ +dnl Process this file with autoconf to produce a configure script. + +# get rid of that stupid cache mechanism +rm -f config.cache + +PROJECT_VERSION([0], [0], [1], [dev]) +AC_INIT([eina_graph], [v_ver], [jeremy@asynk.ch]) +AC_PREREQ([2.65]) +AC_CONFIG_SRCDIR([configure.ac]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_CONFIG_HEADERS([config.h]) +AH_TOP([ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ +]) +AH_BOTTOM([ +#endif /* __CONFIG_H__ */ +]) + +AM_INIT_AUTOMAKE([1.10 dist-bzip2]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +# this will speed up libtool checks +LT_PREREQ([2.2]) +LT_INIT([win32-dll]) +PROJECT_INIT + +### Default options with respect to host + +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +### Additional options to configure + +# Build profile + +AC_ARG_WITH([profile], + [AC_HELP_STRING([--with-profile=PROFILE], + [use the predefined build profile, one of: dev, debug and release. + @<:@default=dev@:>@])], + [build_profile=${withval}], + [build_profile=def_build_profile]) + +case "${build_profile}" in + dev|debug|release) + ;; + *) + AC_MSG_ERROR([Unknown build profile --with-profile=${build_profile}]) + ;; +esac + +# Tests + +AC_ARG_WITH([tests], + [AC_HELP_STRING([--with-tests=none|regular|coverage], + [choose testing method: regular, coverage or none. + @<:@default=none@:>@])], + [build_tests=${withval}], + [build_tests=auto]) + +want_coverage="no" +want_tests="no" +case "${build_tests}" in + auto) + if test "${build_profile}" = "dev"; then + want_tests="yes" + fi + ;; + regular) + want_tests="yes" + ;; + coverage) + want_tests="yes" + want_coverage="yes" + ;; + none) + ;; + *) + AC_MSG_ERROR([Unknown build tests option: --with-tests=${build_tests}]) + ;; +esac + +### Checks for programs + +AC_PROG_CC + +# pkg-config + +PKG_PROG_PKG_CONFIG + +# Check whether pkg-config supports Requires.private + +if $PKG_CONFIG --atleast-pkgconfig-version 0.22; then + pkgconfig_requires_private="Requires.private" +else + pkgconfig_requires_private="Requires" +fi +AC_SUBST(pkgconfig_requires_private) + +# lcov + +if test "${want_coverage}" = "yes" ; then + AC_CHECK_PROG([have_lcov], [lcov], [yes], [no]) + if test "x${have_lcov}" = "xyes" ; then + EINA_GRAPH_COV_CFLAGS="${EINA_GRAPH_COV_CFLAGS} -fprofile-arcs -ftest-coverage" + EINA_GRAPH_COV_LIBS="${EINA_GRAPH_COV_LIBS} -lgcov" + if test "x${prefer_assert}" = "xno"; then + EINA_GRAPH_COV_CFLAGS="${EINA_GRAPH_COV_CFLAGS} -DNDEBUG" + else + EINA_GRAPH_COV_CFLAGS="${EINA_GRAPH_COV_CFLAGS} -g -O0 -DDEBUG" + fi + else + AC_MSG_ERROR([lcov is not found]) + fi +fi + +AC_SUBST(EINA_GRAPH_COV_LIBS) +AC_SUBST(EINA_GRAPH_COV_CFLAGS) +AM_CONDITIONAL([EINA_GRAPH_ENABLE_COVERAGE], [test "${want_coverage}" = "yes"]) + +### Checks for libraries + +# check unit testing library + +if test "${want_tests}" = "yes"; then + PKG_CHECK_MODULES([CHECK], [check >= 0.9.5]) +fi +AM_CONDITIONAL([EINA_GRAPH_ENABLE_TESTS], [test "${want_tests}" = "yes"]) + +# Checks for library functions. + +# Evil library for compilation on Windows + +EINA_GRAPH_BUILD="" +case "$host_os" in + mingw*) + PKG_CHECK_MODULES([EVIL], [evil >= 1.0.0]) + AC_DEFINE([HAVE_EVIL], [1], [Set to 1 if Evil library is installed]) + requirement_eina_graph="evil ${requirement_eina_graph}" + EINA_GRAPH_BUILD="-DEINA_GRAPH_BUILD" + ;; +esac +AC_SUBST(EINA_GRAPH_BUILD) + +# Dependencies for the library + +requirement_eina_graph="eina >= 1.8.0 ${requirement_eina_graph}" +PKG_CHECK_MODULES([EFL], [ $requirement_eina_graph ]) + +AC_SUBST(requirement_eina_graph) + +# Checks for library functions. + +AM_GNU_GETTEXT_VERSION([0.18]) + +### Checks for header files + +EFL_CHECK_PATH_MAX + +### Checks for types + +### Checks for structures + +### Checks for compiler characteristics + +AM_PROG_CC_C_O +AC_C_CONST +AC_PROG_CC_STDC +AC_HEADER_STDC + +ELM_QUICKLAUNCH +EFL_ATTRIBUTE_VECTOR + +case "$host_os" in + mingw32ce*) + EINA_GRAPH_CFLAGS="${EINA_GRAPH_CFLAGS} -D_WIN32_WCE=0x0420" + ;; +esac + +EFL_CHECK_COMPILER_FLAGS([EINA_GRAPH], [-Wall -Wunused -Wextra -Wpointer-arith -Wno-missing-field-initializers -fvisibility=hidden -fdata-sections -ffunction-sections]) +EFL_CHECK_LINKER_FLAGS([EINA_GRAPH], [-fvisibility=hidden -fdata-sections -ffunction-sections -Wl,--gc-sections -fno-strict-aliasing -Wl,--as-needed -Wl,--no-copy-dt-needed-entries]) + +case "${build_profile}" in + dev) + dnl Check if compiler has a dodgy -Wshadow that emits errors when shadowing a global + AC_MSG_CHECKING([whether -Wshadow generates spurious warnings]) + CFLAGS_save="${CFLAGS}" + CFLAGS="${CFLAGS} -Werror -Wshadow" + AC_TRY_COMPILE([int x;], [int x = 0; (void)x;], + [AC_MSG_RESULT([no]) + EFL_CHECK_COMPILER_FLAGS([EFL], [-Wshadow])], + [AC_MSG_RESULT([yes])]) + CFLAGS="${CFLAGS_save}" + ;; + + debug) + ;; + + release) + ;; +esac + +# CPU architecture specific assembly + +### Checks for linker characteristics + +lt_enable_auto_import="" +case "$host_os" in + mingw*) + lt_enable_auto_import="-Wl,--enable-auto-import" + ;; +esac +AC_SUBST(lt_enable_auto_import) + +### Output + +AC_OUTPUT([ + eina_graph.pc + Makefile + src/Makefile +]) + +AC_OUTPUT + +##################################################################### +## Info + +echo +echo +echo +echo "------------------------------------------------------------------------" +echo "$PACKAGE $VERSION" +echo "------------------------------------------------------------------------" +echo +echo "Compilation................: make (or gmake)" +echo " CPPFLAGS.................: $CPPFLAGS" +echo " CFLAGS...................: $CFLAGS" +echo " LDFLAGS..................: $LDFLAGS" +echo +echo "Installation...............: make install (as root if needed, with 'su' or 'sudo')" +echo " prefix...................: $prefix" +echo " edje_cc..................: ${edje_cc}" +echo +echo "Configuration...: ${COLOR_OTHER}profile=${build_profile} os=${host_os}${COLOR_RESET}" +echo +if test "${want_coverage}" = "yes"; then +echo "Tests...........: make lcov-check" +else +if test "${want_tests}" = "yes"; then +echo "Tests...........: make check" +else +echo "Tests...........: no" +fi +fi +echo diff --git a/eina_graph.pc.in b/eina_graph.pc.in new file mode 100644 index 0000000..3bd6f75 --- /dev/null +++ b/eina_graph.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +vmaj=@VMAJ@ + +Name: eina_graph +Description: EFL-eina based graph algorithms collection +@pkgconfig_requires_private@: @requirement_eina_graph@ +Version: @VERSION@ +Libs: -L${libdir} -leina_graph +Cflags: -I${includedir}/eina_graph-@VMAJ@ diff --git a/m4/efl_attribute.m4 b/m4/efl_attribute.m4 new file mode 100644 index 0000000..4f31d93 --- /dev/null +++ b/m4/efl_attribute.m4 @@ -0,0 +1,83 @@ +dnl Copyright (C) 2011 Vincent Torri <vtorri at univ-evry dot fr> +dnl That code is public domain and can be freely used or copied. + +dnl Macros for checking if the compiler supports some __attribute__ uses + +dnl Usage: EFL_ATTRIBUTE_VECTOR +dnl call AC_DEFINE for HAVE_GCC_ATTRIBUTE_VECTOR if __attribute__((vector)) is available + +AC_DEFUN([EFL_ATTRIBUTE_VECTOR], +[ +AC_MSG_CHECKING([for __attribute__ ((vector))]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +typedef int v4si __attribute__ ((vector_size (16))); + ]], + [[ +if (sizeof(v4si) == 16) + return 0; +else + return -1; + ]])], + [have_attribute_vector="yes"], + [have_attribute_vector="no"]) +AC_MSG_RESULT([${have_attribute_vector}]) + +if test "x${have_attribute_vector}" = "xyes" ; then + AC_DEFINE([HAVE_GCC_ATTRIBUTE_VECTOR], [1], [Define to 1 if your compiler supports __attribute__ ((vector)).]) +fi +]) + +dnl Usage: EFL_ATTRIBUTE_ALWAYS_INLINE +dnl call AC_DEFINE for alway_inline if __attribute__((always_inline)) is available + +AC_DEFUN([EFL_ATTRIBUTE_ALWAYS_INLINE], +[ + +have_attribute_forceinline="no" + +AC_MSG_CHECKING([for __forceinline]) + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <windows.h> +static __forceinline void foo(void) {} + ]], + [[ + ]])], + [ + have_attribute_always_inline="yes" + have_attribute_forceinline="yes" + ], + [have_attribute_always_inline="no"]) + +AC_MSG_RESULT([${have_attribute_always_inline}]) + +if test "x${have_attribute_always_inline}" = "xno" ; then + AC_MSG_CHECKING([for __attribute__ ((__always_inline__))]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +static __attribute__((__always_inline__)) inline void foo(void) {} + ]], + [[ + ]])], + [have_attribute_always_inline="yes"], + [have_attribute_always_inline="no"]) + AC_MSG_RESULT([${have_attribute_always_inline}]) +fi + +if test "x${have_attribute_always_inline}" = "xyes" ; then + if test "x${have_attribute_forceinline}" = "xyes" ; then + AC_DEFINE([EFL_ALWAYS_INLINE], [__forceinline], [Macro declaring a function to always be inlined.]) + else + AC_DEFINE([EFL_ALWAYS_INLINE], [__attribute__ ((__always_inline__)) inline], [Macro declaring a function to always be inlined.]) + fi +else + AC_DEFINE([EFL_ALWAYS_INLINE], [static inline], [Macro declaring a function to always be inlined.]) +fi +]) + +dnl End of efl_attribute.m4 diff --git a/m4/efl_binary.m4 b/m4/efl_binary.m4 new file mode 100644 index 0000000..c774688 --- /dev/null +++ b/m4/efl_binary.m4 @@ -0,0 +1,71 @@ +dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr> +dnl That code is public domain and can be freely used or copied. + +dnl Macro that check if a binary is built or not + +dnl Usage: EFL_ENABLE_BIN(binary) +dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being transformed into _) +dnl Define have_binary (- is transformed into _) +dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being transformed into _) + +AC_DEFUN([EFL_ENABLE_BIN], +[ + +m4_pushdef([UP], m4_translit([[$1]], [-a-z], [_A-Z]))dnl +m4_pushdef([DOWN], m4_translit([[$1]], [-A-Z], [_a-z]))dnl + +have_[]m4_defn([DOWN])="yes" + +dnl configure option + +AC_ARG_ENABLE([$1], + [AC_HELP_STRING([--disable-$1], [disable building of ]DOWN)], + [ + if test "x${enableval}" = "xyes" ; then + have_[]m4_defn([DOWN])="yes" + else + have_[]m4_defn([DOWN])="no" + fi + ]) + +AC_MSG_CHECKING([whether to build ]DOWN[ binary]) +AC_MSG_RESULT([$have_[]m4_defn([DOWN])]) + +if test "x$have_[]m4_defn([DOWN])" = "xyes"; then + UP[]_PRG=DOWN[${EXEEXT}] +fi + +AC_SUBST(UP[]_PRG) + +AM_CONDITIONAL(BUILD_[]UP, test "x$have_[]m4_defn([DOWN])" = "xyes") + +AS_IF([test "x$have_[]m4_defn([DOWN])" = "xyes"], [$2], [$3]) + +]) + + +dnl Macro that check if a binary is built or not + +dnl Usage: EFL_WITH_BIN(package, binary, default_value) +dnl Call AC_SUBST(_binary) (_binary is the lowercase of binary, - being transformed into _ by default, or the value set by the user) + +AC_DEFUN([EFL_WITH_BIN], +[ + +m4_pushdef([DOWN], m4_translit([[$2]], [-A-Z], [_a-z]))dnl + +dnl configure option + +AC_ARG_WITH([$2], + [AC_HELP_STRING([--with-$2=PATH], [specify a specific path to ]DOWN[ @<:@default=$3@:>@])], + [_efl_with_binary=${withval}], + [_efl_with_binary=$(pkg-config --variable=prefix $1)/bin/$3]) + +DOWN=${_efl_with_binary} +AC_MSG_NOTICE(DOWN[ set to ${_efl_with_binary}]) + +with_binary_[]m4_defn([DOWN])=${_efl_with_binary} + +AC_SUBST(DOWN) + +]) diff --git a/m4/efl_compiler.m4 b/m4/efl_compiler.m4 new file mode 100644 index 0000000..32819f2 --- /dev/null +++ b/m4/efl_compiler.m4 @@ -0,0 +1,90 @@ +dnl Copyright (C) 2012 Vincent Torri <vincent dot torri at gmail dot com> +dnl This code is public domain and can be freely used or copied. + +dnl Macro that check if compiler of linker flags are available + + +dnl Macro that checks for a compiler flag availability +dnl +dnl _EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS) +dnl AC_SUBST : EFL_CFLAGS (EFL being replaced by its value) +dnl have_flag: yes or no. +AC_DEFUN([_EFL_CHECK_COMPILER_FLAGS], +[dnl +m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl + +dnl store in options -Wfoo if -Wno-foo is passed +option="m4_bpatsubst([[$2]], [-Wno-], [-W])" +CFLAGS_save="${CFLAGS}" +CFLAGS="${CFLAGS} ${option}" +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([whether the compiler supports $2]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]])], + [have_flag="yes"], + [have_flag="no"]) +AC_MSG_RESULT([${have_flag}]) + +AC_LANG_POP([C]) +CFLAGS="${CFLAGS_save}" +if test "x${have_flag}" = "xyes" ; then + UPEFL[_CFLAGS]="${UPEFL[_CFLAGS]} [$2]" +fi +AC_SUBST(UPEFL[_CFLAGS])dnl +m4_popdef([UPEFL])dnl +]) + +dnl EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS) +dnl Checks if FLAGS are supported and add to EFL_CLFAGS. +dnl +dnl It will first try every flag at once, if one fails will try them one by one. +AC_DEFUN([EFL_CHECK_COMPILER_FLAGS], +[dnl +_EFL_CHECK_COMPILER_FLAGS([$1], [$2]) +if test "${have_flag}" != "yes"; then +m4_foreach_w([flag], [$2], [_EFL_CHECK_COMPILER_FLAGS([$1], m4_defn([flag]))]) +fi +]) + + +dnl Macro that checks for a linker flag availability +dnl +dnl _EFL_CHECK_LINKER_FLAGS(EFL, FLAGS) +dnl AC_SUBST : EFL_LDFLAGS (EFL being replaced by its value) +dnl have_flag: yes or no +AC_DEFUN([_EFL_CHECK_LINKER_FLAGS], +[dnl +m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl + +LDFLAGS_save="${LDFLAGS}" +LDFLAGS="${LDFLAGS} $2" +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([whether the linker supports $2]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[]])], + [have_flag="yes"], + [have_flag="no"]) +AC_MSG_RESULT([${have_flag}]) + +AC_LANG_POP([C]) +LDFLAGS="${LDFLAGS_save}" +if test "x${have_flag}" = "xyes" ; then + UPEFL[_LDFLAGS]="${UPEFL[_LDFLAGS]} [$2]" +fi +AC_SUBST(UPEFL[_LDFLAGS])dnl +m4_popdef([UPEFL])dnl +]) + +dnl EFL_CHECK_LINKER_FLAGS(EFL, FLAGS) +dnl Checks if FLAGS are supported and add to EFL_CLFAGS. +dnl +dnl It will first try every flag at once, if one fails will try them one by one. +AC_DEFUN([EFL_CHECK_LINKER_FLAGS], +[dnl +_EFL_CHECK_LINKER_FLAGS([$1], [$2]) +if test "${have_flag}" != "yes"; then +m4_foreach_w([flag], [$2], [_EFL_CHECK_LINKER_FLAGS([$1], m4_defn([flag]))]) +fi +])dnl diff --git a/m4/efl_path_max.m4 b/m4/efl_path_max.m4 new file mode 100644 index 0000000..f57bfd2 --- /dev/null +++ b/m4/efl_path_max.m4 @@ -0,0 +1,36 @@ +dnl Check for PATH_MAX in limits.h, and define a default value if not found +dnl This is a workaround for systems not providing PATH_MAX, like GNU/Hurd + +dnl EFL_CHECK_PATH_MAX([DEFAULT_VALUE_IF_NOT_FOUND]) +dnl +dnl If PATH_MAX is not defined in <limits.h>, defines it +dnl to DEFAULT_VALUE_IF_NOT_FOUND if it exists, or fallback +dnl to using 4096 + +AC_DEFUN([EFL_CHECK_PATH_MAX], +[ + +default_max=m4_default([$1], "4096") +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([for PATH_MAX in limits.h]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <limits.h> + ]], + [[ +int i = PATH_MAX; + ]])], + [AC_MSG_RESULT([yes])], + [ + AC_DEFINE_UNQUOTED([PATH_MAX], + [${default_max}], + [default value since PATH_MAX is not defined]) + AC_MSG_RESULT([no: using ${default_max}]) + ]) + +AC_LANG_POP([C]) + +]) +dnl end of efl_path_max.m4 diff --git a/m4/project_init.m4 b/m4/project_init.m4 new file mode 100644 index 0000000..12645a8 --- /dev/null +++ b/m4/project_init.m4 @@ -0,0 +1,115 @@ + +dnl PROJECT_VERSION(major, minor, micro, release) +dnl This setup PROJECT version information and should be called BEFORE AC_INIT(). +dnl +dnl release parameter is 'dev' to use from SVN or libtool -release field. +dnl It may be empty if not dev (svn/live build) and no -release is to be used. +dnl +dnl Examples: +dnl PROJECT_VERSION(1, 7, 99, dev) +dnl PROJECT_VERSION(1, 7, 99, ver-1234) +dnl This will define couple of m4 symbols: +dnl v_maj = given major number (first parameter) +dnl v_min = given minor number (second parameter) +dnl v_mic = given micro number (third parameter) +dnl v_rev = if release, it's 0, otherwise it's dev_version. +dnl v_rel = if release, it's -release followed by fourth parameter, +dnl otherwise it's empty. (mostly for libtool) +dnl v_ver = if release, it's major.minor.micro, otherwise it's +dnl major.minor.micro.dev_version +dnl dev_version = development version (svn revision). +dnl def_build_profile = dev or release based on 'dev' release parameter. +AC_DEFUN([PROJECT_VERSION], +[dnl +m4_define([v_maj], [$1])dnl +m4_define([v_min], [$2])dnl +m4_define([v_mic], [$3])dnl +m4_define([dev_version], m4_esyscmd([(git rev-list --count HEAD 2>/dev/null || echo 0) | tr -d '\n']))dnl +m4_define([v_rev], m4_if($4, dev, [dev_version], [0]))dnl +m4_define([v_rel], m4_if($4, dev, [], m4_ifblank($4, [], [-release $4])))dnl +m4_define([def_build_profile], m4_if($4, dev, [dev], [release]))dnl +m4_define([v_ver], m4_if($4, dev, [v_maj.v_min.v_mic.v_rev], [v_maj.v_min.v_mic]))dnl +]) + +dnl PROJECT_COLOR +dnl will check if terminal supports color and if color is wanted by user. +dnl +dnl Used Variables: +dnl WANT_COLOR: if no, forces no color output. +dnl TERM: used to check if color should be enabled. +dnl +dnl Defined Variables: +dnl COLOR_YES: to be used in positive/yes conditions +dnl COLOR_NO: to be used in negative/no conditions +dnl COLOR_OTHER: to be used to highlight some other condition +dnl COLOR_RESET: to reset color +dnl want_color: yes or no +AC_DEFUN([PROJECT_COLOR], +[dnl +case "$TERM" in + xterm|xterm-color|Eterm|aterm|kterm|rxvt*|screen|gnome|interix) + want_color="${WANT_COLOR:-yes}" + ;; + *) + want_color="no" + ;; +esac + +if test "${want_color}" = "yes"; then + COLOR_YES=`echo -e "\033@<:@1;32m"` + COLOR_NO=`echo -e "\033@<:@1;31m"` + COLOR_OTHER=`echo -e "\033@<:@1;36m"` + COLOR_RESET=`echo -e "\033@<:@0m"` +else + COLOR_YES="" + COLOR_NO="" + COLOR_OTHER="" + COLOR_RESET="" +fi +]) + +dnl PROJECT_INIT() +dnl Will AC_DEFINE() the following: +dnl VMAJ = v_maj +dnl VMIN = v_min +dnl VMIC = v_mic +dnl VREV = v_rev +dnl Will AC_SUBST() the following: +dnl VMAJ = v_maj +dnl VMIN = v_min +dnl VMIC = v_mic +dnl PROJECT_LTLIBRARY_FLAGS="-no-undefined -version-info ..." +dnl PROJECT_LTMODULE_FLAGS="-no-undefined -avoid-version" +dnl Will define the following m4: +dnl lt_cur = libtool 'current' field of libtool's -version-info +dnl lt_rev = libtool 'revision' field of libtool's -version-info +dnl lt_age = libtool 'age' field of libtool's -version-info +AC_DEFUN([PROJECT_INIT], +[dnl +AC_REQUIRE([PROJECT_COLOR])dnl +AC_DEFINE_UNQUOTED([VMAJ], [v_maj], [Major version])dnl +AC_DEFINE_UNQUOTED([VMIN], [v_min], [Minor version])dnl +AC_DEFINE_UNQUOTED([VMIC], [v_mic], [Micro version])dnl +AC_DEFINE_UNQUOTED([VREV], [v_rev], [Revison])dnl +VMAJ=v_maj +VMIN=v_min +VMIC=v_mic +AC_SUBST([VMAJ])dnl +AC_SUBST([VMIN])dnl +AC_SUBST([VMIC])dnl +dnl +dnl TODO: warning - lt_cur: +dnl the previous code assumed v_maj + v_min, but this will be a problem when +dnl we bump v_maj and reset v_min. 1 + 7 == 7 + 1, so if v_maj is bumped +dnl we multiply it by 100. +m4_define([lt_cur], m4_if(m4_cmp(v_maj, 1), 0, m4_eval(v_maj + v_min), m4_eval(v_maj * 100 + v_min)))dnl +m4_define([lt_rev], v_mic)dnl +m4_define([lt_age], v_min)dnl +dnl +PROJECT_LTLIBRARY_FLAGS="-no-undefined -version-info lt_cur:lt_rev:lt_age v_rel" +AC_SUBST(PROJECT_LTLIBRARY_FLAGS)dnl +PROJECT_LTMODULE_FLAGS="-no-undefined -avoid-version" +AC_SUBST([PROJECT_LTMODULE_FLAGS])dnl +AC_MSG_NOTICE([Initialized AC_PACKAGE_NAME (AC_PACKAGE_VERSION) development=dev_version v_rel]) +]) + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..cf11d1c --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,30 @@ +AUTOMAKE_OPTIONS = subdir-objects + +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = +BUILT_SOURCES = + +DIST_SUBDIRS = +SUBDIRS = + +lib_LTLIBRARIES = +bin_PROGRAMS = +bin_SCRIPTS = +noinst_PROGRAMS = +check_PROGRAMS = +TESTS = +EXTRA_DIST = + +EINA_GRAPH_INSTALL_DATA_HOOK= + +AM_CPPFLAGS = -I. \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src/lib \ + -DPACKAGE_BIN_DIR=\"$(bindir)\" \ + -DPACKAGE_LIB_DIR=\"$(libdir)\" \ + -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ + @EFL_CFLAGS@ \ + @EINA_GRAPH_CFLAGS@ \ + @EINA_GRAPH_COV_CFLAGS@ + +include Makefile_lib.am diff --git a/src/Makefile_lib.am b/src/Makefile_lib.am new file mode 100644 index 0000000..f46abe0 --- /dev/null +++ b/src/Makefile_lib.am @@ -0,0 +1,32 @@ +### Libraries + +includesdir = $(includedir)/eina_graph-@VMAJ@ +includes_HEADERS = \ + lib/Eina_Graph.h + +lib_libeina_graph_la_SOURCES = \ + lib/eina_graph_main.c + +EXTRA_DIST += lib/eina_graph_private.h + +lib_LTLIBRARIES += lib/libeina_graph.la + +lib_libeina_graph_la_LIBADD = @EFL_LIBS@ @EINA_GRAPH_COV_LIBS@ +lib_libeina_graph_la_CFLAGS = +lib_libeina_graph_la_LDFLAGS = @EINA_GRAPH_LDFLAGS@ @PROJECT_LTLIBRARY_FLAGS@ + +### Unit tests + +if EINA_GRAPH_ENABLE_TESTS + +TESTS += tests/eina_graph_suite +check_PROGRAMS += tests/eina_graph_suite + +tests_eina_graph_suite_SOURCES = \ + tests/eina_graph_suite.c + +tests_eina_graph_suite_CFLAGS = @CHECK_CFLAGS@ +tests_eina_graph_suite_LDADD = @CHECK_LIBS@ lib/libeina_graph.la +tests_eina_graph_suite_DEPENDENCIES = + +endif diff --git a/src/lib/Eina_Graph.h b/src/lib/Eina_Graph.h new file mode 100644 index 0000000..2a444d8 --- /dev/null +++ b/src/lib/Eina_Graph.h @@ -0,0 +1,60 @@ +/* EINA_GRAPH - EFL graph processing library + * Copyright (C) 2013 Jérémy Zurcher + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software and its Copyright notices. In addition publicly + * documented acknowledgment must be given that this software has been used if no + * source code of this software is made available publicly. This includes + * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing + * documents or any documentation provided with any product containing this + * software. This License does not apply to any software that links to the + * libraries provided by this software (statically or dynamically), but only to + * the software provided. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _EINA_GRAPH_MAIN_H +#define _EINA_GRAPH_MAIN_H + +#include <eina_types.h> + +/** + * Initialize eina_graph. + * + * @return The init counter value. + * + * This function initializes eina_graph and increments a counter of the number + * of calls to it. The new counter value is then returned. + * + * @see eina_graph_shutdown(). + */ +EAPI int +eina_graph_init(void); + +/** + * Shutdown eina_graph. + * + * @return The init counter value. + * + * This function finalizes eina_graph and decrements a counter of the number + * of calls to eina_graph_init(). The new counter value is then returned. + * + * @see eina_graph_init(). + */ +EAPI int +eina_graph_shutdown(void); + +#endif /* _EINA_GRAPH_MAIN_H */ diff --git a/src/lib/eina_graph_main.c b/src/lib/eina_graph_main.c new file mode 100644 index 0000000..bd8be47 --- /dev/null +++ b/src/lib/eina_graph_main.c @@ -0,0 +1,92 @@ +/* EINA_GRAPH - EFL graph processing library + * Copyright (C) 2013 Jérémy Zurcher + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software and its Copyright notices. In addition publicly + * documented acknowledgment must be given that this software has been used if no + * source code of this software is made available publicly. This includes + * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing + * documents or any documentation provided with any product containing this + * software. This License does not apply to any software that links to the + * libraries provided by this software (statically or dynamically), but only to + * the software provided. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ + +int _eina_graph_log_dom = -1; +int _eina_graph_init_count = 0; + +#include <Eina.h> +#include "eina_graph_private.h" + +EAPI int +eina_graph_init(void) +{ + const char * log_dom = "eina_graph"; + + if (++_eina_graph_init_count != 1) + { + DBG("init count is %d.", _eina_graph_init_count); + return _eina_graph_init_count; + } + + if(!eina_init()) + goto shutdown_eina; + + _eina_graph_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_LIGHTBLUE); + if (_eina_graph_log_dom < 0) + { + EINA_LOG_ERR("Could not register log domain: %s", log_dom); + goto shutdown_log_dom; + } + + /* FIXME init stuff goes here */ + DBG("init..."); + + return _eina_graph_init_count; + +shutdown_log_dom: + eina_shutdown(); +shutdown_eina: + return --_eina_graph_init_count; +} + +EAPI int +eina_graph_shutdown(void) +{ + if (_eina_graph_init_count <= 0) + { + ERR("init count not greater than 0."); + return 0; + } + + if (--_eina_graph_init_count != 0) + { + DBG("init count is %d.", _eina_graph_init_count); + return _eina_graph_init_count; + } + + /* FIXME shutdown stuff goes here */ + DBG("shutdown..."); + + eina_shutdown(); + + return _eina_graph_init_count; +} diff --git a/src/lib/eina_graph_private.h b/src/lib/eina_graph_private.h new file mode 100644 index 0000000..a75ed6b --- /dev/null +++ b/src/lib/eina_graph_private.h @@ -0,0 +1,63 @@ +/* EINA_GRAPH - EFL graph processing library + * Copyright (C) 2013 Jérémy Zurcher + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software and its Copyright notices. In addition publicly + * documented acknowledgment must be given that this software has been used if no + * source code of this software is made available publicly. This includes + * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing + * documents or any documentation provided with any product containing this + * software. This License does not apply to any software that links to the + * libraries provided by this software (statically or dynamically), but only to + * the software provided. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _EINA_GRAPH_PRIVATE_H +#define _EINA_GRAPH_PRIVATE_H + +#include <Eina.h> + +#include "Eina_Graph.h" + +extern int _eina_graph_log_dom; + +#ifdef CRITICAL +#undef CRITICAL +#endif +#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eina_graph_log_dom, __VA_ARGS__) + +#ifdef ERR +#undef ERR +#endif +#define ERR(...) EINA_LOG_DOM_ERR(_eina_graph_log_dom, __VA_ARGS__) + +#ifdef WRN +#undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_eina_graph_log_dom, __VA_ARGS__) + +#ifdef INF +#undef INF +#endif +#define INF(...) EINA_LOG_DOM_INFO(_eina_graph_log_dom, __VA_ARGS__) + +#ifdef DBG +#undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_eina_graph_log_dom, __VA_ARGS__) + +#endif /* _EINA_GRAPH_PRIVATE_H */ diff --git a/src/tests/eina_graph_suite.c b/src/tests/eina_graph_suite.c new file mode 100644 index 0000000..79c02aa --- /dev/null +++ b/src/tests/eina_graph_suite.c @@ -0,0 +1,41 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include <check.h> +#include "Eina_Graph.h" + + +START_TEST (test_eina_graph_lib) +{ + ck_assert(eina_graph_init() == 1); + ck_assert(eina_graph_init() == 2); + + ck_assert(eina_graph_shutdown() == 1); + ck_assert(eina_graph_shutdown() == 0); +} +END_TEST + +Suite * +eina_graph_suite (void) +{ + Suite *s = suite_create ("Eina Graph"); + + TCase *tc_core = tcase_create ("Core"); + tcase_add_test (tc_core, test_eina_graph_lib); + suite_add_tcase (s, tc_core); + + return s; +} + +int +main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED) +{ + int number_failed; + Suite *s = eina_graph_suite(); + SRunner *sr = srunner_create(s); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return ((number_failed == 0) ? 0: 1); +} |