Harbour Make (hbmk2)

Harbour Make (hbmk2) 3.2.0dev (r2013-04-03 03:33)
Copyright (c) 1999-2013, Viktor Szakáts
http://harbour-project.org/

Syntax:

hbmk2 [options] [<script[s]>] <src[s] [.prg|.c|.obj|.o|.rc|.res|.def|.po|.pot|.hbl|@.clp|.d|.ch]>

Description:

hbmk2 is an integrated and portable build tool, making it possible to create various types of executable binaries (executable, dynamic library, static library, Harbour portable binary) out of multiple types of source files (C, C++, Objective-C, Harbour, gettext translations, Windows resources). ‘Integrated’ means that a single hbmk2 project file can control all or most aspects of the build process. ‘Portable’ means that a single hbmk2 project file can control the build on all supported OS platforms and across all supported C compilers. It also aims to cover the majority of build tasks via short and simple project files (options). hbmk2 supports pure -non-Harbour- C/C++/Objective-C projects as well. In order to achieve above goals, hbmk2 will autodetect Harbour, C compiler and other required tools, then configure and call them appropriately. hbmk2 allows to extend the types of supported source files via plugins.

Besides building executables, hbmk2 is able to run Harbour scripts (both source and precompiled) directly, and it also features an interactive shell prompt.

Options:

  • -o<outname> output file name
  • -l<libname> link with <libname> library. <libname> should be without path, extension and ‘lib’ prefix (unless part of the name). Do not add core Harbour libraries, they are automatically added as needed. If <libname> starts with a ‘-‘ character, the library will be removed from the list of libraries at link time.
  • -L<libpath> additional path to search for libraries
  • -i<p>|-incpath=<p> additional path to search for headers
  • -static|-shared link with static/shared libs
  • -gt<name> link with GT<name> GT driver, can be repeated to link with more GTs. First one will be the default at run-time
  • -inc[-] enable/disable incremental build mode (default: disabled)
  • -hbexe create executable (default)
  • -hblib create static library
  • -hbdyn create dynamic library (without linked Harbour VM)
  • -hbdynvm create dynamic library (with linked Harbour VM)
  • -mt|-st link with multi/single-thread Harbour VM
  • -gui|-std create GUI/console executable
  • -main=<mainfunc> override the name of starting function/procedure
  • -request=<func> force function/procedure to be linked
  • -fullstatic link with all static libs
  • -pic[-] create position independent object code (always enabled in -hbdyn/-hbdynvm modes)
  • -[full|fix]shared create shared Harbour binaries without/with absolute dir reference to Harbour library (default: ‘fullshared’ when Harbour is installed on system location, ‘fixshared’ otherwise) (fix/full option in *nix only)
  • -nulrdd[-] link with nulrdd
  • -debug[-] add/exclude C compiler debug info. For Harbour level debug, use Harbour option -b as usual
  • -optim[-] toggle C compiler optimizations (default: on)
  • -cpp[-] force C++/C mode
  • -cpp=<value> select C++ mode. Allowed values are: def, yes, no
  • -map[-] create (or not) a map file
  • -implib[-] create (or not) an import library (in -hbdyn/-hbexe mode). The name will have a postfix added.
  • -implib=<output> create import library (in -hbdyn/-hbexe mode) name to <output> (default: same as output)
  • -ln=<link> create symbolic link pointing to <output> (<link> is considered relative to <output>)
  • -strip[-] strip (no strip) binaries
  • -trace[-] show commands executed
  • -beep[-] enable (or disable) single beep on successful exit, double beep on failure
  • -ignore[-] ignore errors when running compiler tools (default: off)
  • -hbcppmm[-] override standard C++ memory management functions with Harbour ones
  • -winuni[-] select between UNICODE (WIDE) and ANSI compilation modes (default: ANSI) (Windows only. For WinCE it is always set to UNICODE)
  • -nohblib[-] do not use static core Harbour libraries when linking
  • -nodefgt[-] do not link default GTs (effective in -static mode)
  • -nolibgrouping[-] disable library grouping on gcc based compilers
  • -nomiscsyslib[-] do not add extra list of system libraries to default library list
  • -traceonly show commands to be executed, but do not execute them
  • -warn=<level> set C compiler warning level
    <level> can be: max, yes, low, no, def (default: yes)
  • -safe[-] enable safety options in C compiler/linker (default: enabled on Windows, disabled on other systems)
  • -compr=<level> compress executable/dynamic lib (needs UPX tool)
    <level> can be: yes, no, min, max
  • -run[-] run/do not run output executable
  • -vcshead=<file> generate .ch header file with local repository information. Git, SVN, Mercurial, Bazaar, Fossil, CVS and Monotone are currently supported. Generated header will define preprocessor constant _HBMK_VCS_TYPE_ with the name of detected VCS and _HBMK_VCS_ID_ with the unique ID of local repository. If no VCS system is detected, a sequential number will be rolled automatically on each build.
  • -tshead=<file> generate .ch header file with timestamp information. Generated header will define preprocessor constants _HBMK_BUILD_DATE_, _HBMK_BUILD_TIME_, _HBMK_BUILD_TIMESTAMP_ with the date/time of build
  • -icon=<file> set <file> as application icon. <file> should be a supported format on the target platform (not supported by some platforms/compilers). On Windows, it is implemented by generating and linking a resource file.
  • -manifest=<file> embed manifest <file> in executable/dynamic lib (Windows only)
  • -sign=<key> sign executable with <key> (Windows and Darwin only). On Windows signtool.exe is used (part of MS Windows SDK) or posign.exe (part of Pelles C 7), in that order, both autodetected.
  • -signpw=<pw> use <pw> as password when signing executable (Windows and Darwin only)
  • -instfile=<g:file> add <file> in to the list of files to be copied to path specified by -instpath option. <g> is an optional copy group (case sensitive), it must be at least two characters long. In case you do not specify <file>, the list of files in that group will be emptied.
  • -instpath=<g:path> copy target file(s) to <path>. if <path> is a directory, it should end with path separator, in this case files specified by -instfile option will also be copied. can be specified multiple times. <g> is an optional copy group, it must be at least two characters long. Build target will be automatically copied to default (empty) copy group. There exist following built-in <g> groups: ‘depimplib’ for import libraries and ‘depimplibsrc’ for import library source (.dll) files, both belonging to dependencies.
  • -instforce[-] copy target file(s) to install path even if already up to date
  • -depimplib[-] enable (or disable) import library generation for import library sources specified in -depimplibs= options (default: yes)
  • -stop[=<text>] stop without doing anything and display <text> if specified
  • -echo=<text> echo text on screen
  • -pause force waiting for a key on exit in case of failure (with alternate GTs only)
  • -exitstr show error result as human readable text on exit
  • -info turn on informational messages
  • -quiet[-] suppress all screen messages
  • -bldf[-] inherit all/no (default) flags from Harbour build
  • -bldf=[p][c][l] inherit .prg/.c/linker flags (or none) from Harbour build
  • -F<framework> link with <framework> framework (Darwin only)
  • -prgflag=<f> pass single flag to Harbour compiler
  • -cflag=<f> pass single flag to C compiler
  • -resflag=<f> pass single flag to resource compiler (Windows only)
  • -ldflag=<f> pass single flag to linker (executable)
  • -dflag=<f> pass single flag to linker (dynamic library)
  • -aflag=<f> pass single flag to linker (static library)
  • -iflag=<f> pass single flag to import library creation command
  • -signflag=<f> pass single flag to code sign command
  • -runflag=<f> pass single flag to output executable when -run option is used
  • -cflag+=<f> pass single flag to C compiler overriding C compiler flags added by hbmk2 itself. Use with caution.
  • -ldflag+=<f> pass single raw option to linker (executable) after the library list. Use with caution.
  • -dflag+=<f> pass single raw option to linker (dynamic library) after the library list. Use with caution.
  • -3rd=<f> options/flags reserved for 3rd party tools, always ignored by hbmk2 itself
  • -env:<e>[<o>[<v>]] alter local environment. <e> is the name of the environment variable to alter. <o> can be ‘=’ to set/override, ‘-‘ to delete, ‘+’ to append to the end of existing value, ‘#’ to insert to the beginning of existing value. <v> is the value to set/append/insert.
  • -jobs=<n> start n compilation threads (multiprocess platforms only)
  • -head=<m> control source header parsing (in incremental build mode)
    <m> can be: native (uses compiler to extract dependencies), full (default, uses simple text parser on the whole file), dep, off
  • -rebuild rebuild (in incremental build mode)
  • -rebuildall rebuild with sub-projects (in incremental build mode)
  • -clean clean (in incremental build mode)
  • -workdir=<dir> working directory
    (default: .hbmk/<platform>/<compiler> [*] in incremental mode, OS temp directory otherwise)
  • -hbcontainer virtual build target, it does not create anything. Useful for creating an .hbp with the sole purpose of referencing sub-projects
  • -hbimplib create import library (Windows only)
  • -hbl[=<output>] output .hbl filename. %{hb_lng} macro is accepted in filename
  • -lng=<languages> list of languages to be replaced in %{hb_lng} macros in .pot/.po filenames and output .hbl/.po filenames. Comma separated list:
    -lng=en,hu-HU,de
  • -po=<output> create/update .po file from source. Merge it with previous .po file of the same name
  • -minipo[-] do (not) add Harbour version number and source file reference to .po (default: add them)
  • -rebuildpo recreate .po file, thus removing all obsolete entries in it
  • -hbx=[<.ch>] Create Harbour header (in .hbx format) with all external symbols. Empty parameter will disable it.
  • -autohbc=<.ch:.hbc> <.ch> is a header file name. <.hbc> is a .hbc filename to be automatically included in case the header is found in any of the compiled sources. (EXPERIMENTAL)
  • -deppkgname=<d:n> <d> is the name of the dependency. <n> name of the package dependency. Can be specified multiple times.
  • -depkeyhead=<d:h> <d> is the name of the dependency. <h> is the key header (.h) of the package dependency. Multiple alternative headers can be specified.
  • -depoptional=<d:f> <d> is the name of the dependency. <f> can be ‘yes’ or ‘no’, specifies whether the dependency is optional. Default: no
  • -depcontrol=<d:v> <d> is the name of the dependency. <v> is a value that controls how detection is done. Accepted values: no, yes, force, nolocal, local. Default: content of environment variable HBMK_WITH_<d>
  • -depincroot=<d:r> <d> is the name of the dependency. Set <r> as root directory for paths specified in -depincpath options.
  • -depincpath=<d:i> <d> is the name of the dependency. Add <i> to the header detection path list.
  • -depincpathlocal=<d:i> <d> is the name of the dependency. Add <i> to the header detection path list, where <i> is pointing to a directory local to the project and containing an embedded (aka. ‘locally hosted’) dependency.
  • -depimplibs=<d:dll> <d> is the name of the dependency. Add <dll> to the import library source list.
  • -depimplibd=<d:lib> <d> is the name of the dependency. Set generated import library name to <lib>
  • -depfinish=<d> <d> is the name of the dependency. Closes the dependency definition and does the actual dependency detection, setting all predefined filter macro variables and build options accordingly. Optional, if omitted, detection will take place after processing all options.
  • -plugin=<filename> add plugin. <filename> can be: .hb, .prg, .hrb
  • -pi=<filename> pass input file to plugins
  • -pflag=<f> pass single flag to plugins

