pad2ps


pad2ps は、プログラムの構造図(PAD図)をテキストベースで簡単に描けてしまうツールである。

既存のプログラムを逆変換して眺めることも出来る。

とまあ、割とすごいツールなのであるが、UNIX 上での使用を前提にしてるので事務所での設計作業ではちょっと、使いにくい。

こいつを Windows 上で普通に(Cygwin にすら依存せず)使えるようにしてしまうことを目標とする。→ 2007-02-10 (Sat) 10:55:32 目標達成!!

ダウンロード、説明

本家(3.1j のアーカイブと 3.11j への差分)

http://www.aerith.net/project/pad2ps-j.html

3.11j-pl5 修正パッチ(桑田正行氏のページ)

http://axion-gw.ee.uec.ac.jp/japanese/tools/pad2ps/pad2ps.html

pad2ps の win32 版コンパイル

Cygwin のセットアップ

標準インストール後に下記を追加

  1. binutils
  2. byacc
  3. flex
  4. gcc
  5. gcc-mingw
  6. libiconv
  7. make
  8. patchutils

環境変数の設定(~/.bashrc)

export CC="gcc -mno-cygwin"

nkf のコンパイル、インストール

nkf207.tar.gz を解凍し、Makefile 先頭の cc を gcc -mno-cygwin に変更後、make。

$ gzip -dc nkf207.tar.gz | tar xvf -
nkf207
nkf207/NKF.mod
nkf207/NKF.mod/Changes
nkf207/NKF.mod/MANIFEST
(略)
nkf207/nkf32dll.c
nkf207/version.rc
nkf207/dll.rc
nkf207/dll.def

$ cd nkf207

$ make
gcc -mno-cygwin -O -c utf8tbl.c
gcc -mno-cygwin -O -o nkf nkf.c utf8tbl.o

$ cp -p nkf.exe /usr/local/bin/.

zlib のコンパイル、インストール

$ gzip -dc zlib-1.2.3.tar.gz | tar xvf -
zlib-1.2.3/
zlib-1.2.3/adler32.c
zlib-1.2.3/algorithm.txt
zlib-1.2.3/amiga/
(略)
zlib-1.2.3/zlib.3
zlib-1.2.3/zlib.h
zlib-1.2.3/zutil.c
zlib-1.2.3/zutil.h

$ cd zlib-1.2.3

$ ./configure --libdir=/lib/mingw --includedir=/usr/include/mingw
Building static library libz.a version 1.2.3 with gcc -mno-cygwin.
Checking for unistd.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for errno.h... Yes.
Checking for mmap support... No.

$ make
gcc -mno-cygwin -O3   -c -o example.o example.c
gcc -mno-cygwin -O3   -c -o adler32.o adler32.c
gcc -mno-cygwin -O3   -c -o compress.o compress.c
gcc -mno-cygwin -O3   -c -o crc32.o crc32.c
gcc -mno-cygwin -O3   -c -o gzio.o gzio.c
gcc -mno-cygwin -O3   -c -o uncompr.o uncompr.c
gcc -mno-cygwin -O3   -c -o deflate.o deflate.c
gcc -mno-cygwin -O3   -c -o trees.o trees.c
gcc -mno-cygwin -O3   -c -o zutil.o zutil.c
gcc -mno-cygwin -O3   -c -o inflate.o inflate.c
gcc -mno-cygwin -O3   -c -o infback.o infback.c
gcc -mno-cygwin -O3   -c -o inftrees.o inftrees.c
gcc -mno-cygwin -O3   -c -o inffast.o inffast.c
ar rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zut
il.o inflate.o infback.o inftrees.o inffast.o
gcc -mno-cygwin -O3 -o example.exe example.o -L. libz.a
gcc -mno-cygwin -O3   -c -o minigzip.o minigzip.c
gcc -mno-cygwin -O3 -o minigzip.exe minigzip.o -L. libz.a

