移動先 先頭, , , 末尾 セクション, 目次.

gawkのインストール

この章ではデベロッパによってサポートされているさまざまなプラットフォームでの gawkのインストールについて説明する。本来のデベロッパはUnix(そしていつ かはGNU)をサポートし、他の環境へは移植される。 gawkの配布パッケージ中 の`ACKNOWLEDGMENT'というファイルには移植作業を行なっている人達の電子メ イルアドレスがリストアップされている。

gawkの配布

このセクションではまずgawkの配布パッケージの入手と展開。そしてサブディ レクトリ中のファイルについて説明する。

gawk の配布キットの入手

gawkはGNU Zipプログラム、gzipによって圧縮されたtarファ イルとして配布されている。そしてそれは インターネットのprep.ai.mit.eduにanonymous ftpすることによって 入手できる。 全てのGNUソフトウェアと同じように、anonymous uucpを使って配布を受ける こともできる。 また、Free Software Foundationに直接gawkの入ったテープやCD-ROMを オーダーすることも可能である。(そのアドレスはcopyrightページにある。) そのような直接的な寄付はfoundatiosのサポートやより多くのフリーソフトの 作成のためになる。

配布を受けたならば(`gawk-2.15.0.tar.z'というファイルだとしよう) まずgzipを使って伸張し、さらにtarで展開する。 gawkの配布パッケージを次のようなパイプで展開できる。

# Under System V, add 'o' to the tar flags
gzip -d -c gawk-2.15.0.tar.z | tar -xvpf -

このやり方では`gawk-2.15.0'という名前のディレクトリをカレントディレクトリ の下に作成する。

配布ファイルは`gawk-2.15.n.tar.z'という形の名前がついていて、 nパッチレベルを表わし、メジャーリリースのなかで バグフィックスが行なわれたマイナーチェンジを意味する。 現在ののパッチレベルは0であるが、配布を受けたときには もっとも高いパッチレベルのバージョンを入手すべきであろう。

もしあなたがの使うシステムがUNIXでないのであれば、入手や展開の方法を変える必 要があるかもしれない。詳しいことは身近の詳しい人に相談すべきだろう。

gawkの配布キットの内容

gawkには複数のCのソースファイルと、ドキュメントファイル、サブディレク トリとオペレーティングシステムごとのコンフィグレーションプロセス (セクション Unix上でのgawkのコンパイルとインストールを参照), に関係したファイルがある。

various `.c', `.y', and `.h' files
CとYACCのソースファイルはgawkのソースコードである。
`README'
`README.VMS'
`README.dos'
`README.rs6000'
`README.ultrix'
`README'は UNIX上のgawkのもので、その他のものは様々なハードウェ ア・ソフトウェアの組み合わせのものである。
`PORTS'
gawkがすでに移植され、テストに成功しているシステムのリスト。
`ACKNOWLEDGMENT'
プログラムのコードやドキュメントの主要な部分を寄附してくれた人の リスト。
`NEWS'
gawkの以前のリリース、またはパッチからの変更点のリスト。
`COPYING'
GNU General Public License(GNU 一般公有使用許諾書)。
`FUTURES'
将来のリリースで考慮されている機能や変更のリスト。 (機能や変更の)難しさに応じて、いつぐらいに (どのバージョンくらいに)それが行われるかの目安もある。
`LIMITATIONS'
gawkの動作上の限界のリスト。その多くはハードウェアやオペレーティング システムに依存するもので、 gawk自身の制限ではではない。
`PROBLEMS'
現時点で知られている問題点を記述したファイル。
`gawk.1'
gawkについて記述されたマニュアルページのtroffソース。
`gawk.texinfo'
このマニュアルのtexinfoのソースファイル。 これをTeXで処理すると印刷マニュアルを作成し、 makeinfoでInfoファイルを作成する。
`Makefile.in'
`config'
`config.in'
`configure'
`missing'
`mungeconf'
さまざまなUNIXシステムのためにgawkを変更するときに使用する ファイルやサブディレクトリ セクション Unix上でのgawkのコンパイルとインストールを参照.
`atari'
gawkをAtari ST上で作成するときに必要となるファイル。詳しくは セクション Atari STへのgawkのインストールを参照.
`pc'
MS-DOS環境下でgawkを作成するときに必要となるファイル。詳しくは セクション MS-DOS上へのgawkのインストールを参照.
`vms'
VMS の元でgawkを作成するときに必要となるファイル。詳しくは セクション VMSでのgawkのコンパイル、インストールと実行を参照.
`test'
gawkをテストするための多くの興味深いawkプログラム。 gawkのトップディレクトリで`make test'とすることで、作成した gawkに対してテストを行なう。そこにあるプログラムはその正しさにおいて 便利である(?)。 gawk`make bigtest'に成功すれば、移植に成功した と確信できる。

