
############################################################################
#                                                                          #
#  Make file for installing Nonpareil                                      #
#  Jeffrey H. Kingston                                                     #
#                                                                          #
#  The simple way to install Nonpareil is just to set NP_BIN_DIR below,    #
#  then type "make".  For more details and options, consult the adjacent   #
#  README file.  Mail jeff@it.usyd.edu.au if you have any problems.        #
#                                                                          #
#     make              Compile and install Nonpareil                      #
#     make clean        Undo "make"                                        #
#                                                                          #
#     make np           Same as plain "make"                               #
#     make npc          Compile the Nonpareil compiler                     #
#     make sys          Compile the included Nonpareil system              #
#     make init         Initialize the included Nonpareil system           #
#                                                                          #
#     make npc_clean    Undo "make npc"                                    #
#     make sys_clean    Undo "make sys"                                    #
#     make init_clean   Undo "make init"                                   #
#                                                                          #
############################################################################

############################################################################
#                                                                          #
#  NP_BIN_DIR                                                              #
#                                                                          #
#  The directory where the "np" and "np_init" executables will be          #
#  left after "make".  Set this variable to an existing directory,         #
#  lying on your command path, for which you have write permission.        #
#                                                                          #
############################################################################

NP_BIN_DIR = /home/jeff/bin


############################################################################
#                                                                          #
#   RULES                                                                  #
#                                                                          #
############################################################################

np:		npc sys init

npc:
		@echo ""
		@echo "Step 1: compiling the compiler"
		@echo "-------------------------------------------------------"
		cd compiler && $(MAKE)
		@echo "-------------------------------------------------------"

sys:		npc
		@echo ""
		@echo "Step 2: compiling the system"
		@echo "-------------------------------------------------------"
		cd system && ../compiler/npc
		cd system && mv ccode/np_init ccode/np $(NP_BIN_DIR)
		@echo "-------------------------------------------------------"

init:		sys
		@echo ""
		@echo "Step 3: initializing the system"
		@echo "-------------------------------------------------------"
		np_init
		@echo "-------------------------------------------------------"

clean:		npc_clean sys_clean init_clean doc_clean

npc_clean:
		@echo ""
		@echo "Step 1: undoing \"make npc\""
		@echo "-------------------------------------------------------"
		cd compiler && $(MAKE) clean
		@echo "-------------------------------------------------------"

sys_clean:	compiler
		@echo ""
		@echo "Step 2: undoing \"make sys\""
		@echo "-------------------------------------------------------"
		cd compiler/lib && rm -fr char_pool_* char_trie_*
		cd system && rm -fr ccode
		cd system/lang && rm -f functs tuples char
		rm -f $(NP_BIN_DIR)/np $(NP_BIN_DIR)/np_init
		@echo "-------------------------------------------------------"

init_clean:	system
		@echo ""
		@echo "Step 3: undoing \"make init\""
		@echo "-------------------------------------------------------"
		cd system && rm -f data_be data_le
		@echo "-------------------------------------------------------"

doc_clean:
		@echo ""
		@echo "Clearing temporary files from documentation directories"
		@echo "-------------------------------------------------------"
		rm -f doc/*/*.ld doc/*/lout.li doc/*/op* doc/*/*.ps
		@echo "-------------------------------------------------------"
