NAME

Alien::TinyCC - retrieve useful information about the Alien installation of tcc

ALIEN SYNOPSIS

use Alien::TinyCC;


## libtcc location functions ##

say 'The libtcc headers can be found in ',
    Alien::TinyCC->libtcc_include_path;
say 'The libtcc library can be found in ',
    Alien::TinyCC->libtcc_library_path;


## tcc functions ##

say 'The tcc executable can be found in ',
    Alien::TinyCC->path_to_tcc;

# Create a C file
open my $out_fh, '>', 'test.c';
print $out_fh <<'EOF';
#include <stdio.h>

int main() {
    printf("Good to go");
    return 1;
}

EOF
close $out_fh;

# Alien::TinyCC ensures that the tcc executable is
# in your PATH environment variable, so this Just Works:
my $output = `tcc -run test.c`;

XS SYNOPSIS

If you want to build against libtcc, then in your Build.PL file you should have something like this:

 use Module::Build;
 use Alien::TinyCC;
 Module::Build->new(
     ...
	 configure_requires => {
         'Alien::TinyCC' => 0,
         ...
	 },
     build_requires => {
         'Alien::TinyCC' => 0,
         ...
     },
     requires => {
         'Alien::TinyCC' => 0,
         ...
     },
     needs_compiler => 1,
     dynamic_config => 1,
     include_dirs => [Alien::TinyCC->libtcc_include_path],
     extra_linker_flags => [Alien::TinyCC->MB_linker_flags],
 )->create_build_script

At the top of the Perl module that provides the Perl libtcc interface:

# My/C/Tiny/Interface.pm
use Alien::TinyCC;  # set LD_LIBRARY_PATH, PATH, etc

BEGIN {
    our $VERSION = '0.02';
    use XSLoader;
    XSLoader::load 'My::C::Tiny::Interface', $VERSION;
}

In your XS file that interfaces with libtcc:

/* Usual Perl XS suspects */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"

/* This is the important one */
#include "libtcc.h"

DESCRIPTION

This module ensures that you have a copy of the Tiny C Compiler accessible to your Perl code, ensures that tcc is in your path after saying use Alien::TinyCC, ensures that libtcc is in your LD_LIBRARY_PATH for Unixen and PATH for Windows, and provides some functions for identifying those paths and building against them.

This module is blissfully unaware of any other tcc installations on your system and it does not install tcc into a generically usable location. Rather, it installs it into a Perl-specific location. The basic idea is that this Perl module should not interfere with your non-Perl stuff.

The provided path functions include:

path_to_tcc

gives the full path to the directory containing the tcc executable

libtcc_include_path

gives the full path to the diretory containing libtcc.h

libtcc_library_path

gives the full path to the directory containing libtcc.dll or libtcc.a

If you want to link against libtcc, you will need to include Alien::TinyCC in your .pm file that loads your XS bindings, to ensure that the PATH or LD_LIBRARY_PATH is properly set. Then, in your Build.PL file, you can use

MB_linker_flags

gives the proper list of arguments to link against libtcc.

SEE ALSO

This module provides the Tiny C Compiler. To learn more about this great project, see http://bellard.org/tcc/ and http://savannah.nongnu.org/projects/tinycc.

To learn more about Alien Perl distributions in general, read the Alien manifesto.

This library was built specifically to be used by the C code system provided by C::TinyCompiler.

AUTHOR

David Mertens (dcmertens.perl@gmail.com)

BUGS

Please report any bugs or feature requests for the Alien bindings at the project's main github page: http://github.com/run4flat/Alien-TinyCC/issues.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Alien::TinyCC

You can also look for information at:

ACKNOWLEDGEMENTS

The tcc developers have made this a very easy project to wrap up. They even had the Windows install command nicely packaged up! How amazing!

LICENSE AND COPYRIGHT

Code copyright 2013 Dickinson College. Documentation copyright 2013 David Mertens.

Everything not contained in the src/ directory is free software, the distribution and/or modification of which is governed by the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

TINY C COMPILER LICENSE AND COPYRIGHT

This distribution distributes the source for the Tiny C Compiler project under the src/ directory, for which the following notice is in effect:

* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.