[m-rev.] diff: simplify simpler_X_calls_mercury samples
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Dec 21 17:38:18 AEDT 2001
Estimated hours taken: 0.25
Branches: main
Simplify the simpler_c_calls_mercury and
simpler_cplusplus_calls_mercury samples to
avoid explicit construction of the `ml' command line.
samples/c_interface/simpler_c_calls_mercury/c_main.c:
Renamed as main.c.
samples/c_interface/simpler_cplusplus_calls_mercury/cpp_main.cc:
Renamed as main.cc.
samples/c_interface/simpler_c_calls_mercury/c_main.m:
samples/c_interface/simpler_cplusplus_calls_mercury/cpp_main.m:
Empty main modules, used to set the name executable
produced by mmake.
samples/c_interface/simpler_cplusplus_calls_mercury/Mmakefile:
samples/c_interface/simpler_c_calls_mercury/Mmakefile:
Handle file renamings.
Remove explicit rules to build executables.
Remove unnecessary header file dependencies.
Index: simpler_c_calls_mercury/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/samples/c_interface/simpler_c_calls_mercury/Mmakefile,v
retrieving revision 1.7
diff -u -u -r1.7 Mmakefile
--- simpler_c_calls_mercury/Mmakefile 19 Dec 2001 15:08:28 -0000 1.7
+++ simpler_c_calls_mercury/Mmakefile 21 Dec 2001 06:34:30 -0000
@@ -4,38 +4,29 @@
MAIN_TARGET=all
-depend: mercury_lib.depend
+depend: c_main.depend
all: c_main
-OBJECTS = c_main.o mercury_lib_init.o
-LIBS = libmercury_lib
-LIBSLINK = libmercury_lib.a
-
-c_main: $(OBJECTS) $(LIBS)
- $(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -o c_main $(OBJECTS) $(LIBSLINK)
-
#-----------------------------------------------------------------------------#
-# pass `-g' to the C compiler and linker, so we can use a debugger (e.g. gdb)
+# Pass `-g' to the C compiler and linker, so we can use a debugger (e.g. gdb).
MGNUCFLAGS=-g
-# tell Mercury that this the Mercury stuff we're building is a library,
-# not a main program
-MLFLAGS=--no-main
+# Tell the Mercury linker that the Mercury stuff we're building
+# should not define the C function main().
+MLFLAGS=--no-main -g
-#-----------------------------------------------------------------------------#
+# Tell the Mercury linker to link with main.o.
+MLOBJS=main.o
-c_main.o: mercury_lib.h c_main.c
+MCFLAGS-c_main=--no-warn-nothing-exported
-# to make mercury_lib.h, just compile mercury_lib.m;
-# the Mercury compiler will create mercury_lib.h as a side-effect.
-mercury_lib.h: mercury_lib.o
+#-----------------------------------------------------------------------------#
-# make sure that `mmake clean' removes c_main.o
-clean_local:
- rm -f c_main.o mercury_lib.h
+main.o: mercury_lib.h
-realclean_local:
- rm -f c_main
+# make sure that `mmake clean' removes main.o
+clean_local:
+ rm -f main.o mercury_lib.h
#-----------------------------------------------------------------------------#
Index: simpler_c_calls_mercury/c_main.m
===================================================================
RCS file: simpler_c_calls_mercury/c_main.m
diff -N simpler_c_calls_mercury/c_main.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ simpler_c_calls_mercury/c_main.m 21 Dec 2001 06:32:56 -0000
@@ -0,0 +1,9 @@
+%-----------------------------------------------------------------------------%
+% This source file is hereby placed in the public domain. -stayl (the author).
+%
+% This empty module is used to give the executable produced
+% by mmake the correct name.
+%-----------------------------------------------------------------------------%
+:- module c_main.
+
+:- import_module mercury_lib.
Index: simpler_cplusplus_calls_mercury/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/samples/c_interface/simpler_cplusplus_calls_mercury/Mmakefile,v
retrieving revision 1.6
diff -u -u -r1.6 Mmakefile
--- simpler_cplusplus_calls_mercury/Mmakefile 19 Dec 2001 15:08:28 -0000 1.6
+++ simpler_cplusplus_calls_mercury/Mmakefile 21 Dec 2001 06:29:01 -0000
@@ -4,7 +4,7 @@
MAIN_TARGET=all
-depend: mercury_lib.depend
+depend: cpp_main.depend
all: cpp_main
#-----------------------------------------------------------------------------#
@@ -26,34 +26,25 @@
-DMR_MACHDEPS_PA_REGS_H \
-DMR_MACHDEPS_RS6000_REGS_H
-# pass `-g' to the C compiler and linker, so we can use a debugger (e.g. gdb)
+# Pass `-g' to the C compiler and linker, so we can use a debugger (e.g. gdb).
CXXFLAGS=-g
MGNUCFLAGS=-g
-MLFLAGS=-g
-# tell Mercury that this the Mercury stuff we're building is a library,
-# not a main program
-MLFLAGS=--no-main
+# Tell the Mercury linker that the Mercury stuff we're building should
+# not define the C function main().
+MLFLAGS=--no-main -g
-OBJECTS = cpp_main.o mercury_lib_init.o $(mercury_lib.os)
+# Tell the Mercury linker to link with main.o.
+MLOBJS=main.o
-#-----------------------------------------------------------------------------#
-
-cpp_main: $(OBJECTS)
- $(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -o cpp_main $(OBJECTS) \
- $(ALL_MLLIBS)
+MCFLAGS-cpp_main=--no-warn-nothing-exported
-cpp_main.o: mercury_lib.h
+#-----------------------------------------------------------------------------#
-# to make mercury_lib.h, just compile mercury_lib.m;
-# the Mercury compiler will create mercury_lib.h as a side-effect.
-mercury_lib.h: mercury_lib.o
+main.o: mercury_lib.h
-# make sure that `mmake clean' removes c_main.o
+# make sure that `mmake clean' removes main.o
clean_local:
- rm -f cpp_main.o mercury_lib.h
-
-realclean_local:
- rm -f cpp_main
+ rm -f main.o mercury_lib.h
#-----------------------------------------------------------------------------#
Index: simpler_cplusplus_calls_mercury/cpp_main.m
===================================================================
RCS file: simpler_cplusplus_calls_mercury/cpp_main.m
diff -N simpler_cplusplus_calls_mercury/cpp_main.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ simpler_cplusplus_calls_mercury/cpp_main.m 21 Dec 2001 06:33:09 -0000
@@ -0,0 +1,9 @@
+%-----------------------------------------------------------------------------%
+% This source file is hereby placed in the public domain. -stayl (the author).
+%
+% This empty module is used to give the executable produced
+% by mmake the correct name.
+%-----------------------------------------------------------------------------%
+:- module cpp_main.
+
+:- import_module mercury_lib.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list