瀏覽代碼

Use built-in rules in qubes-rpc makefile

That allows a build system to customize compiler and linker and pass
extra flags to these.

Remove `-g` as default flag and enable it only when `DEBUG` variable is
set.
Amadeusz Piotr Żołnowski 4 年之前
父節點
當前提交
863c7e130f
共有 1 個文件被更改,包括 13 次插入8 次删除
  1. 13 8
      qubes-rpc/Makefile

+ 13 - 8
qubes-rpc/Makefile

@@ -5,22 +5,27 @@ QUBESLIBDIR = $(LIBDIR)/qubes
 QUBESRPCCMDDIR = $(SYSCONFDIR)/qubes-rpc
 QUBESCONFDIR = $(SYSCONFDIR)/qubes
 QUBESRPCCONFDIR = $(QUBESCONFDIR)/rpc-config
-CC=gcc
-CFLAGS=-g -O2 -Wall -Wextra -Werror -I. -fPIC -pie
+
+ifneq ($(DEBUG),0)
+DEBUG_FLAGS := -g
+endif
+CPPFLAGS := -I.
+CFLAGS := $(DEBUG_FLAGS) -O2 -Wall -Wextra -Werror -fPIC -pie $(CFLAGS)
+LDFLAGS := $(DEBUG_FLAGS) -pie $(LDFLAGS)
+LDLIBS := -lqubes-rpc-filecopy
+
+.PHONY: all clean install
+
 all:	vm-file-editor qopen-in-vm qfile-agent qfile-unpacker tar2qfile
+
 vm-file-editor: vm-file-editor.o
-	$(CC) -pie -g -o $@ $^ -lqubes-rpc-filecopy
 qopen-in-vm: qopen-in-vm.o gui-fatal.o
-	$(CC) -pie -g -o $@ $^ -lqubes-rpc-filecopy
 qfile-agent: qfile-agent.o gui-fatal.o
-	$(CC) -pie -g -o $@ $^ -lqubes-rpc-filecopy
 qfile-unpacker: qfile-unpacker.o gui-fatal.o
-	$(CC) -pie -g -o $@ $^ -lqubes-rpc-filecopy
 tar2qfile: tar2qfile.o gui-fatal.o
-	$(CC) -pie -g -o $@ $^ -lqubes-rpc-filecopy
 
 clean:
-	rm -f qopen-in-vm qfile-agent qfile-unpacker tar2qfile vm-file-editor *.o *~
+	-$(RM) qopen-in-vm qfile-agent qfile-unpacker tar2qfile vm-file-editor *.o *~
 
 install:
 	install -d $(DESTDIR)$(BINDIR)