# Created by Xun Dong, Computer Science Department of York, University of York

# This is the make file to install the statically built cross compiler GCC for 
# both Arm and Pisa, It also install the simple scalar simulator tools for Arm
# and Pisa architecture. 

# Note: The user should modify the attributes if you want to install the tools in
# other place instead of the default setting.

SOURCE = asproject.tar
AUTOSCRIPTS = AutoSim.pl

INSTALL_DIR = /tmp/xun/localinstall/local/pkg
PROFILE     = /usr/xd101/.profile

#assume the BIN_DIR is already in the path, if changed this value make sure
#update the PATH according.
BIN_DIR = /tmp/xun/localinstall/local/bin

GCC_ARM_TAR = gcc-arm-2.95.2.tar.gz
GCC_ARM     = gcc-arm-2.95.2
SIM_ARM_TAR = simplescalar-arm-4.0.tar.gz
SIM_ARM     = simplescalar-arm-4.0
GCC_PISA_TAR = linux-gcc-pisa.tar.gz
GCC_PISA    = linux-gcc-pisa
SIM_PISA_TAR = simplesim-pisa-3.0d.tar.gz
SIM_PISA    = simplesim-pisa-3.0d


# This is the default; it installs everything.


intall : 
	@tar xvf $(SOURCE)

#install the AutoSim.pl

	@mkdir -p $(BIN_DIR)
	@mkdir -p $(INSTALL_DIR)
	@mv -f $(AUTOSCRIPTS) $(BIN_DIR)

#install the GCC_ARM and simple scalar simulator for ARM.

	@tar xvzf $(GCC_ARM_TAR);	rm $(GCC_ARM_TAR) 
	@mv -f $(GCC_ARM) $(INSTALL_DIR)/$(GCC_ARM)
	@tar xvzf $(SIM_ARM_TAR);	rm $(SIM_ARM_TAR)
	@mv -f $(SIM_ARM) $(INSTALL_DIR)

#install the GCC_PISA and simple scalar simulator for PISA.

	@tar xvzf $(GCC_PISA_TAR);	rm $(GCC_PISA_TAR)
	@mv -f $(GCC_PISA) $(INSTALL_DIR)/$(GCC_PISA)
	@tar xvzf $(SIM_PISA_TAR);	rm $(SIM_PISA_TAR)
	@mv -f $(SIM_PISA) $(INSTALL_DIR)
	
#create the symbolic link for cross compiler
	@ln -sv $(INSTALL_DIR)/$(GCC_ARM)/bin/* $(BIN_DIR)
	@ln -sv $(INSTALL_DIR)/$(GCC_PISA)/bin/* $(BIN_DIR)
	@chmod 755 $(BIN_DIR)/$(AUTOSCRIPTS)
	@perl install.pl --profile=$(PROFILE) --gcc_bin=$(BIN_DIR) --ss_arm=$(INSTALL_DIR)/$(SIM_ARM)/bin --ss_pisa=$(SIM_PISA)/* $(INSTALL_DIR)/$(SIM_PISA)/bin
	@echo "Removing temporary files\n"
	@rm install.pl
	@echo "Installation completed successfully"
