整个系统的Makefile配置

时间:2015-02-28 12:11:16

标签: c++ c makefile clang cs50

我们知道,在我们使用命令的设备中

make [file-name]

它会自动编译一些标志:

-ggdb -O0 -std=c99 -Wall - Werror

我需要知道CS50编辑的Makefile位于哪个目录中,因为我想为整个系统配置我自己的Makefile,通过它我可以创建任何 .cpp 文件。 当我使用make编译c ++文件时,它会自动编译g++但我想用clang++编译器编译 .cpp 文件,为{添加一些基本标志{1}}用于汇编代码的-g

我问如何在可能的情况下出于特定原因创建Makefile。

1 个答案:

答案 0 :(得分:0)

在当前目录和Implicit-Rules中使用Makefile。您可以通过更改这些显式规则使用的变量来修改隐式规则的行为。 例如,要更改 .cpp 文件的编译器,您可以设置自己的CXX变量

    环境中的
  1. (使用它):

    CXX=clang++ make [file-name]
    #OR
    export CXX=clang++; make [file-name]
    
  2. 在本地Makefile中:

    CXX:=clang++
    #The implicit rule, which you'll find in the link, takes care of the rest