Skip to content

Commit

Permalink
Windows: Support --cygwin64 to configure.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 16, 2022
1 parent d1eb59d commit 4a4b3d4
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 39 deletions.
6 changes: 3 additions & 3 deletions trunk/auto/auto_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ if [ $SRS_CROSS_BUILD = YES ]; then
else
srs_undefine_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_WINDOWS = YES ]; then
srs_define_macro "SRS_WINDOWS" $SRS_AUTO_HEADERS_H
if [ $SRS_CYGWIN64 = YES ]; then
srs_define_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_WINDOWS" $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_OSX = YES ]; then
srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
Expand Down
43 changes: 17 additions & 26 deletions trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -314,28 +314,17 @@ OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$re
#####################################################################################
# Detect CPU archs.
#####################################################################################
OS_IS_LOONGARCH64=$(g++ -dM -E - </dev/null |grep '#define __loongarch64 1' -q && echo YES)
OS_IS_MIPS64=$(g++ -dM -E - </dev/null |grep '#define __mips64 1' -q && echo YES)
OS_IS_LOONGARCH64=$(gcc -dM -E - </dev/null |grep '#define __loongarch64 1' -q && echo YES)
OS_IS_MIPS64=$(gcc -dM -E - </dev/null |grep '#define __mips64 1' -q && echo YES)
OS_IS_LOONGSON=$(uname -r |grep -q loongson && echo YES)
OS_IS_X86_64=$(g++ -dM -E - </dev/null |grep -q '#define __x86_64 1' && echo YES)
echo "OS_IS_LOONGARCH64:$OS_IS_LOONGARCH64, OS_IS_MIPS64:$OS_IS_MIPS64, OS_IS_LOONGSON:$OS_IS_LOONGSON, OS_IS_X86_64:$OS_IS_X86_64"

#####################################################################################
# For windows with cygwin64
#####################################################################################
OS_IS_WINDOWS_CYGWIN64=NO
function windows_cygwin64_prepare()
{
# TODO auto install cygwin64 tools ?
if [[ $OSTYPE == cygwin ]]; then
OS_IS_WINDOWS_CYGWIN64=YES
SRS_WINDOWS=YES
fi

return 0
}

windows_cygwin64_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "windows_cygwin64 prepare failed, ret=$ret"; exit $ret; fi
OS_IS_X86_64=$(gcc -dM -E - </dev/null |grep -q '#define __x86_64 1' && echo YES)
OS_IS_RISCV=$(gcc -dM -E - </dev/null |grep -q '#define __riscv 1' && echo YES)
if [[ ! -z $OS_IS_LOONGARCH64 ]]; then echo -n "OS_IS_LOONGARCH64:$OS_IS_LOONGARCH64, "; fi
if [[ ! -z $OS_IS_MIPS64 ]]; then echo -n "OS_IS_MIPS64:$OS_IS_MIPS64, "; fi
if [[ ! -z $OS_IS_LOONGSON ]]; then echo -n "OS_IS_LOONGSON:$OS_IS_LOONGSON, "; fi
if [[ ! -z $OS_IS_X86_64 ]]; then echo -n "OS_IS_X86_64:$OS_IS_X86_64, "; fi
if [[ ! -z $OS_IS_RISCV ]]; then echo -n "OS_IS_RISCV:$OS_IS_RISCV, "; fi
echo "ok"

