summaryrefslogtreecommitdiffstats
path: root/src/crypto/mac
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-03 03:34:00 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-03 03:34:00 +0100
commiteabbb5eb368df3ff606a472bd96a4a4077a214d8 (patch)
tree211ad12c827a823949b1c5c3cc9dc4343e85ca01 /src/crypto/mac
parente7893cc54fb0eaba0cfe88ff44cf52a3f7ff2200 (diff)
downloadfastd-eabbb5eb368df3ff606a472bd96a4a4077a214d8.tar
fastd-eabbb5eb368df3ff606a472bd96a4a4077a214d8.zip
Improve build system for ciphers and MACs as well
Diffstat (limited to 'src/crypto/mac')
-rw-r--r--src/crypto/mac/CMakeLists.txt56
-rw-r--r--src/crypto/mac/ghash/CMakeLists.txt20
-rw-r--r--src/crypto/mac/ghash/builtin/CMakeLists.txt3
3 files changed, 43 insertions, 36 deletions
diff --git a/src/crypto/mac/CMakeLists.txt b/src/crypto/mac/CMakeLists.txt
index 7f8664c..eb3c903 100644
--- a/src/crypto/mac/CMakeLists.txt
+++ b/src/crypto/mac/CMakeLists.txt
@@ -1,34 +1,58 @@
-set(MACS "")
+add_library(macs STATIC "${CMAKE_CURRENT_BINARY_DIR}/macs.c")
-if(WITH_MAC_GHASH)
- list(APPEND MACS ghash)
-endif(WITH_MAC_GHASH)
+function(fastd_mac name)
+ string(REPLACE - _ name_ "${name}")
+ string(TOUPPER "${name_}" NAME)
+
+ set(WITH_MAC_${NAME} TRUE CACHE BOOL "Include the ${name} MAC")
+
+ if(WITH_MAC_${NAME})
+ set_property(GLOBAL APPEND PROPERTY FASTD_MACS ${name})
+ endif(WITH_MAC_${NAME})
+endfunction(fastd_mac)
+
+
+macro(fastd_mac_impl mac name)
+ string(REPLACE - _ mac_ "${mac}")
+ string(TOUPPER "${mac_}" MAC)
+
+ set_property(GLOBAL APPEND PROPERTY FASTD_MAC_${MAC}_IMPLS ${name})
+
+ fastd_module(mac "MAC implementation" "${mac} ${name}" ${ARGN})
+endmacro(fastd_mac_impl)
+
+macro(fastd_mac_impl_include_directories mac name)
+ fastd_module_include_directories(mac "${mac} ${name}" ${ARGN})
+endmacro(fastd_mac_impl_include_directories)
+
+macro(fastd_mac_impl_link_libraries mac name)
+ fastd_module_link_libraries(mac "${mac} ${name}" ${ARGN})
+endmacro(fastd_mac_impl_link_libraries)
+
+
+add_subdirectory(ghash)
-set(MAC_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/macs.c")
set(MAC_DEFINITIONS "")
set(MAC_IMPLS "")
set(MAC_LIST "")
+get_property(MACS GLOBAL PROPERTY FASTD_MACS)
foreach(mac ${MACS})
- add_subdirectory(${mac})
-
- list(APPEND MAC_SOURCES ${IMPL_SOURCES})
+ string(REPLACE - _ mac_ "${mac}")
+ string(TOUPPER "${mac_}" MAC)
- set(MAC_LIST "${MAC_LIST}\n{\"${MAC_NAME}\", mac_${mac}_impls},")
- set(MAC_IMPLS "${MAC_IMPLS}\nstatic const fastd_mac_t *const mac_${mac}_impls[] = {")
+ set(MAC_LIST "${MAC_LIST}\n{\"${mac}\", mac_${mac_}_impls},")
+ set(MAC_IMPLS "${MAC_IMPLS}\nstatic const fastd_mac_t *const mac_${mac_}_impls[] = {")
+ get_property(IMPLS GLOBAL PROPERTY FASTD_MAC_${MAC}_IMPLS)
foreach(impl ${IMPLS})
- set(MAC_DEFINITIONS "${MAC_DEFINITIONS}\nextern const fastd_mac_t fastd_mac_${mac}_${impl};")
- set(MAC_IMPLS "${MAC_IMPLS}&fastd_mac_${mac}_${impl}, ")
+ set(MAC_DEFINITIONS "${MAC_DEFINITIONS}\nextern const fastd_mac_t fastd_mac_${mac_}_${impl};")
+ set(MAC_IMPLS "${MAC_IMPLS}&fastd_mac_${mac_}_${impl}, ")
endforeach(impl)
set(MAC_IMPLS "${MAC_IMPLS}NULL};")
endforeach(mac)
-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/macs.c.in ${CMAKE_CURRENT_BINARY_DIR}/macs.c)
-
-
-set(MAC_SOURCES "${MAC_SOURCES}" PARENT_SCOPE)
diff --git a/src/crypto/mac/ghash/CMakeLists.txt b/src/crypto/mac/ghash/CMakeLists.txt
index 7d697e8..7d44b8a 100644
--- a/src/crypto/mac/ghash/CMakeLists.txt
+++ b/src/crypto/mac/ghash/CMakeLists.txt
@@ -1,18 +1,2 @@
-set(IMPLS "")
-
-if(WITH_MAC_GHASH_BUILTIN)
- list(APPEND IMPLS builtin)
-endif(WITH_MAC_GHASH_BUILTIN)
-
-set(IMPL_SOURCES "")
-
-foreach(impl ${IMPLS})
- add_subdirectory(${impl})
-
- list(APPEND IMPL_SOURCES $<TARGET_OBJECTS:mac_ghash_${impl}>)
-endforeach(impl)
-
-
-set(MAC_NAME "ghash" PARENT_SCOPE)
-set(IMPLS "${IMPLS}" PARENT_SCOPE)
-set(IMPL_SOURCES "${IMPL_SOURCES}" PARENT_SCOPE)
+fastd_mac(ghash)
+add_subdirectory(builtin)
diff --git a/src/crypto/mac/ghash/builtin/CMakeLists.txt b/src/crypto/mac/ghash/builtin/CMakeLists.txt
index b7b862a..f5cb130 100644
--- a/src/crypto/mac/ghash/builtin/CMakeLists.txt
+++ b/src/crypto/mac/ghash/builtin/CMakeLists.txt
@@ -1,4 +1,3 @@
-add_library(mac_ghash_builtin OBJECT
+fastd_mac_impl(ghash builtin
ghash_builtin.c
)
-set_property(TARGET mac_ghash_builtin PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")