Use standard compiler environment variables.
This commit is contained in:
parent
d05bc1c6f5
commit
e259e8ae52
|
@ -36,6 +36,9 @@ software_meant_for_sortix:
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Determine whether a function is unset or is a Make default.
|
||||||
|
is_unset_or_default = $(filter undefined default,$(origin $(1)))
|
||||||
|
|
||||||
# Provide deprecated CPU variable so makefiles can select CPU-specific dirs.
|
# Provide deprecated CPU variable so makefiles can select CPU-specific dirs.
|
||||||
ifeq ($(HOST),i486-sortix)
|
ifeq ($(HOST),i486-sortix)
|
||||||
MACHINE:=i486
|
MACHINE:=i486
|
||||||
|
@ -61,66 +64,57 @@ ifndef HOST_TOOL_PREFIX
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Determine the names of the tools that target the build platform.
|
# Determine the names of the tools that target the build platform.
|
||||||
ifndef BUILDCC
|
ifndef CC_FOR_BUILD
|
||||||
BUILDCC:=$(BUILD_TOOL_PREFIX)gcc
|
CC_FOR_BUILD:=$(BUILD_TOOL_PREFIX)gcc
|
||||||
endif
|
endif
|
||||||
ifndef BUILDCXX
|
ifndef CXX_FOR_BUILD
|
||||||
BUILDCXX:=$(BUILD_TOOL_PREFIX)g++
|
CXX_FOR_BUILD:=$(BUILD_TOOL_PREFIX)g++
|
||||||
endif
|
endif
|
||||||
ifndef BUILDAR
|
ifndef AR_FOR_BUILD
|
||||||
BUILDAR:=$(BUILD_TOOL_PREFIX)ar
|
AR_FOR_BUILD:=$(BUILD_TOOL_PREFIX)ar
|
||||||
endif
|
endif
|
||||||
ifndef BUILDAS
|
ifndef AS_FOR_BUILD
|
||||||
BUILDAS:=$(BUILD_TOOL_PREFIX)as
|
AS_FOR_BUILD:=$(BUILD_TOOL_PREFIX)as
|
||||||
endif
|
endif
|
||||||
ifndef BUILDLD
|
ifndef LD_FOR_BUILD
|
||||||
BUILDAS:=$(BUILD_TOOL_PREFIX)ld
|
LD_FOR_BUILD:=$(BUILD_TOOL_PREFIX)ld
|
||||||
endif
|
endif
|
||||||
ifndef BUILDOBJCOPY
|
ifndef OBJCOPY_FOR_BUILD
|
||||||
BUILDOBJCOPY:=$(BUILD_TOOL_PREFIX)objcopy
|
OBJCOPY_FOR_BUILD:=$(BUILD_TOOL_PREFIX)objcopy
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Determine the names of the tools that target the host platform.
|
# Determine the names of the tools that target the host platform.
|
||||||
ifndef HOSTCC
|
ifneq ($(call is_unset_or_default,CC),)
|
||||||
HOSTCC:=$(HOST_TOOL_PREFIX)gcc
|
CC:=$(HOST_TOOL_PREFIX)gcc
|
||||||
endif
|
endif
|
||||||
ifndef HOSTCXX
|
ifneq ($(call is_unset_or_default,CXX),)
|
||||||
HOSTCXX:=$(HOST_TOOL_PREFIX)g++
|
CXX:=$(HOST_TOOL_PREFIX)g++
|
||||||
endif
|
endif
|
||||||
ifndef HOSTAR
|
ifneq ($(call is_unset_or_default,AR),)
|
||||||
HOSTAR:=$(HOST_TOOL_PREFIX)ar
|
AR:=$(HOST_TOOL_PREFIX)ar
|
||||||
endif
|
endif
|
||||||
ifndef HOSTAS
|
ifneq ($(call is_unset_or_default,AS),)
|
||||||
HOSTAS:=$(HOST_TOOL_PREFIX)as
|
AS:=$(HOST_TOOL_PREFIX)as
|
||||||
endif
|
endif
|
||||||
ifndef HOSTLD
|
ifneq ($(call is_unset_or_default,LD),)
|
||||||
HOSTLD:=$(HOST_TOOL_PREFIX)ld
|
LD:=$(HOST_TOOL_PREFIX)ld
|
||||||
endif
|
endif
|
||||||
ifndef HOSTOBJCOPY
|
ifneq ($(call is_unset_or_default,OBJCOPY),)
|
||||||
HOSTOBJCOPY:=$(HOST_TOOL_PREFIX)objcopy
|
OBJCOPY:=$(HOST_TOOL_PREFIX)objcopy
|
||||||
endif
|
endif
|
||||||
ifdef SYSROOT
|
ifdef SYSROOT
|
||||||
HOSTCC:=$(HOSTCC) --sysroot="$(SYSROOT)"
|
CC:=$(CC) --sysroot="$(SYSROOT)"
|
||||||
HOSTCXX:=$(HOSTCXX) --sysroot="$(SYSROOT)"
|
CXX:=$(CXX) --sysroot="$(SYSROOT)"
|
||||||
HOSTLD:=$(HOSTLD) --sysroot="$(SYSROOT)"
|
LD:=$(LD) --sysroot="$(SYSROOT)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC:=$(HOSTCC)
|
|
||||||
CXX:=$(HOSTCXX)
|
|
||||||
AR:=$(HOSTAR)
|
|
||||||
AS:=$(HOSTAS)
|
|
||||||
LD:=$(HOSTLD)
|
|
||||||
OBJCOPY:=$(HOSTOBJCOPY)
|
|
||||||
|
|
||||||
# Determine default optimization level.
|
# Determine default optimization level.
|
||||||
DEFAULT_GENERIC_OPTLEVEL_BASE:=-O2 -g
|
DEFAULT_GENERIC_OPTLEVEL_BASE:=-O2 -g
|
||||||
DEFAULT_BUILD_OPTLEVEL:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
|
DEFAULT_OPTLEVEL_FOR_BUILD:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
|
||||||
ifeq ($(BUILD_IS_SORTIX),1)
|
ifeq ($(BUILD_IS_SORTIX),1)
|
||||||
DEFAULT_BUILD_OPTLEVEL+=
|
DEFAULT_OPTLEVEL_FOR_BUILD+=
|
||||||
endif
|
endif
|
||||||
DEFAULT_HOST_OPTLEVEL:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
|
|
||||||
DEFAULT_OPTLEVEL:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
|
DEFAULT_OPTLEVEL:=$(DEFAULT_GENERIC_OPTLEVEL_BASE)
|
||||||
ifeq ($(HOST_IS_SORTIX),1)
|
ifeq ($(HOST_IS_SORTIX),1)
|
||||||
DEFAULT_HOST_OPTLEVEL+=
|
|
||||||
DEFAULT_OPTLEVEL+=
|
DEFAULT_OPTLEVEL+=
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -5,7 +5,7 @@ include ../build-aux/version.mak
|
||||||
include ../build-aux/dirs.mak
|
include ../build-aux/dirs.mak
|
||||||
|
|
||||||
# Default values in case the user doesn't override these variables.
|
# Default values in case the user doesn't override these variables.
|
||||||
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
|
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
||||||
DISKWRITE?=1
|
DISKWRITE?=1
|
||||||
CPPFLAGS?=
|
CPPFLAGS?=
|
||||||
CXXFLAGS?=$(OPTLEVEL)
|
CXXFLAGS?=$(OPTLEVEL)
|
||||||
|
@ -67,8 +67,8 @@ endif
|
||||||
# Object files that constitute the kernel.
|
# Object files that constitute the kernel.
|
||||||
|
|
||||||
CRTI_OBJ:=$(CPUDIR)/crti.o
|
CRTI_OBJ:=$(CPUDIR)/crti.o
|
||||||
CRTBEGIN_OBJ:=$(shell $(HOSTCXX) $(CXXFLAGS) -print-file-name=crtbegin.o)
|
CRTBEGIN_OBJ:=$(shell $(CXX) $(CXXFLAGS) -print-file-name=crtbegin.o)
|
||||||
CRTEND_OBJ:=$(shell $(HOSTCXX) $(CXXFLAGS) -print-file-name=crtend.o)
|
CRTEND_OBJ:=$(shell $(CXX) $(CXXFLAGS) -print-file-name=crtend.o)
|
||||||
CRTN_OBJ:=$(CPUDIR)/crtn.o
|
CRTN_OBJ:=$(CPUDIR)/crtn.o
|
||||||
|
|
||||||
LIBS=\
|
LIBS=\
|
||||||
|
@ -176,10 +176,10 @@ headers:
|
||||||
ifeq ($(CPU),x64)
|
ifeq ($(CPU),x64)
|
||||||
|
|
||||||
sortix-x86_64.bin: $(ALLOBJS)
|
sortix-x86_64.bin: $(ALLOBJS)
|
||||||
$(HOSTCXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 -Wl,-z -Wl,max-page-size=0x1000 $(LINK_OBJECTS) -o $@
|
$(CXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 -Wl,-z -Wl,max-page-size=0x1000 $(LINK_OBJECTS) -o $@
|
||||||
|
|
||||||
sortix.bin: sortix-x86_64.bin
|
sortix.bin: sortix-x86_64.bin
|
||||||
$(HOSTOBJCOPY) $< -O elf32-i386-sortix $@
|
$(OBJCOPY) $< -O elf32-i386-sortix $@
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -187,15 +187,15 @@ endif
|
||||||
ifeq ($(CPU),x86)
|
ifeq ($(CPU),x86)
|
||||||
|
|
||||||
sortix.bin: $(ALLOBJS)
|
sortix.bin: $(ALLOBJS)
|
||||||
$(HOSTCXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 $(LINK_OBJECTS) -o $@
|
$(CXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 $(LINK_OBJECTS) -o $@
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ALLOBJS) sortix.bin
|
rm -f $(ALLOBJS) sortix.bin
|
||||||
|
|
|
@ -4,7 +4,7 @@ include ../build-aux/compiler.mak
|
||||||
include ../build-aux/version.mak
|
include ../build-aux/version.mak
|
||||||
include ../build-aux/dirs.mak
|
include ../build-aux/dirs.mak
|
||||||
|
|
||||||
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
|
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
||||||
|
|
||||||
CPUDIR:=$(CPU)
|
CPUDIR:=$(CPU)
|
||||||
|
|
||||||
|
@ -684,19 +684,19 @@ libs-kernel: $(BINSKERNEL)
|
||||||
FORCE:
|
FORCE:
|
||||||
|
|
||||||
libc.a: $(OBJS)
|
libc.a: $(OBJS)
|
||||||
$(HOSTAR) rcs $@ $(OBJS)
|
$(AR) rcs $@ $(OBJS)
|
||||||
|
|
||||||
libdl.a:
|
libdl.a:
|
||||||
$(HOSTAR) rcs $@
|
$(AR) rcs $@
|
||||||
|
|
||||||
libg.a:
|
libg.a:
|
||||||
$(HOSTAR) rcs $@
|
$(AR) rcs $@
|
||||||
|
|
||||||
libk.a: $(LIBK_OBJS)
|
libk.a: $(LIBK_OBJS)
|
||||||
$(HOSTAR) rcs $@ $(LIBK_OBJS)
|
$(AR) rcs $@ $(LIBK_OBJS)
|
||||||
|
|
||||||
librt.a:
|
librt.a:
|
||||||
$(HOSTAR) rcs $@
|
$(AR) rcs $@
|
||||||
|
|
||||||
crt0.o: $(CPUDIR)/crt0.o
|
crt0.o: $(CPUDIR)/crt0.o
|
||||||
ln -f $< $@
|
ln -f $< $@
|
||||||
|
@ -717,23 +717,23 @@ headers:
|
||||||
|
|
||||||
# standard library
|
# standard library
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
|
$(CC) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CXXFLAGS)
|
$(CXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
|
$(CXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
|
||||||
|
|
||||||
# libk
|
# libk
|
||||||
%.libk.o: %.c
|
%.libk.o: %.c
|
||||||
$(HOSTCC) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CFLAGS)
|
$(CC) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CFLAGS)
|
||||||
|
|
||||||
%.libk.o: %.cpp
|
%.libk.o: %.cpp
|
||||||
$(HOSTCXX) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CXXFLAGS)
|
$(CXX) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CXXFLAGS)
|
||||||
|
|
||||||
%.libk.o: %.S
|
%.libk.o: %.S
|
||||||
$(HOSTCC) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CFLAGS)
|
$(CC) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o */*.o */*/*.o *.a
|
rm -f *.o */*.o */*/*.o *.a
|
||||||
|
|
|
@ -3,7 +3,7 @@ include ../build-aux/compiler.mak
|
||||||
include ../build-aux/version.mak
|
include ../build-aux/version.mak
|
||||||
include ../build-aux/dirs.mak
|
include ../build-aux/dirs.mak
|
||||||
|
|
||||||
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
|
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
||||||
CFLAGS?=$(OPTLEVEL)
|
CFLAGS?=$(OPTLEVEL)
|
||||||
|
|
||||||
# TODO: Better detection of the proper subdirectory here!
|
# TODO: Better detection of the proper subdirectory here!
|
||||||
|
@ -383,13 +383,13 @@ arch/i387/s_modf.o: src/s_modf.c
|
||||||
headers:
|
headers:
|
||||||
|
|
||||||
libm.a: $(OBJS)
|
libm.a: $(OBJS)
|
||||||
$(HOSTAR) rcs $@ $(OBJS)
|
$(AR) rcs $@ $(OBJS)
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
|
$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
|
$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(BINS) $(OBJS) $(ARCH_SUBDIR)/*.o src/*.o */*.o arch/*/*.o
|
rm -f $(BINS) $(OBJS) $(ARCH_SUBDIR)/*.o src/*.o */*.o arch/*/*.o
|
||||||
|
|
|
@ -4,7 +4,7 @@ include ../build-aux/compiler.mak
|
||||||
include ../build-aux/version.mak
|
include ../build-aux/version.mak
|
||||||
include ../build-aux/dirs.mak
|
include ../build-aux/dirs.mak
|
||||||
|
|
||||||
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
|
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
||||||
CXXFLAGS?=$(OPTLEVEL)
|
CXXFLAGS?=$(OPTLEVEL)
|
||||||
CPPFLAGS?=
|
CPPFLAGS?=
|
||||||
|
|
||||||
|
@ -77,10 +77,10 @@ headers:
|
||||||
libs: $(BINS)
|
libs: $(BINS)
|
||||||
|
|
||||||
libpthread.a: $(OBJS)
|
libpthread.a: $(OBJS)
|
||||||
$(HOSTAR) rcs $@ $(OBJS)
|
$(AR) rcs $@ $(OBJS)
|
||||||
|
|
||||||
%.o: %.c++
|
%.o: %.c++
|
||||||
$(HOSTCXX) -std=gnu++11 -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
$(CXX) -std=gnu++11 -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(BINS) $(OBJS) *.o
|
rm -f $(BINS) $(OBJS) *.o
|
||||||
|
|
Loading…
Reference in New Issue