本文介绍了使用相同的Makefile化妆(Linux)的和NMAKE(视窗)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想要编译Linux和Windows上通过化妆RESP一个简单的C-PROGRAMM(1源文件)。 NMAKE。有没有一个单一的makefile来完成这个可能性?

I have a simple C-Programm (1 source file) which I want to compile on Linux and on Windows via make resp. nmake. Is there a possibility to accomplish this with a single makefile?

我想过像

ifeq($(MAKE), nmake)
    // nmake code here
else
    // make code here
endif

不幸的是NMAKE似乎不明白 IFEQ ,所以我不能使用它。我有一个工作的Makefile,但产生非常难看的结果:

Unfortunately nmake seems not to understand ifeq, so i cannot use that. I have a working makefile but that produces very ugly results:

hello: hello.c
    $(CC) hello.c

这两个系统的工作原理。问题是,该结果依赖于各自的编译器的默认行为。在Linux下,我得到一个名为a.out的',而不是'你好'的executeable。在Windows下,我得到'文件hello.exe,但也有hello.obj我不希望有。

That works on both systems. The problem is that the outcome depends on the default behaviors of the respective compilers. Under Linux I get an executeable named 'a.out' rather than 'hello'. Under Windows I get 'hello.exe' but there is also 'hello.obj' which I do not want to have.

有谁知道的替代方式?或者是我想要绝对不可能的?

Does anyone know of an alternative way? Or is what I'm trying absolutely impossible?

推荐答案

这也许不是不可能的,但最有可能这么难,这将是更容易反正写两个makefile文件。

It's probably not impossible, but most likely so hard that it would be easier to write two makefiles anyway.

这两个GNU使(在Linux中使用),并有NMAKE包含指令的,所以一些共同的东西可以放在由主makefile文件包含一个共同的makefile。

Both GNU make (used in Linux) and nmake have include directives though, so some common things can be put in a common makefile that is included by the main makefile.

这篇关于使用相同的Makefile化妆(Linux)的和NMAKE(视窗)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:57