我正在尝试制作一个可以运行多个公共目录并在不同目录中创建对象的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
答案 0 :(得分:0)
我知道了
# "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/*