summaryrefslogtreecommitdiff
path: root/games-emulation/advancemame/files/advancemame-3.9-pkgconfig_for_ncurses_and_slang.patch
blob: b91c887e030faa2eeaacf302145a4e7602360fb2 (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
diff --git a/Makefile.in b/Makefile.in
index 4e30ada3..e92a1072 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -27,6 +27,8 @@ CONF_LIB_ALSA=@CONF_LIB_ALSA@
 CONF_LIB_OSS=@CONF_LIB_OSS@
 CONF_LIB_SDL=@CONF_LIB_SDL@
 CONF_LIB_FREETYPE=@CONF_LIB_FREETYPE@
+CONF_LIB_SLANG=@CONF_LIB_SLANG@
+CONF_LIB_NCURSES=@CONF_LIB_NCURSES@
 CONF_LIB_SVGAWIN=@CONF_LIB_SVGAWIN@
 CONF_LIB_PTHREAD=@CONF_LIB_PTHREAD@
 CONF_LIB_SLANG=@CONF_LIB_SLANG@
@@ -97,6 +99,10 @@ SDLCFLAGS=@SDLCFLAGS@
 SDLLIBS=@SDLLIBS@
 FREETYPECFLAGS=@FREETYPECFLAGS@
 FREETYPELIBS=@FREETYPELIBS@
+SLANGCFLAGS=@SLANGCFLAGS@
+SLANGLIBS=@SLANGLIBS@
+NCURSESCFLAGS=@NCURSESCFLAGS@
+NCURSESLIBS=@NCURSESLIBS@
 VCCFLAGS=@VCCFLAGS@
 VCLIBS=@VCLIBS@
 ASMFLAGS=@ASMFLAGS@
diff --git a/advance/cfg.mak b/advance/cfg.mak
index 222533ff..d2f83233 100644
--- a/advance/cfg.mak
+++ b/advance/cfg.mak
@@ -57,15 +57,17 @@ CFGOBJS += \
 	$(CFGOBJ)/linux/os.o
 ifeq ($(CONF_LIB_SLANG),yes)
 CFGCFLAGS += \
+	$(SLANGCFLAGS) \
 	-DUSE_VIDEO_SLANG
-CFGLIBS += -lslang
+CFGLIBS += $(SLANGLIBS)
 CFGOBJS += \
 	$(CFGOBJ)/linux/vslang.o
 endif
 ifeq ($(CONF_LIB_NCURSES),yes)
 CFGCFLAGS += \
+	$(NCURSESCFLAGS) \
 	-DUSE_VIDEO_CURSES
-CFGLIBS += -lncurses
+CFGLIBS += $(NCURSESLIBS)
 CFGOBJS += \
 	$(CFGOBJ)/linux/vcurses.o
 endif
diff --git a/advance/v.mak b/advance/v.mak
index 4ffe708f..451f0d55 100644
--- a/advance/v.mak
+++ b/advance/v.mak
@@ -53,15 +53,17 @@ VOBJS += \
 	$(VOBJ)/linux/os.o
 ifeq ($(CONF_LIB_SLANG),yes)
 VCFLAGS += \
+	$(SLANGCFLAGS) \
 	-DUSE_VIDEO_SLANG
-VLIBS += -lslang
+VLIBS += $(SLANGLIBS)
 VOBJS += \
 	$(VOBJ)/linux/vslang.o
 endif
 ifeq ($(CONF_LIB_NCURSES),yes)
 VCFLAGS += \
+	$(NCURSESCFLAGS) \
 	-DUSE_VIDEO_CURSES
-VLIBS += -lncurses
+VLIBS += $(NCURSESLIBS)
 VOBJS += \
 	$(VOBJ)/linux/vcurses.o
 endif
diff --git a/configure.ac b/configure.ac
index 063c407a..f8ba989a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -717,29 +717,41 @@ AC_ARG_ENABLE(
 	[ac_lib_slang=auto]
 )
 if test $ac_lib_slang = auto; then
-	AC_CHECK_LIB(
-		[slang],
-		[SLang_init_tty],
-		[ac_lib_slang=yes],
-		[ac_lib_slang=no],
-		[]
-	)
+	PKG_CHECK_MODULES([SLANG], [slang], [ac_lib_slang=yes], [ac_lib_slang=no])
+	if test $ac_lib_slang = yes; then
+		ac_save_CFLAGS="$CFLAGS"
+		ac_save_LIBS="$LIBS"
+		CFLAGS="SLANG_CFLAGS $CFLAGS"
+		LIBS="$SLANG_LIBS $LIBS"
+                AC_MSG_CHECKING([for linking slang])
+                AC_TRY_LINK([
+				#include <slang.h>
+			], [
+				if (SLang_init_tty(-1, 0, 0) < 0) {
+					perror("SLang_init_tty");
+					return 1;
+				}
+
+				SLang_reset_tty();
+				return 0;
+			],[ac_lib_slang=yes],[ac_lib_slang=no])
+		AC_MSG_RESULT([$ac_lib_slang])
+		CFLAGS="$ac_save_CFLAGS"
+		LIBS="$ac_save_LIBS"
+        fi
 elif test $ac_lib_slang = yes; then
-	AC_CHECK_LIB(
-		[slang],
-		[SLang_init_tty],
-		[],
-		[AC_MSG_ERROR([the sLang library is missing])],
-		[]
-	)
+	PKG_CHECK_MODULES([SLANG], [slang], [], AC_MSG_ERROR([the slang library is missing]))
 fi
 if test $ac_lib_slang = yes; then
 	AC_CHECK_HEADERS([slang.h slang/slang.h], [break])
 	ac_lib_video="$ac_lib_video slang"
 	ac_lib_text_flag=yes
 fi
+AC_SUBST([SLANGCFLAGS],[$SLANG_CFLAGS])
+AC_SUBST([SLANGLIBS],[$SLANG_LIBS])
 AC_SUBST([CONF_LIB_SLANG],[$ac_lib_slang])
 
+
 dnl Checks for ncurses
 AC_ARG_ENABLE(
 	[ncurses],
@@ -748,28 +760,37 @@ AC_ARG_ENABLE(
 	[ac_lib_ncurses=auto]
 )
 if test $ac_lib_ncurses = auto; then
-	AC_CHECK_LIB(
-		[ncurses],
-		[endwin],
-		[ac_lib_ncurses=yes],
-		[ac_lib_ncurses=no],
-		[]
-	)
+	PKG_CHECK_MODULES([NCURSES], [ncurses], [ac_lib_ncurses=yes], [ac_lib_ncurses=no])
+	if test $ac_lib_ncurses = yes; then
+		ac_save_CFLAGS="$CFLAGS"
+		ac_save_LIBS="$LIBS"
+		CFLAGS="$NCURSES_CFLAGS $CFLAGS"
+		LIBS="$NCURSES_LIBS $LIBS"
+		AC_MSG_CHECKING([for linking ncurses])
+		AC_TRY_LINK([
+				#include <ncurses.h>
+			], [
+				initscr();
+				noecho();
+				curs_set(FALSE);
+				endwin();
+			],[ac_lib_ncurses=yes],[ac_lib_ncurses=no])
+                AC_MSG_RESULT([$ac_lib_ncurses])
+                CFLAGS="$ac_save_CFLAGS"
+                LIBS="$ac_save_LIBS"
+        fi
 elif test $ac_lib_ncurses = yes; then
-	AC_CHECK_LIB(
-		[ncurses],
-		[endwin],
-		[],
-		[AC_MSG_ERROR([the sLang library is missing])],
-		[]
-	)
+	PKG_CHECK_MODULES([NCURSES], [ncurses], [], AC_MSG_ERROR([the ncurses library is missing]))
 fi
 if test $ac_lib_ncurses = yes; then
 	ac_lib_video="$ac_lib_video ncurses"
 	ac_lib_text_flag=yes
 fi
+AC_SUBST([NCURSESCFLAGS],[$NCURSES_CFLAGS])
+AC_SUBST([NCURSESLIBS],[$NCURSES_LIBS])
 AC_SUBST([CONF_LIB_NCURSES],[$ac_lib_ncurses])
 
+
 dnl Checks for freetype
 AC_ARG_ENABLE(
 	[freetype],