#
# If you add a new variable to this file (mk/make_config),
# make sure to also add a default value to mk/defaults.
#

#
# Function to generate the config file
#
MakeConfig(CONFIG_FILE) =
    #
    # If possible, express PREFIX subdirs via $(PREFIX)/...
    #
    if $(equal $(BINDIR), $(PREFIX)/bin)
        BINDIR = $'$(PREFIX)/bin'
        export

    if $(equal $(LIBDIR), $(PREFIX)/lib)
        LIBDIR = $'$(PREFIX)/lib'
        export

    if $(equal $(MANDIR), $(PREFIX)/man)
        MANDIR = $'$(PREFIX)/man'
        export

    CONFIG = $"""# Main OMake configuration file.

#
# This file ($(CONFIG_FILE)) is generated by omake using mk/make_config.
# If you want to change anything except for the variable values,
# put it into $(CONFIG_FILE).local.
#

#
# Where is the install location?  OMake installs files into the
# following directories.
#    BINDIR: program executables
#    LIBDIR: omake standard library
#    MANDIR: documentation
#
PREFIX = $$'$(PREFIX)'
BINDIR = $$"$(BINDIR)"
LIBDIR = $$"$(LIBDIR)"
MANDIR = $$"$(MANDIR)"

#
# What C compiler do you want to use?
# By default, the C compiler is "cc".
# Many Unix users will prefer "gcc".
#
CC = $(CC)
CFLAGS = $(CFLAGS)

#
# Do you want native and/or byte code?
# By default, we make native code.  If you want
# byte code, set it to true.
#
NATIVE_ENABLED = $(NATIVE_ENABLED)
BYTE_ENABLED = $(BYTE_ENABLED)

#
# Do you want to enable native-code profiling?
# Unless you really care, you should leave this disabled.
#
NATIVE_PROFILE = $(NATIVE_PROFILE)
"""$(if $(READLINE_AVAILABLE), $"""
#
# Do you want to include readline for the interactive shell?
# Your system appears to support readline, so this is enabled by default.
#
READLINE_ENABLED = $(READLINE_ENABLED)
""", $"""
#
# Your system does not appear to have the readline library development files
# installed, readline support in the interactive shell will not be available.
#
""")$(if $(FAM_AVAILABLE), $"""
#
# Do you want to include filesystem monitoring? This will enable the
# omake -P and -p options, which are quite useful.
# Your system appears to support this functionality (via FAM, Gamin, kqueue, or Win32).
#
FAM_ENABLED = $(FAM_ENABLED)
""", $"""
#
# Your system does not appear to support filesystem monitoring (either FAM library,
# or Gamin library, or Kqueue event interface). Omake's -P and -p options will not
# be available.
#
""")

    # Save the text in the output file
    exists = $(file-exists $(CONFIG_FILE))
    if $(exists)
        eprintln(Updating the $(CONFIG_FILE) file.)
    fprint($(CONFIG_FILE), $(CONFIG))
