diff --git a/ChangeLog b/ChangeLog
index 5516ba28b92a846599c1bb56060d920e895c63de..f4c109a52deeb3753037186ae383a46195800eea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2012-02-18  Niels Möller  <nisse@lysator.liu.se>
 
+	* run-tests, getopt.c, getopt1.c, getopt.h: These files were moved
+	to the top-level in the conversion to an independent git
+	repository. They used to be symlinks to lsh files, from the
+	subdirectories which use them.
+
+	* Makefile.in: Build and distribute getopt files. Distribute
+	run-tests script.
+	* examples/Makefile.in: Adapt to getopt files and the run-tests
+	script now located in the parent directory.
+	* testsuite/Makefile.in: Likewise.
+	* tools/Makefile.in: Likewise.
+
 	* index.html: Converted to xhtml (from lsh repository, change
 	dated 2012-02-03). Updated git instructions.
 
diff --git a/Makefile.in b/Makefile.in
index f3fa571c8f5b85b6be97c1154133e63241bbf96e..9c97ef6192ad5eeab7fcd4ea30e2379b4d917383 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -23,7 +23,12 @@ PRE_CPPFLAGS = -I.
 LIBTARGETS = libnettle.a @IF_HOGWEED@ libhogweed.a
 SHLIBTARGETS = $(LIBNETTLE_FORLINK) @IF_HOGWEED@ $(LIBHOGWEED_FORLINK)
 
-TARGETS = aesdata$(EXEEXT) desdata$(EXEEXT) shadata$(EXEEXT) gcmdata$(EXEEXT)\
+getopt_SOURCES = getopt.c getopt1.c
+
+getopt_TARGETS = $(getopt_SOURCES:.c=.$(OBJEXT))
+
+TARGETS = aesdata$(EXEEXT) desdata$(EXEEXT) shadata$(EXEEXT) gcmdata$(EXEEXT) \
+	  $(getopt_TARGETS) \
 	  $(LIBTARGETS) @IF_SHARED@ $(SHLIBTARGETS)
 IMPLICIT_TARGETS = @IF_DLL@ $(LIBNETTLE_FILE) $(LIBHOGWEED_FILE)
 
@@ -125,9 +130,11 @@ HEADERS = aes.h arcfour.h arctwo.h asn1.h bignum.h blowfish.h \
 
 INSTALL_HEADERS = $(HEADERS) nettle-stdint.h
 
-SOURCES = $(nettle_SOURCES) $(hogweed_SOURCES) aesdata.c desdata.c shadata.c gcmdata.c
+SOURCES = $(nettle_SOURCES) $(hogweed_SOURCES) $(getopt_SOURCES) \
+	  aesdata.c desdata.c shadata.c gcmdata.c
 
-DISTFILES = $(SOURCES) $(HEADERS) .bootstrap aclocal.m4 configure.ac \
+DISTFILES = $(SOURCES) $(HEADERS) getopt.h .bootstrap run-tests \
+	aclocal.m4 configure.ac \
 	configure stamp-h.in \
 	config.guess config.sub install-sh texinfo.tex \
 	config.h.in config.m4.in config.make.in	Makefile.in \
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 2336a62fd76505a0016dba9b8e5b6aeb644207f9..c5d09586a88f0c12d3c31c415ddeb3a50d7695eb 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -18,21 +18,24 @@ RSA_TARGETS = rsa-keygen$(EXEEXT) rsa-sign$(EXEEXT) \
 TARGETS = nettle-benchmark$(EXEEXT) eratosthenes$(EXEEXT) @IF_HOGWEED@ $(RSA_TARGETS) next-prime$(EXEEXT) random-prime$(EXEEXT)
 SOURCES = nettle-benchmark.c eratosthenes.c next-prime.c random-prime.c \
 	nettle-openssl.c \
-	io.c read_rsa_key.c getopt.c getopt1.c \
+	io.c read_rsa_key.c \
 	rsa-encrypt.c rsa-decrypt.c rsa-keygen.c rsa-sign.c rsa-verify.c
 
-GETOPT_OBJS = getopt.$(OBJEXT) getopt1.$(OBJEXT)
+GETOPT_OBJS = ../getopt.$(OBJEXT) ../getopt1.$(OBJEXT)
 
 TS_ALL = rsa-sign-test rsa-verify-test rsa-encrypt-test
 
-DISTFILES= $(SOURCES) Makefile.in $(TS_ALL) run-tests setup-env teardown-env \
-	io.h rsa-session.h getopt.h
+DISTFILES= $(SOURCES) Makefile.in $(TS_ALL) setup-env teardown-env \
+	io.h rsa-session.h
 
 all: $(TARGETS)
 
 .c.$(OBJEXT):
 	$(COMPILE) -c $< && $(DEP_PROCESS)
 
+$(getopt_OBJS):
+	( cd .. && $(MAKE) $@ )
+
 # For Solaris and BSD make, we have to use an explicit rule for each executable
 next-prime$(EXEEXT): next-prime.$(OBJEXT) $(GETOPT_OBJS) ../libhogweed.a
 	$(LINK) next-prime.$(OBJEXT) $(GETOPT_OBJS) \
@@ -76,7 +79,7 @@ $(TARGETS) : io.$(OBJEXT) ../libnettle.a
 check: $(TS_ALL)
 	LD_LIBRARY_PATH=../.lib PATH="../.lib:$$PATH" srcdir="$(srcdir)" \
 	  EMULATOR="$(EMULATOR)" EXEEXT="$(EXEEXT)" \