$ make install
cp zlib.h zconf.h /usr/include/mingw
chmod 644 /usr/include/mingw/zlib.h /usr/include/mingw/zconf.h
cp libz.a /lib/mingw
cd /lib/mingw; chmod 755 libz.a
cd /lib/mingw; if test -f libz.so.1.2.3; then \
          rm -f libz.so libz.so.1; \
          ln -s libz.so.1.2.3 libz.so; \
          ln -s libz.so.1.2.3 libz.so.1; \
          (ldconfig || true)  >/dev/null 2>&1; \
        fi
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3

pad2ps-3.1j-3.11j.diff.gz の解凍

pad2ps-3.11j-pl5-patch.gz の解凍

pad2ps-3.1j.tar.gz の解凍

$ gzip -dc pad2ps-3.1j.tar.gz | tar xvf -
pad2ps-3.1j/
pad2ps-3.1j/doc/
pad2ps-3.1j/doc/ack.1.eps
pad2ps-3.1j/doc/ack.2.eps
(略)
pad2ps-3.1j/padsty-1.1j.tar.gz
pad2ps-3.1j/INSTALL
pad2ps-3.1j/configure.diff
pad2ps-3.1j/mkpad.man

$ cd pad2ps-3.1j

$ gzip -dc padsty-1.1j.tar.gz | tar xvf -
padsty-1.1j/
padsty-1.1j/guide-j.dvi
padsty-1.1j/guide-j.tex
padsty-1.1j/pad.sty

パッチあて

マニュアルのパッチに失敗したが、使ってないのでよしとする。

$ patch -p1 < ../pad2ps-3.1j-3.11j.diff
patching file HISTORY
patching file INSTALL
patching file README
patching file mkpad.man
patching file pad2ps.man
patching file src/awk2pad/awk2pad.c
patching file src/awk2pad/awk2pad.h
patching file src/awk2pad/token.c
patching file src/c2pad/c2pad.c
patching file src/c2pad/c2pad.h
patching file src/c2pad/parser.c
patching file src/c2pad/token.c
patching file src/csh2pad/csh2pad.c
patching file src/csh2pad/csh2pad.h
patching file src/csh2pad/token.c
patching file src/java2pad/java2pad.c
patching file src/java2pad/java2pad.h
patching file src/java2pad/token.c
patching file src/sh2pad/sh2pad.c
patching file src/sh2pad/sh2pad.h
patching file src/sh2pad/token.c
patching file src/version.h

$ patch -p0 < ../pad2ps-3.11j-pl5-patch
patching file HISTORY
patching file configure
patching file configure.in
patching file doc/manual.index
patching file doc/manual.ps
patching file doc/manual.tex
Hunk #1 succeeded at 1 with fuzz 2.
Hunk #2 FAILED at 71.
Hunk #3 FAILED at 182.
2 out of 3 hunks FAILED -- saving rejects to file doc/manual.tex.rej
patching file doc/modules.eps
patching file pad2ps.man
patching file padsty-1.1j/pad.sty
patching file src/awk2pad/Makefile.in
patching file src/c2pad/Makefile.in
patching file src/c2pad/c2pad.c
patching file src/config.h.in
patching file src/csh2pad/Makefile.in
patching file src/java2pad/Makefile.in
patching file src/java2pad/java2pad.c
patching file src/lib/Makefile.in
patching file src/main/Makefile.in
patching file src/main/main.c
patching file src/pad2ps/Makefile.in
patching file src/pad2ps/pad2ps.c
patching file src/pad2ps/pad2ps.h
patching file src/pad2ps/ps.c
patching file src/pad2ps/tex.c
patching file src/sh2pad/Makefile.in
patching file src/version.h

hnd パッチあて

fp = stdout; 対策

MinGWでも有効になるようにした。

ファイルビジー対策

pad2ps シリーズは、出力先のファイルを開いていたりすると、いきなり落ちるのでエラー処理を追加。
eps の場合は、当該ページの出力だけ飛ばして進む造りも考えたが、現状の処理ではページ単位での処理分割は考慮されていないため断念した。最初のエラーがあったページ以降は出力されません。