Options below are available on command-line:

  • -target=<script> specify a new build target. <script> can be .prg (or no extension) or .hbp file. Note that .hbp files are automatically considered as separate build targets.
  • -hbrun run build target
  • -hbraw stop after running Harbour compiler
  • -hbcmp|-clipper stop after creating the object files
    create link/copy hbmk2 to hbcmp/clipper for the same effect
  • -hbcc accept raw C flags
    create link/copy hbmk2 to hbcc for the same effect
  • -hblnk accept raw linker flags
  • -autohbm[-] enable (or disable) processing of hbmk.hbm in current directory (default: yes)
  • -hb10 enable Harbour 1.0.x compatibility mode
  • -hb20 enable Harbour 2.0.x compatibility mode
  • -hb30 enable Harbour 3.0.x compatibility mode
  • -xhb enable xhb mode
  • -hbc enable pure C mode
  • -rtlink
  • -blinker
  • -exospace emulate Clipper compatible linker behavior
    create link/copy hbmk2 to rtlink/blinker/exospace for the same effect
  • -hbreg[=global] register Harbour Script (.hb) with hbmk2 (Windows only)
  • -hbunreg[=global] unregister Harbour Script (.hb) from hbmk2 (Windows only)
  • -find <text> lists all known Harbour functions that contain <text> in their name, along with their package (case insensitive, accepts multiple values, can contain wildcard characters)
  • -hbmake=<file> convert hbmake project <file> to .hbp file
  • -xbp=<file> convert .xbp (xbuild) project <file> to .hbp file
  • -xhp=<file> convert .xhp (xMate) project <file> to .hbp file
  • –hbdirbin output Harbour binary directory to stdout
  • –hbdirdyn output Harbour dynamic library directory to stdout
  • –hbdirlib output Harbour static library directory to stdout
  • –hbdirinc output Harbour header directory to stdout
  • –hbinfo[=nested] output Harbour build information to stdout. Output is in JSON format. The included paths always contain forward slashes. Each JSON block is followed by an 0x0A byte.
  • -plat=<platform> override default target platform (default: automatic)
  • -cpu=<cpu> override default target CPU (default: automatic) (EXPERIMENTAL)
  • -comp=<compiler> override C compiler autodetection
    Special value:
    – bld: use original build settings (default on *nix)
  • -build=<name> specify a build name
  • -lang=<lang> override default language. <lang> is an ISO language code.
  • -width=<n> set output width to <n> characters (0=unlimited).
  • -shl show sub-project level in output lines
  • -viewhelp long help in text viewer
  • -longhelp long help
  • -longhelpmd long help in Markdown format
  • -harbourhelp Harbour compiler help (all Harbour compiler options are accepted as is by hbmk2)
  • -credits Harbour compiler credits
  • -build Harbour compiler build information
  • -version display version header only

Options below are internal/developer ones (compatibility not guaranteed):

  • -debugtime measure time spent on the build
  • -debuginc display internals of incremental build
  • -debugstub display content of all internally generated source files
  • -debugi18n display internals on translation file generation
  • -debugdepd display internals of dependency detection
  • -debugpars display all input parameters in processing order
  • -debugrte generate a run-time error

You can sym-link/copy/rename hbmk2 to the following names to alter default mode of operation:

  • hbrun*|*hbrun mode script runner / interactive shell
  • hbrund|hbrun*d mode script runner / interactive shell in debug mode
  • harbour mode -hbraw (emulate – raw – Harbour compiler)
  • clipper mode -hbcmp (emulate Clipper compiler)
  • rtlink mode -rtlink (emulate Clipper linker)
  • exospace mode -rtlink (emulate Clipper linker)
  • blinker mode -rtlink (emulate Clipper linker)
  • *10 option -hb10
  • *20 option -hb20
  • *30 option -hb30
  • x\* option -xhb
  • hbcmp*|*hbcmp mode -hbcmp (emulate Harbour compiler producing a binary object)
  • hbcc*|*hbcc mode -hbcc (emulate C compiler)
  • hblnk*|*hblnk mode -hblnk (emulate C linker)
  • hbexe*|*hbexe mode -hbexe
  • hblib*|*hblib mode -hblib
  • hbdyn*|*hbdyn mode -hbdyn

Files:

  • *.hbp project file. Can contain any number of command-line options, which are expected to create an output. Lines beginning with ‘#’ character are ignored, otherwise newline is optional and options are space separated, just like on the command-line. You must enclose option containing space in double quotes. Each .hbp file reference will be executed as a sub-project.
  • *.hbm collection of options. Can be used to collect common ones into a file and include that into project files. Uses same format as .hbp files.
  • *.hbc collection of options that accompany components (aka ‘libs’, aka packages). Use different syntax than command-line and .hbp/.hbm files. Lines beginning with ‘#’ character are ignored, each directive must be placed in separate line.
  • *.ch if passed directly as a source file, it will be used as additional standard header
  • hbmk.hbc standard .hbc file that gets automatically processed, if present. Possible location(s) (in order of precedence) [*]: %APPDATA%\.harbour, <hbmk2 directory>
  • hbmk.hbm optional .hbm file residing in current working directory, which gets automatically processed before other options
  • $hb_pkg_dynlib.hbm special .hbm file embedded inside hbmk2. It manages the details of creating a dynamic library (in the style of Harbour contribs).
  • $hb_pkg_install.hbm special .hbm file embedded inside hbmk2. It manages the details of installing build targets and related package files to standard locations (in the style of Harbour contribs).
  • *.hb Harbour script
  • *.hrb Harbour portable binary (aka precompiled Harbour script)
  • hbstart.hb startup Harbour script for interactive Harbour shell. It gets executed automatically on shell startup, if present. Possible locations (in order of precedence) [*]: .\, %APPDATA%\.harbour, <hbmk2 directory>
  • shell plugins .hb and .hrb plugins for interactive Harbour shell. They may reside in [*]: %APPDATA%\.harbour\
  • .hb_history stores command history for interactive Harbour shell. You can disable history by making the first line ‘no’ (without quotes and with newline). Resides in [*]: %APPDATA%\.harbour\
  • hb_extension list of extensions to load in interactive Harbour shell. One extension per line, part of line beyond a ‘#’ character is ignored. Alternate filename on MS-DOS: hb_ext.ini. Resides in [*]: %APPDATA%\.harbour\

Macro variables:

  • ${hb_root} directory of hbmk2
  • ${hb_dir} directory of the filename it is used in
  • ${hb_dirname} top directory of the filename it is used in
  • ${hb_name} name of the filename it is used in (without directory and extension)
  • ${hb_self} full filename it is used in
  • ${hb_curdir} current working directory
  • ${hb_tempdir} OS directory for temporary files
  • ${hb_targetname} name of the project (without directory and extension). Returns .adhoc. if there is not project file.
  • ${hb_targettype} type of the project (hbexe, hblib, hbdyn, hbdynvm, hbimplib, hbppo, hbhrb, hbcontainer)
  • ${hb_plat} selected platform
  • ${hb_comp} selected C compiler
  • ${hb_comp_ver} C compiler version
  • ${hb_build} build name
  • ${hb_cpu} selected CPU
  • ${hb_work} default base workdir name
  • ${hb_workdynsub} default workdir subdirectory for dynamic library targets
  • ${hb_dynprefix} dynamic library prefix
  • ${hb_dynsuffix} dynamic library suffix
  • ${hb_dynext} dynamic library extension
  • ${hb_ver} Harbour version in hexadecimal triple byte format. F.e.: 030200
  • ${hb_verstr} Harbour version in human readable format <major>.<minor>.<release><status>. F.e.: 3.2.0dev
  • ${hb_major} Harbour major version number
  • ${hb_minor} Harbour minor version number
  • ${hb_release} Harbour release version number
  • ${hb_status} Harbour version status
  • ${hb_revision} Harbour revision
  • ${hb_host_plat} Harbour host platform
  • ${hb_host_plat_unix} returns ‘1’ if Harbour host platform is *nix compatible
  • ${hb_bin} Harbour binary directory
  • ${hb_lib} Harbour static library directory
  • ${hb_lib3rd} Harbour 3rd party static library directory
  • ${hb_dyn} Harbour dynamic library directory
  • ${hb_inc} Harbour header directory
  • ${hb_addons} Harbour add-ons base directory
  • ${hb_first} name of source file that holds the entry function (without directory and extension)
  • ${hb_outputdir} directory of the output
  • ${hb_outputname} name of the output (without extension)
  • ${hb_level} sub-project recursion level
  • ${<depname>} returns the header directory of dependency <depname>, or ‘1’ if it is not detected
  • ${<envvar>} returns the value of the environment variable <envvar>

