diff --git a/config/perl.m4 b/config/perl.m4
index bed2eae..d2ac2ef 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -49,6 +49,16 @@ AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
 [m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])])
 
 
+# PGAC_CHECK_PERL_EMBED_CCFLAGS
+# -----------------------------
+AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
+[AC_REQUIRE([PGAC_PATH_PERL])
+AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
+perl_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {if ($f =~ /^-D/) {print $f, " "}}'`
+AC_SUBST(perl_ccflags)dnl
+AC_MSG_RESULT([$perl_ccflags])])
+
+
 # PGAC_CHECK_PERL_EMBED_LDFLAGS
 # -----------------------------
 # We are after Embed's ldopts, but without the subset mentioned in
diff --git a/configure b/configure
index aff72eb..1e6bf86 100755
--- a/configure
+++ b/configure
@@ -667,6 +667,7 @@ python_includespec
 python_version
 python_majorversion
 PYTHON
+perl_ccflags
 perl_embed_ldflags
 perl_useshrplib
 perl_privlibexp
@@ -7767,6 +7768,19 @@ documentation for details.  Use --without-perl to disable building
 PL/Perl." "$LINENO" 5
   fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ccflags for embedded Perl" >&5
+$as_echo_n "checking for ccflags for embedded Perl... " >&6; }
+
+perl_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {if ($f =~ /^-D/) {print $f, " "}}'`
+
+if test -z "$perl_ccflags" ; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $perl_ccflags" >&5
+$as_echo "$perl_ccflags" >&6; }
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flags to link embedded Perl" >&5
 $as_echo_n "checking for flags to link embedded Perl... " >&6; }
 if test "$PORTNAME" = "win32" ; then
diff --git a/configure.in b/configure.in
index 72e5b17..13c69d6 100644
--- a/configure.in
+++ b/configure.in
@@ -938,6 +938,7 @@ You might have to rebuild your Perl installation.  Refer to the
 documentation for details.  Use --without-perl to disable building
 PL/Perl.])
   fi
+  PGAC_CHECK_PERL_EMBED_CCFLAGS
   PGAC_CHECK_PERL_EMBED_LDFLAGS
 fi
 
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index dc8a89a..ff1c185 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -304,6 +304,7 @@ else
 endif
 perl_archlibexp		= @perl_archlibexp@
 perl_privlibexp		= @perl_privlibexp@
+perl_ccflags		= @perl_ccflags@
 perl_embed_ldflags	= @perl_embed_ldflags@
 
 # Miscellaneous
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index b8e3585..dce0513 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -12,7 +12,7 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
 override CPPFLAGS += -Wno-comment
 endif
 
-override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) -I$(perl_archlibexp)/CORE
+override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) -I$(perl_archlibexp)/CORE $(perl_ccflags)
 
 rpathdir = $(perl_archlibexp)/CORE
 
