如何编译C两个Linux和Solaris? [英] How to compile C in both Linux and Solaris?

查看:104
本文介绍了如何编译C两个Linux和Solaris?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个Makefile来既可以在Linux和Solaris中进行编译。
我知道如何让单独做,但我怎么能两者结合起来,并能到我在用什么样的操作系统?
我想只是一个简单的C文件做到这一点 - 但它是改变了编译器的名称

I want to make a Makefile to can compile both in Linux and in Solaris. I know how to do so individually, but how can I combine both and be able to detect what kind of OS I am using? I am trying to do this for just a simple C file - but it is the name of the compiler that changes.

推荐答案

GNU的Autoconf是旨在解决这个问题很

的Autoconf是一个可扩展的包
  产生shell脚本M4宏
  自动配置软件
  来源$ C ​​$ C包。这些脚本
  能适应包多种
  无需人工UNIX类系统的
  用户干预。 Autoconf的创建
  一个包配置脚本
  从模板文件,该文件列出了
  操作系统功能的
  包可以使用,在M4的形式
  宏调用。

Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages. These scripts can adapt the packages to many kinds of UNIX-like systems without manual user intervention. Autoconf creates a configuration script for a package from a template file that lists the operating system features that the package can use, in the form of M4 macro calls.

我已经用自己的Autoconf了几个简单的项目。你可以看看源$ C ​​$ C,看看如何使用autoconf简单的功能检测:

I've used Autoconf myself for a couple of simple projects. You can have a look at the source code to see how to use Autoconf for simple feature detection:

  • count

注意的Autoconf的目的不是为了检测到您的操作系统。更确切地说,它的设计以检测功能,设置等,这可能会或可能不会被$操作系统在页码$ psent

Note that the purpose of Autoconf is not to detect your operating system. Rather, it's designed to detect features, settings, etc. that may or may not be present on your operating system.

想提出的问题是什么是所谓的这个平台上的C编译器?不是我是在Linux或Solaris上运行?

Think of asking the question "what is the C compiler called on this platform?" not "am I running on Linux or Solaris?"

这篇关于如何编译C两个Linux和Solaris?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