-          "$(srcdir)"/run-tests $(TS_ALL)
+          "$(top_srcdir)"/run-tests $(TS_ALL)
 
 Makefile: $(srcdir)/Makefile.in ../config.status
 	cd .. && $(SHELL) ./config.status examples/$@
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index a147f449e9e11c3162599ea9ccdc75d34dda8346..8dfc62b7be6c42c787be4f222a3275c593bfc04a 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -48,7 +48,7 @@ EXTRA_TARGETS = $(EXTRA_SOURCES:.c=$(EXEEXT))
 SOURCES = $(TS_SOURCES) testutils.c
 
 DISTFILES = $(SOURCES) $(EXTRA_SOURCES) cxx-test.cxx Makefile.in .test-rules.make \
-	$(TS_SH) run-tests setup-env teardown-env \
+	$(TS_SH) setup-env teardown-env \
 	gold-bug.txt testutils.h
 
 all: $(TARGETS) $(EXTRA_TARGETS)
@@ -87,10 +87,10 @@ $(TARGETS) $(EXTRA_TARGETS): testutils.$(OBJEXT) \
 	../libnettle.a @IF_HOGWEED@ ../libhogweed.a
 
 # The PATH update is for locating dlls on w*ndows.
-check: $(TS_ALL) $(srcdir)/run-tests
+check: $(TS_ALL)
 	LD_LIBRARY_PATH=../.lib PATH="../.lib:$$PATH" srcdir="$(srcdir)" \
 	  EMULATOR="$(EMULATOR)" NM="$(NM)" EXEEXT="$(EXEEXT)" \
-          $(srcdir)/run-tests $(TS_ALL)
+          $(top_srcdir)/run-tests $(TS_ALL)
 
 
 Makefile: $(srcdir)/Makefile.in ../config.status
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 5ca73b2073cf1ed9415442ae76418d1a7ad5f322..a14e908bcad5b7f253a4b65ab3896e4c8486c999 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -23,28 +23,29 @@ TARGETS = sexp-conv$(EXEEXT) nettle-hash$(EXEEXT) nettle-lfib-stream$(EXEEXT) \
 
 all: $(TARGETS)
 
-sexp_conv_SOURCES = sexp-conv.c input.c output.c parse.c \
-	getopt.c getopt1.c misc.c
-pkcs1_conv_SOURCES = pkcs1-conv.c getopt.c getopt1.c misc.c
-nettle_hash_SOURCES = nettle-hash.c getopt.c getopt1.c misc.c
+getopt_OBJS = ../getopt.$(OBJEXT) ../getopt1.$(OBJEXT)
+
+sexp_conv_SOURCES = sexp-conv.c input.c output.c parse.c misc.c
+pkcs1_conv_SOURCES = pkcs1-conv.c misc.c
+nettle_hash_SOURCES = nettle-hash.c misc.c
 
 SOURCES = $(sexp_conv_SOURCES) nettle-hash.c nettle-lfib-stream.c pkcs1-conv.c
 
-DISTFILES = $(SOURCES) Makefile.in getopt.h input.h misc.h output.h parse.h
+DISTFILES = $(SOURCES) Makefile.in input.h misc.h output.h parse.h
 
-sexp_conv_OBJS = $(sexp_conv_SOURCES:.c=.$(OBJEXT))
+sexp_conv_OBJS = $(sexp_conv_SOURCES:.c=.$(OBJEXT)) $(getopt_OBJS)
 sexp-conv$(EXEEXT): $(sexp_conv_OBJS) ../libnettle.a
 	$(LINK) $(sexp_conv_OBJS) -lnettle $(LIBS) -o $@
 
 nettle-lfib-stream$(EXEEXT): nettle-lfib-stream.$(OBJEXT) ../libnettle.a
 	$(LINK) nettle-lfib-stream.$(OBJEXT) -lnettle $(LIBS) -o $@
 
-pkcs1_conv_OBJS = $(pkcs1_conv_SOURCES:.c=.$(OBJEXT))
+pkcs1_conv_OBJS = $(pkcs1_conv_SOURCES:.c=.$(OBJEXT)) $(getopt_OBJS)
 pkcs1-conv$(EXEEXT): $(pkcs1_conv_OBJS) ../libnettle.a ../libhogweed.a
 	$(LINK) $(pkcs1_conv_OBJS) -lhogweed -lnettle $(LIBS) -o $@
 
 # FIXME: Avoid linking with gmp
-nettle_hash_OBJS = $(nettle_hash_SOURCES:.c=.$(OBJEXT))
+nettle_hash_OBJS = $(nettle_hash_SOURCES:.c=.$(OBJEXT)) $(getopt_OBJS)
 nettle-hash$(EXEEXT): $(nettle_hash_OBJS) ../libnettle.a
 	$(LINK) $(nettle_hash_OBJS) -lnettle $(LIBS) -o $@
 
@@ -52,6 +53,8 @@ nettle-hash$(EXEEXT): $(nettle_hash_OBJS) ../libnettle.a
 .c.$(OBJEXT):
 	$(COMPILE) -c $< && $(DEP_PROCESS)
 
+$(getopt_OBJS):
+	( cd .. && $(MAKE) $@ )
 
 Makefile: $(srcdir)/Makefile.in ../config.status
 	cd .. && $(SHELL) ./config.status tools/$@