[m-rev.] diff: make installation fo extras/references more reliable

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Nov 16 18:11:55 AEDT 2011


Branches: main, 11.07

Make compilation of extras/references more reliable.

extras/references/Makefile:
extras/references/Mmakefile:
extras/references/Mercury.options:
 	Use mmc --make to build and install this library (as we do with
 	some of the other extras packages) instead of mmake.  This allows
 	us to sue the grade filtering mechanism in mmc --make to ensure
 	that we only install the library in grades that support trailing.

 	Fix a number of problems that prevent this library installing cleanly:

 	+ don't require the presence of asm_fast grades; build the library in
 	the default grade with the trail segment component added.

 	+ use trail segment grades instead of fixed sized trail grades (the latter
 	are not installed anymore unless specifically requested by the user).

 	+ install the C header file that is part of this library.

 	+ delete ancient workarounds for supporting shared libraries on Linux.

extras/references/tests/Mmakefile:
extras/references/samples/Mmakefile:
 	Conform to the above changes.

 	Don't assume that the extension for static libraries is .a; it's
 	not on some systems.

extras/references/global.m:
 	Add a feature set pragma specifying that trailing is required.

extras/references/nb_reference.m:
 	s/__/./

extras/lex/lex.m:
 	Unrelated change: avoid using an obsolete function.

Julien.

Index: extras/lex/lex.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/lex/lex.m,v
retrieving revision 1.9
diff -u -r1.9 lex.m
--- extras/lex/lex.m	10 Jan 2011 04:32:25 -0000	1.9
+++ extras/lex/lex.m	16 Nov 2011 06:39:56 -0000
@@ -697,7 +697,7 @@
              R = null
            else
              L = string.length(S),
-            C = string.index_det(S, L - 1),
+            C = string.det_index(S, L - 1),
              R = str_foldr(func(Cx, Rx) = (Cx ++ Rx), S, re(C), L - 2)
          )
  ].
@@ -719,7 +719,7 @@
          R = null
        else
          L = string.length(S),
-        C = string.index_det(S, L - 1),
+        C = string.det_index(S, L - 1),
          R = str_foldr(func(Cx, Rx) = (Cx or Rx), S, re(C), L - 2)
      ).

@@ -739,7 +739,7 @@

  str_foldr(Fn, S, X, I) =
      ( if I < 0 then X
-               else str_foldr(Fn, S, Fn(string.index_det(S, I), X), I - 1)
+               else str_foldr(Fn, S, Fn(string.det_index(S, I), X), I - 1)
      ).

  ?(R) = (R or null).
Index: extras/references/Makefile
===================================================================
RCS file: extras/references/Makefile
diff -N extras/references/Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ extras/references/Makefile	16 Nov 2011 06:58:26 -0000
@@ -0,0 +1,22 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 2011 The University of Melbourne.
+# This file may only be copied under the terms of the GNU Library General
+# Public License - see the file COPYING.LIB in the Mercury distribution.
+#-----------------------------------------------------------------------------#
+
+# Build the global library using mmc --make.
+
+TARGET=global
+
+.PHONY: build
+build: 
+	mmc --make lib$(TARGET)
+
+.PHONY: install
+install:
+	mmc --make lib$(TARGET).install
+
+.PHONY: realclean
+realclean:
+	mmc --make $(TARGET).realclean
+	/bin/rm -rf Mercury
Index: extras/references/Mercury.options
===================================================================
RCS file: extras/references/Mercury.options
diff -N extras/references/Mercury.options
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ extras/references/Mercury.options	16 Nov 2011 06:24:22 -0000
@@ -0,0 +1,12 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 2011 The University of Melbourne.
+# This file may only be copied under the terms of the GNU Library General
+# Public License - see the file COPYING.LIB in the Mercury distribution.
+#-----------------------------------------------------------------------------#
+
+MCFLAGS = --use-trail --trail-segments        \
+	  --use-grade-subdirs		      \
+          --libgrades-include-component trseg \
+	  --extra-library-header c_reference.h
+
+MCFLAGS-global = --no-warn-nothing-exported --no-warn-interface-imports
Index: extras/references/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/references/Mmakefile,v
retrieving revision 1.7
diff -u -r1.7 Mmakefile
--- extras/references/Mmakefile	21 Apr 2006 04:56:52 -0000	1.7
+++ extras/references/Mmakefile	16 Nov 2011 06:00:24 -0000
@@ -1,58 +1,29 @@
  #-----------------------------------------------------------------------------#
