From ad62adf9040c9b2856994fe950e1743b1b3d3355 Mon Sep 17 00:00:00 2001 From: John Marino Date: Mon, 13 Apr 2015 07:06:08 +0000 Subject: [PATCH] games/megaglest: Fix code to allow Clang to build it again Not only was the previous commit unsavory, it didn't work due to conflict between libc++ and libstdc++. The added patch from miniz upstream fixes the breakage. Suggested by: jbeich --- games/megaglest/Makefile | 9 +++------ ...h-source_shared__lib_sources_miniz_miniz.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 games/megaglest/files/patch-source_shared__lib_sources_miniz_miniz.c diff --git a/games/megaglest/Makefile b/games/megaglest/Makefile index 065867b00f63..969811bd192f 100644 --- a/games/megaglest/Makefile +++ b/games/megaglest/Makefile @@ -3,7 +3,7 @@ PORTNAME= megaglest PORTVERSION= 3.9.0.4 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= games MASTER_SITES= SF/${PORTNAME}/${PORTNAME}_3.9.0/ DISTNAME= ${PORTNAME}-source-${PORTVERSION} @@ -23,11 +23,8 @@ RUN_DEPENDS= ${DATADIR}/tutorials/2_basic_tutorial/2_basic_tutorial.xml:${PORTSD SUB_FILES= pkg-message -# Clang catches a c++11 violation that older GCC misses, so until the -# code is fixed, remove USES+=compiler:c++11-lib and set USE_GCC=yes -USES= cmake display:build dos2unix lua openal:al,alut pkgconfig \ - tar:xz -USE_GCC= yes +USES= cmake compiler:c++11-lib display:build dos2unix lua \ + openal:al,alut pkgconfig tar:xz USE_GL= glew gl glu USE_SDL= yes USE_WX= 3.0 diff --git a/games/megaglest/files/patch-source_shared__lib_sources_miniz_miniz.c b/games/megaglest/files/patch-source_shared__lib_sources_miniz_miniz.c new file mode 100644 index 000000000000..4f91feb21783 --- /dev/null +++ b/games/megaglest/files/patch-source_shared__lib_sources_miniz_miniz.c @@ -0,0 +1,19 @@ +--- source/shared_lib/sources/miniz/miniz.c.orig 2015-04-13 04:50:02 UTC ++++ source/shared_lib/sources/miniz/miniz.c +@@ -2765,6 +2765,7 @@ mz_uint tdefl_create_comp_flags_from_zip + // http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. + void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) + { ++ static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06}; + tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0; + if (!pComp) return NULL; + MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57+MZ_MAX(64, (1+bpl)*h); if (NULL == (out_buf.m_pBuf = (mz_uint8*)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; } +@@ -2778,7 +2779,7 @@ void *tdefl_write_image_to_png_file_in_m + *pLen_out = out_buf.m_size-41; + { + mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, +- 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0, ++ 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0, + (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; + c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); + memcpy(out_buf.m_pBuf, pnghdr, 41);