[ di - disk information utility ]    [ mkconfig - build configuration utility ]
[ mkconfig manual ]    [ mkconfig_c manual ]    [ mkconfig_env manual ]
Name
       mkconfig_d - mkconfig D language units

Description
       The D language units create an import file for use by D programs.

D Language Units
       d-main
	      The d-main unit creates a configuration file for D programs.

       Check  variables  are  output as type enum where possible.  Other vari‐
       ables are also output as enums where possible.

       e.g. D2
       enum bool _d_tango_lib = false;
       enum int _csiz_long_double = 16;
       enum int D_VERSION = 2;
       enum string SYSTYPE = "Linux";
       e.g. D1
       enum : bool { _d_tango_lib = true };
       enum : int { _csiz_long_double = 16 };
       enum : int { D_VERSION = 1 };
       string SYSTYPE = "Linux";

       module module-name
	      Sets the module name to be output to the output file.

       noprefix
	      Turns off prefix (C_TYP_, C_ST_, C_ENUM_, C_UN_, C_MACRO_)  gen‐
	      eration in the converted C code.

       standard
	      Executes	any  Standard  checks  for  the D language.  Currently
	      there are checks for: (a) import of std.string for D version  2;
	      (b)  see	if  the  'string' type is valid; and (c) to see if the
	      tango library is in use.	If 'string' is not valid, an alias  is
	      added  to  the configuration file.  The tango library check cre‐
	      ates a check variable named '_d_tango_lib'.

       import name-e
	      Checks to see if module can be imported.

	      e.g.
	      import std.stdio
	      Check Variable: _import_std_stdio

       lib function [libs, ...]
	      Check to see if the library function function  exists.   If  the
	      optional libs are specified, the test will try first without the
	      libraries, then with the first set of libraries specified linked
	      in,  then the next set, etc.  Sets of libraries to be tested are
	      separated by commas.  If link libraries are specified, any value
	      in the cache is ignored, and the function is retested.

       class class [libs, ...]
	      Check  to  see  if the class class exists.  If the optional libs
	      are specified, the test will try first  without  the  libraries,
	      then  with  the  first set of libraries specified, then the next
	      set, etc.  Sets of libraries to be tested are separated by  com‐
	      mas.

       member struct-name member
	      Check to see if member is a member of struct-name.

       size type-name
	      Check the size of type-name

       type type-name
	      Check  to  see  if type-name exists.  This is used internally to
	      see if 'string' is valid.

       D Language Units - C Language Interface

       All C language types are converted to the corresponding D language type
       when  output  (operating  system, architecture and compiler dependent).
       Any variables with two leading underscores will be converted to '_t_'.

       chdr header
	      Checks to see if the C Language header  exists.	The  chdr  and
	      csys  directives must appear before other C language directives.
	      The appropriate headers must be checked so that structure, type‐
	      def, defines and declarations may be extracted.

	      e.g.
	      chdr stdlib.h
	      Check Variable: _hdr_stdlib

       csys header
	      Checks to see if the C language sys/header exists.  The chdr and
	      csys directives must appear before other C language directives.

	      e.g.
	      csys types.h
	      Check Variable: _sys_types

       csizes
	      Checks the sizes of the standard C data types.   This  directive
	      is  required  for most of the D/C language interface directives.
	      Operating system, architecture and compiler dependent.

	      Output:
	      alias char C_TYP_char;
	      alias short C_TYP_short;
	      alias int C_TYP_int;
	      alias long C_TYP_long;
	      alias long C_TYP_long_long;
	      alias float C_TYP_float;
	      alias double C_TYP_double;
	      alias real C_TYP_long_double;
	      enum int _csiz_char = 1;
	      enum int _csiz_short = 2;
	      enum int _csiz_int = 4;
	      enum int _csiz_long = 8;
	      enum int _csiz_long_long = 8;
	      enum int _csiz_float = 4;
	      enum int _csiz_double = 8;
	      enum int _csiz_long_double = 16;

       clib function [libs, ...]
	      Check to see if the C library function function exists.  If  the
	      optional libs are specified, the test will try first without the
	      libraries, then with the first set of libraries specified linked
	      in,  then the next set, etc.  Sets of libraries to be tested are
	      separated by commas.

	      Execute mkc.sh -reqlib after creating the output file to	output
	      the libraries required for linking.

	      mkc.sh  -reqlib creates the list of libraries required for link‐
	      ing based on the output file.  This allows the  user  to	modify
	      the  output file and only the necessary libraries will be linked
	      in.

	      mkc.sh -reqlib is executed with a command line argument  of  the
	      output  file  name  created  by mkconfig.sh.  The output library
	      file defaults to 'mkconfig.reqlibs', but may be changed with the
	      -o command line option.

	      e.g.
	      clib quotactl
	      Check Variable: _clib_quotactl

	      clib bindtextdomain -lintl, -lintl -liconv
	      [will  test  w/o	any  library, then with -lintl, then with both
	      -lintl and -liconv]

       cdefine	{short|int|long|longlong|hex|hexlong|hexlonglong|float|string}
       def
	      Checks  if  a C #define of def exists.  A D language 'enum' will
	      be output to the output file.  The type is used to properly con‐
	      vert  the  C  definition.  The type output as the D enum will be
	      the appropriate type that has the same  size.   All  floats  are
	      output as double enums.

	      e.g.
	      cdefine hex LC_ALL
	      cdefine string _PATH_MOUNTED
	      Check Variable: _cdefine_LC_ALL

       ctype {int|float} type-name
	      type-name  will be converted to a D language alias for the type.
	      The size of the type will be determined, and the corresponding D
	      type  will  be used to alias the type.  The C language type will
	      be renamed to C_TYP_.  All further instances of that  type
	      in  the output will also be converted.  The int or float keyword
	      indicates whether or not type-name  is  an  integer  type  or  a
	      floating	point type.  For structures, character pointers, func‐
	      tion pointers or if the actual typedef is wanted, use ctypedef.

	      e.g.
	      ctype int uid_t
	      Check Variable: _ctype_uid_t
	      Output:
	      alias uint C_TYP_uid_t;
	      static assert ((C_TYP_uid_t).sizeof == 4);
	      enum int _ctype_uid_t = 4;

       ctypedef type-name
	      Checks for the typedef type-name, and if it exists, outputs  the
	      D  language alias for that typedef.  Unlike the ctype directive,
	      the size of the object is not determined.  The typedef  is  con‐
	      verted  to a D alias as is and output.  If the type that is con‐
	      verted from is not defined, further ctype or ctypedef directives
	      will  be	need to be added to the configuration file.  The 'awk'
	      program is a requirement for this directive.

	      For structures, the cstruct directive should be used.

	      e.g.
	      ctypedef __caddr_t
	      ctypedef caddr_t
	      Output:
	      alias _t_caddr_t caddr_t;
	      // from: typedef __caddr_t caddr_t;
	      alias char *_t_caddr_t;
	      // from: typedef char * __caddr_t;

       cmacro macro-name req-header [req-hdr2 [...]] rettype [type1 ...]
	      macro-name will be converted to a D language function to replace
	      the   macro.    The   C	language  macro  will  be  renamed  to
	      C_MACRO_.	 req-header  is  the  list  of	headers  where
	      macro-name will be found.  The return type of macro-name must be
	      listed after the required headers, and if macro-name takes argu‐
	      ments,  then  the  list of types must be specified at the end of
	      the cmacro directive.  The return type is only used for  D  ver‐
	      sion  1.	 D  version 2 will always set the macro return type to
	      'auto'.  The 'awk' program is a requirement for this directive.

	      e.g.
	      cmacro MIN sys/types.h int int int
	      Check Variable: _cmacro_MIN
	      auto C_MACRO_MIN(int a, int b) { return ((a) < (b) ? (a) : (b)); }
	      enum bool _cmacro_MIN = true;

       cstruct struct-name
	      cunion union-name
	      cenum enum-name
	      Checks to see if struct struct-name or a typedef definition  for
	      struct-name  exists.   The  structure will be modified for the D
	      language and output to the output file.	Note  that  any  types
	      used  by the structure must be checked for first using the ctype
	      or ctypedef  directives.	 The  structure  will  be  renamed  to
	      C_ST_struct-name (C_UN for unions, C_ENUM for enums).  The 'awk'
	      program is a requirement for this directive.

	      e.g.
	      ctype int __time_t
	      ctype int __suseconds_t
	      cstruct timeval
	      Output:
	      struct C_ST_timeval
	       {
	       C_TYP___time_t tv_sec;
	       C_TYP___suseconds_t tv_usec;
	       };
	      alias long C_TYP___time_t;
	      alias long C_TYP___suseconds_t;
	      static assert ((C_TYP___time_t).sizeof == 8);
	      static assert ((C_TYP___suseconds_t).sizeof == 8);
	      static assert ((C_ST_timeval).sizeof == 16);
	      enum bool _cstruct_timeval = true;
	      enum int _ctype___time_t = 8;
	      enum int _ctype___suseconds_t = 8;

       cmember struct-name member
	      Checks to see if member is a member of struct-name.  The cstruct
	      directive for the structure must appear before this directive.

	      e.g.
	      cmember statvfs f_basetype
	      Output:
	      enum bool _cmem_statvfs_f_basetype = false;

       cmembertype struct-name member
	      Gets  the type of struct-name.member.  The cstruct directive for
	      the structure must appear before this directive.

	      e.g.
	      cmembertype getquota_args gqa_uid
	      Output:
	      enum bool _cmembertype_getquota_args_gqa_uid = true;

       cmemberxdr struct-name member
	      Aliases the appropriate xdr function for struct-name.member.
	      The cstruct directive for the structure must appear
	      before this directive.

	      e.g.
	      cmemberxdr getquota_args gqa_uid
	      Output:
	      alias xdr_int xdr_gqa_uid;
	      enum bool _cmemberxdr_getquota_args_gqa_uid = true;

       cdcl [args [noconst]] function
	      Checks to see if function is declared and outputs  the  declara‐
	      tion  to	the  output file.  If the args keyword is present, the
	      number of arguments to the function is counted,  and  the  check
	      variables: _c_args_function, _c_arg_N_function, and c_type_func‐
	      tion are written to the output file.  _c_args_function indicates
	      the  number  of arguments that should be passed to the function.
	      _c_arg_N_function indicates the type of argument where N	refers
	      to the argument position.  _c_type_function indicates the return
	      type of the function.  If the noconst keyword  is  present,  all
	      'const' keywords are stripped from the type.  All C declarations
	      are wrapped in an 'extern (C) { ... }' block in the output file.
	      The 'awk' program is a requirement for this directive.

	      e.g.
	      cdcl args noconst setmntent
	      Output:
	      extern (C) {
	       FILE *setmntent (const char *_t_file, const char *_t_mode) ;
	      }
	      enum string _c_arg_1_setmntent = "char *";
	      enum string _c_arg_2_setmntent = "char *";
	      enum string _c_type_setmntent = "FILE *";
	      enum bool _cdcl_setmntent = true;
	      enum int _c_args_setmntent = 2;

See Also
       iffe(1) autoconf(1) dist(7) mkconfig(7) mkconfig_c(7) mkconfig_env(7)

Bugs
       Send bug reports to: brad.lanam.di_at_gmail.com

Website
       http://www.gentoo.com/di/mkconfig.html

Author
       This program is Copyright 2011-2012 by Brad Lanam, Walnut Creek CA

       Brad Lanam, Walnut Creek, CA (brad.lanam.di_at_gmail.com)