***************
*** 708,717 ****
  #========================================================================
  
  pkgIndex.tcl: $(PKG_LIB_FILE)
- 	@echo package ifneeded nsf $(PACKAGE_VERSION) \"load [list [file join \$$dir . $(PKG_LIB_FILE)] Nsf]\; package provide nsf $(PACKAGE_VERSION)\" > pkgIndex.tcl
  
  install-pkgIndex:
- #	@echo package ifneeded nsf $(PACKAGE_VERSION) [list load [file join \$$dir .. "$(PKG_LIB_FILE)"] Nsf] > "$(pkglibdir)/pkgIndex.tcl"
  
  #nxsh: tclAppInit.o $(PKG_OBJECTS) $(CONDITIONAL_STUB_OBJECTS)
  #	$(CC) -rdynamic -o $@ tclAppInit.o \
--- 708,731 ----
  #========================================================================
  
  pkgIndex.tcl: $(PKG_LIB_FILE)
+ 	@echo "if {[package vsatisfies [package provide Tcl] 9]} {" > pkgIndex.tcl
+ 	@echo "    package ifneeded nsf @PACKAGE_VERSION@ \\" >> pkgIndex.tcl
+ 	@echo "	    [list load [file join \$$dir @PKG_LIB_FILE9@] Nsf]" >> pkgIndex.tcl
+ 	@echo "} else {" >> pkgIndex.tcl
+ 	@echo "    package ifneeded nsf @PACKAGE_VERSION@ \\" >> pkgIndex.tcl
+ 	@echo "	    [list load [file join \$$dir @PKG_LIB_FILE8@] Nsf]" >> pkgIndex.tcl
+ 	@echo "}" >> pkgIndex.tcl
+ 	@echo "package provide nsf $(PACKAGE_VERSION)" >> pkgIndex.tcl
+ 	
  
  install-pkgIndex:
+ 	@echo "if {[package vsatisfies [package provide Tcl] 9]} {" > pkgIndex.tcl
+ 	@echo "    package ifneeded nsf @PACKAGE_VERSION@ \\" >> pkgIndex.tcl
+ 	@echo "	    [list load [file join \$$dir @PKG_LIB_FILE9@] Nsf]" >> pkgIndex.tcl
+ 	@echo "} else {" >> pkgIndex.tcl
+ 	@echo "    package ifneeded nsf @PACKAGE_VERSION@ \\" >> pkgIndex.tcl
+ 	@echo "	    [list load [file join \$$dir @PKG_LIB_FILE8@] Nsf]" >> pkgIndex.tcl
+ 	@echo "}" >> pkgIndex.tcl
  
  #nxsh: tclAppInit.o $(PKG_OBJECTS) $(CONDITIONAL_STUB_OBJECTS)
  #	$(CC) -rdynamic -o $@ tclAppInit.o \