ページ番号を用紙下端にする

そのままだと、ページ番号が割と上にあって用紙がもったいないので、ページの座標を修正。(これはなぜかパラメータでは指定できない。出来るようにするのはやめました。)

mkstemp 対策

MinGW にはmkstemp 関数がないので static 関数を定義。

case 文の最初と最後の条件式がくっつきすぎ

ボックスの縦のスペース(box_vspace)だけ空けて体裁を良くした。

make 対応

makefile を組んで使う場合、エラーの時に終了コードが 0 だったり、成果物のタイムスタンプが更新されては困るので対策を行った。

  1. エラーになったときには、出力ファイルに手を付けずに終了するようにした。
  2. エラーになったときには、終了コードを 1 にセットするようにした。

case 文の自動生成文字列

これは趣味の範疇で不具合対策ではないが、switch 文から PAD に落ちるときに、標準では "=" でつなげる。if の中などで " == " としておくと、出来た PAD で不自然なので、switch 文の自動生成では " == " で接続するようにした。(でも no break のときに、|| でつなぐのはやってくれないのでほんの少しだけトーンが合わなくなることがある)

手順

以下のファイルを、pad2ps-3.11j-pl5-hnd-patch として保存(EUCコードで)

その後、pad2ps ディレクトリ内で以下を実行

patch -p1 < ../pad2ps-3.11j-pl5-hnd-patch
diff -ru pad2ps-3.11j-pl5/src/config.h.in pad2ps-3.11j-pl5-hnd/src/config.h.in
--- pad2ps-3.11j-pl5/src/config.h.in    2007-02-09 07:10:46.974776000 +0900
+++ pad2ps-3.11j-pl5-hnd/src/config.h.in    2007-02-10 09:37:51.303710400 +0900
@@ -58,4 +58,21 @@
 /* Define if you enable the feature pdf_info */
 #undef PDF_INFO
 
+/* Add mkstemp function for MinGW */
+#ifdef __MINGW32__
+#include<windows.h>
+static int mkstemp(char* template){
+    char temppath[512];
+    if(GetTempPath(512,temppath)!=0){
+        if(GetTempFileName(temppath,"pad",0,template)!=0){
+            FILE *pFile;
+            pFile=fopen(template,"w+");
+            if(pFile!=NULL)
+            return (int)pFile;
+        }
+    }
+    return -1;
+}
+#endif
+
 #endif /* _CONFIG_H */
diff -ru pad2ps-3.11j-pl5/src/pad2ps/locate.c pad2ps-3.11j-pl5-hnd/src/pad2ps/locate.c
--- pad2ps-3.11j-pl5/src/pad2ps/locate.c    1996-06-28 05:22:44.000000000 +0900
+++ pad2ps-3.11j-pl5-hnd/src/pad2ps/locate.c    2007-02-10 09:59:56.078643200 +0900
@@ -659,13 +659,17 @@
    if(count == 1){             /* 最初の条件式 */
        for(i = 0 ; i <= p->depth_number ; i++){
        rt_labels = rt_labels->next;
-       move_down(rt_labels,child_y - top);
+       /* ぴったり付きすぎるので、                     */
+       /* ボックスの縦のスペース(box_vspace)だけ空ける */
+       move_down(rt_labels,child_y - top + box_vspace);
        }
        parent_next_y += child_y - top;
        top = child_y;
    }else{
        if(count == ptr->child_number)  /* 最後の条件式 */
-       label_y = parent_next_y - vspace;
+       /* ぴったり付きすぎるので、                     */
+       /* ボックスの縦のスペース(box_vspace)だけ空ける */
+       label_y = parent_next_y - vspace + box_vspace;
        else                /* 途中の条件式 */
        label_y = center;
 
diff -ru pad2ps-3.11j-pl5/src/pad2ps/pad2ps.c pad2ps-3.11j-pl5-hnd/src/pad2ps/pad2ps.c
--- pad2ps-3.11j-pl5/src/pad2ps/pad2ps.c    2007-02-09 07:10:47.074920000 +0900
+++ pad2ps-3.11j-pl5-hnd/src/pad2ps/pad2ps.c    2007-02-10 20:57:45.189820800 +0900
@@ -103,7 +103,7 @@
 int line_count = 1;        /* 処理している行 */
 
 FILE *input_stream;        /* 入力ファイル */
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__MINGW32__)
 FILE *fp;              /* 出力ファイル */
 static void fp_construct (void) __attribute__((constructor));
 static void fp_construct (void) { fp = stdout;}