-# Copyright (C) 1997-2000, 2003-2004, 2006 The University of Melbourne.
+# Copyright (C) 2011 The University of Melbourne.
  # This file may only be copied under the terms of the GNU Library General
  # Public License - see the file COPYING.LIB in the Mercury distribution.
  #-----------------------------------------------------------------------------#

--include ../Mmake.params
-
-GRADEFLAGS += --use-trail
-
-# Install in an "extras" subdirectory of the main installation tree
-INSTALL_PREFIX := $(INSTALL_PREFIX)/extras
-LIBGRADES = asm_fast.gc.tr asm_fast.gc.tr.debug
-
-MAIN_TARGET = libglobal
-
-# In case the user of the library wants to do intermodule optimisation
-MCFLAGS += --intermodule-optimisation
-MCFLAGS += --transitive-intermodule-optimisation
-
-MCFLAGS-global+=--no-warn-nothing-exported --no-warn-interface-imports
+# This is file exists so that do an `mmake' from the top-level of the extras
+# distribution works.  The actual work of building this library is done
+# using the Makefile and mmc --make.  This file just fowards all the work
+# to there.
+
+MAIN_TARGET=build
+
+.PHONY: build
+build:
+	$(MAKE) build INSTALL_PREFIX=$(INSTALL_PREFIX)/extras

+# The depend target does nothing, mmc --make will handle that for us.
+#
  .PHONY: depend
-depend: global.depend
-	cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" depend
-	cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" depend
-
-.PHONY: check
-check: libglobal
-	cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check
+depend:

  .PHONY: install
-install: libglobal.install
-
-.PHONY: install_check
-install_check:
-	cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" \
-		EXTRA_LIB_DIRS="$(INSTALL_PREFIX)/lib/mercury" check
-
-.PHONY: clean
-clean: clean_subdirs
-
-.PHONY: clean_subdirs
-clean_subdirs:
-	cd samples && mmake $(MMAKEFLAGS) clean
-	cd tests && mmake $(MMAKEFLAGS) clean
+install:
+	$(MAKE) install INSTALL_PREFIX=$(INSTALL_PREFIX)/extras

  .PHONY: realclean
-realclean: realclean_subdirs
-
-.PHONY: realclean_subdirs
-realclean_subdirs:
-	cd samples && mmake $(MMAKEFLAGS) realclean
-	cd tests && mmake $(MMAKEFLAGS) realclean
-
-# We need this to use shared libraries on Linux
-ML = ml --mercury-libs shared
-
+realclean:
+	$(MAKE) realclean
Index: extras/references/global.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/references/global.m,v
retrieving revision 1.2
diff -u -r1.2 global.m
--- extras/references/global.m	21 Apr 2006 04:56:52 -0000	1.2
+++ extras/references/global.m	14 Nov 2011 04:51:39 -0000
@@ -3,3 +3,5 @@
  :- import_module nb_reference.
  :- import_module reference.
  :- import_module scoped_update.
+:- implementation.
+:- pragma require_feature_set([trailing]).
Index: extras/references/nb_reference.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/references/nb_reference.m,v
retrieving revision 1.8
diff -u -r1.8 nb_reference.m
--- extras/references/nb_reference.m	28 Jul 2006 05:23:17 -0000	1.8
+++ extras/references/nb_reference.m	16 Nov 2011 06:01:40 -0000
@@ -129,12 +129,12 @@
  % from_c_pointer(CPointer) = Ref
  %	Convert a c_pointer to a nb_reference.