#####################################################################################
# for Centos, auto install tools by yum
Expand Down Expand Up @@ -383,7 +372,7 @@ function _srs_link_file()
# directly build on arm/mips, for example, pi or cubie,
# export srs-librtmp
# others is invalid.
if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO && $SRS_CROSS_BUILD = NO && $OS_IS_WINDOWS_CYGWIN64 = NO ]]; then
if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO && $SRS_CROSS_BUILD = NO && $SRS_CYGWIN64 = NO ]]; then
echo "Your OS `uname -s` is not supported."
exit 1
fi
Expand Down Expand Up @@ -420,7 +409,7 @@ if [[ $SRS_OSX == YES ]]; then
_ST_MAKE=darwin-debug && _ST_OBJ="DARWIN_`uname -r`_DBG"
fi
# for windows/cygwin
if [[ $OS_IS_WINDOWS_CYGWIN64 = YES ]]; then
if [[ $SRS_CYGWIN64 = YES ]]; then
_ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG"
fi
# For Ubuntu, the epoll detection might be fail.
Expand Down Expand Up @@ -672,13 +661,15 @@ if [[ $SRS_RTC == YES ]]; then
rm -rf libsrtp-2-fit &&
cp -R ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit . &&
cd libsrtp-2-fit &&
patch -p0 crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/gcc10-01.patch &&
patch -p0 crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/config.guess-02.patch &&
if [[ $OS_IS_RISCV == YES ]]; then
patch -p0 crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/config.guess-02.patch;
fi &&
$SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_3RD_SRTP2_STORE_PATH} &&
make ${SRS_JOBS} && make install &&
cp -rf ${SRS_3RD_SRTP2_STORE_PATH} ${SRS_OBJS}
)
fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build libsrtp failed, ret=$ret"; exit $ret; fi
fi

#####################################################################################
Expand Down Expand Up @@ -855,7 +846,7 @@ if [[ $SRS_SRT == YES ]]; then
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --with-compiler-prefix=$SRT_COMPILER_PREFIX"
fi
# For windows build, over cygwin
if [[ $SRS_WINDOWS == YES ]]; then
if [[ $SRS_CYGWIN64 == YES ]]; then
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix"
fi

Expand Down
18 changes: 16 additions & 2 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ SRS_GPROF=NO # Performance test: gprof
#
################################################################
# Preset options
# TODO: FIXME: Remove the CPU arch, as we should detect by gcc automatically.
SRS_X86_X64=NO # For x86_64 servers
SRS_OSX=NO # For OSX/macOS PC.
SRS_WINDOWS=NO # For Cygwin/Windows PC or servers.
SRS_CYGWIN64=NO # For Cygwin64 for Windows PC or servers.
SRS_CROSS_BUILD=NO # For cross build, for example, on Ubuntu.
# For cross build, whether armv7 or armv8(aarch64).
SRS_CROSS_BUILD_ARMV7=NO
Expand Down Expand Up @@ -120,6 +121,7 @@ Presets:
--x86-64, --x86-x64 For x86/x64 cpu, common pc and servers. Default: $(value2switch $SRS_X86_X64)
--cross-build Enable cross-build, please set bellow Toolchain also. Default: $(value2switch $SRS_CROSS_BUILD)
--osx Enable build for OSX/Darwin AppleOS. Default: $(value2switch $SRS_OSX)
--cygwin64 Use cygwin64 to build for Windows. Default: $(value2switch $SRS_CYGWIN64)
Features:
-h, --help Print this message and exit 0.
Expand Down Expand Up @@ -255,6 +257,7 @@ function parse_user_option() {
--x86-x64) SRS_X86_X64=YES ;;
--x86-64) SRS_X86_X64=YES ;;
--osx) SRS_OSX=YES ;;
--cygwin64) SRS_CYGWIN64=YES ;;

--without-srtp-nasm) SRS_SRTP_ASM=NO ;;
--with-srtp-nasm) SRS_SRTP_ASM=YES ;;
Expand Down Expand Up @@ -423,8 +426,13 @@ do
done

