Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update target to version 3 #716

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.21)

project(libsrtp2 VERSION 3.0.0 LANGUAGES C)
project(libsrtp3 VERSION 3.0.0 LANGUAGES C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -269,7 +269,7 @@ source_group("src\\Math" FILES ${MATH_SOURCES_C})
source_group("src\\Replay" FILES ${REPLAY_SOURCES_C})
source_group("include" FILES ${SOURCES_H})

add_library(srtp2
add_library(srtp3
${SOURCES_C}
${CIPHERS_SOURCES_C}
${HASHES_SOURCES_C}
Expand All @@ -278,12 +278,12 @@ add_library(srtp2
${REPLAY_SOURCES_C}
${SOURCES_H}
)
add_library(libSRTP::srtp2 ALIAS srtp2)
add_library(libSRTP::srtp3 ALIAS srtp3)

if (${ENABLE_WARNINGS})
target_set_warnings(
TARGET
"srtp2"
"srtp3"
ENABLE
${ENABLE_WARNINGS}
AS_ERRORS
Expand All @@ -293,60 +293,60 @@ endif()
if(${ENABLE_LTO})
target_enable_lto(
TARGET
"srtp2"
"srtp3"
ENABLE
ON)
endif()


set_target_properties(srtp2 PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(srtp3 PROPERTIES VERSION 1)

target_include_directories(srtp2 PUBLIC
target_include_directories(srtp3 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/crypto/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if(ENABLE_OPENSSL)
target_include_directories(srtp2 PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(srtp2 OpenSSL::Crypto)
target_include_directories(srtp3 PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(srtp3 OpenSSL::Crypto)
elseif(ENABLE_WOLFSSL)
target_include_directories(srtp2 PRIVATE ${WOLFSSL_INCLUDE_DIR})
target_link_libraries(srtp2 ${WOLFSSL_LIBRARY})
target_include_directories(srtp3 PRIVATE ${WOLFSSL_INCLUDE_DIR})
target_link_libraries(srtp3 ${WOLFSSL_LIBRARY})
elseif(ENABLE_MBEDTLS)
target_include_directories(srtp2 PRIVATE ${MBEDTLS_INCLUDE_DIRS})
target_link_libraries(srtp2 ${MBEDTLS_LIBRARIES})
target_include_directories(srtp3 PRIVATE ${MBEDTLS_INCLUDE_DIRS})
target_link_libraries(srtp3 ${MBEDTLS_LIBRARIES})
elseif(ENABLE_NSS)
target_include_directories(srtp2 PRIVATE ${NSS_INCLUDE_DIRS})
target_link_libraries(srtp2 ${NSS_LIBRARIES})
target_include_directories(srtp3 PRIVATE ${NSS_INCLUDE_DIRS})
target_link_libraries(srtp3 ${NSS_LIBRARIES})
endif()
if(WIN32)
target_link_libraries(srtp2 ws2_32)
target_compile_definitions(srtp2 PUBLIC _CRT_SECURE_NO_WARNINGS)
target_link_libraries(srtp3 ws2_32)
target_compile_definitions(srtp3 PUBLIC _CRT_SECURE_NO_WARNINGS)
endif()

install(TARGETS srtp2 DESTINATION lib
install(TARGETS srtp3 DESTINATION lib
EXPORT libSRTPTargets
)

install(FILES include/srtp.h crypto/include/auth.h
crypto/include/cipher.h
crypto/include/crypto_types.h
DESTINATION include/srtp2)
DESTINATION include/srtp3)

if(LIBSRTP_TEST_APPS)
enable_testing()

find_package(PCAP)
if (PCAP_FOUND)
add_executable(rtp_decoder test/rtp_decoder.c test/getopt_s.c test/util.c)
target_link_libraries(rtp_decoder srtp2 ${PCAP_LIBRARY})
target_link_libraries(rtp_decoder srtp3 ${PCAP_LIBRARY})
endif()

if(NOT (BUILD_SHARED_LIBS AND WIN32))
if(NOT USE_EXTERNAL_CRYPTO)
add_executable(aes_calc crypto/test/aes_calc.c test/getopt_s.c test/util.c)
target_include_directories(aes_calc PRIVATE test)
target_link_libraries(aes_calc srtp2)
target_link_libraries(aes_calc srtp3)
target_set_warnings(
TARGET
aes_calc
Expand All @@ -370,7 +370,7 @@ if(LIBSRTP_TEST_APPS)
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_include_directories(sha1_driver PRIVATE test)
target_link_libraries(sha1_driver srtp2)
target_link_libraries(sha1_driver srtp3)
add_test(sha1_driver sha1_driver -v)
endif()

Expand All @@ -383,7 +383,7 @@ if(LIBSRTP_TEST_APPS)
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_include_directories(datatypes_driver PRIVATE test)
target_link_libraries(datatypes_driver srtp2)
target_link_libraries(datatypes_driver srtp3)
add_test(datatypes_driver datatypes_driver -v)

add_executable(cipher_driver crypto/test/cipher_driver.c test/getopt_s.c)
Expand All @@ -395,7 +395,7 @@ if(LIBSRTP_TEST_APPS)
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_include_directories(cipher_driver PRIVATE test)
target_link_libraries(cipher_driver srtp2)
target_link_libraries(cipher_driver srtp3)
add_test(cipher_driver cipher_driver -v)

add_executable(kernel_driver crypto/test/kernel_driver.c test/getopt_s.c)
Expand All @@ -407,7 +407,7 @@ if(LIBSRTP_TEST_APPS)
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_include_directories(kernel_driver PRIVATE test)
target_link_libraries(kernel_driver srtp2)
target_link_libraries(kernel_driver srtp3)
add_test(kernel_driver kernel_driver -v)

add_executable(rdbx_driver test/rdbx_driver.c test/getopt_s.c test/ut_sim.c)
Expand All @@ -419,7 +419,7 @@ if(LIBSRTP_TEST_APPS)
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_include_directories(rdbx_driver PRIVATE test)
target_link_libraries(rdbx_driver srtp2)
target_link_libraries(rdbx_driver srtp3)
add_test(rdbx_driver rdbx_driver -v)

add_executable(replay_driver test/replay_driver.c test/ut_sim.c)
Expand All @@ -431,7 +431,7 @@ if(LIBSRTP_TEST_APPS)
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_include_directories(replay_driver PRIVATE test)
target_link_libraries(replay_driver srtp2)
target_link_libraries(replay_driver srtp3)
add_test(replay_driver replay_driver -v)

add_executable(roc_driver test/roc_driver.c test/ut_sim.c)
Expand All @@ -443,7 +443,7 @@ if(LIBSRTP_TEST_APPS)
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_include_directories(roc_driver PRIVATE test)
target_link_libraries(roc_driver srtp2)
target_link_libraries(roc_driver srtp3)
add_test(roc_driver roc_driver -v)
endif()

Expand All @@ -456,7 +456,7 @@ if(LIBSRTP_TEST_APPS)
${ENABLE_WARNINGS}
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_link_libraries(srtp_driver srtp2)
target_link_libraries(srtp_driver srtp3)
add_test(srtp_driver srtp_driver -v)

if(NOT (BUILD_SHARED_LIBS AND WIN32))
Expand All @@ -477,7 +477,7 @@ if(LIBSRTP_TEST_APPS)
elseif(ENABLE_NSS)
target_include_directories(test_srtp PRIVATE ${NSS_INCLUDE_DIRS})
endif()
target_link_libraries(test_srtp srtp2)
target_link_libraries(test_srtp srtp3)
add_test(test_srtp test_srtp)
endif()

Expand All @@ -491,7 +491,7 @@ if(LIBSRTP_TEST_APPS)
${ENABLE_WARNINGS}
AS_ERRORS
${ENABLE_WARNINGS_AS_ERRORS})
target_link_libraries(rtpw srtp2)
target_link_libraries(rtpw srtp3)
add_test(NAME rtpw_test
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/rtpw_test.sh -w ${CMAKE_CURRENT_SOURCE_DIR}/test/words.txt
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
Expand Down
76 changes: 38 additions & 38 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# runtest runs test applications
# runtest-valgrind runs test applications with valgrind
# test builds test applications
# libsrtp2.a static library implementing srtp
# libsrtp2.so shared library implementing srtp
# libsrtp3.a static library implementing srtp
# libsrtp3.so shared library implementing srtp
# clean removes objects, libs, and executables
# distribution cleans and builds a .tgz
# tags builds etags file from all .c and .h files
Expand Down Expand Up @@ -43,7 +43,7 @@ endif
all: test

runtest: test
@echo "running libsrtp2 test applications..."
@echo "running libsrtp3 test applications..."
$(FIND_LIBRARIES) crypto/test/cipher_driver$(EXE) -v >/dev/null
$(FIND_LIBRARIES) crypto/test/kernel_driver$(EXE) -v >/dev/null
$(FIND_LIBRARIES) test/test_srtp$(EXE) >/dev/null
Expand All @@ -55,14 +55,14 @@ runtest: test
ifeq (1, $(USE_EXTERNAL_CRYPTO))
cd test; $(CRYPTO_LIBDIR_FORWARD) $(abspath $(srcdir))/test/rtpw_test_gcm.sh -w $(abspath $(srcdir))/test/words.txt >/dev/null
endif
@echo "libsrtp2 test applications passed."
@echo "libsrtp3 test applications passed."
$(MAKE) -C crypto runtest

runtest-valgrind: test
@echo "running libsrtp2 test applications... (valgrind)"
@echo "running libsrtp3 test applications... (valgrind)"
valgrind --error-exitcode=1 --leak-check=full test/test_srtp$(EXE) -v >/dev/null
valgrind --error-exitcode=1 --leak-check=full test/srtp_driver$(EXE) -v >/dev/null
@echo "libsrtp2 test applications passed. (valgrind)"
@echo "libsrtp3 test applications passed. (valgrind)"

# makefile variables

Expand All @@ -78,7 +78,7 @@ srtp-fuzzer: CXXFLAGS += -g
LIBS = @LIBS@
LDFLAGS = -L. @LDFLAGS@
COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
SRTPLIB = -lsrtp2
SRTPLIB = -lsrtp3
PCAP_LIB = @PCAP_LIB@

AR = @AR@
Expand All @@ -103,7 +103,7 @@ libdir = @libdir@
bindir = @bindir@

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libsrtp2.pc
pkgconfig_DATA = libsrtp3.pc

SHAREDLIBVERSION = 1
ifneq (,$(or $(findstring linux,@host@), $(findstring gnu,@host@)))
Expand All @@ -113,7 +113,7 @@ SHAREDLIBSUFFIXNOVER = so
SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER).$(SHAREDLIBVERSION)
else ifneq (,$(or $(findstring cygwin,@host@), $(findstring mingw,@host@)))
SHAREDLIB_DIR = $(bindir)
SHAREDLIB_LDFLAGS = -shared -Wl,--out-implib,libsrtp2.dll.a
SHAREDLIB_LDFLAGS = -shared -Wl,--out-implib,libsrtp3.dll.a
SHAREDLIBVERSION =
SHAREDLIBSUFFIXNOVER = dll
SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER)
Expand Down Expand Up @@ -154,26 +154,26 @@ kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \

cryptobj = $(ciphers) $(hashes) $(math) $(kernel) $(replay)

# libsrtp2.a (implements srtp processing)
# libsrtp3.a (implements srtp processing)

srtpobj = srtp/srtp.o

libsrtp2.a: $(srtpobj) $(cryptobj) $(gdoi)
$(AR) cr libsrtp2.a $^
$(RANLIB) libsrtp2.a
libsrtp3.a: $(srtpobj) $(cryptobj) $(gdoi)
$(AR) cr libsrtp3.a $^
$(RANLIB) libsrtp3.a

libsrtp2.$(SHAREDLIBSUFFIX): $(srtpobj) $(cryptobj) $(gdoi)
libsrtp3.$(SHAREDLIBSUFFIX): $(srtpobj) $(cryptobj) $(gdoi)
$(CC) -shared -o $@ $(SHAREDLIB_LDFLAGS) \
$^ $(LDFLAGS) $(LIBS)
if [ -n "$(SHAREDLIBVERSION)" ]; then \
ln -sfn $@ libsrtp2.$(SHAREDLIBSUFFIXNOVER); \
ln -sfn $@ libsrtp3.$(SHAREDLIBSUFFIXNOVER); \
fi

shared_library: libsrtp2.$(SHAREDLIBSUFFIX)
shared_library: libsrtp3.$(SHAREDLIBSUFFIX)

libsrtp2.so: $(srtpobj) $(cryptobj)
$(CC) -shared -Wl,-soname,libsrtp2.so \
-o libsrtp2.so $^ $(LDFLAGS)
libsrtp3.so: $(srtpobj) $(cryptobj)
$(CC) -shared -Wl,-soname,libsrtp3.so \
-o libsrtp3.so $^ $(LDFLAGS)

# test applications
ifneq (1, $(USE_EXTERNAL_CRYPTO))
Expand All @@ -193,7 +193,7 @@ ifeq (1, $(HAVE_PCAP))
testapp += test/rtp_decoder$(EXE)
endif

$(testapp): libsrtp2.a
$(testapp): libsrtp3.a

test/rtpw$(EXE): test/rtpw.c test/rtp.c test/util.c test/getopt_s.c \
crypto/math/datatypes.c
Expand Down Expand Up @@ -264,47 +264,47 @@ tags:
etags */*.[ch] */*/*.[ch]


# documentation - the target libsrtp2doc builds html documentation
# documentation - the target libsrtp3doc builds html documentation

libsrtp2doc:
libsrtp3doc:
$(MAKE) -C doc

# fuzzer

srtp-fuzzer: libsrtp2.a
srtp-fuzzer: libsrtp3.a
$(MAKE) -C fuzzer

.PHONY: clean superclean distclean install

install:
$(INSTALL) -d $(DESTDIR)$(includedir)/srtp2
$(INSTALL) -d $(DESTDIR)$(includedir)/srtp3
$(INSTALL) -d $(DESTDIR)$(libdir)
cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp2
cp $(srcdir)/crypto/include/cipher.h $(DESTDIR)$(includedir)/srtp2
cp $(srcdir)/crypto/include/auth.h $(DESTDIR)$(includedir)/srtp2
cp $(srcdir)/crypto/include/crypto_types.h $(DESTDIR)$(includedir)/srtp2
if [ -f libsrtp2.a ]; then cp libsrtp2.a $(DESTDIR)$(libdir)/; fi
if [ -f libsrtp2.dll.a ]; then cp libsrtp2.dll.a $(DESTDIR)$(libdir)/; fi
if [ -f libsrtp2.$(SHAREDLIBSUFFIX) ]; then \
cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp3
cp $(srcdir)/crypto/include/cipher.h $(DESTDIR)$(includedir)/srtp3
cp $(srcdir)/crypto/include/auth.h $(DESTDIR)$(includedir)/srtp3
cp $(srcdir)/crypto/include/crypto_types.h $(DESTDIR)$(includedir)/srtp3
if [ -f libsrtp3.a ]; then cp libsrtp3.a $(DESTDIR)$(libdir)/; fi
if [ -f libsrtp3.dll.a ]; then cp libsrtp3.dll.a $(DESTDIR)$(libdir)/; fi
if [ -f libsrtp3.$(SHAREDLIBSUFFIX) ]; then \
$(INSTALL) -d $(DESTDIR)$(SHAREDLIB_DIR); \
cp libsrtp2.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/; \
cp libsrtp2.$(SHAREDLIBSUFFIXNOVER) $(DESTDIR)$(SHAREDLIB_DIR)/; \
cp libsrtp3.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/; \
cp libsrtp3.$(SHAREDLIBSUFFIXNOVER) $(DESTDIR)$(SHAREDLIB_DIR)/; \
if [ -n "$(SHAREDLIBVERSION)" ]; then \
ln -sfn libsrtp2.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/libsrtp2.$(SHAREDLIBSUFFIXNOVER); \
ln -sfn libsrtp3.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/libsrtp3.$(SHAREDLIBSUFFIXNOVER); \
fi; \
fi
$(INSTALL) -d $(DESTDIR)$(pkgconfigdir)
cp $(top_builddir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/

uninstall:
rm -f $(DESTDIR)$(includedir)/srtp2/*.h
rm -f $(DESTDIR)$(libdir)/libsrtp2.*
-rmdir $(DESTDIR)$(includedir)/srtp2
rm -f $(DESTDIR)$(includedir)/srtp3/*.h
rm -f $(DESTDIR)$(libdir)/libsrtp3.*
-rmdir $(DESTDIR)$(includedir)/srtp3
rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA)

clean:
rm -rf $(cryptobj) $(srtpobj) TAGS \
libsrtp2.a libsrtp2.so libsrtp2.dll.a core *.core test/core
libsrtp3.a libsrtp3.so libsrtp3.dll.a core *.core test/core
for a in * */* */*/*; do \
if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
done;
Expand Down
Loading
Loading