@@ -173,29 +173,40 @@
     pad_parser();          /* PAD のパーサをコール */
     parameter();           /* -P で指定したパラメータ */
 
-    if(outfile[0] != '\0'  &&  outdir[0] != '\0'){ /* 出力ファイルのディレクトリ指定 */
-   char tmp[BUFSIZ];
-   strcpy(tmp,outfile);
-   sprintf(outfile,"%s/%s",outdir,tmp);
-    }
+   if(error_count == 0){
 
-    if(strcmp(thiscmd,"pad2tex") == 0)
-   tex();
-    else{
-   fold();
-   locate();
-   sort();
-   if(strcmp(thiscmd,"pad2eps") == 0)
-       eps_flag = On;
-   if(strcmp(thiscmd,"pad2pdf") == 0)
-       pdf_flag = On;
-   ps();
-    }
+       if(outfile[0] != '\0'  &&  outdir[0] != '\0'){  /* 出力ファイルのディレクトリ指定 */
+       char tmp[BUFSIZ];
+       strcpy(tmp,outfile);
+       sprintf(outfile,"%s/%s",outdir,tmp);
+       }
+
+       if(strcmp(thiscmd,"pad2tex") == 0)
+       tex();
+       else{
+       fold();
+       locate();
+       sort();
+       if(strcmp(thiscmd,"pad2eps") == 0)
+           eps_flag = On;
+       if(strcmp(thiscmd,"pad2pdf") == 0)
+           pdf_flag = On;
+       ps();
+       }
+
+   }else{
+       /* パーサでエラーがあった場合は出力しない(make対策) */
+       fprintf(stderr,"\nAborted.\n");
+   }
 
     if(quiet == Off)
    fprintf(stderr,"\n%d errors, %d warnings.\n",error_count,warning_count);
 
-    return 0;
+   if(error_count > 0){
+       return 1;
+   }else{
+       return 0;
+   }
 }
 
 void pad_parser(void)
diff -ru pad2ps-3.11j-pl5/src/pad2ps/pad2ps.h pad2ps-3.11j-pl5-hnd/src/pad2ps/pad2ps.h
--- pad2ps-3.11j-pl5/src/pad2ps/pad2ps.h    2007-02-09 07:10:47.074920000 +0900
+++ pad2ps-3.11j-pl5-hnd/src/pad2ps/pad2ps.h    2007-02-10 01:02:44.008969600 +0900
@@ -29,7 +29,7 @@
 #define PAGE_BOTTOM    0   /* ページの下端 */
 #define PAGE_LEFT  500 /* ページの左端 */
 #define PAGE_RIGHT 8500    /* ページの右端 */
-#define PAGENUMBER_Y   -1000   /* ページ番号の出力位置 */
+#define PAGENUMBER_Y   -2000   /* ページ番号の出力位置 */
 #define INVALID        -50000  /* 無効な座標 */
 #define INFINITY   50000   /* 無限幅 */
 
