c - 尝试在 Ubuntu 的 makefile 中运行多个命令

标签 c makefile

我正在尝试制作一个可以运行多个公共(public)并在不同目录中创建对象的 makefile

all: clean debug release 

debug:
gcc -g -o debug/client.o client.c
gcc -g -o debug/server server.c -pthread
gcc -g -Wall -o debug/serverLog -DLOGFILE server.c -pthread

release:

gcc -Wall -o release/client client.c
gcc -Wall -o release/server server.c -pthread
gcc -Wall -o release/serverLog -DLOGFILE server.c -pthread

clean: 
-rm debug/client 
-rm debug/server 
-rm debug/serverLog

最佳答案

我明白了

# "Debug" build - no optimization, and debugging symbols
DBG_FLAGS=-Wall -O0 -g

# "Release" build - optimization, and no debug symbols
REL_FLAGS =-Wall

all: debug release

debug: mkdirs
   gcc $(DBG_FLAGS) -o debug/client client.c
    gcc $(DBG_FLAGS) -o debug/server server.c
    gcc $(DBG_FLAGS) -o debug/serverLog -DLOGFILE server.c


release:mkdirs
    gcc $(REL_FLAGS) -o release/client client.c
    gcc $(REL_FLAGS) -o release/server server.c
    gcc $(REL_FLAGS) -o release/serverLog -DLOGFILE server.c

mkdirs:
   -mkdir debug
   -mkdir release


clean:
    -rm debug/* release/*

关于c - 尝试在 Ubuntu 的 makefile 中运行多个命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54283005/

相关文章:

c++ - 在 eclipse、Red Hat Linux 中运行 c++ 项目时出现问题

python - 如何在python中将unsigned char类型的int字符串转换为int

c - 为什么 strcat 函数会出现段错误?

shell - 捕获由 Makefile 启动的后台进程的 PID

shell - 将环境变量导出到 Makefile shell

bash - 使用 bash 4 语法将 Makefile 中字符串的首字母大写

c - Floodfill 算法 C - 返回双数组?

c - 即使我在 Linux(Mint 18.3)上使用 kill 命令发送信号,WIFSIGNALED 也会返回 false

c - GCC 4.5/Ubuntu 11.04 是自动线程代码吗?

qt - QMake SUBDIRS 项目 : How to call release-clean from top-level Makefile?