Unix上でのgawkのコンパイルとインストール

大概の場合、gawkをコンパイルし、インストールするのにたった二つのコマ ンドをタイプするだけですむが、もしあなたがサポートされているシステムを使って いないのであれば、あなたの使っているシステムの為にgawkを修正する必要 があるかもしれない。

サポートされているUnixでのgawkのコンパイル

配布されたgawkを展開した後、`gawk-2.15'cdする。 `config'サブディレクトリ中であなたの使っているハードウェア/ソフトウェア の組み合わせに合うファイルを探す。通常は、ソフトウェアだけが問題となる。たと えば、 sunos41はSun 3 と Sun 4 という両方のハードウェア上の SunOS 4.1 のときに使われる。

そういったファイルが見つかったら次のコマンドを実行する。

# assume you have SunOS 4.1
./configure sunos41

これによりあなたの使用しているシステムの為の `Makefile'`config.h' が作られる。このときGNU Cコンパイラ以外のCコンパイラを使うために`Makefile' をエディットすることもできる。 Cコンパイラに渡すオプションを、 CFLAGS という変数を変更することで制御できる(最適化のレベルや、デバッグ用のコンパイ ルなどの指定)。

`Makefile'`config.h'を修正した後にこうタイプする。

make

するとgawkの実行ファイルが得られる。 そして、これで全ておしまい!

コンフィグレーションの手順

(このセクションは、C や Unix の使い方を知っている人でなければ興味が ないところだろう)

gawkのソースコードは、一般に可能であるならば産業的な標準にくっつく(?) ことを試みる。つまりこれは、gawkは ANSI のC標準や、POSIX のオペレーティ ングシステムインターフェース標準のライブラリルーチンを使用するということであ る。 ANSI コンパイラを使用するとき、コンパイル時のチェックをよりよくするため に関数プロトタイプが使用される。

古いUNIXシステムの多くでは、ANSI も POSIX の標準もサポートしていない。 gawkの配布キットには、そういったシステムで足りないものの多くが `missing'というサブディレクトリに入れられている。

`config.h'というファイルは、gawkをコンパイルしようとするオペレー ティングシステムの機能の記述をもとに configureプログラムによって作成 される。その記述の大部分は、ある基本的なサブルーチンが使えないというリストで ある。たとえば、コンパイルしようとしている環境に`getopt'がない場合には、 `GETOPT_MISSING'が定義される。

`config.h'はまた、さまざまなUNIXシステムの記述や、定数の定義を行なう。 たとえば、`st_blksize'というメンバが、構造体statに含まれていない 場合、 `BLKSIZE_MISSING'が定義される。

`config.h'中の足りない基本サブルーチンのリストを基に、 `missing.c' はサブディレクトリ`missing'から必要なファイルを`#include'する。

ほかのソースファイル中の条件コンパイルされるコードは、 `config.h'で定義される他の定義に依存する。

さらに`config.h'の作成によって、configure`Makefile.in'か ら `Makefile'を作成する。 `Makefile.in'の何行かはシステムや、機能 の特定をするものである。

たとえば、`##MAKE_ALLOCA_C##'がそうである。これは`#'で始まっているので 通常はコメント行である。コンフィグレーションファイルの中に`MAKE_ALLOCA_C'と いう行があったならば、 configureは行の最初から`##MAKE_ALLOCA_C##'を 削除する。これはCバージョンの`alloca'を 使うときに`Makefile'のルールの中で可能となる。幾つかの似たような機能に ついても、同様の操作が行なわれる。

