%CODEGEN Generate C/C++ code from MATLAB code
%
%   CODEGEN generates C/C++ code from a MATLAB function and all the
%   functions that this function calls.  From the C/C++ code, CODEGEN can
%   build a MEX-function, C/C++ static library, C/C++ shared library, or a
%   C/C++ executable.
%
%   You must specify the type of inputs the generated code should accept.
%   The generated C/C++ code will be specialized to the class, size, and
%   complexity of the inputs.  Using this information, CODEGEN is able to
%   generate efficient, standalone C/C++ code.
%
%   Alternatively, the CODER command provides access to the same
%   functionality via a graphical user interface.
%
%   The general syntax of the CODEGEN command is
%     codegen [-options] [files]
%
%   FILES:
%
%   Specify the name of the main (entry point) MATLAB file you want to
%   compile on the command line.  (Please refer to the documentation for
%   information on generating code from multiple entry points.)
%
%   In addition to your main MATLAB file, you can include additional files
%   to build.  The following extensions are supported:
%
%     .c    custom C file
%     .cpp  custom C++ file
%     .cu   custom CUDA file (GPU Coder)
%     .h    custom header file (included by all generated files)
%     .hpp
%     .cuh  custom CUDA header file (GPU Coder)
%     .o    object file
%     .obj
%     .a    library
%     .so
%     .lib
%     .tmf  custom TMF file*
%
%   *NOTE: TMF files can be used to customize Makefile generation.  Please
%   refer to the documentation for more information.
%
%   COMMON OPTIONS:
%
%   -args ARGS  Specify the types that the generated code should
%               accept.  ARGS is a cell array specifying the type of
%               each function argument.  (Elements are converted to
%               types using coder.typeof.)
%
%   -nargout NARGOUT Specify the nonnegative number of output arguments
%               for the given function. If using VARARGOUT, this is required.
%
%   -config:mex  Generate a MEX function (default)
%   -config:lib  Generate a C/C++ static library
%   -config:dll  Generate a C/C++ dynamic library
%   -config:exe  Generate a C/C++ executable
%   -config:hdl  Generate VHDL/Verilog code
%
%   -config CONFIG  Specify a custom configuration object (use coder.config
%               to create one).
%
%   -double2single CONFIG Specify a doubles to singles configuration object
%               to convert double-precision MATLAB code to single-precision
%               MATLAB code (use coder.config to create one).
%
%   -float2fixed CONFIG Specify a fixpt configuration object(use
%               coder.config to create one).
%
%   -lang:c     Specify the language to use in the generated code as C.
%   -lang:c++   Specify the language to use in the generated code as C++.
%
%   -o OUTPUT   Specify the name of the output.  CODEGEN adds a
%               platform-specific extension to this name depending
%               on the output type.
%
%   -profile    Generate code with profiling information enabled for MEX targets.
%
%   -report     Generate a code generation report.
%
%   OPTIONS:
%
%   -c          Generate C/C++ code only.  (Do not call the C/C++ compiler.)
%
%   -d DIR      Specify the output directory.  All generated files will
%               be placed in DIR.  By default, files are placed in
%               ./codegen/<output type>/<function>.  For example, when
%               compiling the function FUN to a MEX-function, the
%               generated code will be placed in ./codegen/mex/FUN.
%
%   -g          Enable debugging when invoking the C/C++ compiler. By
%               default, the C/C++ compiler is configured for faster
%               execution (for MEX outputs) or faster builds (for LIB, DLL
%               and EXE outputs). When this option is specified, the C/C++
%               compiler is configured to disable most optimizations and to
%               enable debugging of the generated C/C++ code.
%
%   -globals GLOBALS  Specify types and initial values for global variables
%               used in the MATLAB files.  For more information, refer
%               to the documentation.
%
%   -I PATH     Add files to the include path.  PATH is used to find
%               custom C/C++ files, and MATLAB functions (but not classes).
%               CODEGEN searches PATH before the MATLABPATH when looking
%               for MATLAB functions.
%
%   -jit        Use just-in-time (JIT) compilation for generation of a MEX
%               function. JIT compilation can speed up MEX function
%               generation. This option applies only to MEX function generation.
%               This option is not compatible with certain code generation
%               features or options, such as custom code or using the OpenMP
%               library.
%
%   -package FILENAME Run packNGo on generated code to package all files
%               into <FILENAME>.zip with a flat hierarchy
%
%   -rowmajor   Generates code that uses row-major array layout in all
%               functions. If this option is not specified, the generated code 
%               uses column-major array layout. To override the used array 
%               layout for a particular function and its called functions, 
%               specify coder.rowMajor or coder.columnMajor in the body of 
%               the function.
%
%   -reportinfo VAR_NAME  Exports information used in the code generation 
%               report to a variable in the base workspace, identified by 
%               VAR_NAME.                 
%
%   -launchreport  Generate and launch code generation report.
%
%   -O OPTION   Control CODEGEN optimizations.
%     Supported values for OPTION are:
%       enable:inline  - Enable function inlining (default)
%       disable:inline - Disable function inlining
%       enable:openmp  - Use OpenMP library if available (default)
%       disable:openmp - Disable OpenMP library
%
%   -profile    Generate a MEX function with profiling enabled. This MEX file 
%               can participate in profiling using MATLAB Profiler. Using this
%               option, the Profile Summary Report can show execution counts
%               and timing information for the generated code contained in the
%               MEX function. This option applies only to MEX function generation.
%
%   -singleC    Use single-precision for floating-point literals and operations
%               when generating mex or C lib/dll/exe.
%
%   -std:c89/90 Use the C89/90 (ANSI) standard math library for the generated code.
%   -std:c99    Use the C99 (ISO) standard math library for the generated code.
%   -std:c++03  Use the C++03 (ISO) standard math library for the generated code.
%               You can use this library only if you generate C++ code.
%   -std:c++11  Use the C++11 (ISO) standard math library for the generated code.
%               You can use this library only if you generate C++ code.
%
%   -v          Show verbose output during code generation.
%
%   -silent     Only show warning/error output during code generation.
%
%   -toproject PROJECT Generates a project file PROJECT that incorporates
%               all the arguments and settings passed to codegen without
%               generating code.
%
%   -test TEST  Specify a test file to run after code generation.
%               Applies only to MEX outputs.
%
%   -preservearraydims  Generate code that preserves array dimensions by using 
%                       N-dimensional indexing.
%
%   Examples:
%     % Generate C code from a MATLAB function fun.m where the first
%     % argument is a single scalar and the second argument is a double
%     % scalar.  By default, the generated C code will be built into a
%     % MEX-function.
%     codegen fun -args { single(0), double(0) }
%
%     % Generate C code from a MATLAB function fun.m same as above, but
%     % specifying the number of outputs.
%     codegen fun -args { single(0), double(0) } -nargout 2
%
%     % Generate C code from a MATLAB function fun.m where the first
%     % argument 'u' is a double of variable size with maximum size 2x2,
%     % and the second argument 'k' has the constant value 42. The
%     % '-config:lib' option  instructs  codegen to build the generated
%     % C code into a static library.
%     u = coder.typeof(0,[2 2],1);
%     k = coder.Constant(42);
%     codegen fun -config:lib -args {u,k}
%
%     % Create a MEX-function xbar from a MATLAB function bar.m which
%     % takes no inputs.
%     codegen -o xbar bar
%
%     % Create a MEX-function from a MATLAB function bar.m same as above,
%     % with profiling information enabled. xbar MEX-function will 
%     % participate in MATLAB profiling.
%     codegen -profile -o xbar bar
%
%   See also coder, coderTypeEditor, coder.config, coder.getArgTypes,
%   coder.screener, coder.runTest, coder.typeof, coder.Constant.

 
% Copyright 2010-2019 The MathWorks, Inc.

