From 2c5c2c7362a6bd913fed16f8e250eae01d2ac241 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Thu, 21 Dec 2023 18:53:54 +0100
Subject: [PATCH 5/5] Reallu disable gprof

---
 gcl/configure.in | 3 ++-
 gcl/o/main.c     | 4 ++++
 gcl/o/makefile   | 4 ++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcl/configure.in b/gcl/configure.in
index 15a637f90..3a2a9ac10 100644
--- a/gcl/configure.in
+++ b/gcl/configure.in
@@ -383,7 +383,7 @@ fi
 AC_SUBST(GCL_CC)
 
 
-GPROF="gprof_objs"
+GPROF="gprof"
 AC_ARG_ENABLE([gprof],[  --enable-gprof builds gcl with -pg in CFLAGS to enable profiling with gprof],
 	      [if test "$enableval" != "yes" ; then GPROF=""; fi])
 
@@ -408,6 +408,7 @@ if test "$GPROF" != "" ; then
        OLD_CFLAGS=$CFLAGS  # Do not run configure tests with -pg
        assert_arg_to_cflags -pg
        CFLAGS=$OLD_CFLAGS
+       AC_DEFINE(USE_GPROF,1,[use gprof])
    fi
 fi
 AC_SUBST(GPROF)
diff --git a/gcl/o/main.c b/gcl/o/main.c
index ae93a228f..ba945bee0 100644
--- a/gcl/o/main.c
+++ b/gcl/o/main.c
@@ -370,7 +370,9 @@ minimize_image(void) {
   nrbpage=0;
   resize_hole(0,t_relocatable,0);
 
+#ifdef USE_GPROF
   gprof_cleanup();
+#endif
   
 #if defined(BSD) || defined(ATT)  
   mbrk(core_end=heap_end);
@@ -470,7 +472,9 @@ gcl_cleanup(int gc) {
   {extern void _cleanup(void);_cleanup();}
 #endif
 
+#ifdef USE_GPROF
   gprof_cleanup();
+#endif
 
   if (gc) {
 
diff --git a/gcl/o/makefile b/gcl/o/makefile
index 349d84d7a..5b1c7d56b 100644
--- a/gcl/o/makefile
+++ b/gcl/o/makefile
@@ -22,7 +22,7 @@ OBJS:=$(addsuffix .o,typespec alloc gbc bitop boot main eval macros lex bds fram
 	 hash array string regexpr structure toplevel file read backq print format\
 	 pathname unixfsys unixfasl error unixtime unixsys unixsave funlink  fat_string\
 	 run_process nfunlink usig usig2 utils makefun sockets gmp_wrappers clxsocket\
-	 init_pari nsocket new_init prelink sfasl gprof $(RL_OBJS))
+	 init_pari nsocket new_init prelink sfasl $(RL_OBJS))
 OBJS:=$(OBJS) $(EXTRAS)
 
 INI_FILES=$(patsubst %.o,%.ini,${OBJS})
@@ -30,7 +30,7 @@ INI_FILES:=$(filter-out new_init.ini,$(filter-out boot.ini,$(INI_FILES)))
 
 OBJECTS:=$(OBJS) $(LIBFILES) new_init.o  $(GCLIB) $(LAST_FILE)  $(FIRST_FILE) 
 
-all:  $(OBJECTS) #$(GPROF)
+all:  $(OBJECTS) $(GPROF)
 
 gprof_objs: $(addprefix ../gprof/,$(OBJECTS))
 
-- 
2.43.0

