--- a/tclpkg/Makefile.am
+++ b/tclpkg/Makefile.am
@@ -18,6 +18,12 @@
 pkgindex_DATA = pkgIndex.tcl
 endif
 
+if WITH_WIN32
+SO_DLL ?= dll
+else
+SO_DLL ?= so
+endif
+
 SUBDIRS = tclstubs gdtclft tcldot tclpathplan gv
 
 pkgIndex.tcl: $(TCL_PKGINDEX) $(TCL_PKGINDEX_GD) $(TCL_PKGINDEX_SWIG)
@@ -35,7 +41,7 @@
 	-mkdir -p $(DESTDIR)$(LUA_INSTALL_DIR);
 	if test -w $(DESTDIR)$(LUA_INSTALL_DIR); then \
 		(cd $(DESTDIR)$(LUA_INSTALL_DIR); \
-			cp -f $(DESTDIR)$(pkgluadir)/libgv_lua.so gv.so;) \
+			cp -f $(DESTDIR)$(pkgluadir)/libgv_lua.$(SO_DLL) gv.$(SO_DLL);) \
 	else \
 		echo "Warning: $(LUA_INSTALL_DIR) is not writable."; \
 		echo "Skipping system installation of lua binding."; \
@@ -45,7 +51,7 @@
 	-mkdir -p $(DESTDIR)$(PERL_INSTALL_DIR);
 	if test -w $(DESTDIR)$(PERL_INSTALL_DIR); then \
 		(cd $(DESTDIR)$(PERL_INSTALL_DIR); \
-			cp -f $(DESTDIR)$(pkgperldir)/libgv_perl.so gv.so; \
+			cp -f $(DESTDIR)$(pkgperldir)/libgv_perl.$(SO_DLL) gv.$(SO_DLL); \
 			cp -f $(DESTDIR)$(pkgperldir)/gv.pm gv.pm;) \
 	else \
 		echo "Warning: $(PERL_INSTALL_DIR) is not writable."; \
@@ -56,7 +66,7 @@
 	-mkdir -p $(DESTDIR)$(PHP_INSTALL_DIR);
 	if test -w $(DESTDIR)$(PHP_INSTALL_DIR); then \
 		(cd $(DESTDIR)$(PHP_INSTALL_DIR); \
-			cp -f $(DESTDIR)$(pkgphpdir)/libgv_php.so gv.so;) \
+			cp -f $(DESTDIR)$(pkgphpdir)/libgv_php.$(SO_DLL) gv.$(SO_DLL);) \
 	else \
 		echo "Warning: $(PHP_INSTALL_DIR) is not writable."; \
 		echo "Skipping system installation of php binding."; \
@@ -76,7 +82,7 @@
 	-mkdir -p $(DESTDIR)$(PYTHON3_INSTALL_DIR);
 	if test -w $(DESTDIR)$(PYTHON3_INSTALL_DIR); then \
 		(cd $(DESTDIR)$(PYTHON3_INSTALL_DIR); \
-			cp -f $(DESTDIR)$(pkgpython3dir)/libgv_python3.so _gv.so; \
+			cp -f $(DESTDIR)$(pkgpython3dir)/libgv_python3.$(SO_DLL) _gv.$(SO_DLL); \
 			cp -f $(DESTDIR)$(pkgpython3dir)/gv.py gv.py;) \
 	else \
 		echo "Warning: $(PYTHON3_INSTALL_DIR) is not writable."; \
@@ -87,7 +93,7 @@
 	-mkdir -p $(DESTDIR)$(RUBY_INSTALL_DIR);
 	if test -w $(DESTDIR)$(RUBY_INSTALL_DIR); then \
 		(cd $(DESTDIR)$(RUBY_INSTALL_DIR); \
-			cp -f $(DESTDIR)$(pkgrubydir)/libgv_ruby.so gv.so;) \
+			cp -f $(DESTDIR)$(pkgrubydir)/libgv_ruby.$(SO_DLL) gv.$(SO_DLL);) \
 	else \
 		echo "Warning: $(RUBY_INSTALL_DIR) is not writable."; \
 		echo "Skipping system installation of ruby binding."; \
@@ -114,16 +120,16 @@
 	-rm -rf $(DESTDIR)$(pkgiodir);
 	-rm -rf $(DESTDIR)$(pkgjavadir);
 	-rm -rf $(DESTDIR)$(pkgluadir);
-	-rm -rf $(DESTDIR)$(LUA_INSTALL_DIR)/gv.so;
+	-rm -rf $(DESTDIR)$(LUA_INSTALL_DIR)/gv.$(SO_DLL);
 	-rm -rf $(DESTDIR)$(pkgperldir);
