[实作] J001:用 MinGW 编译 Ratfor

楼主: jans0204 (jans0204)   2022-08-19 08:08:30
1. 下载原始码:
#
# C Ratfor is a ratfor preprocessor written in C.
#
https://github.com/slattarini/ratfor # ratfor-master.zip
2. 下载测试码:
#
# Sieve.r
#
https://rosettacode.org/wiki/Sieve_of_Eratosthenes#RATFOR
3. 编写补钉码:
//
// config.h
//
#define PACKAGE_STRING "C Ratfor"
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IRGRP 040
#define S_IWGRP 020
#define S_IROTH 04
#define S_IWOTH 02
4. 编写编译码:
::
:: mk-exe.bat
::
if exist ratfor.exe del ratfor.exe
if exist a.exe del a.exe
if exist a.log del a.log
gcc -I. codegen.c define.c error.c include.c init.c io.c labgen.c main.c
parser.c rat4-hash.c tokenizer.c xopen.c > a.log 2>&1
if exist a.exe ren a.exe ratfor.exe
5. 抽取 ratfor-master.zip\src\ 至工作目录,例如:R:\src\ (RAMDRIVE)
6. 将 Sieve.r, config.h, mk-exe.bat 三档案加入 R:\src\
7. 在 R:\src\ 开启 Console Cmd (命令提示字符),执行 mk-exe.bat 开始编译,产生
ratfor.exe
8. 测试:
R:\src>ratfor.exe -o Sieve.f Sieve.r
R:\src>g77 -o Sieve.exe Sieve.f
R:\src>Sieve.exe
There are 168 primes.
2 3 5 7 11 13 17 19 23 29
31 37 41 43 47 53 59 61 67 71
73 79 83 89 97 101 103 107 109 113
127 131 137 139 149 151 157 163 167 173
179 181 191 193 197 199 211 223 227 229
233 239 241 251 257 263 269 271 277 281
283 293 307 311 313 317 331 337 347 349
353 359 367 373 379 383 389 397 401 409
419 421 431 433 439 443 449 457 461 463
467 479 487 491 499 503 509 521 523 541
547 557 563 569 571 577 587 593 599 601
607 613 617 619 631 641 643 647 653 659
661 673 677 683 691 701 709 719 727 733
739 743 751 757 761 769 773 787 797 809
811 821 823 827 829 839 853 857 859 863
877 881 883 887 907 911 919 929 937 941
947 953 967 971 977 983 991 997
R:\src>
9. 编译环境:gcc 3.4.5 (2004) (mingw-vista special r3)
附注1:不用 gcc -o ratfor.exe 改用 ren a.exe ratfor.exe 是因为参数列太长。
附注2:gcc -I. 是因为原始码使用: #include <config.h> 是角括号而非双引号。
附注3:不用 configure; make 而用 DOS.bat 是因为不想进入 MSYS 且 autoconfig 没
什么内容,干脆自己制造 config.h 也解决档案权限问题。还有也不用 make clean。
附注4:没有入错板,我的领域是 Program Language 的实作。Ratfor 是我 Review 之旅
的首步。
(END)
https://github.com/jans0204/J001-MinGW-Ratfor
作者: stopcrying (卖考)   2022-08-25 06:36:00
好耶,先 m 起来
作者: xcycl (XOO)   2022-08-28 14:30:00
目的?
作者: stopcrying (卖考)   2022-08-25 14:36:00
好耶,先 m 起来
作者: stopcrying (卖考)   2022-08-25 14:36:00
好耶,先 m 起来

Links booklink

Contact Us: admin [ a t ] ucptt.com