+2019-12-30 Olivier Hainque <hainque@adacore.com>
+ Jerome Lambourg <labourg@adacore.com>
+
+ * config/t-vxworks: Arrange to alter/restore glimits.h
+ before/after stmp-int-hdrs, so it uses a different macro
+ name to protect itself against recursive inclusions.
+
2019-12-30 Peter Bergner <bergner@linux.ibm.com>
PR target/92923
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-# Both the kernel and RTP headers provide limits.h.
-LIMITS_H_TEST = true
-
vxworks.o: $(srcdir)/config/vxworks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TARGET_H) output.h $(TM_H)
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+
+# Both the kernel and RTP headers provide limits.h. They embed VxWorks
+# specificities and are dated on some configurations so we both need to
+# provide our own version and make sure the system one gets exposed.
+
+LIMITS_H_TEST = true
+STMP_FIXINC = stmp-fixinc
+
+# VxWorks system environments have been GCC based for a long time and we need
+# to make sure that our files and the system ones use distinct macro names to
+# protect against recursive inclusions. We achieve this by temporarily
+# substituting the headers used by stmp-int-headers with alternative versions
+# where we add some version indication in the inclusion-protection macro
+# names.
+
+# Before the standard stmp-int-headers operations take place, arrange to
+# copy the current version of the relevant header files locally, generate
+# the alternate version and replace the original version with ours:
+
+stmp-int-hdrs: subst-glimits.h
+
+subst-%.h:
+ cp -p $(srcdir)/$*.h orig-$*.h
+ ID=$$(echo $(BASEVER_c) | sed -e 's/\./_/g'); \
+ sed -e "s/_LIMITS_H__/_LIMITS_H_$${ID}_/" < $(srcdir)/$*.h > $@
+ cp $@ $(srcdir)/$*.h
+
+# Then arrange to restore the original versions after the standard
+# operations have taken place:
+
+INSTALL_HEADERS += restore-glimits.h
+
+restore-glimits.h: stmp-int-hdrs
+ cp -p orig-glimits.h $(srcdir)/glimits.h