Home » FreeBSD » Migrate to FreeBSD 9.1-RELEASE (ImageMagick 6.4) (Tag: )

古い 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;

Random Select

YASAI シャンプー & ヘアパック
こなゆきコラーゲン でお世話になっている タマチャンショップ が実に色々商品を出していることを知り、国産 21 世紀雑穀米 を買った際に YASAI シャンプー & ヘアパック も併せて買って
ARROWS X F-10D
ARROWS X F-10D (No. 3) の続きです。電源が入らなくなりました使い始めて 8 ヶ月程で数回腰程の高さから落としてしまったことがあります。リアカバー (裏フタ) までパカッと開いてお
石垣島ドリーム観光 (3)
石垣島 (No. 11 – 石垣御神埼灯台) の続きです。前日は石垣島をほぼ一周しましたが、翌日 05/06 は黒島を訪れることにしていました。石垣港離島ターミナルは数年前に西表島を訪れて
2013/01/14 14:00 羽田空港
沖縄出張 (No. 14 ? 欠航 Part 2) の続きです。充電避難と振り替え手続き地下まで降りてようやくマクドナルドで空席を見つけました。着席して 10 分程でコンセントの空きが出来たので、手持
立山連峰 (4)
富山出張 (No. 4 ? スターバックス コーヒー 富山環水公園店) の続きです。出張 2 日目は移動日として東京に帰りました。初日に富山空港の外に出た瞬間に気が付きましたが、正面一帯に立山連峰が見
伊江島 (11)
伊江島 (No. 4 – 湧出 〜 島の駅) の続きです。島の駅から戻って伊江港ターミナルにつくと、もう車を搬入するにはちょうど良い時間でした。乗船まではまだ少し時間がありそうでしたので、
エビだけ天丼 (2)
My Select "日本一シリーズ" 第 2 弾です。"エビだけ天丼" というメニュー自体、あまり聞きませんが沖縄出張の際の楽しみの 1 つになりつつあります
Havana カレー (キーマ, ライス大盛り, ルー大盛り x 2, 辛さ 20 倍)
沖縄出張 (No. 20 – Havana CURRY ふたたび) の続きです。投稿としては Season 2 (2013/01/15 – 2013/01/26) 以来ですが、
百人のキセキ 至福のブラウンエール (3)
最近黒ビールを良く試していますが、ある時また見慣れないビールを見つけました。ニュースリリース 百人ビール・ラボ によると "サッポロ 百人のキセキ 至福のブラウンエール" 限定発売
スーパーマック
マクドナルド 懐かしのメニュー (イントロ) の続き。第一弾は "スーパーマック" です。写真が残っていました。(Web 上にですが)価格は単品で 450 円。単品価格としては史上
Valid HTML5 Valid CSS3 Another HTML Lint