diff --git a/Makefile.am b/Makefile.am
index 5293612..201e3bd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,7 +25,7 @@
ACLOCAL_AMFLAGS = -I m4
-MODULECOMMONFLAGS = -no-undefined -export-symbols-regex ".*" -module -avoid-version
+MODULECOMMONFLAGS = -no-undefined -export-symbols-regex ".*" -shared -module -avoid-version
# Options to pass when running configure in the distcheck target.
#
diff --git a/Makefile.in b/Makefile.in
index d61088a..4208286 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2543,7 +2543,7 @@
-I$(srcdir)/ltdl -I$(srcdir)/ltdl/libltdl \
-I$(top_srcdir)/Magick++/lib
ACLOCAL_AMFLAGS = -I m4
-MODULECOMMONFLAGS = -no-undefined -export-symbols-regex ".*" -module -avoid-version
+MODULECOMMONFLAGS = -no-undefined -export-symbols-regex ".*" -shared -module -avoid-version
# Options to pass when running configure in the distcheck target.
#
diff --git a/magick/utility.c b/magick/utility.c
index 196f94f..3e242bf 100644
--- a/magick/utility.c
+++ b/magick/utility.c
@@ -702,7 +702,6 @@
Expand any wildcard filenames.
*/
*home_directory='\0';
- cwd=getcwd(home_directory,MaxTextExtent);
count=0;
for (i=0; i < (long) *number_arguments; i++)
{
@@ -758,6 +757,8 @@
GetPathComponent(option,HeadPath,path);
GetPathComponent(option,SubimagePath,subimage);
ExpandFilename(path);
+ if (*home_directory == '\0')
+ cwd=getcwd(home_directory,MaxTextExtent-1);
filelist=ListFiles(*path == '\0' ? home_directory : path,filename,
&number_files);
}