Browse Source

[LibOS,Pal] Unify the setting of CC and remove raw gcc invocations

Isaku Yamahata 4 years ago
parent
commit
0912f20ccf

+ 3 - 4
LibOS/Makefile

@@ -1,5 +1,6 @@
-SYS ?= $(shell gcc -dumpmachine)
-export SYS
+include ../Scripts/Makefile.configs
+include ../Scripts/Makefile.rules
+include ../Pal/src/Makefile.Host
 
 export DEBUG
 
@@ -38,8 +39,6 @@ export GLIBC_CFLAGS
 all: $(GLIBC_TARGET) $(GLIBC_RUNTIME)
 	$(MAKE) -C $(SHIM_DIR) all
 
-include ../Scripts/Makefile.rules
-
 .PHONY: format
 format:
 	$(MAKE) -C $(SHIM_DIR) format

+ 2 - 3
LibOS/shim/Makefile

@@ -1,7 +1,6 @@
-MAKEFLAGS += --check-symlink-times
+include ../../Scripts/Makefile.configs
 
-SYS ?= $(shell gcc -dumpmachine)
-export SYS
+MAKEFLAGS += --check-symlink-times
 
 .PHONY: all
 all:

+ 3 - 3
LibOS/shim/test/Makefile

@@ -1,9 +1,9 @@
+include ../../../Scripts/Makefile.configs
+include ../../../Pal/src/Makefile.Host
+
 # SUBDIRS = regression native inline benchmark
 SUBDIRS = native fs
 
-SYS ?= $(shell gcc -dumpmachine)
-export SYS
-
 .PHONY: default
 default: all
 

+ 2 - 2
Makefile

@@ -1,5 +1,5 @@
-SYS ?= $(shell gcc -dumpmachine)
-export SYS
+include Scripts/Makefile.configs
+include Pal/src/Makefile.Host
 
 targets = all clean format test sgx-tokens distclean
 

+ 1 - 0
Pal/Makefile

@@ -1,3 +1,4 @@
+include ../Scripts/Makefile.configs
 include src/Makefile.Host
 
 DIRS = src test regression

+ 3 - 4
Pal/regression/Makefile

@@ -1,6 +1,8 @@
+include ../../Scripts/Makefile.configs
 include ../src/Makefile.Host
+include ../../Scripts/Makefile.rules
+include ../src/Makefile.Test
 
-CC	= gcc
 CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib \
 	  -I../include/pal -I../lib -I../src
 
@@ -46,9 +48,6 @@ pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
 
 .PHONY: default
 default: all
-include ../../Scripts/Makefile.configs
-include ../../Scripts/Makefile.rules
-include ../src/Makefile.Test
 
 RUNTIME_DIR = $(CURDIR)/../../Runtime
 

+ 4 - 2
Pal/src/Makefile.Host

@@ -1,6 +1,9 @@
 all_hosts = Skeleton Linux Linux-SGX
 
-SYS ?= $(shell gcc -dumpmachine)
+ifneq ($(MAKEFILE_CONFIGS_INCLUDED),y)
+$(error Makfile.configs must be included before Makefile.Host)
+endif
+
 ifeq ($(PAL_HOST),)
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
 PAL_HOST := Linux
@@ -21,7 +24,6 @@ ifeq ($(findstring $(PAL_HOST),$(all_hosts)),)
 $(error Unsupported platform: $(PAL_HOST))
 endif
 
-export SYS
 export PAL_HOST
 export PAL_HOST_MACRO = $(shell echo $(PAL_HOST) | tr '[:lower:]' '[:upper:]' | tr '-' '_')
 

+ 3 - 4
Pal/test/Makefile

@@ -1,14 +1,13 @@
+include ../../Scripts/Makefile.configs
 include ../src/Makefile.Host
+include ../../Scripts/Makefile.rules
+include ../src/Makefile.Test
 
-CC	= gcc
 CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -no-pie \
 	  -I../include/pal -I../lib
 
 .PHONY: default
 default: all
-include ../../Scripts/Makefile.configs
-include ../../Scripts/Makefile.rules
-include ../src/Makefile.Test
 
 executables = HelloWorld File Failure Thread Fork Event Process Exception \
 	      Memory Pipe Tcp Udp Yield Server Wait HandleSend Select Segment \

+ 1 - 1
Runtime/pal_loader

@@ -37,7 +37,7 @@ if [ -z $PAL_HOST ]; then
         PAL_HOST="${libpal%.so}"
         PAL_HOST="${PAL_HOST#libpal-}"
     else
-        PAL_HOST=$(/usr/bin/make --no-print-directory --quiet -f $RUNTIME_DIR/../Pal/src/Makefile.Host print_host 2>&1)
+        PAL_HOST=$(/usr/bin/make --no-print-directory --quiet -f "$RUNTIME_DIR/../Scripts/Makefile.configs" -f "$RUNTIME_DIR/../Pal/src/Makefile.Host" print_host 2>&1)
     fi
 fi
 

+ 5 - 9
Scripts/Makefile.Test

@@ -1,21 +1,21 @@
 SCRIPTS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
 SHIM_TEST_DIR = $(SCRIPTS_DIR)/../LibOS/shim/test
 
-SYS ?= $(shell gcc -dumpmachine)
-export SYS
-
 PALDIR  = $(abspath $(SCRIPTS_DIR)/../Pal/src)
 SHIMDIR = $(abspath $(SCRIPTS_DIR)/../LibOS/shim)
 RUNTIME = $(abspath $(SCRIPTS_DIR)/../Runtime)
 
+include $(SCRIPTS_DIR)/Makefile.configs
+include $(PALDIR)/Makefile.Host
+include $(SCRIPTS_DIR)/Makefile.rules
+include $(PALDIR)/Makefile.Test
+
 ifeq ($(SGX),1)
 PAL_LOADER = pal_loader SGX
 else
 PAL_LOADER = pal_loader
 endif
 
-CC = gcc
-CXX = g++
 CFLAGS 	= -Wall -std=gnu99
 CXXFLAGS = -Wall -std=c++14
 LDFLAGS	=
@@ -29,10 +29,6 @@ LDFLAGS-libos-debug = -L$(SHIMDIR)/src -L$(PALDIR)/host/$(PAL_HOST) -Wl,-rpath-l
 .PHONY: default
 default: all
 
-include $(SCRIPTS_DIR)/Makefile.configs
-include $(SCRIPTS_DIR)/Makefile.rules
-include $(PALDIR)/Makefile.Test
-
 .PHONY: all
 all: pal_loader $(target) | $(call expand_target,$(exec_target))
 

+ 4 - 0
Scripts/Makefile.configs

@@ -17,3 +17,7 @@ ifeq ($(origin CXX),default)
 CXX = g++
 endif
 OBJCOPY ?= objcopy
+SYS ?= $(shell $(CC) -dumpmachine)
+export SYS
+
+MAKEFILE_CONFIGS_INCLUDED = y