# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------
# Copyright © 2011, libcorkipset authors
# All rights reserved.
#
# Please see the COPYING file in this distribution for license details.
# ----------------------------------------------------------------------

#-----------------------------------------------------------------------
# Build the library

# Update the VERSION_INFO property below according to the following rules (taken
# from [1]):
#
# VERSION_INFO = current:revision:age
#
#   1. Start with a VERSION of `0:0:0` for each shared library.
#   2. Update VERSION_INFO only immediately before a public release of your
#      software.  More frequent updates are unnecessary, and only guarantee that
#      the current interface number gets larger faster.
#   3. If the library source code has changed at all since the last update, then
#      increment `revision` (`c:r:a` becomes `c:r+1:a`).
#   4. If any interfaces have been added, removed, or changed since the last
#      update, increment `current`, and set `revision` to 0.
#   5. If any interfaces have been added since the last public release, then
#      increment `age`.
#   6. If any interfaces have been removed or changed since the last public
#      release, then set `age` to 0.
#
# Note that changing `current` and setting `age` to 0 means that you are
# releasing a new backwards-incompatible version of the library.  This has
# implications on packaging, so once an API has stabilized, this should be a
# rare occurrence.
#
# [1] http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info

add_c_library(
    libcorkipset
    OUTPUT_NAME corkipset
    PKGCONFIG_NAME libcorkipset
    VERSION_INFO 2:0:1
    SOURCES
        libcorkipset/general.c
        libcorkipset/bdd/assignments.c
        libcorkipset/bdd/basics.c
        libcorkipset/bdd/bdd-iterator.c
        libcorkipset/bdd/expanded.c
        libcorkipset/bdd/reachable.c
        libcorkipset/bdd/read.c
        libcorkipset/bdd/write.c
        libcorkipset/map/allocation.c
        libcorkipset/map/inspection.c
        libcorkipset/map/ipv4_map.c
        libcorkipset/map/ipv6_map.c
        libcorkipset/map/storage.c
        libcorkipset/set/allocation.c
        libcorkipset/set/inspection.c
        libcorkipset/set/ipv4_set.c
        libcorkipset/set/ipv6_set.c
        libcorkipset/set/iterator.c
        libcorkipset/set/storage.c
    LIBRARIES
        libcork
)

#-----------------------------------------------------------------------
# Utility commands

add_c_executable(
    ipsetbuild
    OUTPUT_NAME ipsetbuild
    SOURCES ipsetbuild/ipsetbuild.c
    LOCAL_LIBRARIES
        libcorkipset
)

add_c_executable(
    ipsetcat
    OUTPUT_NAME ipsetcat
    SOURCES ipsetcat/ipsetcat.c
    LOCAL_LIBRARIES
        libcorkipset
)

add_c_executable(
    ipsetdot
    OUTPUT_NAME ipsetdot
    SOURCES ipsetdot/ipsetdot.c
    LOCAL_LIBRARIES
        libcorkipset
)
