Commit 9e6148f6 authored by Jonas Termansen's avatar Jonas Termansen

Refactor default compiler options logic.

parent 12eaf468
......@@ -3,13 +3,8 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL=-g -O2
endif
ifndef CXXFLAGS
CXXFLAGS:=$(OPTLEVEL)
endif
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
......
......@@ -112,3 +112,15 @@ AS:=$(HOSTAS)
LD:=$(HOSTLD)
OBJCOPY:=$(HOSTOBJCOPY)
# Determine default optimization level.
DEFAULT_GENERIC_OPTLEVEL_BASE:=-O2 -g
DEFAULT_BUILD_OPTLEVEL:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
ifeq ($(BUILD_IS_SORTIX),1)
DEFAULT_BUILD_OPTLEVEL+=
endif
DEFAULT_HOST_OPTLEVEL:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
DEFAULT_OPTLEVEL:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
ifeq ($(HOST_IS_SORTIX),1)
DEFAULT_HOST_OPTLEVEL+=
DEFAULT_OPTLEVEL+=
endif
......@@ -3,13 +3,8 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-g -O2
endif
ifndef CXXFLAGS
CXXFLAGS:=$(OPTLEVEL)
endif
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
CPPFLAGS:=$(CPPFLAGS) -I include
......@@ -35,7 +30,7 @@ headers:
client: client/libdispd.a
client/libdispd.a: $(CLIENT_OBJS)
$(HOSTAR) rcs $@ $(CLIENT_OBJS)
$(AR) rcs $@ $(CLIENT_OBJS)
server: server/dispd
......@@ -48,7 +43,7 @@ clean:
rm -f *.o client/*.o server/*.o
%.o: %.cpp
$(HOSTCXX) -std=gnu++11 -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
$(CXX) -std=gnu++11 -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
# Installation into sysroot
install: install-headers install-client install-server
......
......@@ -2,7 +2,7 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
OPTLEVEL?=-g -O2
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CPPFLAGS:=$(CPPFLAGS)
......
......@@ -3,13 +3,8 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL=-g -O2
endif
ifndef CXXFLAGS
CXXFLAGS:=$(OPTLEVEL)
endif
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
......
......@@ -4,7 +4,7 @@ include ../version.mak
include ../dirs.mak
# Default values in case the user doesn't override these variables.
OPTLEVEL?=-g -O2
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
CALLTRACE?=0
DISKWRITE?=1
CPPFLAGS?=
......
......@@ -3,9 +3,7 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-g -O2 -fno-omit-frame-pointer
endif
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
CPUDIR:=$(CPU)
......
......@@ -3,7 +3,7 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
OPTLEVEL?=-O2 -g
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
CFLAGS?=$(OPTLEVEL)
# TODO: Better detection of the proper subdirectory here!
......
......@@ -3,7 +3,7 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
OPTLEVEL?=-O2 -g
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CPPFLAGS?=
......
......@@ -3,7 +3,7 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
OPTLEVEL?=-g -O2
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
......
......@@ -2,13 +2,8 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL=-g -O2
endif
ifndef CXXFLAGS
CXXFLAGS:=$(OPTLEVEL)
endif
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
SORTIXKERNEL=../kernel
......
......@@ -3,7 +3,7 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
OPTLEVEL?=-O2 -g
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
TESTDIR?=$(LIBEXECDIR)/test
......
......@@ -2,7 +2,7 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
OPTLEVEL?=-g -O2
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CPPFLAGS?=
CXXFLAGS?=$(OPTLEVEL)
......
......@@ -3,13 +3,8 @@ include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL=-g -O2
endif
ifndef CXXFLAGS
CXXFLAGS:=$(OPTLEVEL)
endif
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment