fix subdir linking for repos/

Change-Id: I727ad790f5658c6b080651deaf8b6235e5f691bc
diff --git a/Makefile b/Makefile
index 027660a..c52a1ad 100644
--- a/Makefile
+++ b/Makefile
@@ -80,17 +80,17 @@
 	  then git clone $(REPO_HOST)/$(@F) $@ ;\
 	fi
 
-# link subdirectories (if applicable) into main docs dir, then checkout ref if
-# not under test
+# checkout correct ref if not under test, then link subdirectories into main
+# docs dir
 $(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS)
-	GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\
-	ln -s repos/$(@)$$GIT_SUBDIR $@ ;\
 	if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\
 	  then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\
-	  pushd $@ ;\
+	  pushd repos/$@ ;\
 	    git checkout $$GIT_REF ;\
 	  popd ;\
 	fi
+	GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\
+	ln -s repos/$(@)$$GIT_SUBDIR $@ ;\
 
 # generate a list of git checksums suitable for updating git_refs
 freeze: repos