-:- func nb_reference__from_c_pointer(c_pointer) = nb_reference(T).
+:- func nb_reference.from_c_pointer(c_pointer) = nb_reference(T).

  % to_c_pointer(Ref) = CPointer
  %	Convert a nb_reference to a c_pointer.

-:- func nb_reference__to_c_pointer(nb_reference(T)) = c_pointer.
+:- func nb_reference.to_c_pointer(nb_reference(T)) = c_pointer.

  :- implementation.

@@ -142,11 +142,11 @@
  init(Ref, X) :-
  	impure update(Ref, X).

-:- pragma inline(nb_reference__from_c_pointer/1).
-nb_reference__from_c_pointer(CPointer) = nb_reference(Ref) :-
+:- pragma inline(nb_reference.from_c_pointer/1).
+nb_reference.from_c_pointer(CPointer) = nb_reference(Ref) :-
  	private_builtin.unsafe_type_cast(CPointer, Ref).

-:- pragma inline(nb_reference__to_c_pointer/1).
-nb_reference__to_c_pointer(nb_reference(Ref)) = CPointer :-
+:- pragma inline(nb_reference.to_c_pointer/1).
+nb_reference.to_c_pointer(nb_reference(Ref)) = CPointer :-
  	private_builtin.unsafe_type_cast(Ref, CPointer).

Index: extras/references/samples/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/references/samples/Mmakefile,v
retrieving revision 1.4
diff -u -r1.4 Mmakefile
--- extras/references/samples/Mmakefile	21 Oct 1999 14:36:39 -0000	1.4
+++ extras/references/samples/Mmakefile	16 Nov 2011 06:12:37 -0000
@@ -6,19 +6,17 @@

  MAIN_TARGET = all

-# We need to use a grade with trailing
-GRADEFLAGS += --use-trail
+# We need to use a grade with trailing.
+# The following causes the compiler to attempt to use the default grade
+# with trail segments enabled.  It won't work unless the trseg variant
+# of the default grade is also installed.
+#
+GRADEFLAGS += --use-trail --trail-segments

  EXTRA_LIB_DIRS = $(INSTALL_PREFIX)/extras/lib/mercury

  EXTRA_LIBRARIES = global

-# We need the following to use shared libraries on Linux
-#MGNUCFLAGS += -DPIC_REG
-#MLFLAGS += --shared
-
-#MLFLAGS += --static
-
  #-----------------------------------------------------------------------------#

  PROGS	=	max_test
Index: extras/references/tests/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/references/tests/Mmakefile,v
retrieving revision 1.6
diff -u -r1.6 Mmakefile
--- extras/references/tests/Mmakefile	21 Dec 2004 06:37:22 -0000	1.6
+++ extras/references/tests/Mmakefile	16 Nov 2011 06:28:27 -0000
@@ -7,22 +7,10 @@
  MAIN_TARGET = all

  # We need to use a grade with trailing
-GRADEFLAGS += --use-trail
+GRADEFLAGS += --use-trail --trail-segments

-CFLAGS= -I..
-
-# Link in the reference library from ..
-MCFLAGS += -I.. $(EXTRA_MCFLAGS)
-MLFLAGS += -R`pwd`/.. -L.. $(EXTRA_MLFLAGS)
-MLLIBS = -lglobal $(EXTRA_MLLIBS)
-VPATH = ..:$(MMAKE_VPATH)
-C2INITARGS = ../global.init
-
-# We need the following to use shared libraries on Linux
-#CFLAGS += -DPIC_REG
-#MLFLAGS += --shared
-
-#MLFLAGS += --static
+EXTRA_LIB_DIRS = $(INSTALL_PREFIX)/extras/lib/mercury
+EXTRA_LIBRARIES = global

  #-----------------------------------------------------------------------------#

@@ -34,7 +22,7 @@

  #-----------------------------------------------------------------------------#

-$(PROGS): ../libglobal.a
+$(PROGS): ../global.init

  %.out: %
  	./$< > $@ 2>&1;

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list