瀏覽代碼

[LibOS] Use Makefile.rules to simplify Makefile

Simplify shim/test/{regression, native, benchmark, inline}/Makefile.
Isaku Yamahata 4 年之前
父節點
當前提交
94d2197720

+ 3 - 3
LibOS/shim/test/Makefile

@@ -16,11 +16,11 @@ endif
 CC = gcc
 CXX = g++
 CFLAGS 	= -Wall -std=gnu99
-CFLAGS-debug = $(CFLAGS) -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
+CFLAGS-debug = -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
 CXXFLAGS = -Wall -std=c++14
-CXXFLAGS-debug = $(CXXFLAGS) -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
+CXXFLAGS-debug = -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
 LDFLAGS	=
-LDFLAGS-debug = $(LDFLAGS) -L$(SHIMDIR) -L$(PALDIR) -Wl,-rpath-link=$(abspath $(RUNTIME))
+LDFLAGS-debug = -L$(SHIMDIR) -L$(PALDIR) -Wl,-rpath-link=$(abspath $(RUNTIME))
 
 CFLAGS-libos = -I$(SHIMDIR)/../include -L$(SHIMDIR)/../../glibc-build/libos
 

+ 12 - 6
LibOS/shim/test/benchmark/Makefile

@@ -5,6 +5,8 @@ target = $(c_executables) $(cxx_executables) \
 	  manifest
 
 level = ../
+include ../../../../Makefile.configs
+include ../../../../Makefile.rules
 include ../Makefile
 
 CFLAGS-libos = -L../../../glibc-build/libos -I../../include
@@ -14,15 +16,19 @@ CFLAGS-libos = -L../../../glibc-build/libos -I../../include
 	cp $@.template $@
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
+
+CFLAGS-rpc_latency.libos += $(CFLAGS-libos)
+CFLAGS-rpc_latency2.libos += $(CFLAGS-libos)
+
+LDLIBS-rpc_latency.libos += -llibos
+LDLIBS-rpc_latency2.libos += -llibos
+LDLIBS-test_start.m += -lm
+
 $(c_executables): %: %.c
-	@echo [ $@ ]
-	@$(CC) $(CFLAGS) $(if $(findstring .libos,$@),$(CFLAGS-libos),) -o $@ $< \
-	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
+	$(call cmd,csingle)
 
 $(cxx_executables): %: %.cpp
-	@echo [ $@ ]
-	@$(CC) $(CFLAGS) -o $@ $< \
-	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
+	$(call cmd,cxxsingle)
 else
 .IGNORE: $(c_executables) $(cxx_executables)
 $(c_executables) $(cxx_executables):

+ 16 - 7
LibOS/shim/test/inline/Makefile

@@ -1,22 +1,31 @@
 c_executables = $(patsubst %.c,%,$(wildcard *.c))
 cxx_executables = $(patsubst %.cpp,%,$(wildcard *.cpp))
 
+exec_target = $(c_executables) $(cxx_executables)
 target = $(c_executables) $(cxx_executables) manifest
 
+.PHONY: default
+default: all
+
 level = ../
+include ../../../../Makefile.configs
+include ../../../../Makefile.rules
 include ../Makefile
 
 CFLAGS-debug += -fno-builtin -nostdlib
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
-$(c_executables): %: %.c $(libs) $(level)../../../Pal/src/user_start.o
-	@echo [ $@ ]
-	$(CC) $(CFLAGS-debug) $(LDFLAGS-debug) -o $@ $^ -lpal -lsysdb_debug
-
+LDLIBS-c_executables = $(libs) $(level)../../../Pal/src/user_start.o
+$(c_executables): CFLAGS += $(CFLAGS-debug)
+$(c_executables): LDLIBS += $(LDFLAGS-debug) $(LDLIBS-c_executables) -lpal -lsysdb_debug
+%: %.c $(LDLIBS-c_executables)
+	$(call cmd,csingle)
 
-$(cxx_executables): %: %.cpp $(libs) $(level)../../../Pal/src/user_start.o
-	@echo [ $@ ]
-	$(CXX) $(CFLAGS-debug) $(LDFLAGS-debug) -o $@ $^ -lpal -lsysdb_debug
+LDLIBS-cxx_executables = $(libs) $(level)../../../Pal/src/user_start.o
+$(cxx_executables): CXXFLAGS += $(CFLAGS-debug)
+$(cxx_executables): LDLIBS += $(LDFLAGS-debug) $(LDLIBS-cxx_executables) -lpal -lsysdb_debug
+%: %.cpp $(LDLIBS-cxx_executables)
+	$(call cmd,cxxsingle)
 else
 .IGNORE: $(c_executables) $(cxx_executables)
 $(c_executables) $(cxx_executables):

+ 19 - 6
LibOS/shim/test/native/Makefile

@@ -6,18 +6,31 @@ exec_target = $(c_executables) $(cxx_executables) ls.manifest
 target = $(exec_target) $(manifests)
 
 level = ../
+include ../../../../Makefile.configs
+include ../../../../Makefile.rules
 include ../Makefile
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
+
+CFLAGS-msg_create.libos += $(CFLAGS-libos)
+CFLAGS-msg_send.libos += $(CFLAGS-libos)
+
+LDLIBS-condvar.pthread += -lpthread
+LDLIBS-futextest.pthread += -lpthread
+LDLIBS-get_time.m += -lm
+LDLIBS-helloworld.pthread += -lpthread
+LDLIBS-msg_create.libos += -llibos
+LDLIBS-msg_send.libos += -llibos
+LDLIBS-sqrt.m += -lm
+LDLIBS-start.pthread.m += -lpthread -lm
+LDLIBS-sync.pthread += -lpthread
+LDLIBS-test_start_pthread_m.m += -lm
+
 $(c_executables): %: %.c
-	@echo [ $@ ]
-	@$(CC) -MD -MP $(CFLAGS) $(if $(findstring .libos,$@),$(CFLAGS-libos),) -o $@ $< \
-	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
+	$(call cmd,csingle)
 
 $(cxx_executables): %: %.cpp
-	@echo [ $@ ]
-	@$(CXX) -MD -MP $(CXXFLAGS) $(if $(findstring .libos,$@),$(CFLAGS-libos),) -o $@ $< \
-	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
+	$(call cmd,cxxsingle)
 
 include $(wildcard *.d)
 else

+ 2 - 2
LibOS/shim/test/regression/Makefile

@@ -24,10 +24,10 @@ CFLAGS-syscall += -I$(PALDIR)/../include -I$(PALDIR)/host/$(PAL_HOST)
 CFLAGS-openmp = -fopenmp
 CFLAGS-multi_pthread = -pthread
 
-$(c_executables): %: %.c
+%: %.c
 	$(call cmd,csingle)
 
-$(cxx_executables): %: %.cpp
+%: %.cpp
 	$(call cmd,cxxsingle)
 
 else