--- Makefile.in.orig	2008-03-09 05:31:40.000000000 +1100
+++ Makefile.in	2021-02-06 11:24:44.000000000 +1100
@@ -112,7 +112,7 @@
 	@$(LIBTOOL) --mode=compile $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $<
 
 $(LIB_NAME): $(LIB_OBJS)
-	@$(LIBTOOL) --mode=link $(CC) -o $(LIB_NAME) $(LIB_OBJS) -rpath $(libdir) \
+	@$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $(LIB_NAME) $(LIB_OBJS) -rpath $(libdir) \
 	    -version-info `$(SHTOOL) version -l c -d libtool $(S)/uuid_vers.h`
 
 $(DCE_NAME): $(DCE_OBJS)
@@ -127,7 +127,10 @@
 	@$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $(PRG_NAME) $(PRG_OBJS) $(LIB_NAME) $(LIBS)
 
 $(PERL_NAME): $(PERL_OBJS) $(LIB_NAME)
-	@cd $(S)/perl && $(PERL) Makefile.PL PREFIX=$(prefix) COMPAT=$(WITH_PERL_COMPAT) && $(MAKE) $(MFLAGS) all
+	@cd $(S)/perl && $(PERL) Makefile.PL PREFIX=$(prefix) CC="$(CC)" LD="$(CC)" COMPAT=$(WITH_PERL_COMPAT)
+	@cd $(S)/perl && env LC_CTYPE=C sed -e "/^CCFLAGS *=/s|$$| $(CFLAGS)|" -e "/^OTHERLDFLAGS *=/s|$$| $(LDFLAGS)|" Makefile > Makefile.tmp
+	@cd $(S)/perl && mv Makefile.tmp Makefile
+	@cd $(S)/perl && $(MAKE) $(MFLAGS) all
 	@touch $(PERL_NAME)
 
 $(PHP_NAME): $(PHP_OBJS) $(LIB_NAME)