新しいシステムに対する gawk のコンフィグレーション

(このセクションはC言語と、UNIXオペレーティングシステムについて知っていて、 gawkの配布キットではサポートされていないシステムにgawkをインス トールしなければならないような人以外には興味をひかないところだろう。もし、あ なたがCやUNIXの初心者であるならば、近くのエキスパートの助けを求めるように)

配布キットでサポートされていないUnixシステムへgawkを コンフィグレーションする必要があるならば、最初に セクション コンフィグレーションの手順を参照を見るように。 そして、`config.in'`config.h'にコピーし、 `Makefile.in'`Makefile'にコピーする。

続いてこの二つのファイルを編集する。二つのファイルともライブラリがコメントさ れていて、必要があれば正直に変更せねばならない。

`config.h'を編集しているときに、システムのドキュメントやarやnmといった ユーティリティを使ってライブラリを見て、ライブラリルーチンがあるかないかを決 定する必要がある。最悪のケースでは、単純にマクロを定義するだけではすまない場 合もある。 gawkをコンパイルしたときに、最後のリンクの段階で失敗する羽 目になる。リンカは解決できなかった外部参照のリストを出力するだろう。そこにあ るのが足りないサブルーチンである。もう一度`config.h'を編集し、コンパイ ルする。

`Makefile'の編集も正直にやらなければならない。 `##MAKE_whatever##'で始まる行から可能か、不可能かを選択する。 Cコ ンパイラや、CFLAGSを選択し、makeを実行する。

正しいコンフィグレーションを得るには、このプロセスが繰り返されることになるだ ろう。もし、何回も試すことになってもがっかりしてはいけない。あなたが幸運の詩 を持っていなければ、あなたのシステムタイプとあなたが行なったステップとをレポ ートして欲しい。一度あなたがコンフィグレーションを行なったら、どうかそれをあ なたの使っているシステムをオフィシャルなリリースに加えさせるために、メンテナ ンスを行なっている人に送って欲しい。

セクション Reporting Problems and Bugsを参照, for information on how to report problems in configuring gawk. You may also use the same mechanisms for sending in new configurations.

VMSでのgawkのコンパイル、インストールと実行

This section describes how to compile and install gawk under VMS.

Compiling gawk under VMS

To compile gawk under VMS, there is a DCL command procedure that will issue all the necessary CC and LINK commands, and there is also a `Makefile' for use with the MMS utility. From the source directory, use either

$ @[.VMS]VMSBUILD.COM

or

$ MMS/DESCRIPTION=[.VMS]DECSRIP.MMS GAWK

Depending upon which C compiler you are using, follow one of the sets of instructions in this table:

VAX C V3.x
Use either `vmsbuild.com' or `descrip.mms' as is. These use
CC/OPTIMIZE=NOLINE, which is essential for Version 3.0.
VAX C V2.x
You must have Version 2.3 or 2.4; older ones won't work. Edit either `vmsbuild.com' or `descrip.mms' according to the comments in them. For `vmsbuild.com', this just entails removing two `!' delimiters. Also edit `config.h' (which is a copy of file `[.config]vms-conf.h') and comment out or delete the two lines `#define __STDC__ 0' and `#define VAXC_BUILTINS' near the end.
GNU C
Edit `vmsbuild.com' or `descrip.mms'; the changes are different from those for VAX C V2.x, but equally straightforward. No changes to `config.h' should be needed.
DEC C
Edit `vmsbuild.com' or `descrip.mms' according to their comments. No changes to `config.h' should be needed.

gawk 2.15 has been tested under VAX/VMS 5.5-1 using VAX C V3.2, GNU C 1.40 and 2.3. It should work without modifications for VMS V4.6 and up.

Installing gawk on VMS

To install gawk, all you need is a "foreign" command, which is a DCL symbol whose value begins with a dollar sign.

$ GAWK :== $device:[directory]GAWK

(Substitute the actual location of gawk.exe for `device:[directory]'.) The symbol should be placed in the `login.com' of any user who wishes to run gawk, so that it will be defined every time the user logs on. Alternatively, the symbol may be placed in the system-wide `sylogin.com' procedure, which will allow all users to run gawk.

Optionally, the help entry can be loaded into a VMS help library:

$ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP

(You may want to substitute a site-specific help library rather than the standard VMS library `HELPLIB'.) After loading the help text,