-	-rm -rf $(DESTDIR)$(PERL_INSTALL_DIR)/gv.so $(DESTDIR)$(PERL_INSTALL_DIR)/gv.pm;
+	-rm -rf $(DESTDIR)$(PERL_INSTALL_DIR)/gv.$(SO_DLL) $(DESTDIR)$(PERL_INSTALL_DIR)/gv.pm;
 	-rm -rf $(DESTDIR)$(pkgphpdir);
-	-rm -rf $(DESTDIR)$(PHP_INSTALL_DIR)/gv.so $(DESTDIR)$(PHP_INSTALL_DATADIR)/gv.php;
+	-rm -rf $(DESTDIR)$(PHP_INSTALL_DIR)/gv.$(SO_DLL) $(DESTDIR)$(PHP_INSTALL_DATADIR)/gv.php;
 	-rm -rf $(DESTDIR)$(pkgpython3dir);
-	-rm -rf $(DESTDIR)$(PYTHON3_INSTALL_DIR)/_gv.so $(DESTDIR)$(PYTHON3_INSTALL_DIR)/gv.py;
+	-rm -rf $(DESTDIR)$(PYTHON3_INSTALL_DIR)/_gv.$(SO_DLL) $(DESTDIR)$(PYTHON3_INSTALL_DIR)/gv.py;
 	-rm -rf $(DESTDIR)$(pkgRdir);
 	-rm -rf $(DESTDIR)$(pkgrubydir);
-	-rm -rf $(DESTDIR)$(RUBY_INSTALL_DIR)/gv.so;
+	-rm -rf $(DESTDIR)$(RUBY_INSTALL_DIR)/gv.$(SO_DLL);
 	-rm -rf $(DESTDIR)$(pkgtcldir);
 	-rm -rf $(DESTDIR)$(TCL_INSTALL_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION);
 
--- a/tclpkg/gv/Makefile.am
+++ b/tclpkg/gv/Makefile.am
@@ -18,6 +18,12 @@
 	$(top_builddir)/lib/cdt/libcdt.la
 BASECPPFLAGS = $(AM_CPPFLAGS) -DDEMAND_LOADING=1
 
+if WITH_WIN32
+SO_DLL ?= dll
+else
+SO_DLL ?= so
+endif
+
 pkgsharpdir = $(pkglibdir)/sharp
 SHARP_data = gv.cs gvPINVOKE.cs SWIGTYPE_p_Agraph_t.cs SWIGTYPE_p_Agnode_t.cs SWIGTYPE_p_Agedge_t.cs SWIGTYPE_p_Agsym_t.cs SWIGTYPE_p_FILE.cs
 nodist_libgv_sharp_la_SOURCES = gv_sharp.cpp $(SHARP_data)
@@ -362,22 +368,22 @@
 	(cd $(DESTDIR)$(pkgjavadir); $(LN_S) -f org/graphviz/libgv_java.$(JSHEXT) ../../libgv.$(JSHEXT); javac -classpath $(DESTDIR)$(libjavadir) gv.java;)
 endif
 if WITH_LUA
-	(cd $(DESTDIR)$(pkgluadir); rm -f gv.so; $(LN_S) libgv_lua.so gv.so;)
+	(cd $(DESTDIR)$(pkgluadir); rm -f gv.$(SO_DLL); $(LN_S) libgv_lua.$(SO_DLL) gv.$(SO_DLL);)
 endif
 if WITH_PERL
-	(cd $(DESTDIR)$(pkgperldir); rm -f gv.so; $(LN_S) libgv_perl.so gv.so;)
+	(cd $(DESTDIR)$(pkgperldir); rm -f gv.$(SO_DLL); $(LN_S) libgv_perl.$(SO_DLL) gv.$(SO_DLL);)
 endif
 if WITH_PHP
-	(cd $(DESTDIR)$(pkgphpdir); rm -f gv.so; $(LN_S) libgv_php.so gv.so;)
+	(cd $(DESTDIR)$(pkgphpdir); rm -f gv.$(SO_DLL); $(LN_S) libgv_php.$(SO_DLL) gv.$(SO_DLL);)
 endif
 if WITH_PYTHON3
-	(cd $(DESTDIR)$(pkgpython3dir); rm -f _gv.so; $(LN_S) libgv_python3.so _gv.so;)
+	(cd $(DESTDIR)$(pkgpython3dir); rm -f _gv.$(SO_DLL); $(LN_S) libgv_python3.$(SO_DLL) _gv.$(SO_DLL);)
 endif
 if WITH_R
-	(cd $(DESTDIR)$(pkgRdir); rm -f gv.so; $(LN_S) libgv_R.so gv.so;)
+	(cd $(DESTDIR)$(pkgRdir); rm -f gv.$(SO_DLL); $(LN_S) libgv_R.$(SO_DLL) gv.$(SO_DLL);)
 endif
 if WITH_RUBY
