Add header wrapper for glib to supply g_memdup2() for glib before 2.68.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jul 2022 15:37:02 +0000 (08:37 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jul 2022 15:37:12 +0000 (08:37 -0700)
Friedrich Beckmann reported that some of our build targets have glib as
old as 2.58.

configure.ac
src/ui/gui/automake.mk
src/ui/gui/include/glib.in.h [new file with mode: 0644]

index b8e8b7ddce58d89d4cef4480ac643a45daefeae5..20338a04b73f8606d18af8a7f5714e2a95b6d88f 100644 (file)
@@ -154,6 +154,7 @@ if test "$with_gui" != "no"; then
 
 fi
 
+gl_NEXT_HEADERS([glib.h])
 gl_NEXT_HEADERS([gtk/gtk.h])
 
 dnl Checks needed for psql reader
index 42500c049fbdd10a842ecfd6eb6dcd0823ae24ff..04da062f21e2c189568982f186e1b2f8ba83c975 100644 (file)
@@ -428,6 +428,22 @@ src/ui/gui/include/gtk/gtk.h: src/ui/gui/include/gtk/gtk.in.h
 CLEANFILES += src/ui/gui/include/gtk/gtk.h
 EXTRA_DIST += src/ui/gui/include/gtk/gtk.in.h src/ui/gui/resources.xml
 
+# <gtk/gtk.h> wrapper
+BUILT_SOURCES += src/ui/gui/include/glib.h
+src/ui/gui/include/glib.h: src/ui/gui/include/glib.in.h
+       @$(MKDIR_P) src/ui/gui/include
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         $(SED) -e 's|%''INCLUDE_NEXT''%|$(INCLUDE_NEXT)|g' \
+             -e 's|%''PRAGMA_SYSTEM_HEADER''%|$(PRAGMA_SYSTEM_HEADER)|g' \
+             -e 's|%''PRAGMA_COLUMNS''%|$(PRAGMA_COLUMNS)|g' \
+             -e 's|%''NEXT_GLIB_H''%|$(NEXT_GLIB_H)|g' \
+             < $(srcdir)/src/ui/gui/include/glib.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+CLEANFILES += src/ui/gui/include/glib.h
+EXTRA_DIST += src/ui/gui/include/glib.in.h
+
 include $(top_srcdir)/src/ui/gui/icons/automake.mk
 
 src/ui/gui/pspp.res: src/ui/gui/pspp.rc $(w32_icons)
diff --git a/src/ui/gui/include/glib.in.h b/src/ui/gui/include/glib.in.h
new file mode 100644 (file)
index 0000000..51178ac
--- /dev/null
@@ -0,0 +1,32 @@
+/* Wrapper for <glib.h>.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef PSPP_GLIB_H
+#define PSPP_GLIB_H
+
+#if __GNUC__ >= 3
+%PRAGMA_SYSTEM_HEADER%
+#endif
+%PRAGMA_COLUMNS%
+
+#%INCLUDE_NEXT% %NEXT_GLIB_H%
+
+
+#if !GLIB_CHECK_VERSION(2,68,0)
+#define g_memdup2 g_memdup
+#endif
+
+#endif /* PSPP_GLIB_H */