Skip to content

Commit a272b7c

Browse files
committed
Add msys support
This adds some support for compiling directly with MSYS. (The native versions of MSYSTEM like ucrt64, mingw64, and mingw32 are already supported). It doesn't work well yet. Signed-off-by: Corey Minyard <[email protected]>
1 parent c852627 commit a272b7c

File tree

11 files changed

+76
-20
lines changed

11 files changed

+76
-20
lines changed

README.rst

+12-2
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,8 @@ think the problem is in the gensio code.
11671167
Building on Windows
11681168
===================
11691169

1170-
The gensio library can be built under Windows using mingw64. The following
1171-
things don't work::
1170+
The gensio library can be built under Windows using mingw64 or ucrt64.
1171+
The following things don't work::
11721172

11731173
* sctp
11741174
* pam
@@ -1180,6 +1180,16 @@ sound.
11801180

11811181
The cm108gpio uses native windows interfaces, so udev is not required.
11821182

1183+
You can compile under msys, which is there primarily to support file
1184+
transfers with gtlssync and gtlssh. It uses the native Windows
1185+
interfaces MDNS and sound, but those are not well tested. Outside of
1186+
that, things may or may not work. In particular, gtlsshd will not
1187+
compile. You can specify serial ports with //./COM<n>, but there are
1188+
issues. Python maybe sort of works. Tests do not run. For anything
1189+
besides running gtlssh and doing file transfers, you should probably
1190+
use the native version. These things can be fixed, but they will take
1191+
some work.
1192+
11831193
The Windows built-in MDNS interfaces are used, so you don't need avahi
11841194
or DNSSD. You will need to install the pcre library if you want
11851195
regular expressions in it.

c++/swig/pygensio/tests/runtest.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fi
5555

5656
if ${PYTHON_MODE}; then
5757
export PYTHONPATH="${BUILDDIR}/tests:${BUILDDIR}/c++/swig/pygensio:${BUILDDIR}/c++/swig/pygensio/.libs:${SRCDIR}/c++/swig/pygensio/test:${BUILDDIR}/glib/c++/swig/pygensio:${BUILDDIR}/glib/c++/swig/pygensio/.libs:${BUILDDIR}/tcl/c++/swig/pygensio:${BUILDDIR}/tcl/c++/swig/pygensio/.libs:${TEST_BUILDDIR}"
58-
if [ ! -z "$MSYSTEM" ]; then
58+
if [ ! -z "$MSYSTEM" -a "$MSYSTEM" != "MSYS" ]; then
5959
# PYTHONPATH is separated by ; on windows
6060
export PYTHONPATH=`echo ${PYTHONPATH} | tr ':' ';'`
6161
fi
@@ -69,7 +69,7 @@ else
6969
fi
7070

7171
# We need to put the DLL in PATH for MSYS on Windows
72-
if [ ! -z "$MSYSTEM" ]; then
72+
if [ ! -z "$MSYSTEM" -a "$MSYSTEM" != "MSYS" ]; then
7373
export PATH="${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/c++/lib/.libs:${BUILDDIR}/c++/swig/pygensio/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/glib/c++/swig/pygensio/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/tcl/c++/swig/pygensio/.libs:$PATH"
7474
else
7575
export LD_LIBRARY_PATH=${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/c++/swig/pygensio/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/glib/c++/pygensio/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/tcl/c++/pygensio/.libs:${BUILDDIR}/c++/lib/.libs
@@ -80,7 +80,7 @@ fi
8080

8181
if ${PRINT_MODE}; then
8282
echo export PYTHONPATH="${PYTHONPATH}"
83-
if [ ! -z "$MSYSTEM" ]; then
83+
if [ ! -z "$MSYSTEM" -a "$MSYSTEM" != "MSYS" ]; then
8484
echo export PATH=${PATH}
8585
elif test `uname` != Darwin; then
8686
echo export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"

configure.ac

+23-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,21 @@ HAVE_UCRED=0
103103

104104
HAVE_WIN32SOUND=0
105105

106+
DISABLE_GO=no
107+
108+
DISABLE_GTLSSHD=no
109+
110+
#
106111
case $target_os in
112+
msys)
113+
OSH_LIBS="$OSH_LIBS -ldl"
114+
uucp_locking_flag=no
115+
flock_locking_flag=no
116+
PYTHON_UNDEF_FLAG=-no-undefined
117+
HAVE_WIN32SOUND=1
118+
DISABLE_GO=yes
119+
DISABLE_GTLSSHD=yes
120+
;;
107121
mingw*)
108122
OSH_LIBS="$OSH_LIBS -lws2_32 -liphlpapi -lgdi32 -lbcrypt"
109123
OSH_LIBS="$OSH_LIBS -lsecur32 -luserenv -lwtsapi32"
@@ -1193,6 +1207,10 @@ if test $trymdns = yes -a ${HAVE_AVAHI} = 0 -a ${HAVE_DNSSD} = 0 \
11931207
if test "$HAVE_WINMDNS" = "1"; then
11941208
mdns=$default_all
11951209
MDNS_LIBS="-ldnsapi"
1210+
if test $target_os = msys; then
1211+
# We are using Windows MDNS on MSYS2
1212+
MDNS_LIBS="-liphlpapi $MDNS_LIBS"
1213+
fi
11961214
HAVE_MDNS=1
11971215
fi
11981216
fi
@@ -2080,7 +2098,7 @@ AC_SUBST(PYTHON_UNDEF_LIBS)
20802098
PYTHON_EXECUTABLE="${PYTHON}"
20812099
AC_SUBST(PYTHON_EXECUTABLE)
20822100

