From: j8takagi Date: Wed, 31 Oct 2012 16:13:40 +0000 (+0900) Subject: バージョン表示機能を追加 X-Git-Tag: 0.2p2~7 X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=commitdiff_plain;h=8b76a2371ab7fc325f11b9164a73e899f98072f0;ds=sidebyside バージョン表示機能を追加 --- diff --git a/Makefile b/Makefile index b2f9ba1..6e145d7 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,21 @@ -.PHONY: all build gtags check doc info html doc-inner install uninstall install-info uninstall-info install-casl2lib uninstall-casl2lib clean clean-src clean-gtags clean-test clean-doc clean-doc-inner +.PHONY: all build gtags check doc info html doc-inner install uninstall install-info uninstall-info install-casl2lib uninstall-casl2lib version clean clean-src clean-gtags clean-test clean-doc clean-doc-inner GTAGS ?= gtags RMF ?= rm -f WHICH ?= which ECHO ?= echo INSTALL ?= install +SED ?= sed prefix ?= ~ bindir ?= $(prefix)/bin casl2libdir ?= $(prefix)/yacasl2/casl2lib +VERSIONFILES = include/package.h test/system/casl2/opt_v/0.txt test/system/comet2/opt_v/0.txt test/system/dumpword/opt_v/0.txt + all: build info html gtags -build: +build: version $(MAKE) -C src all gtags: @@ -52,7 +55,12 @@ install-casl2lib: uninstall-casl2lib: @$(MAKE) -C as/casl2lib uninstall-casl2lib -clean: clean-src clean-gtags clean-doc clean-doc-inner +version: $(VERSIONFILES) + +$(VERSIONFILES): + for f in $(VERSIONFILES); do $(SED) -e "s/@@VERSION@@/`cat VERSION`/g" $$f.version >$$f; done + +clean: clean-src clean-gtags clean-doc clean-doc-inner clean-version clean-src: @$(MAKE) -sC src clean @@ -68,3 +76,6 @@ clean-doc-inner: clean-test: @$(MAKE) -sC test clean + +clean-version: + @$(RMF) $(VERSIONFILES) diff --git a/README b/README index befaa42..661d2c6 100644 --- a/README +++ b/README @@ -1,22 +1,36 @@ このファイルは、YACASL2のREADMEファイルです。 -■YACASL2の概要 -YACASL2は、Linux上で動作するオープンソースのCASL II処理システムです。 +YACASL2の概要 +****************** + +YACASL2は、UNIX/Linuxのコマンドラインインターフェイスで動作する +オープンソースのCASL II処理システムです。 CASL IIは、情報処理試験で用いられるアセンブラ言語で、次の資料で仕様が定義されています。 - 試験で使用する情報処理用語・プログラム言語など(2008å¹´10月版) - http://www.jitec.ipa.go.jp/1_00topic/topic_20081027_hani_yougo.pdf (PDFファイル) + 試験で使用する情報処理用語・プログラム言語など Ver 2.2(平成24å¹´5月22日) + http://www.jitec.jp/1_13download/shiken_yougo_ver2_2.pdf (PDFファイル) 別紙 1 アセンブラ言語の仕様 -■ドキュメント -YACASL2のインストール方法、使い方などはファイルdoc/index.htmlを参照してください。 -■Webサイト -次のURLを参照してください。 -http://www.j8takagi.net/yacasl2/ +同梱ドキュメント +****************** + +YACASL2のインストール方法は、INSTALLを参照してください。 +YACASL2の使い方は、doc/index.htmlを参照してください。 + + +Webサイト +****************** + +YACASL2のWebサイトは、次のURLです。 + + http://www.j8takagi.net/yacasl2/ + + +ライセンス +****************** -■ライセンス -Copyright 2010-2011, j8takagi. +Copyright 2010-2012, j8takagi. YACASL2 is licensed under the MIT license. -ライセンスの詳細は、ファイルLICENSEを参照してください。 +ライセンスの詳細は、同梱のLICENSEを参照してください。 diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..e6ea989 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.2p0 diff --git a/include/package.h.version b/include/package.h.version new file mode 100644 index 0000000..14d755a --- /dev/null +++ b/include/package.h.version @@ -0,0 +1,6 @@ +#ifndef YACASL2_PACKAGE_H_INCLUDED +#define YACASL2_PACKAGE_H_INCLUDED + +#define PACKAGE_VERSION "@@VERSION@@" + +#endif diff --git a/src/Makefile b/src/Makefile index ab66853..afb82a6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,6 +4,7 @@ RMF ?= rm -f WHICH ?= which CTAGS ?= ctags ETAGS ?= etags +SED ?= sed INCLUDE := ../include @@ -32,15 +33,15 @@ all: ../casl2 ../comet2 ../dumpword ctags etags $(CC) -c $(CFLAGS) $< %.d: %.c - @$(CC) -MM -I $(INCLUDE) $< | sed 's/\($*\.o\):/\1 $@:/g' >$@ + @$(CC) -MM -I $(INCLUDE) $< | $(SED) 's/\($*\.o\):/\1 $@:/g' >$@ -include $(subst .c,.d,casl2.c comet2.c dumpword.c $(COMMONSRC) $(CASL2SRC) $(ASSRC) $(EXECSRC)) ctags: $(INCLUDE)/*.h *.c - @($(WHICH) $(CTAGS) && $(CTAGS) $^) >/dev/null + @$(WHICH) $(CTAGS) >/dev/null && $(CTAGS) $^ etags: $(INCLUDE)/*.h *.c - @($(WHICH) $(ETAGS) && $(ETAGS) $^) >/dev/null + @$(WHICH) $(ETAGS) >/dev/null && $(ETAGS) $^ clean: clean_cmd clean_build clean_tags diff --git a/src/casl2.c b/src/casl2.c index 79d3e02..204d307 100644 --- a/src/casl2.c +++ b/src/casl2.c @@ -8,6 +8,7 @@ #include "cerr.h" #include "assemble.h" #include "exec.h" +#include "package.h" /** * casl2コマンドのオプション @@ -26,6 +27,7 @@ static struct option longopts[] = { { "dump", no_argument, NULL, 'd' }, { "memorysize", required_argument, NULL, 'M' }, { "clocks", required_argument, NULL, 'C' }, + { "version", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0 }, }; @@ -107,17 +109,17 @@ asfin: int main(int argc, char *argv[]) { int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS, opt, i, stat; - char *af[argc]; - char *objfile = NULL; + char *af[argc], *objfile = NULL; + const char *version = PACKAGE_VERSION, *cmdversion = "casl2 of YACASL2 version %s\n"; const char *usage = - "Usage: %s [-slLaAtTdh] [-oO[]] [-M ] [-C ] FILE1[ FILE2 ...]\n"; + "Usage: %s [-slLaAtTdvh] [-oO[]] [-M ] [-C ] FILE1[ FILE2 ...]\n"; cerr_init(); addcerrlist_casl2(); addcerrlist_assemble(); addcerrlist_exec(); /* オプションの処理 */ - while((opt = getopt_long(argc, argv, "tTdslLao::O::AM:C:h", longopts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "tTdslLao::O::AM:C:vh", longopts, NULL)) != -1) { switch(opt) { case 's': asmode.src = true; @@ -159,6 +161,9 @@ int main(int argc, char *argv[]) case 'C': clocks = atoi(optarg); break; + case 'v': + fprintf(stdout, cmdversion, version); + return 0; case 'h': fprintf(stdout, usage, argv[0]); return 0; diff --git a/src/comet2.c b/src/comet2.c index 1bdc3e9..36060d3 100644 --- a/src/comet2.c +++ b/src/comet2.c @@ -6,6 +6,7 @@ #include "exec.h" #include "cmem.h" #include "cerr.h" +#include "package.h" /** * comet2コマンドのオプション @@ -17,6 +18,7 @@ static struct option longopts[] = { {"dump", no_argument, NULL, 'd'}, {"memorysize", required_argument, NULL, 'M'}, {"clocks", required_argument, NULL, 'C'}, + { "version", no_argument, NULL, 'v' }, {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0}, }; @@ -28,14 +30,15 @@ int main(int argc, char *argv[]) { int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS; int opt, stat = 0; - const char *usage = "Usage: %s [-tTdh] [-M ] [-C ] FILE\n"; + const char *version = PACKAGE_VERSION, *cmdversion = "comet2 of YACASL2 version %s\n"; + const char *usage = "Usage: %s [-tTdvh] [-M ] [-C ] FILE\n"; cerr_init(); addcerrlist_load(); addcerrlist_exec(); /* オプションの処理 */ - while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "tTdM:C:vh", longopts, NULL)) != -1) { switch(opt) { case 't': execmode.trace = true; @@ -53,6 +56,9 @@ int main(int argc, char *argv[]) case 'C': clocks = atoi(optarg); break; + case 'v': + fprintf(stdout, cmdversion, version); + return 0; case 'h': fprintf(stdout, usage, argv[0]); return 0; diff --git a/src/dumpword.c b/src/dumpword.c index dea7d9b..d39dfaf 100644 --- a/src/dumpword.c +++ b/src/dumpword.c @@ -4,6 +4,7 @@ #include #include "word.h" #include "cerr.h" +#include "package.h" /** * dumpwordコマンドのオプション @@ -11,6 +12,7 @@ static struct option longopts[] = { { "arithmetic", no_argument, NULL, 'a' }, { "logical", no_argument, NULL, 'l' }, + { "version", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0 }, }; @@ -23,15 +25,19 @@ int main(int argc, char *argv[]) bool logicalmode = false; /* レジストリの内容を論理値(0から65535)で表示する場合はtrue */ int opt; WORD word; + const char *version = PACKAGE_VERSION, *cmdversion = "dumpword of YACASL2 version %s\n"; const char *usage = "Usage: %s [-alh] WORD\n"; cerr_init(); addcerrlist_word(); - while((opt = getopt_long(argc, argv, "alh", longopts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "alvh", longopts, NULL)) != -1) { switch(opt) { case 'l': logicalmode = true; break; + case 'v': + fprintf(stdout, cmdversion, version); + return 0; case 'h': fprintf(stdout, usage, argv[0]); return 0; diff --git a/test/system/casl2/opt_h/0.txt b/test/system/casl2/opt_h/0.txt index de9f598..335b97e 100644 --- a/test/system/casl2/opt_h/0.txt +++ b/test/system/casl2/opt_h/0.txt @@ -1,18 +1 @@ -;;; sum_10.casl -;;; 出力 GR0: 1から10までの整数をすべて加算した値 -MAIN START - PUSH 0,GR1 - LAD GR0,0 ; GR0を初期化 - LD GR1,FST ; GR1に初項を転送 -LOOP ADDL GR0,GR1 ; ループ先頭 - ADDL GR1,STEP ; GR1 <- GR1 + 公差 - CPL GR1,LST ; GR1が末項より大きい場合は終了 - JPL FIN ; ↓ - JUMP LOOP ; ループ終端 -FIN POP GR1 - RET -FST DC 1 ; 初項 -LST DC 10 ; 末項 -STEP DC 1 ; 公差 - END Usage: ../../../../casl2 [-slLaAtTdh] [-oO[]] [-M ] [-C ] FILE1[ FILE2 ...] diff --git a/test/system/casl2/opt_h/cmd b/test/system/casl2/opt_h/cmd index 579896a..ecdb7de 100755 --- a/test/system/casl2/opt_h/cmd +++ b/test/system/casl2/opt_h/cmd @@ -1,2 +1 @@ -cat ../../../../as/sum_10.casl -../../../../casl2 -saltdh ../../../../as/sum_10.casl +../../../../casl2 -h diff --git a/test/system/casl2/opt_v/0.txt.version b/test/system/casl2/opt_v/0.txt.version new file mode 100644 index 0000000..fe7c385 --- /dev/null +++ b/test/system/casl2/opt_v/0.txt.version @@ -0,0 +1 @@ +casl2 of YACASL2 version @@VERSION@@ diff --git a/test/system/casl2/opt_v/Makefile b/test/system/casl2/opt_v/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/casl2/opt_v/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/casl2/opt_v/cmd b/test/system/casl2/opt_v/cmd new file mode 100755 index 0000000..3788ac9 --- /dev/null +++ b/test/system/casl2/opt_v/cmd @@ -0,0 +1 @@ +../../../../casl2 -v diff --git a/test/system/comet2/opt_h/cmd b/test/system/comet2/opt_h/cmd index 88ce894..cc7599c 100755 --- a/test/system/comet2/opt_h/cmd +++ b/test/system/comet2/opt_h/cmd @@ -1,3 +1 @@ -../../../../casl2 -O ../../../../as/sum_10.casl -../../../../comet2 -tdh a.o -rm -f a.o +../../../../comet2 -h diff --git a/test/system/comet2/opt_v/0.txt.version b/test/system/comet2/opt_v/0.txt.version new file mode 100644 index 0000000..8604bf2 --- /dev/null +++ b/test/system/comet2/opt_v/0.txt.version @@ -0,0 +1 @@ +comet2 of YACASL2 version @@VERSION@@ diff --git a/test/system/comet2/opt_v/Makefile b/test/system/comet2/opt_v/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/comet2/opt_v/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/comet2/opt_v/cmd b/test/system/comet2/opt_v/cmd new file mode 100755 index 0000000..d0bd98d --- /dev/null +++ b/test/system/comet2/opt_v/cmd @@ -0,0 +1 @@ +../../../../comet2 -v diff --git a/test/system/dumpword/opt_h/0.txt b/test/system/dumpword/opt_h/0.txt new file mode 100644 index 0000000..49695b2 --- /dev/null +++ b/test/system/dumpword/opt_h/0.txt @@ -0,0 +1 @@ +Usage: ../../../../dumpword [-alh] WORD diff --git a/test/system/dumpword/opt_h/Makefile b/test/system/dumpword/opt_h/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/dumpword/opt_h/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/dumpword/opt_h/cmd b/test/system/dumpword/opt_h/cmd new file mode 100755 index 0000000..aed55ae --- /dev/null +++ b/test/system/dumpword/opt_h/cmd @@ -0,0 +1 @@ +../../../../dumpword -h diff --git a/test/system/dumpword/opt_v/0.txt.version b/test/system/dumpword/opt_v/0.txt.version new file mode 100644 index 0000000..332219d --- /dev/null +++ b/test/system/dumpword/opt_v/0.txt.version @@ -0,0 +1 @@ +dumpword of YACASL2 version @@VERSION@@ diff --git a/test/system/dumpword/opt_v/Makefile b/test/system/dumpword/opt_v/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/dumpword/opt_v/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/dumpword/opt_v/cmd b/test/system/dumpword/opt_v/cmd new file mode 100755 index 0000000..402efec --- /dev/null +++ b/test/system/dumpword/opt_v/cmd @@ -0,0 +1 @@ +../../../../dumpword -v