Filters (you can combine and/or negate them):

  • {<platform>} target platform. Where <platform> can be any value accepted by -plat= option.
  • {<compiler>} target C compiler. Where <compiler> can be any value accepted by -comp= option.
  • {<cpu>} target CPU. Where <cpu> can be any of: x86, x86_64, ia64, arm, mips, sh
  • {<targettype>} build target type. Where <targettype> is any of the values returned by macro variable ${hb_targettype}.
  • {mt} build target is multi-threaded (see -mt option)
  • {st} build target is single-threaded (see -st option)
  • {gui} GUI target (see -gui option)
  • {std} console target (see -console option)
  • {debug} C level debugging is enabled (see -debug option)
  • {nodebug} C level debugging is disabled (see -debug- option)
  • {shared} shared build (see -shared and related options)
  • {static} static build (see -static and related options)
  • {lngcpp} forced C++ mode (see -cpp option)
  • {lngc} forced C mode (see -cpp- option)
  • {winuni} Windows UNICODE (WIDE) mode (see -winuni option)
  • {winansi} Windows ANSI mode (see -winuni- option)
  • {unix} target platform is *nix compatible (bsd, hpux, sunos, beos, qnx, android, vxworks, symbian, linux, darwin, cygwin, minix, aix)
  • {allwin} target platform is Windows compatible (win, wce)
  • {allgcc} target C compiler belongs to gcc family (gcc, mingw, mingw64, mingwarm, djgpp, gccomf, clang, open64, pcc)
  • {allmingw} target C compiler is mingw* (mingw, mingw64, mingwarm)
  • {allmsvc} target C compiler is msvc* (msvc, msvc64, msvcia64, msvcarm)
  • {allbcc} target C compiler is bcc* (bcc, bcc64)
  • {allpocc} target C compiler is pocc* (pocc, pocc64, poccarm)
  • {allicc} target C compiler is icc* (icc, iccia64)
  • {hb10} Harbour 1.0.x compatibility mode (see -hb10 option)
  • {hb20} Harbour 2.0.x compatibility mode (see -hb20 option)
  • {hb30} Harbour 3.0.x compatibility mode (see -hb30 option)
  • {xhb} xhb mode (see -xhb option)
  • {hb_ispath='<file|dir>’} filter will pass if <file> or <dir> name exists on disk.
  • {MACRO} filter will pass if ${MACRO} value is not empty and not equal to ‘0’ or ‘no’ (case insensitive)
  • {MACRO='<value>’} filter will pass if ${MACRO} value equals to <value> (case insensitive).
  • {MACRO>'<value>’} filter will pass if ${MACRO} value is larger than <value> (case insensitive).
  • {MACRO<‘<value>’} filter will pass if ${MACRO} value is smaller than <value> (case insensitive).

Predefined constants in sources:

  • __HBSCRIPT__HBMK_PLUGIN when an .hb script is compiled as hbmk2 plugin
  • __HBEXTREQ__ when an .hbx source file is present in a project (available in Harbour sources)
  • HBMK_HAS_<hbcname> when <hbcname>.hbc package is linked to the build target. The value is the version= value from the .hbc file, converted to a decimal number, which is ‘1’, if not specified. (available in Harbour sources)
  • HBMK_HAS_<depname> when <depname> dependency was detected (available in C sources)
  • __HBSCRIPT__HBSHELL when a Harbour source file is run as a shell script
  • <standard Harbour> __PLATFORM__*, __ARCH*BIT__, __*_ENDIAN__, etc…

Predefined constants in build files (they are available after ‘-depfinish=<depname>’ / ‘depfinish=<depname>’):

  • HBMK_HAS_<depname> when <depname> dependency was detected
  • HBMK_DIR_<depname> return the header directory where <depname> was detected, or empty if it was not.
  • HBMK_HAS_<depname>_LOCAL when <depname> dependency was detected in a location configured by -depincpathlocal= option

Environment variables:

  • HBMK_OPTIONS accepts any options as if they were passed in the beginning of the command-line
  • HB_PLATFORM accepts same values as -plat= option
  • HB_COMPILER accepts same values as -comp= option
  • HB_CPU accepts same values as -cpu= option
  • HB_BUILD_NAME accepts same values as -build= option
  • HB_LANG accepts same values as -lang= option
  • HB_USER_LIBS accepts same values (space separated) as -l option
  • HB_USER_LIBPATHS accepts same values (space separated) as -L option
  • HB_USER_PRGFLAGS options to be passed to Harbour compiler (before command-line options)
  • HB_USER_CFLAGS options to be passed to C compiler (before command-line options)
  • HB_USER_RESFLAGS options to be passed to resource compiler (before command-line options) (Windows only)
  • HB_USER_LDFLAGS options to be passed to linker (executable) (before command-line options)
  • HB_USER_DFLAGS options to be passed to linker (dynamic library) (before command-line options)
  • HB_USER_AFLAGS options to be passed to linker (static library) (before command-line options)
  • HB_COMPILER_VER override C compiler version autodetection (gcc and msvc compiler families only). Format: <15><00>[.<00>] = <major><minor>[.<revision>]
  • HB_CCPATH override C compiler executable directory (gcc compiler families only)
  • HB_CCPREFIX override C compiler executable prefix (gcc compiler families only)
  • HB_CCSUFFIX override C compiler executable suffix (gcc compiler families only)
  • HB_INSTALL_PREFIX override Harbour base installation directory
  • HB_INSTALL_ADDONS override Harbour base add-ons directory
  • HB_EXTENSION space separated list of extensions to load in interactive Harbour shell

.hbc directives (they should be written in separate lines):

  • echo=<msg> display <msg>
  • skip=[<msg>] skip processing the rest of the .hbc file. Display <msg>, if specified.
  • stop=[<msg>] stop the build. Display <msg>, if specified.
  • sources= add space separated list of files as input files
  • headers= add space separated list of .ch format headers as standard header
  • libs= add space separated list of libraries (see more at -l option)
  • frameworks= add space separated list of frameworks (Darwin only)
  • requests= add space separated list of symbols to force link to the build target
  • syslibs= add space separated list of libraries as system libraries (before regular libraries)
  • hbcs= embed space separated list of .hbc files. Names without the extension is accepted. These references are processed in place.
  • autohbcs= space separated list of values as in -autohbc= option
  • libpaths= space separated list of additional library paths
  • incpaths= add space separated list of additional header paths (for both Harbour and C)
  • instfiles= space separated list of values as in -instfile= option
  • instpaths= space separated list of values as in -instpath= option
  • prgflags= space separated list of values as in -prgflag= option
  • cflags= space separated list of values as in -cflag= option
  • resflags= space separated list of values as in -resflag= option
  • ldflags= space separated list of values as in -ldflag= option
  • ldflags+= space separated list of values as in -ldflag+= option
  • dflags= space separated list of values as in -dflag= option
  • dflags+= space separated list of values as in -dflag+= option
  • pflags= space separated list of values as in -pflag= option
  • psources= space separated list of values as in -pi= option
  • gui=<bool> ‘yes’ = -gui, ‘no’ = -std option
  • mt=<bool> ‘yes’ = -mt, ‘no’ = -st option
  • pic=<bool> ‘yes’ = -pic, ‘no’ = -pic- option
  • shared=<bool> ‘yes’ = -shared, ‘no’ = -static option
  • shareddef=<bool> similar to shared=, but works only if shared/static mode was not set before
  • fullstatic=<bool> ‘yes’ = -fullstatic, ‘no’ = -static option
  • debug=<bool> ‘yes’ = -debug, ‘no’ = -debug- option
  • optim= ‘yes’ = -optim, ‘no’ = -optim- option
  • nulrdd=<bool> ‘yes’ = -nulrdd, ‘no’ = -nulrdd- option
  • nodefgt=<bool> ‘yes’ = -nodefgt, ‘no’ = -nodefgt- option
  • map=<bool> ‘yes’ = -map, ‘no’ = -map- option
  • hbcppmm=<bool> ‘yes’ = -hbcpmm, ‘no’ = -hbcpmm- option
  • implib=<bool> ‘yes’ = -implib, ‘no’ = -implib- option
  • winuni=<bool> ‘yes’ = -winuni, ‘no’ = -winuni- option
  • strip=<bool> ‘yes’ = -strip, ‘no’ = -strip- option
  • run=<bool> ‘yes’ = -run, ‘no’ = -run- option
  • inc=<bool> ‘yes’ = -inc, ‘no’ = -inc- option
  • safe=<bool> ‘yes’ = -safe, ‘no’ = -safe- option
  • cpp= same as -cpp= option
  • warn= same as -warn= option
  • compr= same as -compr= option
  • head= same as -head= option
  • plugins= space separated list of hbmk2 plugins to load
  • gt=<name> same as -gt<name> option
  • gtdef=<name> set the default GT to be used
  • env= same as -env: option
  • deppkgname= same as -deppkgname= option
  • depkeyhead= same as -depkeyhead= option
  • depoptional= same as -depoptional= option
  • depcontrol= same as -depcontrol= option
  • depincroot= same as -depincroot= option
  • depincpath= same as -depincpath= option
  • depincpathlocal= same as -depincpathlocal= option
  • depimplibs= same as -depimplibs= option
  • depimplibd= same as -depimplibd= option
  • depfinish= same as -depfinish= option
  • name= package name
  • description= package description
  • version=<x.y.z> package version number, where x,y,z >= 0 <= 255. Defaults to 0.0.1, if not specified.
  • keywords= space separated list of keywords
  • licences= space separated list of licenses
  • repository= space separated list of source repository references

Plugin API:
(‘hbmk’ is the context variable received by the plugin entry function)

  • hbmk_Register_Input_File_Extension( hbmk, <cExt> ) -> NIL
    Register input file extension to be passed to plugin (by default all unknown file extensions are passed to Harbour compiler).
  • hbmk_AddInput_PRG( hbmk, <cFileName> ) -> NIL
    Add a Harbour input file to the project.
  • hbmk_AddInput_C( hbmk, <cFileName> ) -> NIL
    Add a C input file to the project.
  • hbmk_AddInput_CPP( hbmk, <cFileName> ) -> NIL
    Add a C++ input file to the project.
  • hbmk_AddInput_RC( hbmk, <cFileName> ) -> NIL
    Add a Windows resource input file to the project.
  • hbmk_AddInput_OBJ( hbmk, <cFileName> ) -> NIL
    Add a binary object file to the project.
  • hbmk_AddInput_INSTFILE( hbmk, <cFileName>, [<cGroup>] ) -> NIL
    Add a file to be installed, with an optional -instpath= group name.
  • hbmk_OutStd( hbmk, <cText> ) -> NIL
    Output text to stdout.
  • hbmk_OutErr( hbmk, <cText> ) -> NIL
    Output text to stderr.
  • hbmk_OutStdRaw( hbmk, … ) -> NIL
    Output text to stdout without any formatting.
  • hbmk_OutErrRaw( hbmk, … ) -> NIL
    Output text to stderr without any formatting.
  • hbmk_Macro( hbmk, <cMacro> ) -> <cResult>
    Evaluate hbmk2 macro expression.
  • hbmk_FNameEscape( hbmk, <cFileName> ) -> <cFileName>
    Escape/quote filename for using it as external command parameter.
  • hbmk_PathSepToTarget( hbmk, <cFileName> ) -> <cFileName>
    Convert filename to the format required for the target platform/C compiler.
  • hbmk_PathSepToForward( <cPath> ) -> <cPath>
    Convert filename to have forward slash directory separators.
  • hbmk_PathFromWorkdirToCWD( hbmk ) -> <cRelativePath>
    Return relative path of -workdir= value from current working directory.
  • hbmk_FindInPath( <cFileName>, [<xPath>], [<aExtDef>] ) -> <cFNFound> | NIL
    Find file in <xPath> (array or pathsep delimited string are accepted) with list of <aExtDef> alternate extensions (defaults to executable binaries). Returns filename if found and NIL if not.
  • hbmk_FNameDirExtSet( <cFileName>, [<cDirNew>], [<cExtNew>] ) -> <cFileName>
    Change directory and/or extension in filename.
  • hbmk_FuncNameEncode( <cFuncName> ) -> <cFuncNameEncoded>
    Encode function name according to Harbour compiler rules for forming HB_FUNC() function names in C code.
  • hbmk_StrStripQuote( <cString> ) -> <cString>
    Strip double quote enclosure from a string.
  • hbmk_ArrayToList( <aList>, [<cSeparator>] ) -> <cList>
    Convert array of strings to a string. Default separator is a single space.

Plugin variables:
(‘hbmk’ context hash items, case-sensitive, read-only unless marked otherwise)

  • “apiver” API version as an integer
  • “cSTATE” callback state. Can be: ‘init’, ‘pre_all’, ‘pre_prg’, ‘pre_res’, ‘pre_c’, ‘pre_link’, ‘pre_lib’, ‘pre_cleanup’, ‘post_build’, ‘post_all’
  • “params” array of parameters passed to plugins via -pflag=/pi= options or having an extension registered via hbmk_Register_Input_File_Extension()
  • “vars” hash of plugin custom variables. Writable, local to each plugin
  • “cPLAT” -plat value
  • “cCOMP” -comp value
  • “nCOMPVer” see HB_COMPILER_VER envvar
  • “cCPU” -cpu value
  • “cBUILD” -build= value
  • “cOUTPUTNAME” -o value
  • “cTARGETNAME” see ${hb_targetname} macro
  • “cTARGETTYPE” see ${hb_targettype} macro
  • “lREBUILD” -rebuild option status
  • “lCLEAN” -clean option status
  • “lDEBUG” -debug option status
  • “lMAP” -map option status
  • “lSTRIP” -strip option status
  • “lDONTEXEC” -traceonly option status
  • “lIGNOREERROR” -ignore option status
  • “lTRACE” -trace option status
  • “lQUIET” -q option status
  • “lINFO” -info option status
  • “lBEEP” -beep option status
  • “lRUN” -run option status
  • “lINC” -inc option status
  • “cCCPATH” see HB_CCPATH envvar
  • “cCCPREFIX” see HB_CCPREFIX envvar
  • “cCCSUFFIX” see HB_CCSUFFIX envvar
  • “cCCEXT” see HB_CCEXT envvar
  • “cWorkDir” -workdir= value
  • “nExitCode” Current exit code

Shell API available in Harbour scripts:

  • hbshell_gtSelect( [<cGT>] ) -> NIL
    Switch GT. Default [*]: ‘gtwin’
  • hbshell_Clipper() -> NIL
    Enable Clipper compatibility (non-Unicode) mode.
  • hbshell_include( <cHeader> ) -> <lSuccess>
    Load Harbour header.
  • hbshell_uninclude( <cHeader> ) -> <lSuccess>
    Unload Harbour header.
  • hbshell_include_list() -> NIL
    Display list of loaded Harbour header.
  • hbshell_ext_load( <cPackageName> ) -> <lSuccess>
    Load package. Similar to #request PP directive.
  • hbshell_ext_unload( <cPackageName> ) -> <lSuccess>
    Unload package.
  • hbshell_ext_get_list() -> <aPackages>
    List of loaded packages.
  • hbshell_DirBase() -> <cBaseDir>
    hb_DirBase() not mapped to script.
  • hbshell_ProgName() -> <cPath>
    hb_ProgName() not mapped to script.

Examples to start with hbmk2:

  • To run the interactive shell (‘dot’ prompt)
    $ hbmk2 .
  • To run a Harbour script
    $ hbmk2 myscript.hb [<parameter[s]>]

Examples to build and run Harbour portable binary (aka precompiled Harbour script):

  • To build
    $ hbmk2 -gh myscript.hb
  • To run result of above
    $ hbmk2 myscript.hrb [<parameter[s]>]

Examples to build a Harbour application:

  • To build one simple .prg
    $ hbmk2 hello.prg
  • To build multiple .prg sources into one application in incremental mode
    $ hbmk2 mymain.prg myfuncs.prg -inc
  • To build an application using a project file
    $ hbmk2 myapp.hbp
  • To build an application using incremental mode
    $ hbmk2 myapp.hbp -inc
  • To build an application which uses a contrib package or 3rd party (add-on) package that ships with an .hbc file
    $ hbmk2 myapp.prg hbct.hbc
  • To build an application which uses a raw library
    $ hbmk2 myapp.prg -lmylib -L<path_to_mylib>
  • To build an application which uses a Windows resource
    $ hbmk2 mymain.prg myres.rc
  • To build an application which links against Harbour dynamic libraries
    $ hbmk2 -shared myapp.prg
  • To build an application out of all .prg and .c sources residing in ‘source’ subdir
    $ hbmk2 -omyapp src/*.prg src/*.c

Examples to build a Harbour static library:

  • To build library ‘mylib’ from sources
    $ hbmk2 -hblib mylibsrc.prg -omylib
  • To build library ‘mylib’ from sources using incremental mode
    $ hbmk2 -hblib mylibsrc.prg -omylib -inc

Exit codes (“errorlevels”):

  • 0 no error
  • 1 unknown platform
  • 2 unknown compiler
  • 3 failed Harbour detection
  • 5 failed stub creation
  • 6 failed in compilation (Harbour, C compiler, Resource compiler)
  • 7 failed in final assembly (linker or library manager)
  • 8 unsupported
  • 9 failed to create working directory
  • 19 help
  • 10 dependency missing or disabled
  • 20 plugin initialization
  • 30 too deep nesting
  • 50 stop requested
  • <other> when -run option is used, the exit code will be the one returned by the target executable

Notes:

  • <script> can be:
    <@script> or <script.hbm>: command-line options in file
    <script.hbp>: command-line options in file, it also marks a new build target if specified on the command-line
    <script.hbc>: package configuration file
  • Source filename without extension will load the .hbp file, if such .hbp file exists in current directory. If not, .prg extension will be used.
  • Multiple -l, -L, -i and <script> parameters are accepted.
  • Regular Harbour compiler options are also accepted as is.
    (see them with -harbourhelp option)
  • hbmk.hbc option file in hbmk2 directory is always processed if it exists. On *nix platforms ~/.harbour, /etc/harbour, <base>/etc/harbour, <base>/etc are checked (in that order) before the hbmk2 directory.
  • hbmk.hbm make script in current directory is always processed if it exists.
  • Using forwards slashes is recommended in option values as directory separator, but backslashes are also equally accepted.
  • Filters are accepted in each .hbc line and most options.
    Filters can be combined using ‘&’ (and), ‘|’ (or) operators, negated by ‘!’ operator and grouped by parentheses. Ex.: {win}, {gcc}, {linux|darwin}, {win&!pocc}, {(win|linux)&!watcom}, {unix&mt&gui}, -cflag={win}-DMYDEF, -stop{dos}, -stop{!allwin}
  • Most .hbc lines (libs=, hbcs=, prgflags=, cflags=, ldflags=, libpaths=, instfiles=, instpaths=, echo=) and corresponding command-line parameters will accept macro variables. libpaths= also accepts %{hb_name} which translates to the name of the .hbc file under search.
  • Options accepting macro variables also support command substitution. Enclose command inside “, and, if the command contains space, also enclose in double quotes. Standard output of the command will be used as the value. F.e. “-cflag=`wx-config –cflags`”, or ldflags={unix&gcc}”`wx-config –libs`”.
  • When multiple build target type selection options (-hblib, -hbdyn, etc.) are specified, the first one will be significant, the rest will be silently ignored.
  • Libraries and object files built with/for CA-Cl*pper will not work with any supported platform/compiler.
  • Defaults and feature support may vary by platform/compiler.
  • GNU Make or any C compiler specific make tool and MSYS (on Windows) are not needed to run hbmk2.
  • . (dot) passed as first parameter will enter the interactive Harbour shell.
  • .hb, .hrb or .dbf file passed as first parameter will be run as Harbour script. If the filename contains no path components, it will be searched in current working directory and in PATH. If not extension is given, .hb and .hrb extensions are searched, in that order. .dbf file will be opened automatically in shared mode and interactive Harbour shell launched. Non-standard extensions will be autodetected for source and precompiled script types. Note, for Harbour scripts, the codepage is set to UTF-8 by default. The default core header ‘hb.ch’ is automatically #included. The default date format is the ISO standard: yyyy-mm-dd. The default GT is ‘gtcgi’, unless full-screen CUI calls are detected, when ‘gtwin’ [*] is automatically selected (except for INIT PROCEDUREs).
  • You can use key <Alt+V> in interactive Harbour shell to paste text from the clipboard.
  • Values marked with [*] may be host platform and/or configuration dependent. This help was generated on ‘win’ host platform.

Supported <compiler> values for each supported <platform> value:

  • linux gcc, clang, icc, watcom, sunpro, open64
  • darwin gcc, clang, icc
  • win mingw, msvc, clang, bcc, bcc64, watcom, icc, pocc, xcc, mingw64, msvc64, msvcia64, iccia64, pocc64
  • wce mingwarm, mingw, msvcarm, poccarm
  • os2 gcc, gccomf, watcom
  • dos djgpp, watcom
  • bsd gcc, clang, pcc
  • hpux gcc
  • beos gcc
  • qnx gcc
  • android gcc, gccarm
  • vxworks gcc, diab
  • symbian gcc
  • cygwin gcc
  • minix clang, gcc
  • aix gcc
  • sunos gcc, sunpro

License:

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
their web site at http://www.gnu.org/).

License extensions:
– This source code must be kept and distributed as part
of the Harbour package and/or the placement of the tool sources
and files must reflect that it is part of Harbour Project.
– Copyright information must always be presented by
projects including this tool or help text.
– Modified versions of the tool must clearly state this
fact on the copyright screen.
– Source code modifications shall always be made available
along with binaries.
– Help text and documentation is licensed under
Creative Commons Attribution-ShareAlike 3.0:
http://creativecommons.org/licenses/by-sa/3.0/

Author:

  • Viktor Szakáts (vszakats.net/harbour)

Source : https://github.com/harbour/core/blob/master/utils/hbmk2/doc/hbmk2.en.md

For further info :

HbMk2 : Harbour Maker

Harbour Make (hbmk2) 3.2.0dev (Rev. 18805)
Copyright (c) 1999-2013, Viktor Szakáts
http://harbour-project.org/

Syntax:

hbmk2 [options] [<script[s]>] <src[s][.prg|.c|.obj|.o|.rc|.res|.def|.po|.pot|.hbl|@.clp|.d|.ch]>

Options:
-o<outname> output file name
-l<libname> link with <libname> library. <libname> should be without
path, extension and ‘lib’ prefix (unless part of
libname). Do not add core Harbour libraries, they are
automatically added as needed.
-L<libpath> additional path to search for libraries
-i<p>|-incpath=<p> additional path to search for headers
-static|-shared link with static/shared libs
-mt|-st link with multi/single-thread Harbour VM
-gt<name> link with GT<name> GT driver, can be repeated to link
with more GTs. First one will be the default at runtime
-inc[-] enable/disable incremental build mode (default: disabled)
-hbexe create executable (default)
-hblib create static library
-hbdyn create dynamic library (without linked Harbour VM)
-hbdynvm create dynamic library
-hbimplib create import library

-gui|-std create GUI/console executable
-main=<mainfunc> override the name of starting function/procedure
-request=<func> force function/procedure to be linked
-fullstatic link with all static libs
-pic[-] create position independent object code (always enabled
in -hbdyn/-hbdynvm modes)
-[full|fix]shared create shared Harbour binaries without/with absolute dir
reference to Harbour library (default: ‘fullshared’ when
Harbour is installed on system location, ‘fixshared’
otherwise) (fix/full option in *nix only)
-nulrdd[-] link with nulrdd
-debug[-] add/exclude C compiler debug info. For Harbour level
debug, use Harbour option -b as usual
-optim[-] toggle C compiler optimizations (default: on)
-cpp[-] force C/C++ mode
-cpp=<value> select C++ mode. Allowed values are: def, yes, no
-map[-] create (or not) a map file
-implib[-] create (or not) an import library (in -hbdyn/-hbexe
mode). The name will have a postfix added.
-implib=<output> create import library (in -hbdyn/-hbexe mode) name to
<output> (default: same as output)
-ln=<link> create symbolic link pointing to <output> (<link> is
considered relative to <output>)
-strip[-] strip (no strip) binaries
-trace[-] show commands executed
-beep[-] enable (or disable) single beep on successful exit,
double beep on failure
-ignore[-] ignore errors when running compiler tools (default: off)
-hbcppmm[-] override standard C++ memory management functions with
Harbour ones
-winuni[-] select between UNICODE (WIDE) and ANSI compilation modes
(default: ANSI) (Windows only. For WinCE it is always set
to UNICODE)
-nohblib[-] do not use static core Harbour libraries when linking
-nodefgt[-] do not link default GTs (effective in -static mode)
-nolibgrouping[-] disable library grouping on gcc based compilers
-nomiscsyslib[-] do not add extra list of system libraries to default
library list
-traceonly show commands to be executed, but do not execute them
-warn=<lev> set C compiler warning level
<lev> can be: max, yes, low, no, def (default: yes)
-compr=<lev> compress executable/dynamic lib (needs UPX)
<lev> can be: yes, no, min, max
-run[-] run/do not run output executable
-vcshead=<file> generate .ch header file with local repository
information. SVN, CVS, Git, Mercurial, Bazaar, Fossil and
Monotone are currently supported. Generated header will
define macro _HBMK_VCS_TYPE_ with the name of detected
VCS and _HBMK_VCS_ID_ with the unique ID of local
repository
-tshead=<file> generate .ch header file with timestamp information.
Generated header will define macros _HBMK_BUILD_DATE_,
_HBMK_BUILD_TIME_, _HBMK_BUILD_TIMESTAMP_ with the
date/time of build
-icon=<file> set <file> as application icon. <file> should be a
supported format on the target platform
-manifest=<file> embed manifest <file> in executable/dynamic lib (Windows
only)
-sign=<key> sign executable with <key> (Windows and Darwin only)
-signpw=<pw> use <pw> as password when signing executable (Windows and
Darwin only)
-instfile=<g:file> add <file> in to the list of files to be copied to path
specified by -instpath option. <g> is an optional copy
group (case sensitive), it must be at least two
characters long. In case you don’t specify <file>, the
list of files in that group will be emptied.
-instpath=<g:path> copy target to <path>. if <path> is a directory, it
should end with path separatorm, in this case files
specified by -instfile option will also be copied. can be
specified multiple times. <g> is an optional copy group,
it must be at least two characters long. Build target
will be automatically copied to default (empty) copy
group.
-instforce[-] copy target to install path even if it is up to date
-depimplib[-] enable (or disable) import library generation for import
library sources specified in -depimplibs= options
(default: yes)
-stop[=<text>] stop without doing anything and display <text> if
specified
-echo=<text> echo text on screen
-pause force waiting for a key on exit in case of failure (with
alternate GTs only)
-info turn on informational messages
-quiet[-] suppress all screen messages

-bldf[-] inherit all/no (default) flags from Harbour build
-bldf=[p][c][l] inherit .prg/.c/linker flags (or none) from Harbour build
-F<framework> link with <framework> framework (Darwin only)
-cflag=<f> pass single flag to C compiler
-resflag=<f> pass single flag to resource compiler (Windows only)
-ldflag=<f> pass single flag to linker (executable)
-aflag=<f> pass single flag to linker (static library)
-dflag=<f> pass single flag to linker (dynamic library)
-iflag=<f> pass single flag to import library creation command
-prgflag=<f> pass single flag to Harbour compiler
-runflag=<f> pass single flag to output executable when -run option is
used
-cflag+=<f> pass single flag to C compiler overriding C compiler
flags added by hbmk2 itself. Use with caution.
-3rd=<f> options/flags reserved for 3rd party tools, always
ignored by hbmk2 itself
-env:<e>[<o>[<v>]] alter local environment. <e> is the name of the
environment variable to alter. <o> can be ‘=’ to
set/override, ‘-‘ to delete, ‘+’ to append to the end of
existing value, ‘#’ to insert to the beginning of
existing value. <v> is the value to set/append/insert.
-jobs=<n> start n compilation threads (multiprocess platforms only)
-head=<m> control source header parsing (in incremental build mode)
<m> can be: native (uses compiler to extract
dependencies), full (default, uses simple text parser on
the whole file), dep, off
-rebuild rebuild (in incremental build mode)
-rebuildall rebuild with sub-projects (in incremental build mode)
-clean clean (in incremental build mode)
-workdir=<dir> working directory
(default: .hbmk/plat/comp in incremental mode, OS temp
directory otherwise)

-hbl[=<output>] output .hbl filename. %{hb_lng} macro is accepted in
filename
-lng=<languages> list of languages to be replaced in %{hb_lng} macros in
.pot/.po filenames and output .hbl/.po filenames. Comma
separared list:
-lng=en,hu-HU,de
-po=<output> create/update .po file from source. Merge it with
previous .po file of the same name
-minipo[-] do (not) add Harbour version number and source file
reference to .po (default: add them)
-rebuildpo recreate .po file, thus removing all obsolete entries in
it

-hbx=[<.ch>] Create Harbour header (in .hbx format) with all external
symbols. Empty parameter will disable it.
-autohbc=<.ch:.hbc> <.ch> is a header file name. <.hbc> is a .hbc filename to
be automatically included in case the header is found in
any of the compiled sources. (EXPERIMENTAL)

-deppkgname=<d:n> <d> is the name of the dependency. <n> name of the
package depedency. Can be specified multiple times.
-depkeyhead=<d:h> <d> is the name of the dependency. <h> is the key header
(.h) of the package dependency. Multiple alternative
headers can be specified.
-depoptional=<d:f> <d> is the name of the dependency. <f> can be ‘yes’ or
‘no’, specifies whether the dependency is optional.
Default: no
-depcontrol=<d:v> <d> is the name of the dependency. <v> is a value that
controls how detection is done. Accepted values: no, yes,
force, nolocal, local. Default: content of envvar
HBMK_WITH_<d>
-depincroot=<d:r> <d> is the name of the dependency. Set <r> as root
directory for paths specified in -depincpath options.
-depincpath=<d:i> <d> is the name of the dependency. Add <i> to the header
detection path list.
-depincpathlocal= <d> is the name of the dependency. Add <i> to the header
<d:i> detection path list, where <i> is pointing to a directory
local to the project and containing an embedded (or
locally hosted) dependency.
-depimplibs=<d:dll> <d> is the name of the dependency. Add <dll> to the
import library source list.
-depimplibd=<d:lib> <d> is the name of the dependency. Set generated import
library name to <lib>

-plugin=<filename> add plugin. <filename> can be: .hb, .prg, .hrb
-pi=<filename> pass input file to plugins
-pflag=<f> pass single flag to plugins

Options below are available on command line only:

-target=<script> specify a new build target. <script> can be .prg (or no
extension) or .hbp file. Note that .hbp files are
automatically considered as separate targets.

-hbrun run target
-hbraw stop after running Harbour compiler
-hbcmp|-clipper stop after creating the object files
create link/copy hbmk2 to hbcmp/clipper for the same
effect
-hbcc accept raw C flags
create link/copy hbmk2 to hbcc for the same effect
-hblnk accept raw linker flags
-autohbm[-] enable (or disable) processing of hbmk.hbm in current
directory (default: yes)
-hb10 enable Harbour 1.0.x compatibility mode
-hb20 enable Harbour 2.0.x compatibility mode
-xhb enable xhb mode
-hbc enable pure C mode
-rtlink
-blinker
-exospace emulate Clipper compatible linker behavior
create link/copy hbmk2 to rtlink/blinker/exospace for the
same effect

-hbreg[=global] register Harbour Script (.hb) with hbmk2 (Windows only)
-hbunreg[=global] unregister Harbour Script (.hb) from hbmk2 (Windows only)

-hbmake=<file> convert hbmake project <file> to .hbp file
-xbp=<file> convert .xbp (xbuild) project <file> to .hbp file
-xhp=<file> convert .xhp (xMate) project <file> to .hbp file

–hbdirbin output Harbour binary directory
–hbdirdyn output Harbour dynamic library directory
–hbdirlib output Harbour static library directory
–hbdirinc output Harbour header directory
–hbinfo[=nested] output Harbour build information. Output is in JSON
format. The included paths always contain forward
slashes. Each JSON block is followed by an 0x0A byte.

-plat=<platform> force/select target platform (default: autodetection)
-comp=<compiler> force/select C compiler (default: autodetection)
Special value:
– bld: use original build settings (default on *nix)
-cpu=<cpu> select target CPU. (EXPERIMENTAL)
-build=<name> use a specific build name
-lang=<lang> override default language. Similar to HB_LANG envvar.
-width=<n> set output width to <n> characters (0=unlimited).
-shl show sub-project level in output lines
–version display version header only

Notes:
– <script> can be:
<@script> or <script.hbm>: command line options in file
<script.hbp>: command line options in file, it also marks a new target if
specified on the command line
<script.hbc>: package configuration file
– Multiple -l, -L, -i and <script> parameters are accepted.
– Regular Harbour compiler options are also accepted.
(see them with -harbourhelp option)
– hbmk.hbc option file in hbmk2 directory is always processed if it exists.
On *nix platforms ~/.harbour, /etc/harbour, <base>/etc/harbour, <base>/etc
are checked (in that order) before the hbmk2 directory.
– hbmk.hbm make script in current directory is always processed if it exists.
– .hbc options (they should come in separate lines): libs=[<libname[s]>],
hbcs=[<.hbc file[s]>], gt=[gtname], syslibs=[<libname[s]>],
frameworks=[<framework[s]>], prgflags=[Harbour flags], cflags=[C compiler
flags], resflags=[resource compiler flags], ldflags=[linker flags],
pflags=[flags for plugins], libpaths=[paths], sources=

,
headers=[Harbour header files], psources=

,
incpaths=[paths], requests=[func], instfiles=[files], instpaths=[paths],
autohbcs=[<.ch>:<.hbc>], plugins=[plugins],
gui|mt|pic|shared|nulrdd|nodefgt|debug|opt|map|strip|hbcppmm|winuni|implib|
run|inc=[yes|no], cpp=[yes|no|def], warn=[max|yes|low|no|def],
compr=[yes|no|min|max], head=[off|full|native|dep], skip=<reason>,
stop=<reason>, echo=<text>
Lines starting with ‘#’ char are ignored
– Platform filters are accepted in each .hbc line and with several options.
Filter format: {[!][<plat>|<comp>|<cpu>|<keyword>]}. Filters can be
combined using ‘&’, ‘|’ operators and grouped by parentheses. Ex.: {win},
{gcc}, {linux|darwin}, {win&!pocc}, {(win|linux)&!watcom}, {unix&mt&gui},
-cflag={win}-DMYDEF, -stop{dos}, -stop{!allwin},
{allwin|allmsvc|allgcc|allmingw|allicc|allbcc|allpocc|unix},
{x86|x86_64|ia64|arm|mips|sh},
{debug|nodebug|gui|std|mt|st|shared|static|winuni|winansi|xhb}
– Certain .hbc lines (libs=, hbcs=, prgflags=, cflags=, ldflags=, libpaths=,
instfiles=, instpaths=, echo=) and corresponding command line parameters
will accept macros: ${hb_root}, ${hb_dir}, ${hb_dirname}, ${hb_name},
${hb_self}, ${hb_curdir}, ${hb_tempdir}, ${hb_targetname},
${hb_targettype}, ${hb_plat}, ${hb_comp}, ${hb_comp_ver}, ${hb_build},
${hb_cpu}, ${hb_work}, ${hb_workdynsub}, ${hb_dynprefix}, ${hb_dynsuffix},
${hb_dynext}, ${hb_ver}, ${hb_verstr}, ${hb_major}, ${hb_minor},
${hb_release}, ${hb_status}, ${hb_revision}, ${hb_host_plat},
${hb_host_plat_unix}, ${hb_bin}, ${hb_lib}, ${hb_lib3rd}, ${hb_dyn},
${hb_inc}, ${hb_first}, ${hb_outputdir}, ${hb_outputname}, ${hb_level},
${<envvar>}. libpaths= also accepts %{hb_name} which translates to the name
of the .hbc file under search.
– Options accepting macros also support command substitution. Enclose command
inside “, and, if the command contains space, also enclose in double
quotes. F.e. “-cflag=`wx-config –cflags`”, or
ldflags={unix&gcc}”`wx-config –libs`”.
– Libraries and object files built with/for CA-Cl*pper won’t work with any
supported platform/compiler.
– Defaults and feature support may vary by platform/compiler.
– Options can also be specified in environment variable HBMK_OPTIONS
– .hb or .hrb file passed as first parameter will be run as Harbour script.
Note, for Harbour scripts, the codepage is set to UTF-8 by default.
– . (dot) passed as first parameter will enter the interactive Harbour shell.

Supported <comp> values for each supported <plat> value:
– linux : gcc, clang, icc, watcom, sunpro, open64
– darwin : gcc, clang, icc
– win : mingw, msvc, clang, bcc, bcc64, watcom, icc, pocc, xcc,
mingw64, msvc64, msvcia64, iccia64, pocc64
– wce : mingwarm, mingw, msvcarm, poccarm
– os2 : gcc, gccomf, watcom
– dos : djgpp, watcom
– bsd : gcc, clang, pcc
– hpux : gcc
– beos : gcc
– qnx : gcc
– android : gcc, gccarm
– vxworks : gcc, diab
– symbian : gcc
– cygwin : gcc
– minix : gcc, clang, ack
– aix : gcc
– sunos : gcc, sunpro

For further info :

 

 

 

How I can migrate ?

How I can migrate DOS  to Windows ?

By principle, Harbour  can compile every Clipper Language program; and Harbour applications can run under Windows ( besides many other platforms ) with no problem. This is one of main goals of Harbour project.

Furthermore, Harbour compiled executables will be 32 bit, not 16 😉

Maybe your application include many ( or too many ) .prg file; no problem; (almost) no modification required on your source code; nor extra scripts for compile. ( Thanks to Viktor Szakáts for really wonderful MAKE utility : HBMK2. )

Only  care is :  if “main” prg of your application doesn’t have a “main” module , add one PROCEDURE or  FUNCTION statement to most top of your “main” .prg.

PROC MAIN

That’s all 🙂

You can build your application via HMG by a .bat file (or direct command in the DOS box) such as :

CALL C:\hmg\build.bat /c <mainPrgName>

or via Harbour:

SET PATH=C:\harbour\bin;C:\hmg\mingw\bin;%PATH%
hbmk2 <mainPrgName> -RUN

or the simplest way :

    C:\harbour\bin hbmk2 <mainPrgName> -RUN

( hbmk2 will find all necessary  paths / files 🙂 )

Of course, you need supply name of your main .prg file in place of <mainPrgName>. You may also want to  change  “C:\hmg” and “C:\hmg\harbour” according to your install configuration.

Please be careful about PATH command : If you call the the .bat file from Windows explorer, no problem. If you are working on command (DOS) box, calling repetitively .bat file may cause problem by grown of PATH . In this case you may build a separate .bat for only PATH command and call it only once at beginning of DOS session.

If you want convert a text (console) based application to GUI ( Graphical User Interface ) based Windows application, this is another thing and there isn’t any automatic way for this.  You have need first a GUI library can be used into Harbour. After selecting which library is convenient to your needs and learning  this library, you may begin planing steps of converting process. Writing your application from scratch may be longest but most secure way.

There are links to some articles  about migration in the Links page; looking at this will be useful.

Milestones


Neither possible to know nor remember everybody who participated this great work.

These are only the biggest milestones, great men who succeed great jobs.

C. Wayne Ratliff

Designed and programmed the first successful DBMS for personal computers, dBASE II; originally named Vulcan. Renamed dBASE II and published in 1981.  It was not only a relational database management system (RDBMS), but also was an interpreted language and would quickly spawn the “xBbase” industry.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Brett Oliver, Jim Warner, Brian Russell, Richard McConnell  …

Main architects and primary developers of Clipper and founders of Nantucket Corporation.  It was 1984 when Clipper was born. Look at here for a tale.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Tom Rettig  ( 1941-1996 )

A major guru in the dBASE, Clipper, whole xBase community. 

Small in stature, but big in heart, a friend in the truest sense. 

More about Tom Rettig.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Antonio Linares

Initiator and one of main developers of Harbour.

The starter of Harbour.

The great man who started the big engines!

He is here.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Phil Barnett

The biggest Clipper fan! 

Author of most useful Clipper utilities,  Harbour Manager, keeper of pieces and parts for years.

He and his famous and largest Clipper repository is here (archive)

Addendum:

A “last” note about Phil.

R.I.P.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(Le Roy) Roberto Lopez

Founder, builder and developer of HMG, Harbour MiniGUI. 

The great man who disclose blocked doors and roads!

He is here.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Viktor Szakáts,  Przemysław Czerpak, Pritpal Bedi, …

Today Habour development is leading by Viktor Szakáts with huge collaborations and leading many components of core and contribs by Przemysław Czerpak. Some components are developed by Pritpal Bedi. Others members participate the project by sending changes to the Sourceforge SVN repository.  As 2011 Harbour development is keeping vibrant activity

They are here.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What is Harbour ?

Harbour is a modern computer programming language. It is a Clipper-compatible compiler which is cross-platform, running on many operating systems (DOSMicrosoft WindowsLinuxUnix variants, several BSD descendants, Mac OS XMINIX 3Windows CEPocket PCSymbianiPhoneQNXVxWorksOS/2/eComStationBeOS/HaikuAIX) using the same source code and databases.

Although it is a powerful general-purpose programming language, it was primarily used to create database/business programs. Harbour have been actively maintained looking for diversity keeping backward-compatible with Clipper style. It has undergone many changes and revisions and regain widely popularity amongst programmers in 1980s and 1990s

The open source Harbour license is similar to the GNU General Public License, with an exception supporting proprietary applications, so proprietary applications can be produced with Harbour and distributed..

Paradigm(s) multi-paradigmimperativefunctional,object-orientedreflective
Appeared in 1999
Designed by Antonio Linares
Developer Viktor Szakáts and community
Stable release 3.0.0 (17 July 2011)
Preview release 3.1.x available from SVN
Typing discipline optionally duckdynamicsafe, partially strong
Dialects Clipper, Xbase ++, Flagship, FoxPro, xHarbour
Influenced by dBase, Clipper
Influenced xHarbour
OS Cross-platform
License Open source GPL Compatible
Usual filename extensions .prg, .ch, .hbs, .dbf
Website http://www.harbour-project.org/

History

The idea of a free software Clipper compiler has been floating around for a long time and the subject has often cropped up in discussion on comp.lang.clipper. Antonio Linares founded the Harbour project and the implementation was started.

Sailing the Clipper ship to a Harbour port. Clipper is a type of ship. Harbour is a synonym to port (where ship docks) Harbour is out port to the Clipper language.

On 2009 Harbour had a huge make over on its design promoted mainly by Viktor Szakáts and Przemyslaw Czerpak

 Database support

Harbour extends the Clipper Replaceable Database Drivers (RDD) approach. It offers multiple RDDs such as DBF, DBFNTX, DBFCDX, DBFDBT and DBFFPT. In Harbour multiple RDDs can be used in a single application, and new logical RDDs can be defined from combination of other RDDs. The RDD architecture allows for inheritance, so that a given RDD may extend the functionality of other existing RDD(s). Third-party RDDs, like RDDSQL, RDDSIX, RMDBFCDX, Advantage Database Server, and Mediator exemplify some of the RDD architecture features. DBFNTX implementation has almost same functionality of DBFCDX and RDDSIX. NETIO and LetoDB provide remote access over TCP protocol Harbour also offers ODBC support by means of an OOP syntax, and ADO support by means of OLEMySQLPostgreSQLSQLiteFirebirdOracle are examples of databases which Harbour can connect.

xBase technologies often is confused with a RDBMS software. Although this is true, xBase is more than a simple database system as the same time xBase languages using purely DBF can not provide full concept of a real RDBMS

Programming philosophy

Unlike Java which is intended to be write once, run anywhere, Harbour aims to be write once, compile anywhere. As the same compiler is available for all of the above operating systems, there is no need for recoding to produce identical products for different platforms, except when operating system dependent features are used. Cross-compiling is supported with MinGW32. Under Microsoft Windows, Harbour is more stable but less well-documented than Clipper, but has multi-platform capability and is more transparent, customizable and can run from a USB flash drive.

Under Linux and Windows Mobile, Clipper source code can be compiled with Harbour with very little adaptation. Most software originally written to run on Xbase ++, Flagship, FoxPro, xHarbour and others dialects can be compiled with Harbor with some adaptation. As 2010 many efforts have been made to turn the transition from other xBase dialects easier.

Harbour can use the following C compilers, amongothers: GCCMinGWClangICCMicrosoft Visual C++ (6.0+), Borland C++Watcom CPelles C and Sun Studio.

Harbour can make use of multiple Graphic Terminal emulations, including console drivers, and Hybrid Console/GUIs, such as GTWvt, and GTWvg.

Harbour supports external GUIs, free (e.g. HWGui, MiniGUI and Qt) and commercial (e.g. FiveWin, Xailer). HBQt is a library provinding bindings to Qt. HBIDE application included in official distribution and SVN repository is a sample of HBQt potencial.

Harbour is 100% Clipper-compatible and supports many language syntax extensions including greatly extended run-time libraries such as OLE, BlatOpenSSLFreeImage,GD, TIP, Tpathy, PCRE, HbZip (zlib and bzip2), cURLCairo, its own implementation of CA-Tools and NanFor libraries and many others. Harbour has an active development community and extensive third party support.

Any xBase language provides a very productive way to build business and data intensive applications. Harbour is not an exception.

Macro Operator (runtime compiler)

One of the most powerful features of xBase languages is the Macro Operator ‘&’. Harbour’s implementation of the Macro Operator allows for runtime compilation of any valid Harbour expression. Such a compiled expression may be used as a VALUE, i.e. the right side of an assignment (rvalue), but more interestingly, such a compiled expression may be used to resolve the left side (lvalue) of an assignment, i.e. PRIVATE, or PUBLIC variables, or a database FIELD.

Additionally, the Macro Operator may compile and execute function calls, complete assignments, or even list of arguments, and the result of the macro may be used to resolve any of the above contexts in the compiled application. In other words, any Harbour application may be extended and modified at runtime to compile and execute additional code on-demand.

Latest Macro compiler can compile any valid Harbour code including code to pre-process before compile.

Syntax:

 &( ... )

The text value of the expression ‘…’ will be compiled, and the value resulting from the execution of the compiled code is the result.

 &SomeId

is the short form for &( SomeId ).

 &SomeId.postfix

is the short form of &( SomeId + “postfix” ).

Object Oriented Programming

Programming in an OOP style is a broader issue than a specific library or a specific interface, but OOP programming is something many Clipper programmers have come to expect. CA-Clipper 5.2 and especially 5.3 added a number of base classes, and a matching OOP syntax. Libraries such as Class(y), Fivewin, Clip4Win, and TopClass provide additional OOP functionality.

Harbour has OOP extensions with full support for classes including inheritance, based on Class(y) syntax. OOP syntax in Harbour is very similar to that of earlier Clipper class libraries so it should be possible to maintain legacy Clipper code with minimal changes.

Syntax and semantics

Harbour as every xBase language is case insensitive and can optionally accept keywords written just by first four characters

Built-in data types

Harbour has 6 scalar types : NilStringDateLogical, NumberPointer, and 4 complex types: ArrayObjectCodeBlock, and Hash. A scalar holds a single value, such as a string, number, or reference to any other type. Arrays are ordered lists of scalars or complex types, indexed by number, starting at 1. Hashes, or associative arrays, are unordered collections of any type values indexed by their associated key, which may be of any scalar or complex type.

Literal (static) representation of scalar types:

  • Nil: NIL
  • String: “hello”, ‘hello’, [hello]
  • Date: 0d20100405
  • Logical: .T., .F.
  • Number: 1, 1.1, −1, 0xFF

Complex Types may also be represent as literal values:

  • Array: { “String””, 1, { “Nested Array” }, .T., FunctionCall(), @FunctionPointer() }
  • CodeBlock: { |Arg1, ArgN| Arg1 := ArgN + OuterVar + FunctionCall() }
  • Hash: { “Name” => “John”, 1 => “Numeric key”, { “Nested” => “Hash” } }

Hashes may use any type including other Hashes as the Key for any element. Hashes and Arrays may contain any type as the Value of any member, including nesting arrays, and Hashes.

Codeblocks may have references to Variables of the Procedure/Function>method in which it was defined. Such Codeblocks may be returned as a value, or by means of an argument passed BY REFERENCE, in such case the Codeblock will “outlive” the routine in which it was defined, and any variables it references, will be a DETACHED variable.

Detached variables will maintain their value for as long as a Codeblock referencing them still exists. Such values will be shared with any other Codeblock which may have access to those same variables. If the Codeblock did not outlive its containing routine, and will be evaluated within the lifetime of the routine in which it is defined, changes to its Detached Variables(s) by means of its evaluation, will be reflected back at its parent routine.

Codeblocks can be evaluated any number of times, by means of the Eval( BlockExp ) function.

Variables

All types can be assigned to named variables. Named variable identifiers are 1 to 63 characters long, start with [A-Z|_] and further consist of the characters [A-Z|0–9|_] up to a maximum of 63 characters. Named variables are not case sensitive.

Variables have one of the following scopes:

  • LOCAL: Visible only within the routine which declared it. Value is lost upon exit of the routine.
  • STATIC: Visible only within the routine which declared it. Value is preserved for subsequent invocations of the routine. If a STATIC variable is declared before any Procedure/Function/Method is defined, it has a MODULE scope, and is visible within any routine defined within that same source file, it will maintain its life for the duration of the application lifetime.
  • PRIVATE: Visible within the routine which declared it, and all routines called by that routine.
  • PUBLIC: Visible by all routines in the same application.

LOCAL and STATIC are resolved at compile time, and thus are much faster than PRIVATE and PUBLIC variables which are dynamic entities accessed by means of a runtime Symbol table. For this same reason, LOCAL and STATIC variables are not exposed to the Macro compiler, and any macro code which attempts to reference them will generate a runtime error.

Due to the dynamic nature of PRIVATE and PUBLIC variables, they can be created and destroyed at runtime, can be accessed and modified by means of runtime macros, and can be accessed and modified by Codeblocks created on the fly.

Control structures

The basic control structures include all of the standard dBase, and Clipper control structures as well as additional ones inspired by the C or Java programming languages:

Loops

[DO] WHILE ConditionExp
   ...
   [LOOP]
   [EXIT]
END[DO]

FOR Var := InitExp TO EndExp [STEP StepExp]
   ...
   [LOOP]
   [EXIT]
NEXT
FOR EACH Var IN CollectionExp
   ...
   [HB_EnumIndex()]
   [LOOP]
   [EXIT]
NEXT
  • The  is a sequence of one of more Harbour statements, and square bracketes [] denote optional syntax.
  • The HB_EnumIndex() may be optionally used to retrieve the current iteration index (1 based).
  • The LOOP statement restarts the current iteration of the enclosing loop structure, and if the enclosing loop is a FOR or FOR EACH loop, it increases the iterator, moving to the next iteration of the loop.
  • The EXIT statement immediately terminates execution of the enclosing loop structure.
  • The NEXT statement closes the control structure and moves to the next iteration of loop structure.

In the FOR statement, the assignment expression is evaluated prior to the first loop iteration. The TO expression is evaluated and compared against the value of the control variable, prior to each iteration, and the loop is terminated if it evaluates to a numeric value greater than the numeric value of the control variable. The optional STEP expression is evaluated after each iteration, prior to deciding whether to perform the next iteration.

In FOR EACH, the Var variable will have the value (scalar, or complex) of the respective element in the collection value. The collection expression, may be an Array (of any type or combinations of types), an Hash Table, or an Object type.

IF statements

IF CondExp
   ...
[ELSEIF] CondExp
   ...
[ELSE]
   ...
END[IF]

 represents 0 or more statement(s). The condition expression(s) has to evaluate to a LOGICAL value.

SWITCH statements

Harbour supports a SWITCH construct inspired by the C implementation of switch().

SWITCH SwitchExp
   CASE LiteralExp
      ...
      [EXIT]
   [CASE LiteralExp]
      ...
      [EXIT]

   [DEFAULT]
      ...
END
  • The LiteralExp must be a compiled time resolvable numeric expression, and may involve operators, as long as such operators involve compile time static value.
  • The EXIT optional statement is the equivalent of the C statement break, and if present, execution of the SWITCH structure will end when the EXIT statement is reached, otherwise it will continue with the first statement below the next CASE statement (fall through).

BEGIN SEQUENCE statements

BEGIN SEQUENCE
   ...
   [BREAK]
   [Break([Exp])]
RECOVER [USING Var]
   ...
END[SEQUENCE]

or:

BEGIN SEQUENCE
   ...
   [BREAK]
   [Break()]
END[SEQUENCE]

The BEGIN SEQUENCE structure allows for a well behaved abortion of any sequence, even when crossing nested procedures/functions. This means that a called procedure/function, may issue a BREAK statement, or a Break() expression, to force unfolding of any nested procedure/functions, all the way back to the first outer BEGIN SEQUENCE structure, either after its respective END statement, or a RECOVER clause if present. The Break statement may optionally pass any type of expression, which may be accepted by the RECOVER statement to allow further recovery handing.

Additionally the Harbour Error Object supports canDefaultcanRetry and canSubstitute properties, which allows error handlers to perform some preparations, and then request a Retry Operation, a Resume, or return a Value to replace the expression triggering the error condition.

Alternatively TRY [CATCH] [FINALLY] statements are available on xHB library working like the SEQUENCE construct.

Procedures/Functions

[STATIC] PROCEDURE SomeProcedureName
[STATIC] PROCEDURE SomeProcedureName()
[STATIC] PROCEDURE SomeProcedureName( Param1' [, ParamsN] )
INIT PROCEDURE SomeProcedureName
EXIT PROCEDURE SomeProcedureName
[STATIC] FUNCTION SomeProcedureName
[STATIC] FUNCTION SomeProcedureName()
[STATIC] FUNCTION SomeProcedureName( Param1' [, ParamsN] )

Procedures/Functions in Harbour can be specified with the keywords PROCEDURE, or FUNCTION. Naming rules are same as those for Variables (up to 63 characters non case sensitive). Both Procedures and Functions may be qualified by the scope qualifier STATIC to restrict their usage to the scope of the module where defined.

The INIT or EXIT optional qualifiers, will flag the procedure to be automatically invoked just before calling the application startup procedure, or just after quitting the application, respectively. Parameters passed to a procedure/function appear in the subroutine as local variables, and may accept any type, including references.

Changes to argument variables are not reflected in respective variables passed by the calling procedure/function/method unless explicitly passed BY REFERENCE using the@ prefix.

PROCEDURE have no return value, and if used in an Expression context will produce a NIL value.

FUNCTION may return any type by means of the RETURN statement, anywhere in the body of its definition.

An example procedure definition and a function call follows:

 x := Cube( 2 )

 FUNCTION Cube( n )
 RETURN n ** 3

 Sample code The typical “hello world” program would be:

 
  ? "Hello, world!"

Or:

  QOut( "Hello, world!" )

Or:

  Alert( "Hello, world!" )

Or, enclosed in an explicit procedure:

 PROCEDURE Main()

    ? "Hello, world!"

 RETURN

 

OOP examples

 #include "hbclass.ch"

 PROCEDURE Main()

    LOCAL oPerson := Person( "Dave" )

    oPerson:Eyes := "Invalid"

    oPerson:Eyes := "Blue"

    Alert( oPerson:Describe() )
 RETURN

 CLASS Person
    DATA Name INIT ""

    METHOD New() CONSTRUCTOR

    ACCESS Eyes INLINE ::pvtEyes
    ASSIGN Eyes( x ) INLINE IIF( ValType( x ) == 'C' .AND. ;
                 x IN "Blue,Brown,Green", ::pvtEyes := x,; 
                 Alert( "Invalid value" ) )

    // Sample of IN-LINE Method definition
    INLINE METHOD Describe()
       LOCAL cDescription

       IF Empty( ::Name )
          cDescription := "I have no name yet."
       ELSE
          cDescription := "My name is: " + ::Name + ";"
       ENDIF

       IF ! Empty( ::Eyes )
          cDescription += "my eyes' color is: " + ::Eyes
       ENDIF
    ENDMETHOD

    PRIVATE:
       DATA pvtEyes
 ENDCLASS

 // Sample of normal Method definition.
 METHOD New( cName ) CLASS Person

   ::Name := cName

 RETURN Self

 

Tools

  • HBMK2 – Powerful build tool like make
  • HBDoc2 and  HBExtern – Creates documentation for Harbour
  • HPPP – Pre-processor, a powerful tool which avoids typical problems found on C language pre-processor
  • HBFormat – Formats source code written on Harbour or another dialect according defined rules
  • HBi18n – Tools to localizing text on applications
  • HBRun – Shell interpreter for Harbour. Macro compiling allows to run any valid Harbour code as it’s being compiled
  • HBIDE – Integrated Development Environment to help Harbour development and various xBase dialects

All tools are multiplatform.

Development

Today Habour development is leading by Viktor Szakáts with huge collaborations and leading many components of core and contribs by Przemysław Czerpak. HBIDE and some components, specially HBQt, are developed by Pritpal Bedi. Others members send minor changes to the Sourceforge SVN repository.  As 2010 Harbour development is keeping vibrant activity

Popularity

Although there is no way to measure popularity of Harbour or xBase, the TIOBE Programming Community Index As of June 2006 ranked Microsoft Visual FoxPro, a high profile dialect of xBase, on 12th position on programming languages popularity ranking. FoxPro/xBase ranked on 25th position As of August 2010. As of September 2010, the Clipper Usenet newsgroupscomp.lang.clipper is still active. As of August 2010 Harbour figured on 16th position on weekly downloads in compiler category and 132th position on global rank.

xHarbour comparison

xHarbour is a fork of the earlier Harbour project. xHarbour takes a more aggressive approach to implementing new features in the language, while Harbour is more conservative in its approach, aiming first of all for an exact replication of Clipper behaviour and then implementing new features and extensions as a secondary consideration. It should also be noted that Harbour is supported on a wide variety of operating systems while xHarbour only really supports MS Windows and Linux 32-bit.

The Harbour developers have attempted to document all hidden behaviour in the Clipper language and test Harbour-compiled code alongside the same code compiled with Clipper to maintain compatibility.

The Harbour developers explicitly reject extensions to the language where those extensions would break Clipper compatibility. These rejections were soften recently since the new Harbour architecture allow extensions out of the core compiler.

A detailed comparison between extensions implemented in Harbour and xHarbour can be found in SVN repository of the project on SourceForge.

As of 2009–2010, Harbour has seen a huge increase in its adoption while xHarbour decline as can be seen on his mailing list

See also

References

  1. ^ Harbour license
  2. ^ LetoDB
  3. ^ Official Harbour page
  4. ^ http://sourceforge.net/projects/harbour-project/
  5. ^ TIOBE Programming Community Index
  6. ^ SourceForge
  7. ^ About xHarbour
  8. ^ xhb-diff.txt
  9. ^ Harbour developers’ mailing list statistics
  10. ^ xHarbour developers’ mailing list statistics
  11. ^ ohloh.net Activity comparison

External links

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note : This post borrowed by curtesy of Vikipedia from here : http://en.wikipedia.org/wiki/Harbour_(software)