Skip to content

Commit 5d084cd

Browse files
committed
Implement a definitive cygwin target for libzmq.
1 parent d2bacdf commit 5d084cd

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

Makefile.am

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ src_libzmq_la_LDFLAGS = \
208208
-version-info @LTVER@ \
209209
@LIBZMQ_EXTRA_LDFLAGS@
210210
else
211+
if ON_CYGWIN
212+
src_libzmq_la_LDFLAGS = \
213+
-no-undefined \
214+
-avoid-version \
215+
-version-info @LTVER@ \
216+
@LIBZMQ_EXTRA_LDFLAGS@
217+
else
211218
if ON_ANDROID
212219
src_libzmq_la_LDFLAGS = \
213220
-avoid-version \
@@ -227,6 +234,7 @@ src_libzmq_la_LDFLAGS = \
227234
endif
228235
endif
229236
endif
237+
endif
230238

231239
src_libzmq_la_CPPFLAGS =
232240
src_libzmq_la_CXXFLAGS = @LIBZMQ_EXTRA_CXXFLAGS@
@@ -507,6 +515,7 @@ tests_test_atomics_SOURCES = tests/test_atomics.cpp
507515
tests_test_atomics_LDADD = src/libzmq.la
508516

509517
if !ON_MINGW
518+
if !ON_CYGWIN
510519
test_apps += \
511520
tests/test_shutdown_stress \
512521
tests/test_pair_ipc \
@@ -539,6 +548,7 @@ test_apps += tests/test_fork
539548
tests_test_fork_SOURCES = tests/test_fork.cpp
540549
tests_test_fork_LDADD = src/libzmq.la
541550

551+
endif
542552
endif
543553
endif
544554

README.cygwin.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
libzmq-cygwin
2+
=============
3+
4+
Definitive build fixes for cygwin (See https://github.com/zeromq/pyzmq/issues/113 for partial solution)
5+
6+
What's changed:
7+
./Makefile.am Add cygwin-specific target mostly the same as mingw
8+
./configure.ac Add cygwin-specific target mostly the same as mingw
9+
./tests/testutil.hpp Lengthen socket timeout to 121 seconds
10+
11+
What's new:
12+
./README.cygwin.md This file
13+
./builds/cygwin Folder for cygwin-specific build files
14+
./builds/cygwin/Makefile.cygwin Makefile for cygwin targets
15+

builds/cygwin/Makefile.cygwin

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
CC=gcc
2+
CFLAGS=-Wall -Os -g -DDLL_EXPORT -DFD_SETSIZE=4096 -DZMQ_USE_SELECT -I.
3+
LIBS=-lws2_32
4+
5+
OBJS = ctx.o reaper.o dist.o err.o \
6+
clock.o metadata.o random.o \
7+
object.o own.o \
8+
io_object.o io_thread.o \
9+
lb.o fq.o \
10+
address.o tcp_address.o ipc_address.o \
11+
ipc_connecter.o ipc_listener.o \
12+
tcp_connecter.o tcp_listener.o \
13+
mailbox.o msg.o mtrie.o \
14+
pipe.o precompiled.o proxy.o \
15+
signaler.o stream_engine.o \
16+
thread.o trie.o \
17+
ip.o tcp.o \
18+
pgm_socket.o pgm_receiver.o pgm_sender.o \
19+
raw_decoder.o raw_encoder.o \
20+
v1_decoder.o v1_encoder.o v2_decoder.o v2_encoder.o \
21+
socket_base.o session_base.o options.o \
22+
req.o rep.o push.o pull.o pub.o sub.o pair.o \
23+
dealer.o router.o xpub.o xsub.o stream.o \
24+
poller_base.o select.o poll.o epoll.o kqueue.o devpoll.o \
25+
curve_client.o curve_server.o \
26+
mechanism.o null_mechanism.o plain_client.o plain_server.o \
27+
zmq.o zmq_utils.o
28+
29+
%.o: ../../src/%.cpp
30+
$(CC) -c -o $@ $< $(CFLAGS)
31+
32+
%.o: ../../perf/%.cpp
33+
$(CC) -c -o $@ $< $(CFLAGS)
34+
35+
all: libzmq.dll
36+
37+
perf: inproc_lat.exe inproc_thr.exe local_lat.exe local_thr.exe remote_lat.exe remote_thr.exe
38+
39+
libzmq.dll: $(OBJS)
40+
g++ -shared -o $@ $^ -Wl,--out-implib,-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive [email protected] -Wl,--no-whole-archive $(LIBS)
41+
42+
%.exe: %.o libzmq.dll
43+
g++ -o $@ $^
44+
45+
clean:
46+
del *.o *.a *.dll *.exe
47+

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ libzmq_dso_visibility="yes"
134134

135135
# Platform specific checks
136136
libzmq_on_mingw32="no"
137+
libzmq_on_cygwin="no"
137138
libzmq_on_android="no"
138139
libzmq_on_linux="no"
139140

@@ -269,6 +270,8 @@ case "${host_os}" in
269270
# Define on Cygwin to enable all library features
270271
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
271272
AC_DEFINE(ZMQ_HAVE_CYGWIN, 1, [Have Cygwin])
273+
libzmq_on_cygwin="yes"
274+
libzmq_dso_visibility="no"
272275
if test "x$enable_static" = "xyes"; then
273276
AC_MSG_ERROR([Building static libraries is not supported under Cygwin])
274277
fi
@@ -472,6 +475,7 @@ AC_LANG_POP([C++])
472475

473476
AM_CONDITIONAL(BUILD_TIPC, test "x$libzmq_tipc_support" = "xyes")
474477
AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw32" = "xyes")
478+
AM_CONDITIONAL(ON_CYGWIN, test "x$libzmq_on_cygwin" = "xyes")
475479
AM_CONDITIONAL(ON_ANDROID, test "x$libzmq_on_android" = "xyes")
476480
AM_CONDITIONAL(ON_LINUX, test "x$libzmq_on_linux" = "xyes")
477481

tests/testutil.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,15 @@ void setup_test_environment()
267267
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
268268
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
269269
# endif
270+
#else
271+
#if defined ZMQ_HAVE_CYGWIN
272+
// abort test after 121 seconds
273+
alarm(121);
270274
#else
271275
// abort test after 60 seconds
272276
alarm(60);
273277
#endif
278+
#endif
274279
#if defined __MVS__
275280
// z/OS UNIX System Services: Ignore SIGPIPE during test runs, as a
276281
// workaround for no SO_NOGSIGPIPE socket option.

0 commit comments

Comments
 (0)