标签: makefile

使用make文件创建目录

我是一个非常新的makefile,我想使用makefile创建目录.我的项目目录是这样的

+--Project  
   +--output  
   +--source  
     +Testfile.cpp  
   +Makefile  
Run Code Online (Sandbox Code Playgroud)

我想将所有对象和输出放入相应的输出文件夹中.我想创建文件夹结构,编译后就像这样.

+--Project
   +--output
     +--debug (or release)
       +--objs
         +Testfile.o
       +Testfile (my executable file)
   +--source
     +Testfile.cpp
   +Makefile
Run Code Online (Sandbox Code Playgroud)

我尝试了几种选择,但无法成功.请帮我用make文件制作目录.我发布了Makefile供你考虑.

#---------------------------------------------------------------------
# Input dirs, names, files
#---------------------------------------------------------------------
OUTPUT_ROOT := output/

TITLE_NAME := TestProj 

ifdef DEBUG 
    TITLE_NAME += _DEBUG
else
ifdef RELEASE
    TITLE_NAME += _RELEASE
endif
endif


# Include all the source files here with the directory tree
SOURCES := \
        source/TestFile.cpp \

#---------------------------------------------------------------------
# configs
#---------------------------------------------------------------------
ifdef DEBUG
OUT_DIR     := $(OUTPUT_ROOT)debug
CC_FLAGS    := -c -Wall
else
ifdef RELEASE …
Run Code Online (Sandbox Code Playgroud)

directory makefile object

90
推荐指数
5
解决办法
11万
查看次数

Makefile,头依赖项

假设我有一个带有规则的makefile

%.o: %.c
 gcc -Wall -Iinclude ...
Run Code Online (Sandbox Code Playgroud)

我想要在头文件更改时重建*.o.无论何时/include更改任何头文件,都必须重建dir中的所有对象,而不是计算出依赖项列表.

我想不出一个改变规则以适应这个的好方法,我愿意接受建议.如果标题列表不必硬编码,则奖励积分

dependencies makefile header-files

90
推荐指数
5
解决办法
10万
查看次数

Makefile中的括号$()和大括号$ {}语法有什么区别?

是否有语法调用变量的任何差异${var}$(var)?例如,变量将被扩展的方式还是什么?

variables syntax makefile

90
推荐指数
6
解决办法
2万
查看次数

如何在Makefile中使用shell命令

我正在尝试使用ls其他命令的结果(例如echo,rsync):

all:
    <Building, creating some .tgz files - removed for clarity>
    FILES = $(shell ls)
    echo $(FILES)
Run Code Online (Sandbox Code Playgroud)

但我得到:

make
FILES = Makefile file1.tgz file2.tgz file3.tgz
make: FILES: No such file or directory
make: *** [all] Error 1
Run Code Online (Sandbox Code Playgroud)

我已经尝试使用echo $$FILES,echo ${FILES}并且echo $(FILES),没有运气.

bash makefile echo

88
推荐指数
2
解决办法
15万
查看次数

如何让Makefile自动重建包含已修改头文件的源文件?(在C/C++中)

我有以下makefile用于构建我正在处理的程序(实际上是内核).它从头开始,我正在学习这个过程,所以它并不完美,但我认为它在这一点上足够强大,因为我在编写makefile时的经验水平.

AS  =   nasm
CC  =   gcc
LD  =   ld

TARGET      =   core
BUILD       =   build
SOURCES     =   source
INCLUDE     =   include
ASM         =   assembly

VPATH = $(SOURCES)

CFLAGS  =   -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions \
            -nostdinc -fno-builtin -I $(INCLUDE)
ASFLAGS =   -f elf

#CFILES     =   core.c consoleio.c system.c
CFILES      =   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
SFILES      =   assembly/start.asm

SOBJS   =   $(SFILES:.asm=.o)
COBJS   =   $(CFILES:.c=.o)
OBJS    =   $(SOBJS) $(COBJS)

build : $(TARGET).img

$(TARGET).img : $(TARGET).elf
    c:/python26/python.exe concat.py stage1 stage2 pad.bin core.elf …
