Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jan 2014 03:19:17 +0900
From:      KATO Tsuguru <tkato432@yahoo.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/185705: emulators/cygne-sdl: Fix build on -current
Message-ID:  <20140113031917.ce91ed06ef1a6f230ce72025@yahoo.com>
Resent-Message-ID: <201401121840.s0CIe7sw049429@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         185705
>Category:       ports
>Synopsis:       emulators/cygne-sdl: Fix build on -current
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 12 18:40:06 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     KATO Tsuguru
>Release:        FreeBSD 8.4-RELEASE-p4 i386
>Organization:
>Environment:
>Description:
- Fix build on -current
- Fix build on non-i386 architectures
- Add LICENSE

New file:
files/patch-src__mainsdl.cpp
files/patch-src__zlib__unzip.h

>How-To-Repeat:
>Fix:

diff -urN /usr/ports/emulators/cygne-sdl/Makefile emulators/cygne-sdl/Makefile
--- /usr/ports/emulators/cygne-sdl/Makefile	2013-12-18 23:44:37.000000000 +0900
+++ emulators/cygne-sdl/Makefile	2014-01-13 00:00:00.000000000 +0900
@@ -9,18 +9,34 @@
 DISTNAME=	Cygne-SDL-${PORTVERSION}-src
 
 MAINTAINER=	ports@FreeBSD.org
-COMMENT=	The SDL port of Cygne, a free Bandai Wonderswan emulator
+COMMENT=	SDL port of Cygne, a free Bandai Wonderswan emulator
+
+LICENSE=	GPLv2
+
+WRKSRC=		${WRKDIR}/Cygne-SDL-${PORTVERSION}/src
 
 USE_SDL=	sdl
-USE_GMAKE=	yes
-ONLY_FOR_ARCHS=	i386
-WRKSRC=	${WRKDIR}/Cygne-SDL-${PORTVERSION}/src
 
-NO_STAGE=	yes
+PLIST_FILES=	bin/cygne
+
+OPTIONS_DEFINE_i386=	OPTIMIZED_CFLAGS
+OPTIONS_DEFAULT_i386=	OPTIMIZED_CFLAGS
+OPTIMIZED_CFLAGS_CFLAGS=\
+		-fomit-frame-pointer -fexpensive-optimizations \
+		-funroll-loops -funroll-all-loops -fschedule-insns2 \
+		-fstrength-reduce -malign-double -mfancy-math-387 \
+		-ffast-math -fforce-addr
+
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} == "i386"
+USE_GCC=	any
+.endif
+
 post-patch:
 	${CP} ${FILESDIR}/Makefile.bsd ${WRKSRC}/Makefile
 
 do-install:
-	${INSTALL_PROGRAM} ${WRKSRC}/cygne ${PREFIX}/bin
+	(cd ${WRKSRC} && ${INSTALL_PROGRAM} cygne ${STAGEDIR}${PREFIX}/bin)
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -urN /usr/ports/emulators/cygne-sdl/files/Makefile.bsd emulators/cygne-sdl/files/Makefile.bsd
--- /usr/ports/emulators/cygne-sdl/files/Makefile.bsd	2013-11-06 22:06:22.000000000 +0900
+++ emulators/cygne-sdl/files/Makefile.bsd	2014-01-13 00:00:00.000000000 +0900
@@ -1,22 +1,11 @@
-LD = ${CXX}
+NASM = nasm
 
 ### Include and lib stuff ####
-#STDINCLUDE = /usr/include
-#STDLIB     = /usr/lib 
-#SDLINCLUDE = /usr/local/include/SDL
-#SDLLIB	   = /usr/local/lib
-
-CFLAGS+= -DUNIX -DTARGET_UNIX -DGCC -DUSES_16BIT_ONLY -D__SDL__ -fomit-frame-pointer \
-         -fexpensive-optimizations -funroll-loops -funroll-all-loops -pipe \
-         -fschedule-insns2 -fstrength-reduce -malign-double -mfancy-math-387 -ffast-math -fforce-addr \
-         -fforce-mem `${SDL_CONFIG} --cflags`# \
-#         -L$(STDLIB) -L$(SDLLIB) -I$(STDINCLUDE) -I$(SDLINCLUDE)
-
-#LDFLAGS = $(CFLAGS)
+CPPFLAGS+= -DUNIX -DTARGET_UNIX -DGCC -DUSES_16BIT_ONLY -D__SDL__
 
 TARGET = cygne
 