2083-
if test $available_swig_vernum -ge 40100 -a "${enable_shared}" = yes; then
2101+
if test $available_swig_vernum -ge 40100 -a "${enable_shared}" = yes -a $DISABLE_GO != yes; then
20842102
trygo=yes
20852103
else
20862104
trygo=no
@@ -2152,7 +2170,9 @@ GTLSSYNCMAN=
21522170
GTLSSHDMAN=
21532171
GTLSSH_KEYGENMAN=
21542172
if test $HAVE_OPENSSL -eq 1; then
2155-
if test $HAVE_PAM -eq 1; then
2173+
if test $DISABLE_GTLSSHD = yes; then
2174+
echo "gltsshD disabled"
2175+
elif test $HAVE_PAM -eq 1; then
21562176
GTLSSHD="gtlsshd\$(EXEEXT)"
21572177
GTLSSHDMAN=gtlsshd.8
21582178
elif test "$version_type" = "windows"; then
@@ -2212,7 +2232,7 @@ AC_SUBST(HAVE_UNIX)
22122232
AC_DEFINE_UNQUOTED([HAVE_UNIX], [$HAVE_UNIX], [Enable unix socket file handling])
22132233

22142234
GENSIO_PTY_HELPER=
2215-
if test "$version_type" = "windows"; then
2235+
if test "$version_type" = "windows" -a "$target_os" != "msys"; then
22162236
# We have PTY support for windows.
22172237
HAVE_PTY=1
22182238
GENSIO_PTY_HELPER="gensio_pty_helper\$(EXEEXT)"

lib/gensio_cm108gpio.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,13 @@ hid_close(int fd)
233233
close(fd);
234234
}
235235

236-
#elif defined(_WIN32)
236+
#elif defined(_WIN32) || defined(__MSYS__)
237237

238238
#include <windows.h>
239239
#include <setupapi.h>
240240
#include <hidsdi.h>
241241
#include <wchar.h>
242+
#include <wctype.h>
242243

243244
/* Stolen from hidclass.h. */
244245
static const GUID my_GUID_DEVINTERFACE_HID =

lib/gensio_pty.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/* This code handles running a child process using a pty. */
99

10-
#ifdef linux
10+
#if defined(linux) || defined(__MSYS__)
1111
#define _GNU_SOURCE /* Get ptsname_r(). */
1212
#endif
1313

lib/mdns.c

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
#else
1919
#include <sys/socket.h>
2020
#include <netinet/in.h>
21+
#include <unistd.h>
22+
#ifdef __MSYS__
23+
typedef struct in6_addr IN6_ADDR;
24+
#include <iphlpapi.h>
25+
#endif
2126
#endif
2227
#include <gensio/gensio.h>
2328
#include <gensio/gensio_list.h>

