ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)

define PINFO
PINFO DESCRIPTION=startup library
endef

ASMOFF_FORMAT_x86 = cpp

NAME = startup

DEFFILE = asmoff.def

INSTALLDIR = usr/lib

EXTRA_SRCVPATH_x86=$(PROJECT_ROOT)/common_x86
EXTRA_SRCVPATH_x86_64=$(PROJECT_ROOT)/common_x86

EXTRA_SRCVPATH_arm=$(PROJECT_ROOT)/common_arm
EXTRA_SRCVPATH_aarch64=$(PROJECT_ROOT)/common_arm

-include ../../roots.mk

VEND_qss=extra
VENDOR=$(VEND_$(firstword $(BUILDENV) qss))

PRE_SRCVPATH = $(if $(wildcard $(PROJECT_ROOT)/$(VENDOR)),$(PROJECT_ROOT)/$(VENDOR)/$(CPU) $(PROJECT_ROOT)/$(VENDOR)) $(EXTRA_SRCVPATH_$(CPU))


#####AUTO-GENERATED by packaging script... do not checkin#####
   INSTALL_ROOT_nto = $(PROJECT_ROOT)/../../../../install
   USE_INSTALL_ROOT=1
##############################################################

include $(MKFILES_ROOT)/qtargets.mk


asmoff.def: $(PROJECT_ROOT)/asmoff.h $(CPU_ROOT)/asmoff.c

POST_INSTALL+=$(CP_HOST) \
	$(PROJECT_ROOT)/$(CPU)/$(VARIANT1)/asmoff.def \
	$(INSTALL_ROOT_$(OS))/usr/include/$(CPU)/asmoff.def;

CCVFLAG_64 = -D_PADDR_BITS=64

CCFLAGS += -Wno-error=missing-prototypes
CCFLAGS_gcc_ = -O2 -fomit-frame-pointer -fno-PIE
CCFLAGS_clang_ = -O2 -fomit-frame-pointer -fno-PIE
CCFLAGS_gcc_qcc = -O2 -Wc,-fomit-frame-pointer -fno-PIE
CCFLAGS_$(BUILDENV) = -DBUILDENV_$(BUILDENV)
CCFLAGS += $(CCFLAGS_$(COMPILER_TYPE)_$(COMPILER_DRIVER)) $(CCFLAGS_$(BUILDENV))

#
# This particular little kludge is to stop GCC from using F.P. instructions
# to move 8 byte quantities around.
#
ifeq ($(BUILDENV),qss)
CC_nto_ppc_gcc += -mno-fp-moves
CC_nto_ppc_gcc_qcc += -Wc,-mno-fp-moves
else
CC_nto_ppc_gcc += -msoft-float
CC_nto_ppc_gcc_qcc += -Wc,-msoft-float
endif

CCFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align -fno-store-merging
CCFLAGS_x86_64 += -mgeneral-regs-only

CCFLAGS_arm += -marm -D_PADDR_BITS=64
CCFLAGS += $(CCFLAGS_$(CPU))

callout_interrupt_mips_smp.o: callout_interrupt_mips_smp.S callout_interrupt_mips.S
callout_interrupt_85xxcpm.o: callout_interrupt_85xxcpm.s callout_interrupt_8260.s

print_sysp.o: print_sysp.c $(CPU_ROOT)/cpu_print_sysp.ci

# Prevent building with debug for the standard build.
# Temporary until linker has been changed.
CCOPTS:=$(filter-out -g,$(CCOPTS))

#
# A custom cinstall target helps to put print_sysc.c into usr/include/private/startup/lib
# in order to sync with utils/p/pidin/print_sysp.c
#
cinstall:
	mkdir -p $(INSTALL_ROOT_nto)/usr/include/private/startup/lib
	$(CP_HOST) -f $(PROJECT_ROOT)/print_sysp.c $(INSTALL_ROOT_nto)/usr/include/private/startup/lib/print_sysp.c

#
# Mainline-SDP production builds only run $make hinstall; make install only
# Here is to force the cinstall like this and it will do it during the initial hinstall stage.
#
hinstall:cinstall