古い ports のスケルトンを最新の OS 環境で make install する場合、必ずしもコンパイルが終了するとは限りません。OS 側 /usr/include/ 下で関数名が微妙に変更されている場合も該当します。
ImageMagick 6.4.9 を FreeBSD 9.1-RELEASE に展開する必要があり、移行前同様 2009 年頃のスケルトンを用いましたが、zlib.h, zconf.h の変更でつまづきました。
9.1-RELEASE 向けに ImageMagick/magick/blob.c を修正した際のメモです。
--- ./work/ImageMagick-6.4.9-3/magick/blob.c 2009-02-11 02:43:17.000000000 +0900
+++ /usr/appli/conf.dna15/blob.c 2013-08-30 12:23:24.000000000 +0900
@@ -88,6 +88,22 @@
/*
Typedef declarations.
*/
+typedef union FileInfo
+{
+ FILE
+ *file;
+
+#if defined(MAGICKCORE_ZLIB_DELEGATE)
+ gzFile
+ gzfile;
+#endif
+
+#if defined(MAGICKCORE_BZLIB_DELEGATE)
+ BZFILE
+ *bzfile;
+#endif
+} FileInfo;
+
struct _BlobInfo
{
size_t
@@ -113,8 +129,8 @@
StreamType
type;
- FILE
- *file;
+ FileInfo
+ file_info;
struct stat
properties;
@@ -182,7 +198,7 @@
blob_info->quantum=(size_t) MagickMaxBufferExtent;
blob_info->offset=0;
blob_info->type=BlobStream;
- blob_info->file=(FILE *) NULL;
+ blob_info->file_info.file=(FILE *) NULL;
blob_info->data=(unsigned char *) blob;
blob_info->mapped=MagickFalse;
}
@@ -425,7 +441,7 @@
clone_info->status=blob_info->status;
clone_info->temporary=blob_info->temporary;
clone_info->type=blob_info->type;
- clone_info->file=blob_info->file;
+ clone_info->file_info.file=blob_info->file_info.file;
clone_info->properties=blob_info->properties;
clone_info->stream=blob_info->stream;
clone_info->data=blob_info->data;
@@ -488,20 +504,20 @@
case StandardStream:
case PipeStream:
{
- status=ferror(image->blob->file);
+ status=ferror(image->blob->file_info.file);
break;
}
case ZipStream:
{
#if defined(MAGICKCORE_ZLIB_DELEGATE)
- (void) gzerror(image->blob->file,&status);
+ (void) gzerror(image->blob->file_info.gzfile,&status);
#endif
break;
}
case BZipStream:
{
#if defined(MAGICKCORE_BZLIB_DELEGATE)
- (void) BZ2_bzerror((BZFILE *) image->blob->file,&status);
+ (void) BZ2_bzerror((BZFILE *) image->blob->file_info.file,&status);
#endif
break;
}
@@ -517,27 +533,27 @@
case FileStream:
case StandardStream:
{
- status=fclose(image->blob->file);
+ status=fclose(image->blob->file_info.file);
break;
}
case PipeStream:
{
#if defined(MAGICKCORE_HAVE_POPEN)
- status=pclose(image->blob->file);
+ status=pclose(image->blob->file_info.file);
#endif
break;
}
case ZipStream:
{
#if defined(MAGICKCORE_ZLIB_DELEGATE)
- status=gzclose(image->blob->file);
+ status=gzclose(image->blob->file_info.gzfile);
#endif
break;
}
case BZipStream:
{
#if defined(MAGICKCORE_BZLIB_DELEGATE)
- BZ2_bzclose((BZFILE *) image->blob->file);
+ BZ2_bzclose((BZFILE *) image->blob->file_info.bzfile);
#endif
break;
}
@@ -639,7 +655,7 @@
blob_info->eof=MagickFalse;
blob_info->exempt=MagickFalse;
blob_info->type=UndefinedStream;
- blob_info->file=(FILE *) NULL;
+ blob_info->file_info.file=(FILE *) NULL;
data=blob_info->data;
blob_info->data=(unsigned char *) NULL;
blob_info->stream=(StreamHandler) NULL;
@@ -685,7 +701,7 @@
case StandardStream:
case PipeStream:
{
- image->blob->eof=feof(image->blob->file) != 0 ? MagickTrue : MagickFalse;
+ image->blob->eof=feof(image->blob->file_info.file) != 0 ? MagickTrue : MagickFalse;
break;
}
case ZipStream:
@@ -700,7 +716,7 @@
status;
status=0;
- (void) BZ2_bzerror((BZFILE *) image->blob->file,&status);
+ (void) BZ2_bzerror((BZFILE *) image->blob->file_info.file,&status);
image->blob->eof=status == BZ_UNEXPECTED_EOF ? MagickTrue : MagickFalse;
#endif
break;
@@ -1049,7 +1065,7 @@
{
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
- return(image->blob->file);
+ return(image->blob->file_info.file);
}
/*
@@ -1162,7 +1178,7 @@
}
case FileStream:
{
- if (fstat(fileno(image->blob->file),&image->blob->properties) == 0)
+ if (fstat(fileno(image->blob->file_info.file),&image->blob->properties) == 0)
length=(MagickSizeType) image->blob->properties.st_size;
break;
}
@@ -1178,7 +1194,7 @@
#if defined(__WINDOWS__)
if (GetPathAttributes(image->filename,&image->blob->properties) != MagickFalse)
#else
- if (fstat(fileno(image->blob->file),&image->blob->properties) == 0)
+ if (fstat(fileno(image->blob->file_info.file),&image->blob->properties) == 0)
#endif
length=(MagickSizeType) image->blob->properties.st_size;
#endif
@@ -1190,7 +1206,7 @@
#if defined(__WINDOWS__)
if (GetPathAttributes(image->filename,&image->blob->properties) != MagickFalse)
#else
- if (fstat(fileno(image->blob->file),&image->blob->properties) == 0)
+ if (fstat(fileno(image->blob->file_info.file),&image->blob->properties) == 0)
#endif
length=(MagickSizeType) image->blob->properties.st_size;
#endif
@@ -2200,10 +2216,10 @@
if ((LocaleCompare(filename,"-") == 0) ||
((*filename == '\0') && (image_info->file == (FILE *) NULL)))
{
- image->blob->file=(*type == 'r') ? stdin : stdout;
+ image->blob->file_info.file=(*type == 'r') ? stdin : stdout;
#if defined(__WINDOWS__)
if (strchr(type,'b') != (char *) NULL)
- setmode(_fileno(image->blob->file),_O_BINARY);
+ setmode(_fileno(image->blob->file_info.file),_O_BINARY);
#endif
image->blob->type=StandardStream;
image->blob->exempt=MagickTrue;
@@ -2216,10 +2232,10 @@
*mode=(*type);
mode[1]='\0';
- image->blob->file=fdopen(atoi(filename+3),mode);
+ image->blob->file_info.file=fdopen(atoi(filename+3),mode);
#if defined(__WINDOWS__)
if (strchr(type,'b') != (char *) NULL)
- setmode(_fileno(image->blob->file),_O_BINARY);
+ setmode(_fileno(image->blob->file_info.file),_O_BINARY);
#endif
image->blob->type=StandardStream;
image->blob->exempt=MagickTrue;
@@ -2240,8 +2256,8 @@
#endif
*mode=(*type);
mode[1]='\0';
- image->blob->file=(FILE *) popen(filename+1,mode);
- if (image->blob->file == (FILE *) NULL)
+ image->blob->file_info.file=(FILE *) popen(filename+1,mode);
+ if (image->blob->file_info.file == (FILE *) NULL)
{
ThrowFileException(exception,BlobError,"UnableToOpenBlob",filename);
return(MagickFalse);
@@ -2255,8 +2271,8 @@
#if defined(S_ISFIFO)
if ((status == MagickTrue) && S_ISFIFO(image->blob->properties.st_mode))
{
- image->blob->file=(FILE *) OpenMagickStream(filename,type);
- if (image->blob->file == (FILE *) NULL)
+ image->blob->file_info.file=(FILE *) OpenMagickStream(filename,type);
+ if (image->blob->file_info.file == (FILE *) NULL)
{
ThrowFileException(exception,BlobError,"UnableToOpenBlob",filename);
return(MagickFalse);
@@ -2308,8 +2324,8 @@
((strlen(filename) > 5) &&
(LocaleCompare(filename+strlen(filename)-5,".svgz") == 0)))
{
- image->blob->file=(FILE *) gzopen(filename,type);
- if (image->blob->file != (FILE *) NULL)
+ image->blob->file_info.file=(FILE *) gzopen(filename,type);
+ if (image->blob->file_info.file != (FILE *) NULL)
image->blob->type=ZipStream;
}
else
@@ -2318,26 +2334,26 @@
if ((strlen(filename) > 4) &&
(LocaleCompare(filename+strlen(filename)-4,".bz2") == 0))
{
- image->blob->file=(FILE *) BZ2_bzopen(filename,type);
- if (image->blob->file != (FILE *) NULL)
+ image->blob->file_info.file=(FILE *) BZ2_bzopen(filename,type);
+ if (image->blob->file_info.file != (FILE *) NULL)
image->blob->type=BZipStream;
}
else
#endif
if (image_info->file != (FILE *) NULL)
{
- image->blob->file=image_info->file;
+ image->blob->file_info.file=image_info->file;
image->blob->type=FileStream;
image->blob->exempt=MagickTrue;
}
else
{
- image->blob->file=(FILE *) OpenMagickStream(filename,type);
- if (image->blob->file != (FILE *) NULL)
+ image->blob->file_info.file=(FILE *) OpenMagickStream(filename,type);
+ if (image->blob->file_info.file != (FILE *) NULL)
{
image->blob->type=FileStream;
#if defined(MAGICKCORE_HAVE_SETVBUF)
- (void) setvbuf(image->blob->file,(char *) NULL,(int) _IOFBF,
+ (void) setvbuf(image->blob->file_info.file,(char *) NULL,(int) _IOFBF,
16384);
#endif
if (*type == 'r')
@@ -2349,26 +2365,26 @@
magick[3];
(void) ResetMagickMemory(magick,0,sizeof(magick));
- count=fread(magick,1,sizeof(magick),image->blob->file);
- (void) rewind(image->blob->file);
+ count=fread(magick,1,sizeof(magick),image->blob->file_info.file);
+ (void) rewind(image->blob->file_info.file);
(void) LogMagickEvent(BlobEvent,GetMagickModule(),
" read %ld magic header bytes",(long) count);
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (((int) magick[0] == 0x1F) && ((int) magick[1] == 0x8B) &&
((int) magick[2] == 0x08))
{
- (void) fclose(image->blob->file);
- image->blob->file=(FILE *) gzopen(filename,type);
- if (image->blob->file != (FILE *) NULL)
+ (void) fclose(image->blob->file_info.file);
+ image->blob->file_info.file=(FILE *) gzopen(filename,type);
+ if (image->blob->file_info.file != (FILE *) NULL)
image->blob->type=ZipStream;
}
#endif
#if defined(MAGICKCORE_BZLIB_DELEGATE)
if (strncmp((char *) magick,"BZh",3) == 0)
{
- (void) fclose(image->blob->file);
- image->blob->file=(FILE *) BZ2_bzopen(filename,type);
- if (image->blob->file != (FILE *) NULL)
+ (void) fclose(image->blob->file_info.file);
+ image->blob->file_info.file=(FILE *) BZ2_bzopen(filename,type);
+ if (image->blob->file_info.file != (FILE *) NULL)
image->blob->type=BZipStream;
}
#endif
@@ -2401,7 +2417,7 @@
*blob;
length=(size_t) properties->st_size;
- blob=MapBlob(fileno(image->blob->file),ReadMode,0,length);
+ blob=MapBlob(fileno(image->blob->file_info.file),ReadMode,0,length);
if (blob != (void *) NULL)
{
/*
@@ -2411,8 +2427,8 @@
image->blob->exempt=MagickFalse;
else
{
- (void) fclose(image->blob->file);
- image->blob->file=(FILE *) NULL;
+ (void) fclose(image->blob->file_info.file);
+ image->blob->file_info.file=(FILE *) NULL;
}
AttachBlob(image->blob,blob,length);
image->blob->mapped=MagickTrue;
@@ -2578,12 +2594,12 @@
{
default:
{
- count=(ssize_t) fread(q,1,length,image->blob->file);
+ count=(ssize_t) fread(q,1,length,image->blob->file_info.file);
break;
}
case 2:
{
- c=getc(image->blob->file);
+ c=getc(image->blob->file_info.file);
if (c == EOF)
break;
*q++=(unsigned char) c;
@@ -2591,7 +2607,7 @@
}
case 1:
{
- c=getc(image->blob->file);
+ c=getc(image->blob->file_info.file);
if (c == EOF)
break;
*q++=(unsigned char) c;
@@ -2609,12 +2625,12 @@
{
default:
{
- count=(ssize_t) gzread(image->blob->file,q,(unsigned int) length);
+ count=(ssize_t) gzread(image->blob->file_info.gzfile,q,(unsigned int) length);
break;
}
case 2:
{
- c=gzgetc(image->blob->file);
+ c=gzgetc(image->blob->file_info.gzfile);
if (c == EOF)
break;
*q++=(unsigned char) c;
@@ -2622,7 +2638,7 @@
}
case 1:
{
- c=gzgetc(image->blob->file);
+ c=gzgetc(image->blob->file_info.gzfile);
if (c == EOF)
break;
*q++=(unsigned char) c;
@@ -2637,7 +2653,7 @@
case BZipStream:
{
#if defined(MAGICKCORE_BZLIB_DELEGATE)
- count=(ssize_t) BZ2_bzread((BZFILE *) image->blob->file,q,(int) length);
+ count=(ssize_t) BZ2_bzread((BZFILE *) image->blob->file_info.bzfile,q,(int) length);
#endif
break;
}
@@ -3300,7 +3316,7 @@
break;
case FileStream:
{
- if (fseek(image->blob->file,offset,whence) < 0)
+ if (fseek(image->blob->file_info.file,offset,whence) < 0)
return(-1);
image->blob->offset=TellBlob(image);
break;
@@ -3310,7 +3326,7 @@
case ZipStream:
{
#if defined(MAGICKCORE_ZLIB_DELEGATE)
- if (gzseek(image->blob->file,(off_t) offset,whence) < 0)
+ if (gzseek(image->blob->file_info.gzfile,(off_t) offset,whence) < 0)
return(-1);
#endif
image->blob->offset=TellBlob(image);
@@ -3461,7 +3477,7 @@
offset;
offset=TellBlob(image);
- status=posix_fallocate(fileno(image->blob->file),(off_t) offset,
+ status=posix_fallocate(fileno(image->blob->file_info.file),(off_t) offset,
(off_t) (extent-offset));
if (status != 0)
return(MagickFalse);
@@ -3481,7 +3497,7 @@
{
if (image->blob->mapped != MagickFalse)
{
- if (image->blob->file == (FILE *) NULL)
+ if (image->blob->file_info.file == (FILE *) NULL)
return(MagickFalse);
(void) UnmapBlob(image->blob->data,image->blob->length);
#if !defined(MAGICKCORE_POSIX_FALLOCATE)
@@ -3495,12 +3511,12 @@
offset;
offset=TellBlob(image);
- status=posix_fallocate(fileno(image->blob->file),(off_t) offset,
+ status=posix_fallocate(fileno(image->blob->file_info.file),(off_t) offset,
(off_t) (extent-offset));
if (status != 0)
return(MagickFalse);
}
- image->blob->data=(unsigned char*) MapBlob(fileno(image->blob->file),
+ image->blob->data=(unsigned char*) MapBlob(fileno(image->blob->file_info.file),
WriteMode,0,(size_t) extent);
image->blob->extent=(size_t) extent;
image->blob->length=(size_t) extent;
@@ -3568,20 +3584,20 @@
case StandardStream:
case PipeStream:
{
- status=fflush(image->blob->file);
+ status=fflush(image->blob->file_info.file);
break;
}
case ZipStream:
{
#if defined(MAGICKCORE_ZLIB_DELEGATE)
- status=gzflush(image->blob->file,Z_SYNC_FLUSH);
+ status=gzflush(image->blob->file_info.gzfile,Z_SYNC_FLUSH);
#endif
break;
}
case BZipStream:
{
#if defined(MAGICKCORE_BZLIB_DELEGATE)
- status=BZ2_bzflush((BZFILE *) image->blob->file);
+ status=BZ2_bzflush((BZFILE *) image->blob->file_info.file);
#endif
break;
}
@@ -3639,7 +3655,7 @@
break;
case FileStream:
{
- offset=ftell(image->blob->file);
+ offset=ftell(image->blob->file_info.file);
break;
}
case StandardStream:
@@ -3648,7 +3664,7 @@
case ZipStream:
{
#if defined(MAGICKCORE_ZLIB_DELEGATE)
- offset=(MagickOffsetType) gztell(image->blob->file);
+ offset=(MagickOffsetType) gztell(image->blob->file_info.gzfile);
#endif
break;
}
@@ -3766,19 +3782,19 @@
default:
{
count=(ssize_t) fwrite((const char *) data,1,length,
- image->blob->file);
+ image->blob->file_info.file);
break;
}
case 2:
{
- c=putc((int) *p++,image->blob->file);
+ c=putc((int) *p++,image->blob->file_info.file);
if (c == EOF)
break;
count++;
}
case 1:
{
- c=putc((int) *p++,image->blob->file);
+ c=putc((int) *p++,image->blob->file_info.file);
if (c == EOF)
break;
count++;
@@ -3795,20 +3811,20 @@
{
default:
{
- count=(ssize_t) gzwrite(image->blob->file,(void *) data,
+ count=(ssize_t) gzwrite(image->blob->file_info.gzfile,(void *) data,
(unsigned int) length);
break;
}
case 2:
{
- c=gzputc(image->blob->file,(int) *p++);
+ c=gzputc(image->blob->file_info.gzfile,(int) *p++);
if (c == EOF)
break;
count++;
}
case 1:
{
- c=gzputc(image->blob->file,(int) *p++);
+ c=gzputc(image->blob->file_info.gzfile,(int) *p++);
if (c == EOF)
break;
count++;
@@ -3822,7 +3838,7 @@
case BZipStream:
{
#if defined(MAGICKCORE_BZLIB_DELEGATE)
- count=(ssize_t) BZ2_bzwrite((BZFILE *) image->blob->file,(void *) data,
+ count=(ssize_t) BZ2_bzwrite((BZFILE *) image->blob->file_info.file,(void *) data,
(int) length);
#endif
break;
- Migrate 32bit to 64bit (FreeBSD, PostgreSQL)
- Migrate 32bit to 64bit (FreeBSD, GDBM)
- Migrate 32bit to 64bit (FreeBSD, ionCube PHP Loader)
- Migrate to FreeBSD 9.1-RELEASE (ImageMagick 6.4)
- Migrate to FreeBSD 9.1-RELEASE (PostgreSQL)
- Migrate to FreeBSD 9.1-RELEASE (JDK 1.6)
- Migrate to FreeBSD 9.1-RELEASE (idnconv)
- Migrate to FreeBSD 9.1-RELEASE (PDFJ)









