###############################################################################
#                                                                             #
# IPFire.org - A linux based firewall                                         #
# Copyright (C) 2007-2018  IPFire Team  <info@ipfire.org>                     #
#                                                                             #
# This program is free software: you can redistribute it and/or modify        #
# it under the terms of the GNU General Public License as published by        #
# the Free Software Foundation, either version 3 of the License, or           #
# (at your option) any later version.                                         #
#                                                                             #
# This program is distributed in the hope that it will be useful,             #
# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
#                                                                             #
###############################################################################

###############################################################################
# Definitions
###############################################################################

include Config

VER        = ipfire

THISAPP    = stage1
TARGET     = $(DIR_INFO)/$(THISAPP)

###############################################################################
# Top-level Rules
###############################################################################

install : $(TARGET)

check :

download :

b2 :

###############################################################################
# Installation Details
###############################################################################

$(TARGET) :
	@$(PREBUILD)

	mkdir -pv $(TOOLS_DIR)/lib
	ln -svf lib $(TOOLS_DIR)/lib64

ifeq "$(BUILD_ARCH)" "riscv64"
	ln -svf . $(TOOLS_DIR)/lib/lp64d
endif

	# Write a cmake toolchain file so cmake knows we're targeting $(BUILD_ARCH)
	-mkdir -pv $(TOOLS_DIR)/share/cmake
	echo "set(CMAKE_SYSTEM_NAME      Linux)" > \
		$(TOOLS_DIR)/share/cmake/toolchain.cmake
	echo "set(CMAKE_SYSTEM_PROCESSOR $(BUILD_ARCH))" >> \
		$(TOOLS_DIR)/share/cmake/toolchain.cmake
	echo "set(CMAKE_C_COMPILER       $(TOOLS_DIR)/bin/cc)"  >> \
		$(TOOLS_DIR)/share/cmake/toolchain.cmake
	echo "set(CMAKE_CXX_COMPILER     $(TOOLS_DIR)/bin/c++)" >> \
		$(TOOLS_DIR)/share/cmake/toolchain.cmake

	@$(POSTBUILD)
