F#、Linux 和 makefile

发布于 2024-09-03 16:24:36 字数 522 浏览 4 评论 0原文

我打算将 F# 程序作为二进制和源代码分发,以便用户可以根据需要选择重新编译它。在 Windows 上,我了解如何执行此操作:提供 Visual Studio 和 MSBuild 都可以理解的 .fsproj 和 .sln 文件。

在 Linux 上,C 程序的传统解决方案是 makefile。这取决于 gcc 是否直接可用,而且始终如此。

F# 编译器可以安装在 Linux 上并在 Mono 下工作,所以到目前为止一切都很好。但是,据我所知,它不会创建 fsc 运行编译器的场景,而是命令是 mono ...path.../fsc.exe.这也很好,只是我不知道这条路会是什么。因此,在我的情况下运行编译器的完整命令可能是 mono ~/FSharp-2.0.0.0/bin/fsc.exe types.fs tptp.fs main.fs -r FSharp.PowerPack.dll只是我不确定 fsc.exe 实际上位于用户计算机上的位置。

有没有办法在 makefile 中找到它,或者最好依靠在文档中解释上述内容并依赖用户根据他的设置修改命令?

I intend to distribute an F# program as both binary and source so the user has the option of recompiling it if desired. On Windows, I understand how to do this: provide .fsproj and .sln files, which both Visual Studio and MSBuild can understand.

On Linux, the traditional solution for C programs is a makefile. This depends on gcc being directly available, which it always is.

The F# compiler can be installed on Linux and works under Mono, so that's fine so far. However, as far as I can tell, it doesn't create a scenario where fsc runs the compiler, instead the command is mono ...path.../fsc.exe. This is also fine, except I don't know what the path is going to be. So the full command to run the compiler in my case could be mono ~/FSharp-2.0.0.0/bin/fsc.exe types.fs tptp.fs main.fs -r FSharp.PowerPack.dll except that I'm not sure where fsc.exe will actually be located on the user's machine.

Is there a way to find that out within a makefile, or would it be better to fall back on just explaining the above in the documentation and relying on the user to modify the command according to his setup?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很糊涂小朋友 2024-09-10 16:24:36

如果您不想使用 autoconf,只需编写 README 并告诉我们如何设置工具来编译您的程序。
例如,您可以要求使用 binfmt_misc 内核模块来允许系统自动对已知格式的文件使用正确的启动程序,因为 $PATH 必须包含 fsc.exe 的路径,因此您的 Makefile 将类似于以下代码:

FILES=types.fs tptp.fs main.fs

target.exe: ${FILES}
        fsc.exe -o $@  ${FILES} -r FSharp.PowerPack.dll

或者您可以允许用户使用 makefile 变量指向编译器:

MONO=/usr/bin/mono
FSC=/usr/local/fsharp/bin/fsc.exe
COMPILER=${MONO} ${FSC}
FILES=types.fs tptp.fs main.fs

target.exe: ${FILES}
        ${COMPILER} -o $@  ${FILES} -r FSharp.PowerPack.dll

If you don't want to use autoconf just write up README and say us how to setup tools to compile your program.
For example, you can require as to use binfmt_misc kernel module to allow system to automatically use right starter program for files with known format as to $PATH must contain path to fsc.exe, so your Makefile simply will be like following code:

FILES=types.fs tptp.fs main.fs

target.exe: ${FILES}
        fsc.exe -o $@  ${FILES} -r FSharp.PowerPack.dll

Or you can allow user to point to compiler by using makefile variables:

MONO=/usr/bin/mono
FSC=/usr/local/fsharp/bin/fsc.exe
COMPILER=${MONO} ${FSC}
FILES=types.fs tptp.fs main.fs

target.exe: ${FILES}
        ${COMPILER} -o $@  ${FILES} -r FSharp.PowerPack.dll
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文