-OBJ = ddrawsdl.o filessdl.o gfx.o nec.o tcache.o memory.o mainsdl.o zlib/unzip.o
+OBJ = ddrawsdl.o filessdl.o gfx.o nec.o tcache.o memory.o mainsdl.o unzip.o
 
 LIBS = `${SDL_CONFIG} --libs` -lz
 
@@ -24,20 +13,25 @@
 
 INCS = -I. `${SDL_CONFIG} --cflags`
 
-THECC = $(CC) $(CFLAGS) $(INCS)
-THECXX = $(CXX) $(CFLAGS) $(INCS)
+THECC = $(CC) $(CFLAGS) $(INCS) $(CPPFLAGS)
+THECXX = $(CXX) $(CXXFLAGS) $(INCS) $(CPPFLAGS)
+
+.SUFFIXES: .asm
 
-%.o: %.asm
+.asm.o:
 	$(NASM) -f elf -o $@ $<
 
-%.o: %.c
+.c.o:
 	$(THECC) -c $< -o $@
 
-%.o: %.cpp
+.cpp.o:
 	$(THECXX) -c $< -o $@
 
+unzip.o:
+	$(THECC) -c zlib/unzip.c -o $@
+
 cygne: $(OBJ) Makefile
-	$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
+	$(CXX) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
 	 
 clean:
 	rm -f cygne *.o zlib/*.o
diff -urN /usr/ports/emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp
--- /usr/ports/emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp	2013-11-06 22:06:22.000000000 +0900
+++ emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp	2014-01-13 00:00:00.000000000 +0900
@@ -1,19 +1,30 @@
 --- ddrawsdl.cpp.orig	Tue Mar 26 09:02:25 2002
 +++ ddrawsdl.cpp	Thu May  4 18:18:12 2006
-@@ -174,67 +174,67 @@
+@@ -12,6 +12,7 @@
+ */
+ 
+ #include <SDL.h>
++#include <assert.h>
+ #include "globals.h"
+ #include "gfx.h"
+ 
+@@ -174,69 +175,83 @@ void UpdateFrame_h()
  {
  	switch(fBlitterMode) {
  		case 1:
 -			__asm__ __volatile__(".align 32
 -							 cld
 -							 rep
--							 movsw"
-+			__asm__ __volatile__(".align 32\n\t"
-+							"cld\n\t"
-+							"rep\n\t"
-+							"movsw"
++#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
++			__asm__ __volatile__(".align 32\n\
++							 cld\n\
++							 rep\n\
+ 							 movsw"
  							 :
  							 :"S"(dx_buffer), "D"(g_pDDSPrimary->pixels), "c"((g_pDDSPrimary->h * g_pDDSPrimary->pitch)>>1));
++#else
++			memcpy(g_pDDSPrimary->pixels, dx_buffer, g_pDDSPrimary->h * g_pDDSPrimary->pitch);
++#endif
  		break;
  		case 2:
 -			__asm__ __volatile__("pusha
@@ -39,33 +50,37 @@
 -								 leal (%1, %2, 4), %1
 -								 jnz sum
 -								 emms
--								 popa"
-+			__asm__ __volatile__("pusha\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								"movl $448, %%ebx\n\t"
-+								"emms\n\t"
-+								"sum:\n\t"
-+								"movq (%0, %%eax, 1), %%mm0\n\t"
-+								"movq %%mm0, %%mm1\n\t"
-+								"punpcklwd %%mm0, %%mm0\n\t"
-+								"addl $8, %%eax\n\t"
-+								"punpckhwd %%mm1,%%mm1\n\t"
-+								"movq %%mm0, -16(%1, %%eax, 2)\n\t"
-+								"cmpl %%ebx, %%eax\n\t"
-+								 
-+								"movq %%mm1, -8(%1, %%eax, 2)\n\t"
-+								"jnz sum\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								 
-+								"addl %2, %0\n\t"
-+								"decl %%edx\n\t"
-+								 
-+								"leal (%1, %2, 4), %1\n\t"
-+								"jnz sum\n\t"
-+								"emms\n\t"
-+								"popa"
++#if defined(__i386__)
++			__asm__ __volatile__("pusha\n\
++								 xorl %%eax, %%eax\n\
++								 movl $448, %%ebx \n\
++								 emms\n\
++								 sum:\n\
++								 movq (%0, %%eax, 1), %%mm0\n\
++								 movq %%mm0, %%mm1\n\
++								 punpcklwd %%mm0, %%mm0\n\
++								 addl $8, %%eax\n\
++								 punpckhwd %%mm1,%%mm1\n\
++								 movq %%mm0, -16(%1, %%eax, 2)\n\
++								 cmpl %%ebx, %%eax\n\
++								 \n\
++								 movq %%mm1, -8(%1, %%eax, 2)\n\
++								 jnz sum\n\
++								 xorl %%eax, %%eax\n\
++								 \n\
++								 addl %2, %0\n\
++								 decl %%edx\n\
++								 \n\
++								 leal (%1, %2, 4), %1\n\
++								 jnz sum\n\
++								 emms\n\
+ 								 popa"
  			:
  			: "S"(dx_buffer), "D"(g_pDDSPrimary->pixels), "c"(g_pDDSPrimary->pitch>>1), "d"(144));
++#else
++			/* If you put real code here, enable the corresponding option in main() */
++			assert(0);
++#endif
  		break;
  		
  		case 3:
@@ -92,48 +107,57 @@
 -								 leal (%1, %2, 4), %1
 -								 jnz sum3
 -								 emms
--								 popa"
-+			__asm__ __volatile__("pusha\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								"movl $896, %%ebx\n\t"
-+								"emms\n"
-+								"sum3:\n\t"
-+								"movq (%0, %%eax, 1), %%mm0\n\t"
-+								"movq %%mm0, %%mm1\n\t"
-+								"punpcklwd %%mm0, %%mm0\n\t"
-+								"addl $8, %%eax\n\t"
-+								"punpckhwd %%mm1,%%mm1\n\t"
-+								"movq %%mm0, -16(%1, %%eax, 2)\n\t"
-+								"cmpl %%ebx, %%eax\n\t"
-+								"\n\t"
-+								"movq %%mm1, -8(%1, %%eax, 2)\n\t"
-+								"jnz sum3\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								"\n\t"
-+								"addl %2, %0\n\t"
-+								"decl %%edx\n\t"
-+								"\n\t"
-+								"leal (%1, %2, 4), %1\n\t"
-+								"jnz sum3\n\t"
-+								"emms\n\t"
-+								"popa"
++#if defined(__i386__)
++			__asm__ __volatile__("pusha\n\
++								 xorl %%eax, %%eax\n\
++								 movl $896, %%ebx \n\
++								 emms\n\
++								 sum3:\n\
++								 movq (%0, %%eax, 1), %%mm0\n\
++								 movq %%mm0, %%mm1\n\
++								 punpcklwd %%mm0, %%mm0\n\
++								 addl $8, %%eax\n\
++								 punpckhwd %%mm1,%%mm1\n\
++								 movq %%mm0, -16(%1, %%eax, 2)\n\
++								 cmpl %%ebx, %%eax\n\
++								 \n\
++								 movq %%mm1, -8(%1, %%eax, 2)\n\
++								 jnz sum3\n\
++								 xorl %%eax, %%eax\n\
++								 \n\
++								 addl %2, %0\n\
++								 decl %%edx\n\
++								 \n\
++								 leal (%1, %2, 4), %1\n\
++								 jnz sum3\n\
++								 emms\n\
+ 								 popa"
  			:
  			: "S"(dx_buffer), "D"(g_pDDSPrimary->pixels), "c"(g_pDDSPrimary->pitch>>1), "d"(144));
++#else
++			/* If you put real code here, enable the corresponding option in main() */
++			assert(0);
++#endif
  		break;
-@@ -418,66 +418,66 @@
+ 	}
+ 	//Niels(adjust to suit) use the asm below, or use standard memcpy/fast_memcpy etc, updateframe_v is not implemented
+@@ -418,68 +433,82 @@ void UpdateFrame_v()
  {
  	switch(fBlitterMode) {
  		case 1:
 -			__asm__ __volatile__(".align 32
 -							 cld
 -							 rep
--							 movsw"
-+			__asm__ __volatile__(".align 32\n\t"
-+							"cld\n\t"
-+							"rep\n\t"
-+							"movsw"
++#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
++			__asm__ __volatile__(".align 32\n\
++							 cld\n\
++							 rep\n\
+ 							 movsw"
  							 :
  							 :"S"(dx_buffer), "D"(g_pDDSPrimary->pixels), "c"((g_pDDSPrimary->h * g_pDDSPrimary->pitch)>>1));
++#else
++			memcpy(g_pDDSPrimary->pixels, dx_buffer, g_pDDSPrimary->h * g_pDDSPrimary->pitch);
++#endif
  		break;
  		case 2: // double scanlines
 -			__asm__ __volatile__("pusha
@@ -159,33 +183,37 @@
 -								 leal (%1, %2, 4), %1
 -								 jnz sumb
 -								 emms
--								 popa"
-+			__asm__ __volatile__("pusha\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								"movl $288, %%ebx\n\t"
-+								"emms\n"
-+								"sumb:\n\t"
-+								"movq (%0, %%eax, 1), %%mm0\n\t"
-+								"movq %%mm0, %%mm1\n\t"
-+								"punpcklwd %%mm0, %%mm0\n\t"
-+								"addl $8, %%eax\n\t"
-+								"punpckhwd %%mm1,%%mm1\n\t"
-+								"movq %%mm0, -16(%1, %%eax, 2)\n\t"
-+								"cmpl %%ebx, %%eax\n\t"
-+								"\n\t"
-+								"movq %%mm1, -8(%1, %%eax, 2)\n\t"
-+								"jnz sumb\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								"\n\t"
-+								"addl %2, %0\n\t"
-+								"decl %%edx\n\t"
-+								"\n\t"
-+								"leal (%1, %2, 4), %1\n\t"
-+								"jnz sumb\n\t"
-+								"emms\n\t"
-+								"popa"
++#if defined(__i386__)
++			__asm__ __volatile__("pusha\n\
++								 xorl %%eax, %%eax\n\
++								 movl $288, %%ebx \n\
++								 emms\n\
++								 sumb:\n\
++								 movq (%0, %%eax, 1), %%mm0\n\
++								 movq %%mm0, %%mm1\n\
++								 punpcklwd %%mm0, %%mm0\n\
++								 addl $8, %%eax\n\
++								 punpckhwd %%mm1,%%mm1\n\
++								 movq %%mm0, -16(%1, %%eax, 2)\n\
++								 cmpl %%ebx, %%eax\n\
++								 \n\
++								 movq %%mm1, -8(%1, %%eax, 2)\n\
++								 jnz sumb\n\
++								 xorl %%eax, %%eax\n\
++								 \n\
++								 addl %2, %0\n\
++								 decl %%edx\n\
++								 \n\
++								 leal (%1, %2, 4), %1\n\
++								 jnz sumb\n\
++								 emms\n\
+ 								 popa"
  			:
  			: "S"(dx_buffer), "D"(g_pDDSPrimary->pixels), "c"(g_pDDSPrimary->pitch>>1), "d"(224));
++#else
++			/* If you put real code here, enable the corresponding option in main() */
++			assert(0);
++#endif
  		break;
  		case 3: // double stretch mode
 -			__asm__ __volatile__("pusha
@@ -211,31 +239,37 @@
 -								 leal (%1, %2, 4), %1
 -								 jnz sumc
 -								 emms
--								 popa"
-+			__asm__ __volatile__("pusha\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								"movl $576, %%ebx\n\t"
-+								"emms\n"
-+								"sumc:\n\t"
-+								"movq (%0, %%eax, 1), %%mm0\n\t"
-+								"movq %%mm0, %%mm1\n\t"
-+								"punpcklwd %%mm0, %%mm0\n\t"
-+								"addl $8, %%eax\n\t"
-+								"punpckhwd %%mm1,%%mm1\n\t"
-+								"movq %%mm0, -16(%1, %%eax, 2)\n\t"
-+								"cmpl %%ebx, %%eax\n\t"
-+								"\n\t"
-+								"movq %%mm1, -8(%1, %%eax, 2)\n\t"
-+								"jnz sumc\n\t"
-+								"xorl %%eax, %%eax\n\t"
-+								"\n\t"
-+								"addl %2, %0\n\t"
-+								"decl %%edx\n\t"
-+								"\n\t"
-+								"leal (%1, %2, 4), %1\n\t"
-+								"jnz sumc\n\t"
-+								"emms\n\t"
-+								"popa"
++#if defined(__i386__)
++			__asm__ __volatile__("pusha\n\
++								 xorl %%eax, %%eax\n\
++								 movl $576, %%ebx \n\
++								 emms\n\
++								 sumc:\n\
++								 movq (%0, %%eax, 1), %%mm0\n\
++								 movq %%mm0, %%mm1\n\
++								 punpcklwd %%mm0, %%mm0\n\
++								 addl $8, %%eax\n\
++								 punpckhwd %%mm1,%%mm1\n\
++								 movq %%mm0, -16(%1, %%eax, 2)\n\
++								 cmpl %%ebx, %%eax\n\
++								 \n\
++								 movq %%mm1, -8(%1, %%eax, 2)\n\
++								 jnz sumc\n\
++								 xorl %%eax, %%eax\n\
++								 \n\
++								 addl %2, %0\n\
++								 decl %%edx\n\
++								 \n\
++								 leal (%1, %2, 4), %1\n\
++								 jnz sumc\n\
++								 emms\n\
+ 								 popa"
  			:
  			: "S"(dx_buffer), "D"(g_pDDSPrimary->pixels), "c"(g_pDDSPrimary->pitch>>1), "d"(224));
++#else
++			/* If you put real code here, enable the corresponding option in main() */
++			assert(0);
++#endif
  		break;
+ 	}
+ 	SDL_Flip(g_pDDSPrimary);
diff -urN /usr/ports/emulators/cygne-sdl/files/patch-src__mainsdl.cpp emulators/cygne-sdl/files/patch-src__mainsdl.cpp
--- /usr/ports/emulators/cygne-sdl/files/patch-src__mainsdl.cpp	1970-01-01 09:00:00.000000000 +0900
+++ emulators/cygne-sdl/files/patch-src__mainsdl.cpp	2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,26 @@
+--- mainsdl.cpp.orig
++++ mainsdl.cpp
+@@ -322,13 +322,23 @@ int main(int argc, char *argv[])
+ 	for (i=0; (i < argc || argv[i] != NULL); i++) {
+ 		
+ 		if(strcmp(argv[i], "-double") == 0) {
++#if defined(__i386__)
+ 			fScreenSize = 2;
+ 			fBlitterMode = 3;
++#else
++			fprintf(stderr, "-double is not supported on this platform\n");
++			exit(1);
++#endif
+ 		}
+ 		
+ 		if(strcmp(argv[i], "-scanline") == 0) {
++#if defined(__i386__)
+ 			fScreenSize = 2;
+ 			fBlitterMode = 2;
++#else
++			fprintf(stderr, "-scanline is not supported on this platform\n");
++			exit(1);
++#endif
+ 		}
+ 		
+ 		if (strncmp(argv[i], "-h", 2) == 0) {
diff -urN /usr/ports/emulators/cygne-sdl/files/patch-src__zlib__unzip.h emulators/cygne-sdl/files/patch-src__zlib__unzip.h
--- /usr/ports/emulators/cygne-sdl/files/patch-src__zlib__unzip.h	1970-01-01 09:00:00.000000000 +0900
+++ emulators/cygne-sdl/files/patch-src__zlib__unzip.h	2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,13 @@
+--- zlib/unzip.h.orig
++++ zlib/unzip.h
+@@ -49,6 +49,10 @@ extern "C" {
+ #include "zlib.h"
+ #endif
+ 
++#ifndef OF
++#define OF(a)	a
++#endif
++
+ #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
+ /* like the STRICT of WIN32, we define a pointer that cannot be converted
+     from (void*) without cast */
diff -urN /usr/ports/emulators/cygne-sdl/pkg-descr emulators/cygne-sdl/pkg-descr
--- /usr/ports/emulators/cygne-sdl/pkg-descr	2013-11-06 22:06:22.000000000 +0900
+++ emulators/cygne-sdl/pkg-descr	2014-01-13 00:00:00.000000000 +0900
@@ -2,4 +2,4 @@
 version of Cygne, a free and now OpenSource (since 12-03-2002) Bandai
 Wonderswan Color handheld software based emulator.
 
-WWW:	http://icculus.org/Cygne-SDL/
+WWW: http://icculus.org/Cygne-SDL/
diff -urN /usr/ports/emulators/cygne-sdl/pkg-plist emulators/cygne-sdl/pkg-plist
--- /usr/ports/emulators/cygne-sdl/pkg-plist	2013-11-06 22:06:22.000000000 +0900
+++ emulators/cygne-sdl/pkg-plist	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-bin/cygne
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140113031917.ce91ed06ef1a6f230ce72025>