Bug 185705 - emulators/cygne-sdl: Fix build on -current
Summary: emulators/cygne-sdl: Fix build on -current
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Martin Wilke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-12 18:40 UTC by tkato432
Modified: 2014-02-07 16:14 UTC (History)
0 users

See Also:


Attachments
file.diff (14.24 KB, patch)
2014-01-12 18:40 UTC, tkato432
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tkato432 2014-01-12 18:40:06 UTC
- 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
Comment 1 Martin Wilke freebsd_committer 2014-01-23 15:48:35 UTC
Responsible Changed
From-To: freebsd-ports-bugs->miwi

I'll take it.
Comment 2 dfilter service freebsd_committer 2014-02-07 13:12:47 UTC
Author: miwi
Date: Fri Feb  7 13:12:37 2014
New Revision: 343235
URL: http://svnweb.freebsd.org/changeset/ports/343235
QAT: https://qat.redports.org/buildarchive/r343235/

Log:
  - Fix build
  - Add LICENSE
  - Stage support
  
  PR:		185705
  Submitted by:	Ports Fury

Added:
  head/emulators/cygne-sdl/files/patch-src__mainsdl.cpp   (contents, props changed)
  head/emulators/cygne-sdl/files/patch-src__zlib__unzip.h   (contents, props changed)
Deleted:
  head/emulators/cygne-sdl/pkg-plist
Modified:
  head/emulators/cygne-sdl/Makefile
  head/emulators/cygne-sdl/files/Makefile.bsd
  head/emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp
  head/emulators/cygne-sdl/pkg-descr

Modified: head/emulators/cygne-sdl/Makefile
==============================================================================
--- head/emulators/cygne-sdl/Makefile	Fri Feb  7 13:11:08 2014	(r343234)
+++ head/emulators/cygne-sdl/Makefile	Fri Feb  7 13:12:37 2014	(r343235)
@@ -9,18 +9,34 @@ MASTER_SITES=	http://sdlemu.ngemu.com/Op
 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>

Modified: head/emulators/cygne-sdl/files/Makefile.bsd
==============================================================================
--- head/emulators/cygne-sdl/files/Makefile.bsd	Fri Feb  7 13:11:08 2014	(r343234)
+++ head/emulators/cygne-sdl/files/Makefile.bsd	Fri Feb  7 13:12:37 2014	(r343235)
@@ -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 @@ all: $(TARGET)
 
 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

Modified: head/emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp
==============================================================================
--- head/emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp	Fri Feb  7 13:11:08 2014	(r343234)
+++ head/emulators/cygne-sdl/files/patch-src-ddrawsdl.cpp	Fri Feb  7 13:12:37 2014	(r343235)
@@ -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);

Added: head/emulators/cygne-sdl/files/patch-src__mainsdl.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/emulators/cygne-sdl/files/patch-src__mainsdl.cpp	Fri Feb  7 13:12:37 2014	(r343235)
@@ -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) {

Added: head/emulators/cygne-sdl/files/patch-src__zlib__unzip.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/emulators/cygne-sdl/files/patch-src__zlib__unzip.h	Fri Feb  7 13:12:37 2014	(r343235)
@@ -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 */

Modified: head/emulators/cygne-sdl/pkg-descr
==============================================================================
--- head/emulators/cygne-sdl/pkg-descr	Fri Feb  7 13:11:08 2014	(r343234)
+++ head/emulators/cygne-sdl/pkg-descr	Fri Feb  7 13:12:37 2014	(r343235)
@@ -2,4 +2,4 @@ Cygne/SDL is the Simple Directmedia Laye
 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/
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 3 Martin Wilke freebsd_committer 2014-02-07 16:14:32 UTC
State Changed
From-To: open->closed

Committed. Thanks!