如何理解这个 SWI-Prolog makefile - Linux 可执行文件是如何创建的?
How to understand this SWI-Prolog makefile - how Linux executable is created?
我正在尝试编译语法分析器https://github.com/RichardMoot/Grail into Linux program according to instructions https://github.com/RichardMoot/Grail/blob/master/README and http://www.labri.fr/perso/moot/tutorial/install.html. There is manual how to create Linux executable from SWI-Prolog code http://www.swi-prolog.org/FAQ/UnixExe.html. All that is fine. But I can not find in the Makefile https://github.com/RichardMoot/Grail/blob/master/Makefile任何编译命令。 SWI-Prolo 使用 swipl 命令进行编译,但此 Makefile swipl 仅调用一次 - 用于显示 swipl 的版本。
我在安装和编译的过程中遇到了一些困难,没关系,我可以execute/debug Makefile 一行一行地得出结果。但我的情况存在问题 - 我看不到我的 makefile 中的最终目标:哪些行负责生成目标文件(如果需要)以及哪些行负责创建最终的 Linux 可执行文件.
这是窗口程序。源代码和文档包含有关与 SWI-Prolog 7 不兼容的警告,但这很好,我可以自己解决它们,但正如我所说 - 我看不到用于创建 exe 的 Makefile 行。
源代码由著名科学家创建,我当然不想用这么低级的技术问题打扰他。如果他继续研究理论并且不在低级编程问题上浪费时间,我会很高兴。希望有 SWI-Prolog 专家。
我在 Ubuntu 16.x 上使用最新的 (7.x) SWI-Prolog,我已经安装了所有提到的先决条件。
如果你仔细看提供的Makefile
,你会发现规则all
和install
定义如下(注释是我加的):
all:
-cd source ; $(edit) g3 > g3.tmp # Replaces placeholders for your
# ... GRAIL_ROOT install directory.
-cd source ; mv -f g3.tmp g3 # Overwrites `g3` with the filled file.
cd source ; chmod a+x g3 # Makes it executable.
install: # Essentially copies all files to
-mkdir $(datarootdir) # ... your install directory.
-mkdir $(datadir)
cp -f $(images) $(datadir)
-mkdir $(bindir)
cp -f source/insertdot $(bindir)
chmod a+x $(bindir)/insertdot
cp -f $(resources) $(datadir)
cp -f source/*.pl $(bindir)
cp -f source/g3 $(bindir)
如果您随后执行常见的 make && make install
,您最终会在 Grail 目录中安装两个文件夹:bin
和 share
。在二进制目录中,您将拥有 g3
文件,无论它是 SWI-Prolog 源文件,它都具有以下初始行:
#!/usr/bin/swipl -q -g start -f
% [... prolog code.]
此 header 应该允许您的控制台终端确定用于此脚本的解释器(在本例中,swipl
)。在我的例子中,使用 ./g3
执行 Grail 返回了一条 SWI-Prolog 消息,表明使用了错误的 options/command 参数。
根据 man
,Unix 系统必须在 header 末尾使用选项 -s
(但这在我的情况下也不起作用):
From the manual:
-s file
Load file as a script. This option may be used from the shell to
make Prolog load a file before entering the toplevel.
It is also used to turn a file into an executable Prolog script
on Unix systems using the following first line
#!/usr/bin/swipl option ... -s
如果您想 运行 这个程序,只需从您的终端调用相同的命令:
swipl -q -g start -s g3
我正在尝试编译语法分析器https://github.com/RichardMoot/Grail into Linux program according to instructions https://github.com/RichardMoot/Grail/blob/master/README and http://www.labri.fr/perso/moot/tutorial/install.html. There is manual how to create Linux executable from SWI-Prolog code http://www.swi-prolog.org/FAQ/UnixExe.html. All that is fine. But I can not find in the Makefile https://github.com/RichardMoot/Grail/blob/master/Makefile任何编译命令。 SWI-Prolo 使用 swipl 命令进行编译,但此 Makefile swipl 仅调用一次 - 用于显示 swipl 的版本。
我在安装和编译的过程中遇到了一些困难,没关系,我可以execute/debug Makefile 一行一行地得出结果。但我的情况存在问题 - 我看不到我的 makefile 中的最终目标:哪些行负责生成目标文件(如果需要)以及哪些行负责创建最终的 Linux 可执行文件.
这是窗口程序。源代码和文档包含有关与 SWI-Prolog 7 不兼容的警告,但这很好,我可以自己解决它们,但正如我所说 - 我看不到用于创建 exe 的 Makefile 行。
源代码由著名科学家创建,我当然不想用这么低级的技术问题打扰他。如果他继续研究理论并且不在低级编程问题上浪费时间,我会很高兴。希望有 SWI-Prolog 专家。
我在 Ubuntu 16.x 上使用最新的 (7.x) SWI-Prolog,我已经安装了所有提到的先决条件。
如果你仔细看提供的Makefile
,你会发现规则all
和install
定义如下(注释是我加的):
all:
-cd source ; $(edit) g3 > g3.tmp # Replaces placeholders for your
# ... GRAIL_ROOT install directory.
-cd source ; mv -f g3.tmp g3 # Overwrites `g3` with the filled file.
cd source ; chmod a+x g3 # Makes it executable.
install: # Essentially copies all files to
-mkdir $(datarootdir) # ... your install directory.
-mkdir $(datadir)
cp -f $(images) $(datadir)
-mkdir $(bindir)
cp -f source/insertdot $(bindir)
chmod a+x $(bindir)/insertdot
cp -f $(resources) $(datadir)
cp -f source/*.pl $(bindir)
cp -f source/g3 $(bindir)
如果您随后执行常见的 make && make install
,您最终会在 Grail 目录中安装两个文件夹:bin
和 share
。在二进制目录中,您将拥有 g3
文件,无论它是 SWI-Prolog 源文件,它都具有以下初始行:
#!/usr/bin/swipl -q -g start -f
% [... prolog code.]
此 header 应该允许您的控制台终端确定用于此脚本的解释器(在本例中,swipl
)。在我的例子中,使用 ./g3
执行 Grail 返回了一条 SWI-Prolog 消息,表明使用了错误的 options/command 参数。
根据 man
,Unix 系统必须在 header 末尾使用选项 -s
(但这在我的情况下也不起作用):
From the manual:
-s file Load file as a script. This option may be used from the shell to make Prolog load a file before entering the toplevel. It is also used to turn a file into an executable Prolog script on Unix systems using the following first line #!/usr/bin/swipl option ... -s
如果您想 运行 这个程序,只需从您的终端调用相同的命令:
swipl -q -g start -s g3