Lua ver1.빌드 1(먼저 빌드 가능 상태)

개시하다


표제와 같다.를 참고하십시오.

환경을 구축하다


gcc를 사용하는 버전은 다음과 같습니다.
(Ubuntu에서 확인)
$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
http://www.lua.org/ftp/lua-1.1.tar.gz 가운데
README를 보면 다음과 같은 기록이 있다.
  • Installing
    To make, simply type domake.
    If make succeeds, you get an interpreter in ./bin/lua.
    The libraries are in ./lib. The include files are in ./include.
    You don't need the other directories for development.
    There is documentation in ./doc and tests in ./test.
    The documentation includes a reference manual and an article on the
    design and implementation of Lua.
    This distribution is biased towards SunOS 4 with gcc but it is simple to
    change the Makefiles for other systems.
  • SunOS 4 & gcc 환경에서 구축된 거죠.

    구문 수정하기


    다음과 같이 수정되었습니다.
    수정된 파일은 다음과 같은 3개가 있다
  • clients/lib/Makefile
  • clients/lib/iolib.c
  • src/Makefile
  • 수정 내용은 다음과 같습니다.
    4
    diff --git a/clients/lib/Makefile b/clients/lib/Makefile
    index 4110a62..291a81a 100644
    --- a/clients/lib/Makefile
    +++ b/clients/lib/Makefile
    @@ -4,7 +4,7 @@ INC= $(LUA)/include
     LIB= $(LUA)/lib
     
     CC= gcc
    -CFLAGS= -Wall -O2 -I$(INC) $(DEFS)
    +CFLAGS= -fPIC -Wall -O2 -I$(INC) $(DEFS)
     
     OBJS= iolib.o mathlib.o strlib.o
     SLIB= $(LIB)/liblualib.a
    @@ -17,7 +17,7 @@ $(SLIB): $(OBJS)
     	ranlib $(SLIB)
     
     $(DLIB): $(OBJS)
    -	ld -o $@ $(OBJS)
    +	ld -shared -o $@ $(OBJS)
     
     clean:
     	rm -f $(OBJS) $(SLIB) $(DLIB)
    diff --git a/clients/lib/iolib.c b/clients/lib/iolib.c
    index b972124..ec2ef3c 100644
    --- a/clients/lib/iolib.c
    +++ b/clients/lib/iolib.c
    @@ -11,14 +11,19 @@ char *rcs_iolib="$Id: iolib.c,v 1.4 1994/04/25 20:11:23 celes Exp $";
     #include <ctype.h>
     #include <sys/stat.h>
     #ifdef __GNUC__
    -#include <floatingpoint.h>
    +// #include <floatingpoint.h>
     #endif
     
     #include "mm.h"
     
     #include "lua.h"
     
    -static FILE *in=stdin, *out=stdout;
    +// static FILE *in=stdin, *out=stdout;
    +static FILE *in, *out;
    +
    + __attribute__((constructor)) void initHw(void){
    +  in=stdin, out=stdout;
    +}
     
     /*
     ** Open a file to read.
    diff --git a/src/Makefile b/src/Makefile
    index 7e833d4..0057074 100644
    --- a/src/Makefile
    +++ b/src/Makefile
    @@ -4,7 +4,7 @@ LIB= $(LUA)/lib
     INC= $(LUA)/include
     
     CC= gcc
    -CFLAGS= -g -Wall -O2 -I$(INC) $(DEFS)
    +CFLAGS= -fPIC -g -Wall -O2 -I$(INC) $(DEFS)
     DEFS= -DMAXCODE=64000 -DMAXCONSTANT=1024 -DMAXSYMBOL=1024 -DMAXARRAY=1024
     
     OBJS= hash.o inout.o lex.o opcode.o table.o y.tab.o
    @@ -18,7 +18,7 @@ $(SLIB): $(OBJS)
     	ranlib $(SLIB)
     
     $(DLIB): $(OBJS)
    -	ld -o $@ $(OBJS)
    +	ld -shared -o $@ $(OBJS)
     
     clean:
     	rm -f $(OBJS) $(SLIB) $(DLIB)
    
    빌딩 집행 후 4bin목록에 있습니다.탭
    몇 가지 잘못이 있는데, 이번에는 무시한다. (나는 잠시 후에 상세한 상황을 조사하고 싶다)
    실행할 수 있을 것 같아요.
    $ ./domake 
    (cd src; make)
    make[1]: ディレクトリ '/home/USER/temp/lua1.1/lua/src' に入ります
    gcc -fPIC -g -Wall -O2 -I/home/USER/temp/lua1.1/lua/include -DMAXCODE=64000 -DMAXCONSTANT=1024 -DMAXSYMBOL=1024 -DMAXARRAY=1024   -c -o hash.o hash.c
    hash.c: In function ‘present’:
    hash.c:70:17: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
       70 |  Node *n=NULL, *p;
          |                 ^
    gcc -fPIC -g -Wall -O2 -I/home/USER/temp/lua1.1/lua/include -DMAXCODE=64000 -DMAXCONSTANT=1024 -DMAXSYMBOL=1024 -DMAXARRAY=1024   -c -o inout.o inout.c
    gcc -fPIC -g -Wall -O2 -I/home/USER/temp/lua1.1/lua/include -DMAXCODE=64000 -DMAXCONSTANT=1024 -DMAXSYMBOL=1024 -DMAXARRAY=1024   -c -o lex.o lex.c
    gcc -fPIC -g -Wall -O2 -I/home/USER/temp/lua1.1/lua/include -DMAXCODE=64000 -DMAXCONSTANT=1024 -DMAXSYMBOL=1024 -DMAXARRAY=1024   -c -o opcode.o opcode.c
    gcc -fPIC -g -Wall -O2 -I/home/USER/temp/lua1.1/lua/include -DMAXCODE=64000 -DMAXCONSTANT=1024 -DMAXSYMBOL=1024 -DMAXARRAY=1024   -c -o table.o table.c
    gcc -fPIC -g -Wall -O2 -I/home/USER/temp/lua1.1/lua/include -DMAXCODE=64000 -DMAXCONSTANT=1024 -DMAXSYMBOL=1024 -DMAXARRAY=1024   -c -o y.tab.o y.tab.c
    lua.stx: In function ‘lua_parse’:
    lua.stx:737:6: warning: implicit declaration of function ‘yyparse’ [-Wimplicit-function-declaration]
    /usr/lib/yaccpar: In function ‘yyparse’:
    /usr/lib/yaccpar:184:39: warning: implicit declaration of function ‘yylex’ [-Wimplicit-function-declaration]
    /usr/lib/yaccpar:284:4: warning: label ‘yyerrlab’ defined but not used [-Wunused-label]
    /usr/lib/yaccpar:96:2: warning: label ‘yynewstate’ defined but not used [-Wunused-label]
    ar ruvl /home/USER/temp/lua1.1/lua/lib/liblua.a hash.o inout.o lex.o opcode.o table.o y.tab.o
    ar: `u' modifier ignored since `D' is the default (see `U')
    r - hash.o
    r - inout.o
    r - lex.o
    r - opcode.o
    r - table.o
    r - y.tab.o
    ranlib /home/USER/temp/lua1.1/lua/lib/liblua.a
    ld -shared -o /home/USER/temp/lua1.1/lua/lib/liblua.so.1.1 hash.o inout.o lex.o opcode.o table.o y.tab.o
    make[1]: ディレクトリ '/home/USER/temp/lua1.1/lua/src' から出ます
    (cd clients/lib; make)
    make[1]: ディレクトリ '/home/USER/temp/lua1.1/lua/clients/lib' に入ります
    gcc -fPIC -Wall -O2 -I/home/USER/temp/lua1.1/lua/include    -c -o iolib.o iolib.c
    gcc -fPIC -Wall -O2 -I/home/USER/temp/lua1.1/lua/include    -c -o mathlib.o mathlib.c
    gcc -fPIC -Wall -O2 -I/home/USER/temp/lua1.1/lua/include    -c -o strlib.o strlib.c
    ar ruvl /home/USER/temp/lua1.1/lua/lib/liblualib.a iolib.o mathlib.o strlib.o
    ar: `u' modifier ignored since `D' is the default (see `U')
    r - iolib.o
    r - mathlib.o
    r - strlib.o
    ranlib /home/USER/temp/lua1.1/lua/lib/liblualib.a
    ld -shared -o /home/USER/temp/lua1.1/lua/lib/liblualib.so.1.1 iolib.o mathlib.o strlib.o
    make[1]: ディレクトリ '/home/USER/temp/lua1.1/lua/clients/lib' から出ます
    (cd clients/lua; make)
    make[1]: ディレクトリ '/home/USER/temp/lua1.1/lua/clients/lua' に入ります
    gcc -g -Wall -O2 -I/home/USER/temp/lua1.1/lua/include   -c -o lua.o lua.c
    lua.c:13:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
       13 | void main (int argc, char *argv[])
          |      ^~~~
    lua.c: In function ‘main’:
    lua.c:22:11: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
       22 |    while (gets(buffer) != 0)
          |           ^~~~
          |           fgets
    gcc -o /home/USER/temp/lua1.1/lua/bin/lua lua.o -L/home/USER/temp/lua1.1/lua/lib -llua -llualib -lm
    /usr/bin/ld: lua.o: in function `main':
    /home/USER/temp/lua1.1/lua/clients/lua/lua.c:22: 警告: the `gets' function is dangerous and should not be used.
    make[1]: ディレクトリ '/home/USER/temp/lua1.1/lua/clients/lua' から出ます
    

    금후


    이번에 먼저 빌딩을 보러 갔다.
    그 다음에 왜 이런 수정이 필요한지 쓰고 싶어요.

    좋은 웹페이지 즐겨찾기