$ HELP GAWK

will provide information about both the gawk implementation and the awk programming language.

The logical name `AWK_LIBRARY' can designate a default location for awk program files. For the `-f' option, if the specified filename has no device or directory path information in it, gawk will look in the current directory first, then in the directory specified by the translation of `AWK_LIBRARY' if the file was not found. If after searching in both directories, the file still is not found, then gawk appends the suffix `.awk' to the filename and the file search will be re-tried. If `AWK_LIBRARY' is not defined, that portion of the file search will fail benignly.

Running gawk on VMS

Command line parsing and quoting conventions are significantly different on VMS, so examples in this manual or from other sources often need minor changes. They are minor though, and all awk programs should run correctly.

Here are a couple of trivial tests:

$ gawk -- "BEGIN {print ""Hello, World!""}"
$ gawk -"W" version     ! could also be -"W version" or "-W version"

Note that upper-case and mixed-case text must be quoted.

The VMS port of gawk includes a DCL-style interface in addition to the original shell-style interface (see the help entry for details). One side-effect of dual command line parsing is that if there is only a single parameter (as in the quoted string program above), the command becomes ambiguous. To work around this, the normally optional `--' flag is required to force Unix style rather than DCL parsing. If any other dash-type options (or multiple parameters such as data files to be processed) are present, there is no ambiguity and `--' can be omitted.

The default search path when looking for awk program files specified by the `-f' option is "SYS$DISK:[],AWK_LIBRARY:". The logical name `AWKPATH' can be used to override this default. The format of `AWKPATH' is a comma-separated list of directory specifications. When defining it, the value should be quoted so that it retains a single translation, and not a multi-translation RMS searchlist.

Building and using gawk under VMS POSIX

Ignore the instructions above, although `vms/gawk.hlp' should still be made available in a help library. Make sure that the two scripts, `configure' and `mungeconf', are executable; use `chmod +x' on them if necessary. Then execute the following commands:

$ POSIX
psx> configure vms-posix
psx> make awktab.c gawk

The first command will construct files `config.h' and `Makefile' out of templates. The second command will compile and link gawk. Due to a make bug in VMS POSIX V1.0 and V1.1, the file `awktab.c' must be given as an explicit target or it will not be built and the final link step will fail. Ignore the warning `"Could not find lib m in lib list"'; it is harmless, caused by the explicit use of `-lm' as a linker option which is not needed under VMS POSIX. Under V1.1 (but not V1.0) a problem with the yacc skeleton `/etc/yyparse.c' will cause a compiler warning for `awktab.c', followed by a linker warning about compilation warnings in the resulting object module. These warnings can be ignored.

Once built, gawk will work like any other shell utility. Unlike the normal VMS port of gawk, no special command line manipulation is needed in the VMS POSIX environment.

MS-DOS上へのgawkのインストール

まず最初にやることは、あなたのPCにgawkの配布キットのファイルをすべて 持ってくるということである。 `pc'というディレクトリの下にあるファイルを 全部メインのディレクトリに持ってくる。そして`make.bat'を MS-DOSがアクセ スできるバッチファイルに編集する。これは、行末をASCIIの復帰と改行に直すとい うことである。

gawkはMicrosoft Cコンパイラのversion 5.1でだけコンパイルされた。ディ レクトリ`pc'から持ってきた`make.bat'は、あなたが持っているコンパイ ラもそうであると仮定している。

`setargv.obj'というファイルをライブラリのディレクトリから gawkの ソースコードのあるディレクトリにコピーする。

`make.bat'を実行する。バッチファイルでコンパイルとリンクを行い、それで 作業は終わる。

Atari STへのgawkのインストール

This section assumes that you are running TOS. It applies to other Atari models (STe, TT) as well.