Run Code Online (Sandbox Code Playgroud)

dependencies gcc makefile header

86
推荐指数
4
解决办法
8万
查看次数

如何在Makefile中定义几个包含路径

C++新手; 基本了解包含,库和编译过程.做了几个简单的makefile.

我当前的项目涉及使用informix DB api,我需要在多个非标准目录中包含头文件.怎么写呢?没有在网上找到任何东西,可能是因为我没有使用好的搜索条件

这是我试过的一种方式(不工作).只是为了显示makefile

LIB=-L/usr/informix/lib/c++
INC=-I/usr/informix/incl/c++ /opt/informix/incl/public

default:    main

main:   test.cpp
        gcc -Wall $(LIB) $(INC) -c test.cpp
        #gcc -Wall $(LIB) $(INC) -I/opt/informix/incl/public -c test.cpp

clean:
        rm -r test.o make.out
Run Code Online (Sandbox Code Playgroud)

c++ makefile include

86
推荐指数
2
解决办法
19万
查看次数

make:'all'无所事事

我正在通过一个例如pgm来创建一个make文件.

http://mrbook.org/tutorials/make/

我的文件夹eg_make_creation包含以下文件,

desktop:~/eg_make_creation$ ls
factorial.c  functions.h  hello  hello.c  main.c  Makefile
Run Code Online (Sandbox Code Playgroud)

Makefile文件

# I am a comment, and I want to say that the variable CC will be
# the compiler to use.
CC=gcc
# Hwy!, I am comment no.2. I want to say that CFLAGS will be the
#options I'll pass to the compiler
CFLAGS=-c -Wall

all:hello

hello:main.o factorial.o hello.o
  $(CC) main.o factorial.o hello.o -o hello

main.o:main.c
  $(CC) $(CFLAGS) main.c

factorial.o:factorial.c
  $(CC) $(CFLAGS) factorial.c

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

clean: …
Run Code Online (Sandbox Code Playgroud)

c makefile

86
推荐指数
7
解决办法
19万
查看次数

GNU中的递归通配符make?

自从我使用以来已经有一段时间了make,所以请耐心等待......

我有一个flac包含.FLAC文件的目录.我有一个相应的目录,mp3包含MP3文件.如果FLAC文件比相应的MP3文件(或相应的MP3文件不存在)更新,那么我想运行一堆命令将FLAC文件转换为MP3文件,然后复制标签.

踢球者:我需要flac递归搜索目录,并在mp3目录中创建相应的子目录.目录和文件名称中可以包含空格,并以UTF-8命名.

而且我想make用来驱动它.

makefile gnu-make

83
推荐指数
3
解决办法
5万
查看次数

Makefile ifeq逻辑或

如何使用make的ifeq运算符执行逻辑OR ?

例如,我有(简化):

ifeq ($(GCC_MINOR), 4)
    CFLAGS += -fno-strict-overflow
endif
ifeq ($(GCC_MINOR), 5)
    CFLAGS += -fno-strict-overflow
endif
Run Code Online (Sandbox Code Playgroud)

但想巩固这些界限.

(是的,是的,autotools,配置等等;对于当前的情况太过苛刻,想在这里保留Makefile中的所有内容)

[与此问题逻辑相反:如何在'ifeq'语句中使用多个条件 ]

makefile

83
推荐指数
4
解决办法
12万
查看次数

在makefile中转义

我正在尝试在makefile中执行此操作,但它失败的可能性非常大:

M_ARCH := $(shell g++ -dumpmachine | awk '{split($1,a,"-");print a[1]}')
Run Code Online (Sandbox Code Playgroud)

你知道为什么吗?我想它与逃避有关,但是在哪里和哪里?

makefile g++ escaping gnu-make

81
推荐指数
2
解决办法
4万
查看次数

标签 统计

makefile ×10

dependencies ×2

gnu-make ×2

bash ×1

c ×1

c++ ×1

directory ×1

echo ×1

escaping ×1

g++ ×1

gcc ×1

header ×1

header-files ×1

include ×1

object ×1

syntax ×1

variables ×1