[m-dev.] diff: runtime clean-ups

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 9 21:20:50 AEDT 1998


On 09-Nov-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Fix the code in the runtime so that `mmake check_headers' succeeds.

Oops, I forgot to include my changes to runtime/Mmakefile in that diff.

--------------------

runtime/Mmakefile:
	Update the reflect the added and removed files.
	Also update the rule for `mmake check_headers' so that
	it can make use of parallelism in parallel makes.
	And make a start towards enforcing namespace cleanliness --
	I've added some code to check it, in part, but as yet the
	check is not enforced.

Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.41
diff -u -r1.41 Mmakefile
--- Mmakefile	1998/11/05 03:53:28	1.41
+++ Mmakefile	1998/11/09 10:11:49
@@ -64,10 +64,6 @@
 			mercury_stack_layout.h	\
 			mercury_stack_trace.h	\
 			mercury_string.h	\
-			mercury_table_any.h	\
-			mercury_table_enum.h	\
-			mercury_table_builtins.h \
-			mercury_table_type_info.h \
 			mercury_tabling.h	\
 			mercury_tags.h		\
 			mercury_thread.h	\
@@ -120,10 +116,7 @@
 			mercury_regs.c		\
 			mercury_signal.c	\
 			mercury_stack_trace.c	\
-			mercury_table_any.c	\
-			mercury_table_enum.c	\
-			mercury_table_builtins.c \
-			mercury_table_type_info.c \
+			mercury_tabling.c	\
 			mercury_thread.c	\
 			mercury_timing.c	\
 			mercury_trace_base.c	\
@@ -147,6 +140,11 @@
 		  esac							\
 		`
 
+HDR_CHECK_CS = $(HDRS:.h=_check.c)
+HDR_CHECK_OBJS = $(HDRS:.h=_check.o)
+HDR_CHECK_NMS = $(HDRS:.h=_check.nms)
+HDR_CHECK_MACROS = $(HDRS:.h=_check.macros)
+
 #-----------------------------------------------------------------------------#
 
 # Stuff for Windows DLLs
@@ -208,14 +206,54 @@
 tags: $(CFILES) $(HDRS)
 	ctags $(CFILES) $(HDRS)
 
+#-----------------------------------------------------------------------------#
+#
+# `mmake check_headers' performs various checks on the header files
+# to make sure that the conform with our coding standards.
+#
+
+#
+# $(HDR_CHECK_OBJS) is used to check that the header files are self-contained.
+# The rule for foo_check.o checks that the header file foo.h is properly
+# self-contained, i.e. that the header file foo.h includes any other
+# header files that define types used by foo.h.
+# It does this by compiling a foo_check.c file that contains only a single
+# `#include' statement that includes foo.h.
+#
+
+%_check.c : %.h
+	echo "#include \"$*.h\"" > $*_check.c
+
+# The mercury_deep_copy_body.h header is not meant to be self-contained.
+# So the following rule is used to suppress that check for this header.
+mercury_deep_copy_body_check.o:
+	@true
+	
+#
+# $(HDR_CHECK_MACROS) is used to check that the headers are properly
+# namespace-clean, with regard to the macros that they define.
+# For each header file foo.h, the rule below produces a file
+# foo_check.macros that contains a list of all the macros defined
+# by the header file (or by headers that it includes, excluding
+# standard headers) that do not start with `GC_', `MR_', or `MERCURY_'.
+#
+# XXX the `cmp' command below, which forces `mmake check_headers' to fail
+# if the foo_check.macros file is non-empty, i.e. if the header is not
+# macro-namespace-clean, is commented out because currently the headers
+# are not namespace-clean.
+# 
+
+AWK = awk
+%_check.macros: %.h %_check.c
+	-$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -E $*_check.c \
+		-nostdinc -dN \
+		2> /dev/null | $(AWK) '/^#define/ { print $$2; }' | \
+		grep -v -e '^MR_' -e '^GC_' -e '^MERCURY_' | \
+		sort | uniq > $@
+	#cmp $@ /dev/null	# XXX disabled for now
+
 .PHONY: check_headers
-check_headers:
-	for file in $(HDRS); do \
-		echo "$$file"; \
-		echo "#include \"$$file\"" > tmp.c; \
-		$(MGNUC) $(MGNUCFLAGS) -c tmp.c || exit 1; \
-	done
-	rm -f tmp.c
+check_headers: $(HDR_CHECK_OBJS) $(HDR_CHECK_MACROS)
 
 #-----------------------------------------------------------------------------#
 
@@ -255,11 +293,15 @@
 
 #-----------------------------------------------------------------------------#
 
-clean: clean_o
+clean: clean_o clean_check
 
 .PHONY: clean_o
 clean_o:
-	rm -f $(OBJS) $(PIC_OBJS) 
+	rm -f $(OBJS) $(PIC_OBJS)
+
+.PHONY: clean_check
+clean_check:
+	rm -f $(HDR_CHECK_OBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS)
 
 realclean:
 	rm -f lib$(RT_LIB_NAME).a lib$(RT_LIB_NAME).so $(RT_LIB_NAME).init

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the developers mailing list