diff: more clpr changes

Fergus Henderson fjh at cs.mu.oz.au
Wed Sep 3 20:34:55 AEST 1997


More changes to clean up the packaging of the CLP(R) interface.

clpr/cfloat.m:
clpr/dump.m:
	Move cfloat__dump_tableaus from cfloat.m to dump.m
	and rename it as unsafe_dump_tableaus.

clpr/*.m:
clpr/*.exp:
	Move the example programs to a new `samples' subdirectory.

clpr/cfloat_lib.m:
	New file, for building the cfloat stuff as a library.

clpr/resolve_name_conflicts.perl:
	Use `$*' rather than hard-coding the list of files to process.

clpr/Mmake:
clpr/Mmakefile:
clpr/clpr/Mmake:
clpr/clpr/Mmakefile:
clpr/samples/Mmakefile:
	Rename Mmake as Mmakefile.
	Move some of the Mmake code into samples/Mmakefile.
	Add rules for building libraries (-lcfloat_lib and -lclpr).
	Add rules for `clean', `realclean', and `install'.

cvs diff: Diffing clpr
Index: Mmakefile
===================================================================
RCS file: Mmakefile
diff -N Mmakefile
--- /dev/null	Wed Sep  3 20:12:20 1997
+++ Mmakefile	Wed Sep  3 20:23:27 1997
@@ -0,0 +1,118 @@
+#-----------------------------------------------------------------------------#
+
+MERCURY_DIR = ../../..
+
+include $(MERCURY_DIR)/Mmake.common
+
+SUBDIR_MMAKE = mmake $(MMAKEFLAGS)
+
+#-----------------------------------------------------------------------------#
+
+MC = mmc
+
+# Call me paranoid...
+# (This may be necessary for code using the `unsafe_*' preds in dump.m.)
+MCFLAGS = --no-optimize-duplicate-calls	
+
+# We need to use a grade with trailing
+GRADE = asm_fast.gc.tr
+
+# Enable C debugging
+MGNUCFLAGS = -g
+MLFLAGS = -g
+RM_C = :
+
+# Link in the CLP(R) library
+MLLIBS = -Lclpr -lclpr $(EXTRA_MLLIBS)
+
+# We need to make sure that the CLP(R) library gets initialized
+C2INITFLAGS = cfloat.c
+%_init.c: cfloat.c
+
+#-----------------------------------------------------------------------------#
+
+MAIN_TARGET = libcfloat_lib
+
+depend: cfloat_lib.depend depend_samples
+
+depend_samples:
+	cd samples && $(SUBDIR_MMAKE) depend
+
+.PHONY: clpr
+clpr:
+	cd clpr && $(SUBDIR_MMAKE)
+
+.PHONY: samples
+samples: libcfloat_lib clpr
+	cd samples && $(SUBDIR_MMAKE)
+
+.PHONY: check
+check: libcfloat_lib clpr
+	cd samples && $(SUBDIR_MMAKE) check
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: install
+install: install_ints install_init install_lib install_clpr
+
+.PHONY: install_ints
+install_ints: $(cfloat_lib.ints) $(cfloat_lib.int3s) $(cfloat_lib.opts)
+	[ -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:
+	-[ -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:
+	cd clpr && $(SUBDIR_MMAKE) install
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: clean
+clean: clean_clpr clean_samples
+
+.PHONY: clean_clpr
+clean_clpr:
+	cd clpr && $(SUBDIR_MMAKE) clean
+
+.PHONY: clean_samples
+clean_samples:
+	cd samples && $(SUBDIR_MMAKE) clean
+
+.PHONY: realclean
+realclean: realclean_clpr realclean_samples
+
+.PHONY: realclean_clpr
+realclean_clpr:
+	cd clpr && $(SUBDIR_MMAKE) realclean
+
+.PHONY: realclean_samples
+realclean_samples:
+	cd samples && $(SUBDIR_MMAKE) realclean
+
+#-----------------------------------------------------------------------------#
Index: cfloat.m
===================================================================
RCS file: /home/staff/zs/imp/clpr/cfloat.m,v
retrieving revision 1.4
diff -u -u -r1.4 cfloat.m
--- 1.4	1997/09/03 06:30:50
+++ cfloat.m	1997/09/03 09:03:12
@@ -267,12 +267,6 @@
 :- mode cfloat__le_float(ca, in) is semidet.
 :- mode cfloat__le_float(co, in) is det.
 
-%-----------------------------------------------------------------------------%
-
-	% for debugging only... this pred (non-logically) dumps the CLP(R)
-	% tableaus to standard error at runtime.
-:- pred cfloat__dump_tableaus is det.
-
 %----------------------------------------------------------------------------%
 %----------------------------------------------------------------------------%
 
@@ -1080,6 +1074,3 @@
 		}
 		"
 		).
-
-:- pragma(c_header_code, "extern void print_tableaus(void);").
-:- pragma c_code(cfloat__dump_tableaus, "print_tableaus(); getchar();").
Index: cfloat_lib.m
===================================================================
RCS file: cfloat_lib.m
diff -N cfloat_lib.m
--- /dev/null	Wed Sep  3 20:12:20 1997
+++ cfloat_lib.m	Wed Sep  3 19:07:42 1997
@@ -0,0 +1,2 @@
+:- module cfloat_lib.
+:- import_module cfloat, cfloat_float, float_cfloat, dump.
Index: dump.m
===================================================================
RCS file: /home/staff/zs/imp/clpr/dump.m,v
retrieving revision 1.7
diff -u -u -r1.7 dump.m
--- 1.7	1997/09/02 19:29:59
+++ dump.m	1997/09/03 09:05:27
@@ -43,12 +43,16 @@
 	% XXX this one is a non-logical hack, use only for debugging
 :- pred unsafe_dump_cfloat(cfloat::ca) is det.
 
+	% for debugging only... this pred (non-logically) dumps the CLP(R)
+	% tableaus to standard error at runtime.
+:- pred unsafe_dump_tableaus is det.
+
 %-----------------------------------------------------------------------------%
 :- implementation.
 :- import_module int, require.
 
-:- pragma(c_header_code, "#include ""clpr/solver.h""").
-:- pragma(c_header_code, "#include ""clpr/clpr_misc.h""").
+:- pragma c_header_code("#include ""clpr/solver.h""").
+:- pragma c_header_code("#include ""clpr/clpr_misc.h""").
 
 :- pragma c_code(dump_cfloat(Svar::ca, IO0::di, IO::uo),
 "{
@@ -130,11 +134,12 @@
 	dump__mercury_cfloat_list_to_clpr_list(Vs, Tail),
 	dump__make_clpr_cfloat_list(V, Tail, Result).
 
-:- pragma(c_header_code, "#include <stdio.h>").
-:- pragma(c_header_code, "#include ""clpr/emul.h""").
-:- pragma(c_header_code, "#include ""clpr/compile.h""").
+:- pragma c_header_code("#include <stdio.h>").
+:- pragma c_header_code("#include ""clpr/emul.h""").
+:- pragma c_header_code("#include ""clpr/compile.h""").
+
 :- pred dump__get_clpr_empty_list(c_pointer::out) is det.
-:- pragma(c_code, dump__get_clpr_empty_list(Empty::out),
+:- pragma c_code(dump__get_clpr_empty_list(Empty::out),
 		"
 		Empty = addtag(CLPR_TAG_NIL, 0);
 		"
@@ -236,9 +241,11 @@
 
 	% Free our dynamically allocated memory.
 :- pred dump__free(c_pointer::in, c_pointer::in) is det.
-:- pragma(c_code, dump__free(Vars::in, TheString::in) ,
+:- pragma(c_code, dump__free(Vars::in, TheString::in),
 		"
 		free_clpr_list_mem(Vars);
 		free((char *) TheString);
 		").
 
+:- pragma c_header_code("extern void print_tableaus(void);").
+:- pragma c_code(unsafe_dump_tableaus, "print_tableaus();").
cvs diff: Diffing clpr/samples
Index: Mmakefile
===================================================================
RCS file: Mmakefile
diff -N Mmakefile
--- /dev/null	Wed Sep  3 20:12:20 1997
+++ Mmakefile	Wed Sep  3 19:54:53 1997
@@ -0,0 +1,55 @@
+#-----------------------------------------------------------------------------#
+
+MAIN_TARGET = all
+
+# Call me paranoid...
+# (This may be necessary for code using the `unsafe_*' preds in dump.m.)
+MCFLAGS = --no-optimize-duplicate-calls	
+
+# We need to use a grade with trailing
+GRADE = asm_fast.gc.tr
+
+# Enable C debugging
+MGNUCFLAGS = -g
+MLFLAGS = -g
+RM_C = :
+
+# Link in the CLP(R) library and the cfloat_lib library
+MCFLAGS += -I..
+MLFLAGS += -R`pwd`/.. -R`pwd`/../clpr -L.. -L../clpr $(EXTRA_MLFLAGS)
+MLLIBS = -lcfloat_lib -lclpr $(EXTRA_MLLIBS)
+VPATH = ..:$(MMAKE_VPATH)
+C2INITFLAGS = ../cfloat_lib.init ../cfloat.c
+%_init.c: $(C2INITFLAGS)
+
+#-----------------------------------------------------------------------------#
+
+PROGS	=	fib laplace mortgage sum_list tranny
+
+DEPENDS =	$(PROGS:%=%.depend)
+CS	=	$(PROGS:%=%.c)
+RESS	=	$(PROGS:%=%.res)
+
+#-----------------------------------------------------------------------------#
+
+%.out: %
+	./$< > $@
+
+%.res: %.out %.exp
+	diff -c $*.out $*.exp > $@
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: depend
+depend: $(DEPENDS)
+
+.PHONY: all
+all: $(PROGS)
+
+.PHONY: check
+check: $(RESS)
+
+.PHONY: cs
+cs: $(CS)
+
+#-----------------------------------------------------------------------------#
cvs diff: Diffing clpr/clpr
Index: Mmake
===================================================================
RCS file: Mmake
diff -N Mmake
--- /var/tmp/aaaa002Ci	Wed Sep  3 20:29:38 1997
+++ /dev/null	Wed Sep  3 20:12:20 1997
@@ -1,8 +0,0 @@
-GRADE= asm_fast.gc.tr
-MGNUCFLAGS=--no-ansi --no-check -- -g
-
-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 \
-	solver.eq.o solver.ineq.o solver.nlin.o table.o trace.o clpr_misc.o
-
-MAIN_TARGET= $(OBJECTS)
Index: Mmakefile
===================================================================
RCS file: Mmakefile
diff -N Mmakefile
--- /dev/null	Wed Sep  3 20:12:20 1997
+++ Mmakefile	Wed Sep  3 20:24:53 1997
@@ -0,0 +1,56 @@
+#-----------------------------------------------------------------------------#
+
+MERCURY_DIR = ../../..
+
+include $(MERCURY_DIR)/Mmake.common
+
+#-----------------------------------------------------------------------------#
+
+MAIN_TARGET = libclpr
+
+MGNUCFLAGS=--no-ansi --no-check -- -g
+
+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 \
+	solver.eq.o solver.ineq.o solver.nlin.o table.o trace.o clpr_misc.o
+
+PIC_OBJS = $(OBJECTS:.o=.$(EXT_FOR_PIC_OBJECTS))
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: libclpr
+libclpr: libclpr.a libclpr.$(EXT_FOR_SHARED_LIB)
+
+libclpr.a : $(OBJECTS)
+	rm -f libclpr.a
+	ar cr libclpr.a $(OBJECTS)
+	$(RANLIB) libclpr.a
+
+libclpr.so : $(PIC_OBJS)
+	$(LINK_SHARED_OBJ) -o libclpr.so $(PIC_OBJS)
+
+clpr:
+	make clpr
+
+#-----------------------------------------------------------------------------#
+
+INSTALL_MERC_CLPR_LIB_DIR = $(INSTALL_MERC_GC_LIB_DIR)
+
+.PHONY: install
+install:
+	-[ -d $(INSTALL_MERC_CLPR_LIB_DIR) ] || \
+		mkdir -p $(INSTALL_MERC_CLPR_LIB_DIR)
+	cp libclpr.a libclpr.$(EXT_FOR_SHARED_LIB) \
+		$(INSTALL_MERC_CLPR_LIB_DIR)
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: clean
+clean:
+	rm -f $(OBJECTS) $(PIC_OBJECTS)
+
+.PHONY: realclean
+realclean: clean
+	rm -f clpr libclpr.a libclpr.so
+
+#-----------------------------------------------------------------------------#
Index: resolve_name_conflicts.perl
===================================================================
RCS file: /home/staff/zs/imp/clpr/clpr/resolve_name_conflicts.perl,v
retrieving revision 1.1
diff -u -u -r1.1 resolve_name_conflicts.perl
--- 1.1	1997/08/24 10:18:08
+++ resolve_name_conflicts.perl	1997/08/27 17:05:17
@@ -4,7 +4,7 @@
 new_file=/tmp/temp.$$
 
 new_file=foobar
-for filename in arithgen.c *.c *.h
+for filename in $*
 do
 	perl -e 'while (<>) {
 			s/\btag\b/CLPR_tag/g;

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list