lib/net_stdsock.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1493,15 +1493,15 @@ gensio_stdsock_mcast_add(struct gensio_iod *iod,
14931493
case AF_INET:
14941494
{
14951495
struct sockaddr_in *a = (struct sockaddr_in *) ai->ai_addr;
1496-
#ifdef _WIN32
1496+
#if defined(_WIN32) || defined(__MSYS__)
14971497
struct ip_mreq m;
14981498
#else
14991499
struct ip_mreqn m;
15001500
#endif
15011501

15021502
memset(&m, 0, sizeof(m));
15031503
m.imr_multiaddr = a->sin_addr;
1504-
#ifndef _WIN32
1504+
#if !defined(_WIN32) && !defined(__MSYS__)
15051505
m.imr_address.s_addr = INADDR_ANY;
15061506
m.imr_ifindex = iface;
15071507
#endif
@@ -1564,15 +1564,15 @@ gensio_stdsock_mcast_del(struct gensio_iod *iod,
15641564
case AF_INET:
15651565
{
15661566
struct sockaddr_in *a = (struct sockaddr_in *) ai->ai_addr;
1567-
#ifdef _WIN32
1567+
#if defined(_WIN32) || defined(__MSYS__)
15681568
struct ip_mreq m;
15691569
#else
15701570
struct ip_mreqn m;
15711571
#endif
15721572

15731573
memset(&m, 0, sizeof(m));
15741574
m.imr_multiaddr = a->sin_addr;
1575-
#ifndef _WIN32
1575+
#if !defined(_WIN32) && !defined(__MSYS__)
15761576
m.imr_address.s_addr = INADDR_ANY;
15771577
m.imr_ifindex = iface;
15781578
#endif
@@ -2206,8 +2206,10 @@ gensio_setup_listen_socket(struct gensio_os_funcs *o,
22062206
#endif
22072207
}else if (family == AF_UNIX)
22082208
protocol = GENSIO_NET_PROTOCOL_UNIX;
2209+
#ifdef IPPROTO_SCTP
22092210
else if (sockproto == IPPROTO_SCTP)
22102211
protocol = GENSIO_NET_PROTOCOL_SCTP;
2212+
#endif
22112213
else if (sockproto == 0 && socktype == SOCK_DGRAM)
22122214
protocol = GENSIO_NET_PROTOCOL_UDP;
22132215
else if (sockproto == 0 && socktype == SOCK_STREAM)

lib/os_osops.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: LGPL-2.1-only
66
*/
77

8-
#ifdef linux
8+
#if defined(linux) || defined(__MSYS__)
99
#define _XOPEN_SOURCE 600 /* Get posix_openpt() and friends. */
1010
#define _GNU_SOURCE /* Get ptsname_r(). */
1111
#endif
@@ -3302,9 +3302,11 @@ gensio_unix_get_bufcount(struct gensio_os_funcs *o,
33023302
#endif
33033303
break;
33043304

3305+
#ifdef TIOCOUTQ
33053306
case GENSIO_OUT_BUF:
33063307
rv = ioctl(fd, TIOCOUTQ, &count);
33073308
break;
3309+
#endif
33083310

33093311
default:
33103312
return GE_NOTSUP;

lib/os_unix.c

+4
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ init_mutex(unsigned int flags, lock_type *mutex)
106106

107107
pthread_mutexattr_init(&mattr);
108108
if (flags & GENSIO_OS_FUNCS_FLAG_PRIO_INHERIT) {
109+
#ifdef PTHREAD_PRIO_INHERIT
109110
int rv = pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
110111
if (rv)
111112
return rv;
113+
#else
114+
return GE_NOTSUP;
115+
#endif
112116
}
113117
pthread_mutex_init(mutex, &mattr);
114118
return 0;

tests/runtest.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fi
5555

5656
if ${PYTHON_MODE}; then
5757
export PYTHONPATH="${BUILDDIR}/swig/python:${BUILDDIR}/swig/python/.libs:${BUILDDIR}/glib/swig/python:${BUILDDIR}/glib/swig/python/.libs:${BUILDDIR}/tcl/swig/python:${BUILDDIR}/tcl/swig/python/.libs:${TEST_BUILDDIR}"
58-
if [ ! -z "$MSYSTEM" ]; then
58+
if [ ! -z "$MSYSTEM" -a "$MSYSTEM" != "MSYS" ]; then
5959
# PYTHONPATH is separated by ; on windows
6060
export PYTHONPATH=`echo ${PYTHONPATH} | tr ':' ';'`
6161
fi
@@ -69,7 +69,7 @@ else
6969
fi
7070

7171
# We need to put the DLL in PATH for MSYS on Windows
72-
if [ ! -z "$MSYSTEM" ]; then
72+
if [ ! -z "$MSYSTEM" -a "$MSYSTEM" != "MSYS" ]; then
7373
export PATH="${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/swig/python/.libs:$PATH"
7474
else
7575
export LD_LIBRARY_PATH=${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/swig/python/.libs
@@ -80,7 +80,7 @@ fi
8080

8181
if ${PRINT_MODE}; then
8282
echo export PYTHONPATH="${PYTHONPATH}"
83-
if [ ! -z "$MSYSTEM" ]; then
83+
if [ ! -z "$MSYSTEM" -a "$MSYSTEM" != "MSYS" ]; then
8484
echo export PATH="${PATH}"
8585
else
8686
echo export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"

tools/gtlssh.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747

4848
unsigned int debug;
4949

50+
/*
51+
* Permissions are not easily fixable on msys, so checking for private
52+
* doesn't work ATM. It always reads 755 for directories and 644 for
53+
* files. You can fix it with icacls, but it still won't display
54+
* properly.
55+
*/
56+
#ifdef __MSYS__
57+
static bool do_check_private = false;
58+
#else
59+
static bool do_check_private = true;
60+
#endif
61+
5062
struct gdata {
5163
struct gensio_os_funcs *o;
5264
struct gensio_waiter *waiter;
@@ -741,7 +753,7 @@ lookup_certinfo(struct gensio_os_funcs *o,
741753
if (err)
742754
goto out_err;
743755

744-
err = checkout_file(glogger, NULL, keyname, false, true);
756+
err = checkout_file(glogger, NULL, keyname, false, do_check_private);
745757
if (err)
746758
goto out_err;
747759

@@ -2064,7 +2076,7 @@ main(int argc, char *argv[])
20642076
return 1;
20652077
}
20662078

2067-
err = checkout_file(glogger, NULL, tlssh_dir, true, true);
2079+
err = checkout_file(glogger, NULL, tlssh_dir, true, do_check_private);
20682080
if (err)
20692081
return 1;
20702082

0 commit comments

Comments
 (0)