diff -ru pad2ps-3.11j-pl5/src/pad2ps/parser.y pad2ps-3.11j-pl5-hnd/src/pad2ps/parser.y
--- pad2ps-3.11j-pl5/src/pad2ps/parser.y	1996-07-30 04:11:28.000000000 +0900
+++ pad2ps-3.11j-pl5-hnd/src/pad2ps/parser.y	2007-02-14 18:43:43.832446400 +0900
@@ -612,9 +612,9 @@
 	s = str;
     else{
 	l = strlen(p)+1;
-	s = (char *)malloc((l+2)*sizeof(char));
+	s = (char *)malloc((l+5)*sizeof(char)); /* C言語ライク("=" → " == ")に変更 */
 	strcpy(s,p);
-	strcat(s,"=");
+	strcat(s," == "); /* C言語ライク("=" → " == ")に変更 */
 	s = joint(2,s,str);
     }
 
diff -ru pad2ps-3.11j-pl5/src/pad2ps/ps.c pad2ps-3.11j-pl5-hnd/src/pad2ps/ps.c
--- pad2ps-3.11j-pl5/src/pad2ps/ps.c    2007-02-09 07:10:47.114977600 +0900
+++ pad2ps-3.11j-pl5-hnd/src/pad2ps/ps.c    2007-02-10 20:53:39.646747200 +0900
@@ -193,6 +193,7 @@
 /* PostScript の作成 */
 {
     char tmp[BUFSIZ];
+    char tmp2[BUFSIZ];
 
 #ifdef DEBUG
     if(quiet == Off){
@@ -214,18 +215,33 @@
        fp = fopen(outfile,"w");
     }
 
-    init_ps();
-
-    begin_ps();
-    draw_pad();
-    end_ps();
-
-    if(eps_flag == On)
-   fclose(fp);
-    else{
-   if(outfile[0] != '\0')
-       fclose(fp);
-    }
+   if(fp != NULL){
+       
+       init_ps();
+
+       begin_ps();
+       draw_pad();
+       
+       if(fp != NULL){
+            /* eps 改ページ時の open error が無い場合 */
+           end_ps();
+
+           if(eps_flag == On)
+           fclose(fp);
+           else{
+           if(outfile[0] != '\0')
+               fclose(fp);
+           }
+       }
+       
+   }else{
+       if(eps_flag == On){
+           sprintf(tmp2,"output file '%s' open error -- aborted.",tmp);
+       }else{/* ps or pdf */
+           sprintf(tmp2,"output file '%s' open error -- aborted.",outfile);
+       }
+       error(tmp2);
+   }
 
     if(quiet == Off  &&  print_warning == Off)
         fputc('\n',stderr);
@@ -267,6 +283,8 @@
        /* 完全に次ページに位置するPADが登場したら改ページ */
        newpage();
 
+   if(fp == NULL) return; /* eps 改ページ時の open error */
+
    if(Y(lp->y + lp->h) <= page_top)    /* 全く範囲外のPADはとばす */
    {
        if(Y(lp->y + lp->h) < page_bottom  &&  back == NULL)
@@ -772,6 +790,7 @@
 /* 改ページ */
 {
     char tmp[BUFSIZ];
+    char tmp2[BUFSIZ];
    
     if(left_more == Off  &&  right_more == Off)
         y_base += page_height;
@@ -787,6 +806,13 @@
 
    sprintf(tmp,"%s.%d.eps",outfile,page + 1);
    fp = fopen(tmp,"w");
+   if(fp == NULL){
+       sprintf(tmp2,"output file '%s' open error -- aborted.",tmp);
+       error(tmp2);
+               /* 処理の流れから、当該ページだけ飛ばして       */
+               /* 次のページを出力するのは困難なため中止とする */
+       return; /* draw_pad() でも検出して ps() に制御を戻す    */
+   }
    begin_ps();
     }else{
    fputs("showpage\n",fp);
diff -ru pad2ps-3.11j-pl5/src/version.h pad2ps-3.11j-pl5-hnd/src/version.h
--- pad2ps-3.11j-pl5/src/version.h	2007-02-09 07:10:47.145020800 +0900
+++ pad2ps-3.11j-pl5-hnd/src/version.h	2007-03-21 08:44:19.257240000 +0900
@@ -7,7 +7,7 @@
 #ifndef _VERSION_H
 #define _VERSION_H
 
-#define VERSION		"3.11j-pl5  2006-07-04"
+#define VERSION		"3.11j-pl5-hnd  2007-02-10"
 #define AUTHOR		"S. Yoshida (seiichi@muraoka.info.waseda.ac.jp)"
 
 #endif  /* ! _VERSION_H */

コンパイル

重要 zlib を使った圧縮 pdf 作成機能は、(少なくともこのページの make 方法では)生成した pdf にエラーが発生してしまう。
圧縮機能を切れば問題ない。ここでは configure に --disable-pdf-deflate オプションを与えて無効化している。これで pad2pdf もまともに動きとっても幸せ。

ストリームのサイズを、他のオブジェクトと同様な指定方法で与えているようであるが、pdf の仕様では、非圧縮を含めて最初に /Length を定義するのが正解。直そうと思ったけど、かなり大変(大体圧縮後のバイト数を最初に算出するなんて面倒すぎ)なんで、とりあえずそのまま…

なお圧縮を切っていることから、zlib のインストールは多分不要。

(後で原因判明し、--disable-pdf-deflate 指定したため下のコンソール出力は実際、--enable-pdf-deflate 状態によるものであるが大きく変わりはない)

$ ./configure --disable-pdf-deflate
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking for gcc... gcc -mno-cygwin
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -mno-cygwin accepts -g... yes
checking for gcc -mno-cygwin option to accept ANSI C... none needed
checking for bison... no
checking for byacc... byacc
checking for flex... flex
checking for yywrap in -lfl... yes
checking lex output file root... lex.yy
checking whether yytext is a pointer... yes
checking for ranlib... ranlib
checking for sh... "/bin/sh"
checking for make... /usr/bin/make
checking how to run the C preprocessor... gcc -mno-cygwin -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for unistd.h... (cached) yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking varargs.h usability... no
checking varargs.h presence... no
checking for varargs.h... no
checking for atexit... yes
checking for on_exit... no
checking for asprintf... no
checking for snprintf... yes
checking for style files directory... "."
checking for deflate in -lz... yes
checking for struct tm.tm_gmtoff... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/lib/Makefile
config.status: creating src/mkpad/Makefile
config.status: creating src/main/Makefile
config.status: creating src/pad2ps/Makefile
config.status: creating src/awk2pad/Makefile
config.status: creating src/c2pad/Makefile
config.status: creating src/csh2pad/Makefile
config.status: creating src/java2pad/Makefile
config.status: creating src/sh2pad/Makefile
config.status: creating src/config.h

$ make
cat src/config.h | sed -e "s/^#define LPATH .*/#define LPATH \"`echo /usr/local/
lib/pad2ps | tr / @`\"/" > src/.config.h.tmp
cat src/.config.h.tmp | tr @ / > src/config.h
if test "byacc" = "yacc"; then \
                cat src/config.h | sed -e "s/^\/\* #undef YACC_NO_VOID_PTR .*/#d
efine YACC_NO_VOID_PTR 1/" > src/.config.h.tmp; \
                mv src/.config.h.tmp src/config.h; \
        fi
rm -f src/.config.h.tmp
cd src/lib; for i in lib mkpad main pad2ps awk2pad c2pad csh2pad java2pad sh2pad
; do cd ../$i; /usr/bin/make ; done
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/lib'
gcc -mno-cygwin -O2 -I.. -I.. -c error.c
gcc -mno-cygwin -O2 -I.. -I.. -c stack.c
gcc -mno-cygwin -O2 -I.. -I.. -c string.c
ar cru libpublic.a error.o stack.o string.o
ranlib libpublic.a
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/lib'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/mkpad'
cat ../version.h | grep "#define\ VERSION" | sed -e "s/.*\"\(.*\)\"/\1/" > .vers
ion
cat ../version.h | grep "#define\ AUTHOR" | sed -e "s/.*\"\(.*\)\"/\1/" > .autho
r
if test "/bin/sh" = no; then \
                cat mkpad.in | sed -e "s/^\(.*\)\@SH\@\(.*\)/\1%bin%sh\2/" > .mk
pad.tmp.1; \
        else \
                cat mkpad.in | sed -e "s/^\(.*\)\@SH\@\(.*\)/\1`echo /bin/sh | t
r / %`\2/" > .mkpad.tmp.1; \
        fi
cat .mkpad.tmp.1 | sed -e "s/^\(.*\)\@LIBDIR\@\(.*\)/\1`echo /usr/local/lib/pad2
ps | tr / %`\2/" > .mkpad.tmp.2
cat .mkpad.tmp.2 | sed -e "s/^\(.*\)\@VERSION\@\(.*\)/\1`cat .version | tr / %`\
2/" > .mkpad.tmp.3
cat .mkpad.tmp.3 | sed -e "s/^\(.*\)\@AUTHOR\@\(.*\)/\1`cat .author | tr / %`\2/
" > .mkpad.tmp.4
cat .mkpad.tmp.4 | tr % / > mkpad
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/mkpad'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/main'
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c main.c
gcc -mno-cygwin  main.o -o pad2ps -lz  -L../lib -lpublic
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/main'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/pad2ps'
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c fold.c
In file included from fold.c:11:
pad2ps.h:34:1: warning: "INFINITY" redefined
In file included from fold.c:10:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/math.h:29
5:1: warning: this is the location of the previous definition
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c font.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c locate.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c pad2ps.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c ps.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c sort.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c string.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c tex.c
if test "flex" = "flex"; then \
                cat parser.l.in | sed -e "s/^CH.*/CH                    [A-Za-z_
\\\\200-\\\\377]/" > parser.l; \
        else \
                cp parser.l.in parser.l; \
        fi
if test "flex" = "lex"; then \
                lex -e parser.l; \
        elif test "flex" = "flex"; then \
                flex -8 parser.l; \
        else \
                flex parser.l; \
        fi
byacc parser.y
byacc: 2 shift/reduce conflicts
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c y.tab.c
gcc -mno-cygwin  fold.o font.o locate.o pad2ps.o ps.o sort.o string.o tex.o y.ta
b.o -o pad2ps -lz  -lfl -L../lib -lpublic -lm
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/pad2ps'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/awk2pad'
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c awk2pad.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c parser.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c token.c
gcc -mno-cygwin  awk2pad.o parser.o token.o -o awk2pad -lz  -L../lib -lpublic
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/awk2pad'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/c2pad'
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c c2pad.c
In file included from c2pad.c:17:
c2pad.h:22:1: warning: "TRUE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from c2pad.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:55:1: war
ning: this is the location of the previous definition
In file included from c2pad.c:17:
c2pad.h:23:1: warning: "FALSE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from c2pad.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:52:1: war
ning: this is the location of the previous definition
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c ifdef.c
In file included from ifdef.c:14:
c2pad.h:22:1: warning: "TRUE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from ifdef.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:55:1: war
ning: this is the location of the previous definition
In file included from ifdef.c:14:
c2pad.h:23:1: warning: "FALSE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from ifdef.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:52:1: war
ning: this is the location of the previous definition
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c parser.c
In file included from parser.c:14:
c2pad.h:22:1: warning: "TRUE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from parser.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:55:1: war
ning: this is the location of the previous definition
In file included from parser.c:14:
c2pad.h:23:1: warning: "FALSE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from parser.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:52:1: war
ning: this is the location of the previous definition
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c token.c
In file included from token.c:14:
c2pad.h:22:1: warning: "TRUE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from token.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:55:1: war
ning: this is the location of the previous definition
In file included from token.c:14:
c2pad.h:23:1: warning: "FALSE" redefined
In file included from /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32
api/windows.h:48,
                 from ../config.h:64,
                 from token.c:7:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api/windef.h:52:1: war
ning: this is the location of the previous definition
gcc -mno-cygwin  c2pad.o ifdef.o parser.o token.o -o c2pad -lz  -L../lib -lpubli
c
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/c2pad'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/csh2pad'
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c csh2pad.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c parser.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c token.c
gcc -mno-cygwin  csh2pad.o parser.o token.o -o csh2pad -lz  -L../lib -lpublic
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/csh2pad'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/java2pad'
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c java2pad.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c parser.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c token.c
gcc -mno-cygwin  java2pad.o parser.o token.o -o java2pad -lz  -L../lib -lpublic
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/java2pad'
make[1]: Entering directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/sh2pad'
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c sh2pad.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c parser.c
gcc -mno-cygwin -O2 -I.. -I../lib -I.. -I../lib -c token.c
gcc -mno-cygwin  sh2pad.o parser.o token.o -o sh2pad -lz  -L../lib -lpublic
make[1]: Leaving directory `/home/cat/pad2ps-3.11j-pl5-hnd/src/sh2pad'
gzip -dc padsty-1.1j.tar.gz | tar xfv -
padsty-1.1j/
padsty-1.1j/guide-j.dvi
padsty-1.1j/guide-j.tex
padsty-1.1j/pad.sty

make install がなぜか出来ない。以下となる。謎… (GNU Make 3.81)
Makefile の中のターゲットを install から install.prg にして、make install.prg とやったらとりあえず動いたが自分としては納得いかず。

make: `install' is up to date.

makefile

hnd パッチ版において、当該ディレクトリの全ての .pad を .pdf に make するには、下記の makefile を用いればよい。
もちろん変更のあった .pad だけを変換してくれる。

パッチを適用していない 3.11j-pl5 版では、エラーになっても .pdf の作成まで突き進む(ファイルのタイムスタンプが更新されてしまう)ので次回 make が通らないのと、常に終了コードが 0 のため中断しない等不都合があるので注意。

TARGETS = \
	$(patsubst %.pad,%.pdf,$(wildcard *.pad))

OPTIONS = \
	hrate=0.5 vrate=0.5 slice=off centering=off \
	page_top=10900 page_right=9400 page_bottom=-1300 \
	linewidth=10 padlinewidth=10 framelinewidth=4 page=1 \
	pad_vspace=300 box_vspace=40

.SUFFIXES:	.pad .pdf

.pad.pdf:
	@echo ------------------------------------------------------------------------------
	pad2pdf $< $@ -P $(OPTIONS)

all: $(TARGETS)

clean:
	rm -f *.pdf

カスタマイズ

調子の良いオプション

試行錯誤した結果、割と大きいモジュールでもそれらしく出るオプション

hrate=0.5 vrate=0.5 slice=off centering=off page_top=10900 page_right=9400 page_bottom=-1300 linewidth=10 padlinewidth=10 framelinewidth=4 page=1 pad_vspace=300 box_vspace=40

その他

MinGW 版の不具合

title パラメータを指定しない場合

title を指定しない場合、ファイル名からタイトルの文字列を生成するが、文字コードの変換をしていないので、MinGW 環境では EUC とならず(SJIS)文字化けする。

ファイル内部で title をインライン指定すべし。

完全にスタンドアロンで使う

完全にスタンドアロンで使うには、実は、cat.exe も必要になる。
これは、textutils というパッケージなので、別途ダウンロードしてコンパイルする。
面倒であれば、UnxUtils(http://unxutils.sourceforge.net/)を使うのも手。

コメント

名前: コメント:

  • 2010-10-13 (Wed) 15:06:02 take? : make install がこけるのは"INSTALL"ファイルがあるから

ナビゲーション

プロフィール

Photo Hondarer  My status

自分に正直に、目指す物を目指すかたちで、全ての人が幸せになれるシステムを削り出す職人でありたい。

Powered by
HndWiki 004388