summaryrefslogtreecommitdiffstats
path: root/src/libcaca-1-fixes.patch
blob: a363133a0d85894f8628b4c3bc4eac9396769d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
This file is part of MXE. See LICENSE.md for licensing information.

From b9f723cf31e007004ccc748a0e16c594fa7fdf35 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Sat, 2 Aug 2014 15:12:50 -0700
Subject: [PATCH 1/3] Fix Windows build for ncurses and slang

Signed-off-by: Timothy Gu <timothygu99@gmail.com>

diff --git a/caca/driver/ncurses.c b/caca/driver/ncurses.c
index 7171e91..8161c0f 100644
--- a/caca/driver/ncurses.c
+++ b/caca/driver/ncurses.c
@@ -187,7 +187,7 @@
  * Local functions
  */
 
-#if defined HAVE_SIGNAL
+#if defined HAVE_SIGNAL && defined SIGWINCH
 static RETSIGTYPE sigwinch_handler(int);
 static caca_display_t *sigwinch_d; /* FIXME: we ought to get rid of this */
 #endif
@@ -237,7 +237,7 @@ static int ncurses_init_graphics(caca_display_t *dp)
     ncurses_install_terminal(dp);
 #endif
 
-#if defined HAVE_SIGNAL
+#if defined HAVE_SIGNAL && defined SIGWINCH
     sigwinch_d = dp;
     signal(SIGWINCH, sigwinch_handler);
 #endif
