This fixes the problems with _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE appearing in /usr/include/parted/*.h:
>From ace74051ebdadd2d6d428948af1982543149ae79 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Mon, 9 Jan 2012 19:11:23 +0100 Subject: [PATCH 1/2] parted.h: use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE in VC'd files However, we will replace those strings with their expansions when installing them. * include/parted/parted.h: Revert part of commit v3.0-83-gd51bfc0. --- include/parted/parted.h | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/include/parted/parted.h b/include/parted/parted.h index dff6dca..fbcb9aa 100644 --- a/include/parted/parted.h +++ b/include/parted/parted.h @@ -43,10 +43,7 @@ extern "C" { #include <stdlib.h> #include <string.h> -extern const char *ped_get_version () -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) - __attribute ((__const__)); -#endif +extern const char *ped_get_version () _GL_ATTRIBUTE_CONST; extern void* ped_malloc (size_t size); extern void* ped_calloc (size_t size); -- 1.7.9.rc0.2.g4b783 >From e977fafd31d61a6fca60e20b86f536048fdaa68e Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Mon, 9 Jan 2012 19:42:49 +0100 Subject: [PATCH 2/2] maint: rename public .h files to .in.h Generate .h files from .in.h files, so that we can continue to use _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST in the primary sources, without including them in publicly-installed files. Each generated (and later installed) header file gets expansions of those macros. * include/parted/Makefile.am: New rules. * .gitignore: Ignore the generated files. * Makefile.am (SUBDIRS): Reorder so we build in include/ before libparted, i.e., so that we generate the .h files we'll need. --- .gitignore | 15 +++++++++ Makefile.am | 2 +- include/parted/Makefile.am | 37 ++++++++++++++++++++- include/parted/{constraint.h => constraint.in.h} | 0 include/parted/{crc32.h => crc32.in.h} | 0 include/parted/{debug.h => debug.in.h} | 0 include/parted/{device.h => device.in.h} | 0 include/parted/{disk.h => disk.in.h} | 0 include/parted/{endian.h => endian.in.h} | 0 include/parted/{exception.h => exception.in.h} | 0 include/parted/{fdasd.h => fdasd.in.h} | 0 include/parted/{filesys.h => filesys.in.h} | 0 include/parted/{geom.h => geom.in.h} | 0 include/parted/{natmath.h => natmath.in.h} | 0 include/parted/{parted.h => parted.in.h} | 0 include/parted/{timer.h => timer.in.h} | 0 include/parted/{unit.h => unit.in.h} | 0 include/parted/{vtoc.h => vtoc.in.h} | 0 18 files changed, 51 insertions(+), 3 deletions(-) rename include/parted/{constraint.h => constraint.in.h} (100%) rename include/parted/{crc32.h => crc32.in.h} (100%) rename include/parted/{debug.h => debug.in.h} (100%) rename include/parted/{device.h => device.in.h} (100%) rename include/parted/{disk.h => disk.in.h} (100%) rename include/parted/{endian.h => endian.in.h} (100%) rename include/parted/{exception.h => exception.in.h} (100%) rename include/parted/{fdasd.h => fdasd.in.h} (100%) rename include/parted/{filesys.h => filesys.in.h} (100%) rename include/parted/{geom.h => geom.in.h} (100%) rename include/parted/{natmath.h => natmath.in.h} (100%) rename include/parted/{parted.h => parted.in.h} (100%) rename include/parted/{timer.h => timer.in.h} (100%) rename include/parted/{unit.h => unit.in.h} (100%) rename include/parted/{vtoc.h => vtoc.in.h} (100%) diff --git a/.gitignore b/.gitignore index da8d7af..690bbbf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,21 @@ .tarball-version .version /ABOUT-NLS +/include/parted/constraint.h +/include/parted/crc32.h +/include/parted/debug.h +/include/parted/device.h +/include/parted/disk.h +/include/parted/endian.h +/include/parted/exception.h +/include/parted/fdasd.h +/include/parted/filesys.h +/include/parted/geom.h +/include/parted/natmath.h +/include/parted/parted.h +/include/parted/timer.h +/include/parted/unit.h +/include/parted/vtoc.h ABOUT-NLS ChangeLog GNUmakefile diff --git a/Makefile.am b/Makefile.am index ae252bd..5e52a42 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = po lib libparted parted partprobe include doc debug tests +SUBDIRS = po lib include libparted parted partprobe doc debug tests EXTRA_DIST = \ .version \ diff --git a/include/parted/Makefile.am b/include/parted/Makefile.am index 022373f..a5d2687 100644 --- a/include/parted/Makefile.am +++ b/include/parted/Makefile.am @@ -4,8 +4,7 @@ else S390_HDRS = endif -partedincludedir = $(includedir)/parted - +partedincludedir = $(includedir)/parted partedinclude_HEADERS = constraint.h \ debug.h \ device.h \ @@ -22,4 +21,38 @@ noinst_HEADERS = crc32.h \ endian.h \ $(S390_HDRS) +BUILT_SOURCES = \ + $(partedinclude_HEADERS) \ + $(noinst_HEADERS) \ + fdasd.h \ + vtoc.h + +EXTRA_DIST = $(BUILT_SOURCES:%.h=%.in.h) + +# We use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE internally, +# but cannot use those in a published header, so replace each of those +# strings with its expansion. +# Technically, attribute const was introduced in gcc-2.95 and +# attribute pure in 2.96, but to keep it simple, we're testing +# for 2.96 or newer for both. + +hash_if = \n\#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)\n +subst_const_attr = \ + s/ _GL_ATTRIBUTE_CONST\b/$(hash_if) __attribute ((__const__))\n\#endif\n/ +subst_pure_attr = \ + s/ _GL_ATTRIBUTE_PURE\b/$(hash_if) __attribute ((__pure__))\n\#endif\n/ + +$(BUILT_SOURCES): Makefile.am + +SUFFIXES = .in.h .h +.in.h.h: + $(AM_V_GEN)rm -f $@ $@-t + $(AM_V_at)perl -p \ + -e '$(subst_const_attr);' \ + -e '$(subst_pure_attr);' \ + $< > $@-t + $(AM_V_at)chmod a=r $@-t + $(AM_V_at)mv $@-t $@ + MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES += $(BUILT_SOURCES) diff --git a/include/parted/constraint.h b/include/parted/constraint.in.h similarity index 100% rename from include/parted/constraint.h rename to include/parted/constraint.in.h diff --git a/include/parted/crc32.h b/include/parted/crc32.in.h similarity index 100% rename from include/parted/crc32.h rename to include/parted/crc32.in.h diff --git a/include/parted/debug.h b/include/parted/debug.in.h similarity index 100% rename from include/parted/debug.h rename to include/parted/debug.in.h diff --git a/include/parted/device.h b/include/parted/device.in.h similarity index 100% rename from include/parted/device.h rename to include/parted/device.in.h diff --git a/include/parted/disk.h b/include/parted/disk.in.h similarity index 100% rename from include/parted/disk.h rename to include/parted/disk.in.h diff --git a/include/parted/endian.h b/include/parted/endian.in.h similarity index 100% rename from include/parted/endian.h rename to include/parted/endian.in.h diff --git a/include/parted/exception.h b/include/parted/exception.in.h similarity index 100% rename from include/parted/exception.h rename to include/parted/exception.in.h diff --git a/include/parted/fdasd.h b/include/parted/fdasd.in.h similarity index 100% rename from include/parted/fdasd.h rename to include/parted/fdasd.in.h diff --git a/include/parted/filesys.h b/include/parted/filesys.in.h similarity index 100% rename from include/parted/filesys.h rename to include/parted/filesys.in.h diff --git a/include/parted/geom.h b/include/parted/geom.in.h similarity index 100% rename from include/parted/geom.h rename to include/parted/geom.in.h diff --git a/include/parted/natmath.h b/include/parted/natmath.in.h similarity index 100% rename from include/parted/natmath.h rename to include/parted/natmath.in.h diff --git a/include/parted/parted.h b/include/parted/parted.in.h similarity index 100% rename from include/parted/parted.h rename to include/parted/parted.in.h diff --git a/include/parted/timer.h b/include/parted/timer.in.h similarity index 100% rename from include/parted/timer.h rename to include/parted/timer.in.h diff --git a/include/parted/unit.h b/include/parted/unit.in.h similarity index 100% rename from include/parted/unit.h rename to include/parted/unit.in.h diff --git a/include/parted/vtoc.h b/include/parted/vtoc.in.h similarity index 100% rename from include/parted/vtoc.h rename to include/parted/vtoc.in.h -- 1.7.9.rc0.2.g4b783
