Commit Graph

9 Commits

Author SHA1 Message Date
Julien Fischer
0cd62edc7c Clean-ups and fixes for the C interface examples.
samples/c_interface/*:
    Replace left over references to the old c_header_code pragma.

    Replace some uses of '__' as a module qualifier.

    Replace tabs with spaces.

    Add some missing words.
2023-02-25 12:53:26 +11:00
Julien Fischer
51745bee09 Remove execute bit from a Makefile.
samples/c_interface/standalone_c/Makefile:
     As above.
2022-12-14 01:36:29 +11:00
Zoltan Somogyi
d33273d033 Tell vim not to expand tabs in Makefiles.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.

*/Makefile:
*/Mmakefile:
    As above.

tests/hard_coded/.gitignore:
    Don't ignore the purity subdir. This ignore must have been left over
    from when purity.m was a test in hard_coded, not hard_coded/purity,
    and it ignored an executable, not a directory.
2015-01-08 22:07:29 +11:00
Julien Fischer
669f9a08bd Fix documentation errors in stand-alone interface example.
samples/c_interface/standalone_c/Makefile:
samples/c_interface/standalone_c/c_main.c:
	As above.

samples/c_interface/README:
	s/C interface/foreign language interface/
2015-01-05 17:24:57 +11:00
Julien Fischer
a0833441e1 Add two new options to the compiler for querying what flags are passed to the
Branches: main

Add two new options to the compiler for querying what flags are passed to the
C compiler at a finer level of detail than that provided by --output-cflags.
The first new option, --output-grade-defines, prints the flags passed to the C
compiler to define the macros that specify the current compilation grade.
The second new option, --output-c-include-dir-flags, prints the flags passed
to C compiler that tell it where to search for C header files.

The rationale for the addition of the new options is that when compiling C++ or
Objective-C programs that call exported Mercury procedures via a standalone
interface we need both the flags for the grade defines and the include search
directories but other flags that we usually pass the C compiler may not be
appropriate for either a C++ or Objective-C compiler.

compiler/options.m:
	Recognise the new options.

compiler/mercury_compile.m:
	Handle the new options.

compiler/compile_target_code.m:
	Separate out the code that generates the grade macro define
	flags into a separate predicate.

	Do likewise with the code that generates the flags for specifying
	C compiler include search directories.

doc/use_guide.texi:
	Document the new options.

samples/c_interface/standalone_c/Makefile:
	Illustrate how to use the new options when compiling a program that
	uses a standalone interface.  Explain why it may not be appropriate
	to use the output of --output-cflags when compiling code that calls
	exported Mercury procedures.
2012-01-18 03:16:19 +00:00
Julien Fischer
a7fdf2d4ca Delete comments regarding the mgnuc and ml scripts.
Branches: main

samples/c_interface/standalone_c/Makefile:
	Delete comments regarding the mgnuc and ml scripts.
	The example was changed so that it doesn't rely on those
	some time ago.
2011-06-03 05:42:39 +00:00
Julien Fischer
190b69d4f1 Add a new command line option that causes the compiler to print out the
set of flags that it passes to the linker in order to link against a
selected set of Mercury libraries (the standard libraries plus any others
specified via the --ml option) in the current grade.
This removes the need for using the ml script with standalone interfaces.
(Which is useful on those systems that don't have a proper shell and can't
use that script!)

compiler/compiler_target_code.m:
	Add a predicate that prints out the above information.

	Refactor code in order to to avoid duplication between the new
	functionality and the existing code for invoking the linker.

compiler/mercury_compile.m:
compiler/options.m:
	Add the new option.

doc/user_guide.texi:
	Add an entry for the new option.

samples/c_interface/standalone_c/Makefile:
	Query the compiler directly about what flags to pass to the linker
	rather than using the ml script.

	Query the compiler about what flags to pass to the C compiler as
	well.  (This was implemented a while ago, but this example was
	never updated.)

	Extend this example to optionally work with shared libraries.
2009-01-20 06:24:05 +00:00
Julien Fischer
8ec6d0ff9c Make it easier to build the stand-alone interface example in different grades.
Estimated hours taken: 0.2
Branches: main

Make it easier to build the stand-alone interface example in different grades.

samples/c_interface/standalone_c/Makefile:
	Add a variable to set the option for setting the grade to build
	the example in.
2007-06-18 05:25:48 +00:00
Julien Fischer
008e7795f2 Add an example of how to use a stand-alone interface to the samples.
Estimated hours taken: 8
Branches: main

Add an example of how to use a stand-alone interface to the samples.

samples/c_interface/standalone_c/Makefile:
samples/c_interface/standalone_c/c_main.c:
samples/c_interface/standalone_c/c_main.exp:
samples/c_interface/standalone_c/mercury_lib.m:
	New files.  An annotated example of how to use a stand-alone interface.

samples/c_interface/README:
	Mention the new example.
2007-02-22 06:52:32 +00:00