@@ -392,9 +392,9 @@ static void ncurses_display(caca_display_t *dp)
 
 static void ncurses_handle_resize(caca_display_t *dp)
 {
+#if defined HAVE_SYS_IOCTL_H
     struct winsize size;
 
-#if defined HAVE_SYS_IOCTL_H
     if(ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0)
     {
         dp->resize.w = size.ws_col;
@@ -587,7 +587,7 @@ static void ncurses_set_cursor(caca_display_t *dp, int flags)
  * XXX: following functions are local
  */
 
-#if defined HAVE_SIGNAL
+#if defined HAVE_SIGNAL && defined SIGWINCH
 static RETSIGTYPE sigwinch_handler(int sig)
 {
     sigwinch_d->resize.resized = 1;
diff --git a/caca/driver/slang.c b/caca/driver/slang.c
index 9714956..4dd9fb6 100644
--- a/caca/driver/slang.c
+++ b/caca/driver/slang.c
@@ -131,7 +131,7 @@ static int slang_init_graphics(caca_display_t *dp)
     slang_install_terminal(dp);
 #endif
 
-#if defined(HAVE_SIGNAL)
+#if defined(HAVE_SIGNAL) && defined(SIGWINCH)
     sigwinch_d = dp;
     signal(SIGWINCH, sigwinch_handler);
 #endif
@@ -534,7 +534,7 @@ static void slang_write_utf32(uint32_t ch)
 #endif
 }
 
-#if defined(HAVE_SIGNAL)
+#if defined(HAVE_SIGNAL) && defined(SIGWINCH)
 static RETSIGTYPE sigwinch_handler(int sig)
 {
     sigwinch_d->resize.resized = 1;
-- 
1.8.3.2


From 0313fb009eca09481d216938db989db9f50672ee Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Sun, 3 Aug 2014 10:56:02 -0700
Subject: [PATCH 2/3] Fix pkg-config file and caca-config script

Signed-off-by: Timothy Gu <timothygu99@gmail.com>

diff --git a/caca-config.in b/caca-config.in
index a54e6e1..f48d9de 100644
--- a/caca-config.in
+++ b/caca-config.in
@@ -67,7 +67,7 @@ do
       echo_libs=yes
       ;;
     caca)
-      libs="$libs -lcaca"
+      libs="$libs -lcaca @ZLIB_LIBS@ @CACA_LIBS@"
       ;;
     *)
       usage 1 1>&2
diff --git a/caca/caca.pc.in b/caca/caca.pc.in
index fa683fb..6e50668 100644
--- a/caca/caca.pc.in
+++ b/caca/caca.pc.in
@@ -9,5 +9,5 @@ Version: @VERSION@
 Requires: 
 Conflicts: 
 Libs: -L${libdir} -lcaca
-Libs.private: @ZLIB_LIBS@
+Libs.private: @ZLIB_LIBS@ @CACA_LIBS@
 Cflags: -I${includedir}
-- 
1.8.3.2


From 50e5c99690c593cc974a49ae21af8fca288bc854 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Sun, 3 Aug 2014 11:13:23 -0700
Subject: [PATCH 3/3] Fix freeglut detection on Windows

Signed-off-by: Timothy Gu <timothygu99@gmail.com>

diff --git a/configure.ac b/configure.ac
index 641dd17..3ce7057 100644
--- a/configure.ac
+++ b/configure.ac
@@ -232,22 +232,83 @@ fi
 
 if test "${enable_gl}" != "no"; then
   ac_cv_my_have_gl="no"
-  AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
-   [AC_CHECK_HEADERS(GL/glut.h,
-     [AC_CHECK_LIB(glut, glutCloseFunc,
-       [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the ‘glutCloseFunc’ function.)])
-      AC_CHECK_LIB(glut, glutMainLoopEvent,
-       [ac_cv_my_have_gl="yes"])
-      AC_CHECK_LIB(glut, glutCheckLoop,
-       [ac_cv_my_have_gl="yes"
-        AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the ‘glutCheckLoop’ function.)])])
-      break])
+
+  dnl GLUT is usable if (by order of checking):
+  dnl 1. OpenGL/gl.h (OS X) or GL/gl.h (others) is available.
+  dnl    The former implies that GLUT header is GLUT/glut.h.
+  dnl    The latter implies that GLUT headers are GL/glut.h and
+  dnl    GL/freeglut_ext.h.
+  dnl 2. pkg-config can find it.
+  dnl 3. glutMainLoopEvent() or glutCheckLoop()'s declarations is in the GLUT
+  dnl    header(s), and it can be linked.
+
+  dnl Also checking for glutCloseFunc(), but that is not mandatory.
+
+  AC_CHECK_HEADERS([OpenGL/gl.h GL/gl.h], [
+   PKG_CHECK_MODULES([GL], [glut glu gl], [
+    CFLAGS="${CFLAGS} ${GL_CFLAGS}"
+    LIBS="${LIBS} ${GL_LIBS}"
+    AC_MSG_CHECKING([for glutCloseFunc()])
+    AC_LINK_IFELSE([
+     AC_LANG_PROGRAM(
+      [[#ifdef HAVE_OPENGL_GL_H
+        # include <OpenGL/gl.h>
+        # include <GLUT/glut.h>
+        #else
+        # include <GL/gl.h>
+        # include <GL/glut.h>   
+        # include <GL/freeglut_ext.h>
+        #endif
+      ]], [[glutCloseFunc(NULL);]])],
+     [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1,
+                [Define to 1 if you have the ‘glutCloseFunc’ function.])
+      AC_MSG_RESULT(yes)],
+     [AC_MSG_RESULT(no)])
+    AC_MSG_CHECKING([for glutMainLoopEvent()])
+    AC_LINK_IFELSE([
+     AC_LANG_PROGRAM(
+      [[#ifdef HAVE_OPENGL_GL_H
+        # include <OpenGL/gl.h>
+        # include <GLUT/glut.h>
+        #else
+        # include <GL/gl.h>
+        # include <GL/glut.h>   
+        # include <GL/freeglut_ext.h>
+        #endif
+      ]], [[glutMainLoopEvent();]])],
+     [ac_cv_my_have_gl="yes"
+      AC_MSG_RESULT(yes)],
+     [AC_MSG_RESULT(no)])
+    AC_MSG_CHECKING([for glutCheckLoop()])
+    AC_LINK_IFELSE([
+     AC_LANG_PROGRAM(
+      [[#ifdef HAVE_OPENGL_GL_H
+        # include <OpenGL/gl.h>
+        # include <GLUT/glut.h>
+        #else
+        # include <GL/gl.h>
+        # include <GL/glut.h>   
+        # include <GL/freeglut_ext.h>
+        #endif
+      ]], [[glutCheckLoop();]])],
+     [ac_cv_my_have_gl="yes"
+      AC_DEFINE(HAVE_GLUTCHECKLOOP, 1,
+                [Define to 1 if you have the ‘glutCheckLoop’ function.])
+      AC_MSG_RESULT(yes)],
+     [AC_MSG_RESULT(no)])
+   ])
+   break
+  ])
+  AC_MSG_CHECKING([if GLUT is usable])
   if test "${ac_cv_my_have_gl}" = "yes"; then
     AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
-    GL_LIBS="${GL_LIBS} -lGL -lGLU -lglut"
     CACA_DRIVERS="${CACA_DRIVERS} gl"
-  elif test "${enable_gl}" = "yes"; then
-    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
+    AC_MSG_RESULT([yes])
+  else
+    AC_MSG_RESULT([no])
+    if test "${enable_gl}" = "yes"; then
+      AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
+    fi
   fi
   PKG_CHECK_MODULES(FTGL, ftgl >= 2.1.3, [FTGL="yes"], [FTGL="no"])
 fi
-- 
1.8.3.2