In order to use gawk, you need to have a shell, either text or graphics, that does not map all the characters of a command line to upper case. Maintaining case distinction in option flags is very important (セクション awkの起動を参照). Popular shells like gulam or gemini will work, as will newer versions of desktop. Support for I/O redirection is necessary to make it easy to import awk programs from other environments. Pipes are nice to have, but not vital.

If you have received an executable version of gawk, place it, as usual, anywhere in your PATH where your shell will find it.

While executing, gawk creates a number of temporary files. gawk looks for either of the environment variables TEMP or TMPDIR, in that order. If either one is found, its value is assumed to be a directory for temporary files. This directory must exist, and if you can spare the memory, it is a good idea to put it on a RAM drive. If neither TEMP nor TMPDIR are found, then gawk uses the current directory for its temporary files.

The ST version of gawk searches for its program files as described in セクション 環境変数AWKPATHを参照. On the ST, the default value for the AWKPATH variable is ".,c:\lib\awk,c:\gnu\lib\awk". The search path can be modified by explicitly setting AWKPATH to whatever you wish. Note that colons cannot be used on the ST to separate elements in the AWKPATH variable, since they have another, reserved, meaning. Instead, you must use a comma to separate elements in the path. If you are recompiling gawk on the ST, then you can choose a new default search path, by setting the value of `DEFPATH' in the file `...\config\atari'. You may choose a different separator character by setting the value of `ENVSEP' in the same file. The new values will be used when creating the header file `config.h'.

Although awk allows great flexibility in doing I/O redirections from within a program, this facility should be used with care on the ST. In some circumstances the OS routines for file handle pool processing lose track of certain events, causing the computer to crash, and requiring a reboot. Often a warm reboot is sufficient. Fortunately, this happens infrequently, and in rather esoteric situations. In particular, avoid having one part of an awk program using print statements explicitly redirected to "/dev/stdout", while other print statements use the default standard output, and a calling shell has redirected standard output to a file.

When gawk is compiled with the ST version of gcc and its usual libraries, it will accept both `/' and `\' as path separators. While this is convenient, it should be remembered that this removes one, technically legal, character (`/') from your file names, and that it may create problems for external programs, called via the system() function, which may not support this convention. Whenever it is possible that a file created by gawk will be used by some other program, use only backslashes. Also remember that in awk, backslashes in strings have to be doubled in order to get literal backslashes.

The initial port of gawk to the ST was done with gcc. If you wish to recompile gawk from scratch, you will need to use a compiler that accepts ANSI standard C (such as gcc, Turbo C, or Prospero C). If sizeof(int) != sizeof(int *), the correctness of the generated code depends heavily on the fact that all function calls have function prototypes in the current scope. If your compiler does not accept function prototypes, you will probably have to add a number of casts to the code.

If you are using gcc, make sure that you have up-to-date libraries. Older versions have problems with some library functions (atan2(), strftime(), the `%g' conversion in sprintf()) which may affect the operation of gawk.

In the `atari' subdirectory of the gawk distribution is a version of the system() function that has been tested with gulam and msh; it should work with other shells as well. With gulam, it passes the string to be executed without spawning an extra copy of a shell. It is possible to replace this version of system() with a similar function from a library or from some other source if that version would be a better choice for the shell you prefer.

The files needed to recompile gawk on the ST can be found in the `atari' directory. The provided files and instructions below assume that you have the GNU C compiler (gcc), the gulam shell, and an ST version of sed. The `Makefile' is set up to use `byacc' as a `yacc' replacement. With a different set of tools some adjustments and/or editing will be needed.

cd to the `atari' directory. Copy `Makefile.st' to `makefile' in the source (parent) directory. Possibly adjust `../config/atari' to suit your system. Execute the script `mkconf.g' which will create the header file `../config.h'. Go back to the source directory. If you are not using gcc, check the file `missing.c'. It may be necessary to change forward slashes in the references to files from the `atari' subdirectory into backslashes. Type make and enjoy.

Compilation with gcc of some of the bigger modules, like `awk_tab.c', may require a full four megabytes of memory. On smaller machines you would need to cut down on optimizations, or you would have to switch to another, less memory hungry, compiler.


移動先 先頭, , , 末尾 セクション, 目次.