瀏覽代碼

[Pal/{test, regression}] Use Makefile.rules to simplify Makefile

Isaku Yamahata 4 年之前
父節點
當前提交
2f03b32db7
共有 2 個文件被更改,包括 16 次插入13 次删除
  1. 12 10
      Pal/regression/Makefile
  2. 4 3
      Pal/test/Makefile

+ 12 - 10
Pal/regression/Makefile

@@ -1,7 +1,7 @@
 include ../src/Makefile.Host
 
 CC	= gcc
-CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -mavx -no-pie \
+CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -mavx \
 	  -I../include/pal -I../lib -I../src
 
 preloads    = $(patsubst %.c,%,$(wildcard *.so.c))
@@ -51,15 +51,17 @@ manifest: manifest.template
 	$(MAKE) -C ../src $(notdir $@)
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
-$(preloads): %.so: %.so.c ../src/user_shared_start.o \
-	$(graphene_lib) $(pal_lib)
-	@echo [ $@ ]
-	@$(CC) -MD -MP -shared -fPIC $(filter-out -no-pie,$(CFLAGS)) $(filter-out %.h,$^) -o $@
-
-$(executables): %: %.c ../src/user_start.o \
-	$(graphene_lib) $(pal_lib) $(preloads)
-	@echo [ $@ ]
-	@$(CC) -MD -MP $(CFLAGS) $(filter-out %.h,$^) -o $@
+LDLIBS-preloads = ../src/user_shared_start.o $(graphene_lib) $(pal_lib)
+$(preloads): CFLAGS += -shared -fPIC
+$(preloads): LDLIBS = $(LDLIBS-preloads)
+$(preloads): %.so: %.so.c $(LDLIBS-preloads)
+	$(call cmd,csingle)
+
+LDLIBS-executables = ../src/user_start.o $(graphene_lib) $(pal_lib) $(preloads)
+$(executables): CFLAGS += -no-pie
+$(executables): LDLIBS = $(LDLIBS-executables)
+$(executables): %: %.c $(LDLIBS-executables)
+	$(call cmd,csingle)
 
 include $(wildcard *.d)
 ifeq ($(SGX), 1)

+ 4 - 3
Pal/test/Makefile

@@ -42,9 +42,10 @@ manifest: manifest.template
 	cp -f $< $@
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
-$(executables): %: %.c $(graphene_lib) $(pal_lib) ../src/user_start.o
-	@echo [ $@ ]
-	@$(CC) -MD -MP $(CFLAGS) $(if $(filter Pie,$@),-fPIC -pie,) $^ -o $@
+CFLAGS-Pie = -fPIC -pie
+LDLIBS = $(graphene_lib) $(pal_lib) ../src/user_start.o
+$(executables): %: %.c $(LDLIBS)
+	$(call cmd,csingle)
 
 .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
 	@mkdir -p .lib