-	(cd $(DESTDIR)$(pkgrubydir); rm -f gv.so; $(LN_S) libgv_ruby.so gv.so;)
+	(cd $(DESTDIR)$(pkgrubydir); rm -f gv.$(SO_DLL); $(LN_S) libgv_ruby.$(SO_DLL) gv.$(SO_DLL);)
 endif
 
 devtsts: $(DEVTSTS)
@@ -385,7 +391,7 @@
 .PHONY: test_sharp
 test_sharp: libgv_sharp.la
 	-(mkdir -p test_sharp; cd test_sharp; \
-		ln -fs ../.libs/libgv_sharp.so libgv_sharp.so; \
+		ln -fs ../.libs/libgv_sharp.$(SO_DLL) libgv_sharp.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.cs .; \
 		$(SHARP) *.cs -out:test.exe; \
 		mono test.exe)
@@ -393,7 +399,7 @@
 .PHONY: test_go
 test_go: libgv_go.la
 	-(mkdir -p test_go; cd test_go; \
-		ln -fs ../.libs/libgv_go.so libgv.so; \
+		ln -fs ../.libs/libgv_go.$(SO_DLL) libgv.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.go .; \
 		$(GO) *.go
 		LD_LIBRARY_PATH=. go test)
@@ -401,14 +407,14 @@
 .PHONY: test_guile
 test_guile: libgv_guile.la
 	-(mkdir -p test_guile; cd test_guile; \
-		ln -fs ../.libs/libgv_guile.so libgv.so; \
+		ln -fs ../.libs/libgv_guile.$(SO_DLL) libgv.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.guile .; \
 		$(GUILE) -s test.guile)
 
 .PHONY: test_java
 test_java: libgv_java.la
 	-(mkdir -p test_java/org/graphviz; cd test_java; \
-		ln -f ../.libs/libgv_java.so libgv.jnilib; \
+		ln -f ../.libs/libgv_java.$(SO_DLL) libgv.jnilib; \
 		ln -f ../$(srcdir)/*.java org/graphviz; \
 		ln -f ../$(srcdir)/test.java .; \
 		ln -f ../$(srcdir)/hello.gv .; \
@@ -419,7 +425,7 @@
 .PHONY: test_lua
 test_lua: libgv_lua.la
 	-(mkdir -p test_lua; cd test_lua; \
-		ln -fs ../.libs/libgv_lua.so gv.so;\
+		ln -fs ../.libs/libgv_lua.$(SO_DLL) gv.$(SO_DLL);\
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.lua .; \
 		$(LUA) test.lua)
 
@@ -426,42 +432,42 @@
 .PHONY: test_perl
 test_perl: libgv_perl.la
 	-(mkdir -p test_perl; cd test_perl; \
-		ln -fs ../.libs/libgv_perl.so gv.so; \
+		ln -fs ../.libs/libgv_perl.$(SO_DLL) gv.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.p[lm] .; \
 		$(PERL) ./test.pl)
 
 .PHONY: test_php
 test_php: libgv_php.la
 	-(mkdir -p test_php; cd test_php; \
-		ln -fs ../.libs/libgv_php.so libgv.so; \
+		ln -fs ../.libs/libgv_php.$(SO_DLL) libgv.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.php .; \
 		$(PHP) ./test.php)
 
 .PHONY: test_python3
 test_python3: libgv_python3.la
 	-(mkdir -p test_python3; cd test_python3; \
-		ln -fs ../.libs/libgv_python3.so _gv.so; \
+		ln -fs ../.libs/libgv_python3.$(SO_DLL) _gv.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.py .; \
 		PYTHONPATH=. $(PYTHON3) test.py)
 
 .PHONY: test_R
 test_R: libgv_R.la
 	-(mkdir -p test_R; cd test_R; \
-		ln -fs ../.libs/libgv_R.so gv.so; \
+		ln -fs ../.libs/libgv_R.$(SO_DLL) gv.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.R .; \
 		$(R) test.R)
 
 .PHONY: test_ruby
 test_ruby: libgv_ruby.la
 	-(mkdir -p test_ruby; cd test_ruby; \
-		ln -fs ../.libs/libgv_ruby.so gv.so; \
+		ln -fs ../.libs/libgv_ruby.$(SO_DLL) gv.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.rb .; \
 		$(RUBY) test.rb)
 
 .PHONY: test_tcl
 test_tcl: libgv_tcl.la
 	-(mkdir -p test_tcl; cd test_tcl; \
-		ln -fs ../.libs/libgv_tcl.so libgv_tcl.so; \
+		ln -fs ../.libs/libgv_tcl.$(SO_DLL) libgv_tcl.$(SO_DLL); \
 		ln -fs ../$(srcdir)/*.gv ../$(srcdir)/*.tcl .; \
 		$(TCLSH) ./test.tcl)
 
