[m-dev.] For review: More clpr updates
Warwick Harvey
wharvey at cs.monash.edu.au
Thu Feb 3 17:50:19 AEDT 2000
Part of this change includes by default installing a standalone version of
CLP(R) if the user installs the CLP(R) libraries. I find this useful, but
maybe it's not appropriate? Unfortunately, if one builds a shared-library
version of it, CLP(R)'s tagging scheme is messed up, so that doesn't appear
to be an option.
Estimated hours taken: 4
A bunch of updates to (extras/)clpr, mainly to make use of the "new" library
install support.
clpr/Mmakefile:
Updated to use the "new" library install support.
clpr/clpr/Mmakefile:
Updated to use the "new" library install support.
Added rules to install a standalone version of CLP(R), including
installing the `init.clpr' file and specifying an appropriate
LIBPATH so it can be found.
Updated some of the hand-coded library targets to match what Mercury
would generate for them if they were Mercury libraries.
clpr/clpr/clpr_script.in:
New script, to be installed in the appropriate `bin' directory as
`clpr', which calls the binary CLP(R) executable (installed in the
appropriate architecture-dependent `bin' directory).
cvs server: Diffing .
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/clpr/Mmakefile,v
retrieving revision 1.17
diff -u -r1.17 Mmakefile
--- Mmakefile 1999/07/20 03:39:21 1.17
+++ Mmakefile 2000/02/03 06:11:42
@@ -1,130 +1,80 @@
#---------------------------------------------------------------------------
--#
-MERCURY_DIR = ../..
+INSTALL_PREFIX := $(INSTALL_PREFIX)/extras
--include $(MERCURY_DIR)/Mmake.common
-
-SUBDIR_MMAKE = mmake $(MMAKEFLAGS) \
- GRADE=$(GRADE) \
- EXTRA_MCFLAGS="$(EXTRA_MCFLAGS)" \
- EXTRA_CFLAGS="$(EXTRA_CFLAGS)"
-
#---------------------------------------------------------------------------
--#
-MC = mmc
-
# In case the user of the library wants intermodule optimization...
-MCFLAGS = --intermodule-optimization
+MCFLAGS += --intermodule-optimization
+MCFLAGS += --trans-intermod-opt
# We need to use a grade with trailing
GRADEFLAGS += --use-trail
+# If we try to build the default set of grades and specify trailing is
+# required, we're likely to try to build libraries for many grades which
+# are not installed, resulting in link errors. As a result, we would like
+# to just try to build those grades which already have a trailing component.
+# Unfortunately, Make does not have a convenient way of selecting words in
+# which a particular pattern appears in the *middle* of the word (only one
+# wildcard available). The following delightful hack gets around this,
+# while preserving grade order and making sure we don't accidentally match
+# any other grade component which starts with `tr'.
+LIBGRADES-cfloat_lib = $(foreach grade,$(LIBGRADES), \
+ $(subst .tr.,$(grade),$(findstring .tr.,$(grade))) \
+ $(filter %.tr,$(grade)))
+
# Enable C debugging
-MGNUCFLAGS = -g
-MLFLAGS = -g
-RM_C = :
+#MGNUCFLAGS = -g
+#MLFLAGS = -g
+#RM_C = :
# The CLP(R) header clpr/lib.h is missing some prototypes,
# so we need to disable some warnings.
MGNUCFLAGS += -Wno-strict-prototypes
-# Link in the CLP(R) library
-MLFLAGS = -R`pwd`/clpr $(EXTRA_MLFLAGS) -Lclpr
-MLLIBS = -lclpr $(EXTRA_MLLIBS)
-
# We need to make sure that the CLP(R) library gets initialized
C2INITARGS = cfloat.c
# We need this to use shared libraries on Linux
ML = ml --mercury-libs shared
+# In case the user doesn't define it, to avoid a warning
+MMAKEFLAGS=
+
#---------------------------------------------------------------------------
--#
MAIN_TARGET = libcfloat_lib
+#---------------------------------------------------------------------------
--#
+
+.PHONY: depend
depend: cfloat_lib.depend depend_samples
+.PHONY: depend_samples
depend_samples:
- cd samples && $(SUBDIR_MMAKE) depend
+ cd samples && $(MMAKE) $(MMAKEFLAGS) depend
+
+.PHONY: install
+install: libcfloat_lib.install clpr_install
+.PHONY: clpr_install
+clpr_install:
+ cd clpr && $(MMAKE) $(MMAKEFLAGS) \
+ INSTALL_PREFIX=$(INSTALL_PREFIX) \
+ install
+
.PHONY: clpr
clpr:
- cd clpr && $(SUBDIR_MMAKE)
+ cd clpr && $(MMAKE) $(MMAKEFLAGS)
.PHONY: samples
samples: libcfloat_lib clpr
- cd samples && $(SUBDIR_MMAKE)
+ cd samples && $(MMAKE) $(MMAKEFLAGS)
.PHONY: check
check: libcfloat_lib clpr
- cd samples && $(SUBDIR_MMAKE) check
-
-.PHONY: ints
-ints: $(cfloat_lib.date3s) $(cfloat_lib.dates) $(cfloat_lib.optdates)
-
-# Because the clpr stuff gets installed in the standard ints directory,
-# which is included in VPATH, if there is an already installed copy,
-# then `mmake' will use that, even if it is out-of-date. We need
-# to add some extra dependencies to prevent this.
-# (Perhaps these rules should go in the standard Mmake.rules file?)
-
-$(MERCURY_INT_DIR)/%.int : %.date
- @:
-$(MERCURY_INT_DIR)/%.int2 : %.date
- @:
-$(MERCURY_INT_DIR)/%.int3 : %.date3
- @:
-$(MERCURY_INT_DIR)/%.opt : %.optdate
- @:
-$(MERCURY_INT_DIR)/%.trans_opt : %.trans_opt_date
- @:
-
-# We need to ensure that libclpr is built before we can build
-# shared library for libcfloat_lib.
-
-libcfloat_lib: clpr
-libcfloat_lib.so libcloat_lib.dll: clpr
-
-#---------------------------------------------------------------------------
--#
-
-.PHONY: install
-install: install_ints install_init install_lib install_clpr
-
-.PHONY: install_ints
-install_ints: ints
- [ -d $(INSTALL_INT_DIR) ] || mkdir -p $(INSTALL_INT_DIR)
- for file in $(cfloat_lib.ints) $(cfloat_lib.int3s) $(cfloat_lib.opts); \
- do \
- target=$(INSTALL_INT_DIR)/`basename $$file`; \
- if cmp -s $$file $$target; then \
- echo "$$target unchanged"; \
- else \
- echo "installing $$target"; \
- cp $$file $$target; \
- fi; \
- done
-
-.PHONY: install_init
-install_init: cfloat_lib.init
- [ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
- cp `vpath_find cfloat_lib.init` $(INSTALL_MODULE_DIR)
-
-.PHONY: install_lib
-install_lib: libcfloat_lib.a libcfloat_lib.$(EXT_FOR_SHARED_LIB)
- -[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
- cp libcfloat_lib.a libcfloat_lib.$(EXT_FOR_SHARED_LIB) \
- $(INSTALL_MERC_LIB_DIR)
-
-# cfloat_lib.split.a is a version of libcfloat_lib.a that has been compiled
-# with `--split-c-files'.
-.PHONY: install_split_library
-install_split_library: cfloat_lib.split.a
- [ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
- cp cfloat_lib.split.a $(INSTALL_MERC_LIB_DIR)/libcfloat_lib.a
-
-.PHONY: install_clpr
-install_clpr: clpr
- cd clpr && $(SUBDIR_MMAKE) install
+ cd samples && $(MMAKE) $(MMAKEFLAGS) check
#---------------------------------------------------------------------------
--#
@@ -133,21 +83,21 @@
.PHONY: clean_clpr
clean_clpr:
- cd clpr && $(SUBDIR_MMAKE) clean
+ cd clpr && $(MMAKE) $(MMAKEFLAGS) clean
.PHONY: clean_samples
clean_samples:
- cd samples && $(SUBDIR_MMAKE) clean
+ cd samples && $(MMAKE) $(MMAKEFLAGS) clean
.PHONY: realclean
realclean: realclean_clpr realclean_samples
.PHONY: realclean_clpr
realclean_clpr:
- cd clpr && $(SUBDIR_MMAKE) realclean
+ cd clpr && $(MMAKE) $(MMAKEFLAGS) realclean
.PHONY: realclean_samples
realclean_samples:
- cd samples && $(SUBDIR_MMAKE) realclean
+ cd samples && $(MMAKE) $(MMAKEFLAGS) realclean
#---------------------------------------------------------------------------
--#
cvs server: Diffing clpr
Index: clpr/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/clpr/clpr/Mmakefile,v
retrieving revision 1.10
diff -u -r1.10 Mmakefile
--- clpr/Mmakefile 1998/04/02 12:48:57 1.10
+++ clpr/Mmakefile 2000/02/03 06:11:42
@@ -1,17 +1,18 @@
#---------------------------------------------------------------------------
--#
-MERCURY_DIR = ../../..
+INSTALL_PREFIX := $(INSTALL_PREFIX)/extras
-LINK_SHARED_OBJ = gcc -shared
+MAKE = gmake
--include $(MERCURY_DIR)/Mmake.common
-
#---------------------------------------------------------------------------
--#
MAIN_TARGET = libclpr
+LIBPATH = \"$(INSTALL_LIBDIR)\"
+
MGNUCFLAGS=--no-ansi --no-check -- -g \
--Wall -W -Wno-uninitialized -Wno-unused -Wno-parentheses
+-Wall -W -Wno-uninitialized -Wno-unused -Wno-parentheses \
+-DLIBPATH=$(LIBPATH)
OBJECTS= arithgen.o codegen.o compile.o debug.o dump.o emit.o emul.o
index.o \
init.o lib.o main.o meta.o parse.o pio.o scan.o solver.btk.o solver.o \
@@ -28,23 +29,30 @@
.PHONY: libclpr
libclpr: libclpr.a libclpr.$(EXT_FOR_SHARED_LIB)
-libclpr.a : $(OBJECTS)
+libclpr.a : $(OBJECTS) $(MLOBJS)
rm -f libclpr.a
- ar cr libclpr.a $(OBJECTS)
- $(RANLIB) libclpr.a
+ $(AR) $(ALL_ARFLAGS) libclpr.a $(OBJECTS) $(MLOBJS)
+ $(RANLIB) $(ALL_RANLIBFLAGS) libclpr.a
-libclpr.so : $(PIC_OBJS)
- $(LINK_SHARED_OBJ) -o libclpr.so $(PIC_OBJS) $(SHARED_LIBS)
+libclpr.so : $(PIC_OBJS) $(MLPICOBJS)
+ $(ML) --make-shared-lib $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) \
+ -o libclpr.so $(PIC_OBJS) $(MLPICOBJS) $(ALL_MLLIBS)
+
+clpr: $(OBJECTS)
+ MAKEFLAGS="" $(MAKE) clpr
+
+# This should be made more general
+clpr_script: clpr_script.in
+ sed -e "s, at LIBDIR@,$(INSTALL_LIBDIR),g" \
+ -e "s, at FULLARCH@,$(FULLARCH),g" < $< > $@
+ chmod +x $@
-clpr:
- MAKEFLAGS="" make clpr
-
#---------------------------------------------------------------------------
--#
-INSTALL_MERC_CLPR_LIB_DIR = $(INSTALL_MERC_GC_LIB_DIR)
+INSTALL_MERC_CLPR_LIB_DIR = $(INSTALL_MERC_GRADELESS_LIB_DIR)
.PHONY: install
-install: install_headers install_lib
+install: install_headers install_lib install_init install_bin
.PHONY: install_headers
install_headers: *.h
@@ -59,6 +67,18 @@
cp libclpr.a libclpr.$(EXT_FOR_SHARED_LIB) \
$(INSTALL_MERC_CLPR_LIB_DIR)
+.PHONY: install_init
+install_init: init.clpr
+ -[ -d $(INSTALL_LIBDIR) ] || mkdir -p $(INSTALL_LIBDIR)
+ cp init.clpr $(INSTALL_LIBDIR)
+
+.PHONY: install_bin
+install_bin: clpr clpr_script
+ -[ -d $(INSTALL_MERC_BIN_DIR) ] || mkdir -p $(INSTALL_MERC_BIN_DIR)
+ cp clpr $(INSTALL_MERC_BIN_DIR)
+ -[ -d $(INSTALL_BINDIR) ] || mkdir -p $(INSTALL_BINDIR)
+ cp clpr_script $(INSTALL_BINDIR)/clpr
+
#---------------------------------------------------------------------------
--#
.PHONY: clean
@@ -67,6 +87,6 @@
.PHONY: realclean
realclean: clean
- rm -f clpr libclpr.a libclpr.so
+ rm -f clpr clpr_script libclpr.a libclpr.so
#---------------------------------------------------------------------------
--#
cvs server: Diffing samples
===================================================================
New file: clpr/clpr/clpr_script.in
#! /bin/sh
export CLPR_CLPRLIB=${CLPR_CLPRLIB="@LIBDIR@"}
CLPR=${CLPR="@LIBDIR@/bin/@FULLARCH@/clpr"}
case $# in
0) exec $CLPR
;;
*) exec $CLPR "$@"
;;
esac
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list