function apply_auto_options() {
# Detect OS option for cygwin64.
if [[ $OSTYPE == cygwin ]]; then
SRS_CYGWIN64=YES
fi

# set default preset if not specifies
if [[ $SRS_X86_X64 == NO && $SRS_OSX == NO && $SRS_CROSS_BUILD == NO ]]; then
if [[ $SRS_X86_X64 == NO && $SRS_OSX == NO && $SRS_CROSS_BUILD == NO && $SRS_CYGWIN64 == NO ]]; then
SRS_X86_X64=YES; opt="--x86-x64 $opt";
fi

Expand Down Expand Up @@ -474,6 +482,11 @@ function apply_auto_options() {
echo "Disable SRTP-ASM, because NASM is disabled."
SRS_SRTP_ASM=NO
fi

if [[ $SRS_CYGWIN64 == YES && $SRS_SANITIZER == YES ]]; then
echo "Disable address sanitizer for cygwin64"
SRS_SANITIZER=NO
fi
}

if [ $help = yes ]; then
Expand Down Expand Up @@ -563,6 +576,7 @@ function regenerate_options() {
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug-stats=$(value2switch $SRS_DEBUG_STATS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cross-build=$(value2switch $SRS_CROSS_BUILD)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer=$(value2switch $SRS_SANITIZER)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cygwin64=$(value2switch $SRS_CYGWIN64)"
if [[ $SRS_CROSS_BUILD_ARCH != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --arch=$SRS_CROSS_BUILD_ARCH"; fi
if [[ $SRS_CROSS_BUILD_CPU != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --cpu=$SRS_CROSS_BUILD_CPU"; fi
if [[ $SRS_CROSS_BUILD_HOST != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --host=$SRS_CROSS_BUILD_HOST"; fi
Expand Down
6 changes: 3 additions & 3 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ CppStd="-ansi"
if [[ $SRS_CXX11 == YES ]]; then
CppStd="-std=c++11"
fi
if [[ $SRS_WINDOWS == YES ]]; then
if [[ $SRS_CYGWIN64 == YES ]]; then
CppStd="-std=gnu++11"
fi
if [[ $SRS_CXX14 == YES ]]; then
Expand Down Expand Up @@ -202,7 +202,7 @@ if [[ $SRS_GCOV == YES ]]; then
fi

# For FFMPEG/RTC on Linux.
if [[ $SRS_OSX != YES && $SRS_WINDOWS != YES && $SRS_RTC == YES && $SRS_FFMPEG_FIT == YES ]]; then
if [[ $SRS_OSX != YES && $SRS_CYGWIN64 != YES && $SRS_RTC == YES && $SRS_FFMPEG_FIT == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -lrt";
fi

Expand All @@ -221,7 +221,7 @@ if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES ]]; then
fi

# For FFMPEG/RTC on windows.
if [[ $SRS_WINDOWS == YES && $SRS_FFMPEG_FIT == YES ]]; then
if [[ $SRS_CYGWIN64 == YES && $SRS_FFMPEG_FIT == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -lbcrypt";
fi

Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_latest_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void srs_build_features(stringstream& ss)
{
if (SRS_OSX_BOOL) {
ss << "&os=mac";
} else if (SRS_WINDOWS_BOOL) {
} else if (SRS_CYGWIN64_BOOL) {
ss << "&os=windows";
} else {
ss << "&os=linux";
Expand Down
6 changes: 3 additions & 3 deletions trunk/src/app/srs_app_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <algorithm>
#if !defined(SRS_OSX) && !defined(SRS_WINDOWS)
#if !defined(SRS_OSX) && !defined(SRS_CYGWIN64)
#include <sys/inotify.h>
#endif
using namespace std;
Expand Down Expand Up @@ -191,7 +191,7 @@ srs_error_t SrsInotifyWorker::start()
{
srs_error_t err = srs_success;

#if !defined(SRS_OSX) && !defined(SRS_WINDOWS)
#if !defined(SRS_OSX) && !defined(SRS_CYGWIN64)
// Whether enable auto reload config.
bool auto_reload = _srs_config->inotify_auto_reload();
if (!auto_reload && _srs_in_docker && _srs_config->auto_reload_for_docker()) {
Expand Down Expand Up @@ -271,7 +271,7 @@ srs_error_t SrsInotifyWorker::cycle()
{
srs_error_t err = srs_success;

#if !defined(SRS_OSX) && !defined(SRS_WINDOWS)
#if !defined(SRS_OSX) && !defined(SRS_CYGWIN64)
string config_path = _srs_config->config();
string config_file = srs_path_basename(config_path);
string k8s_file = "..data";
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/protocol/srs_protocol_st.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ srs_error_t srs_st_init()

// Select the best event system available on the OS. In Linux this is
// epoll(). On BSD it will be kqueue.
#ifdef SRS_WINDOWS
#ifdef SRS_CYGWIN64
if (st_set_eventsys(ST_EVENTSYS_SELECT) == -1) {
return srs_error_new(ERROR_ST_SET_SELECT, "st enable st failed, current is %s", st_get_eventsys_name());
}
Expand Down

0 comments on commit 4a4b3d4

Please sign in to comment.