# -*- coding: utf-8; indent-tabs-mode: nil; -*-

# Declare an OCaml library
LIBRARY = beluga-core
# Declare an OCaml package
PACK    = Core

# Declare the files the package will contain
FILES[] =
        abstract
        check
        common
        context
        convSigma
        subord
        coverage
        ctxsub
        debug
        error
        gensym
        id
        opsem
        parser
        pretty
        reconstruct
        store
        substitution
        syntax
        trail
        token
        unify
        whnf
        monitor


# Declare one pseudo target for the package and one for the files it
# contains
.PHONY: lexer src files pack

.DEFAULT: src

clean:
        rm $(filter-proper-targets $(ls R, .))
        rm $(filter %.omc,         $(ls R, .))

src: lexer files pack $(OCamlLibrary $(LIBRARY), $(PACK))

if $(NATIVE_ENABLED)
    pack: $(OCamlPackage $(PACK), $(FILES) lexer)
else
    pack: $(QuietOCamlPackage $(PACK), $(FILES) lexer)

# **NOTE** Because of the way scoping for OCAMLFLAGS works, the pack
# target must come _BEFORE_ the files target, otherwise pack will be
# passed the -for-pack flag as well, which is not what we want

# Use the -for-pack flag for compiling the individual modules
OCAMLFLAGS += -for-pack $(PACK)
files: $(addsuffixes $(if $(BYTE_ENABLED), .cmo) $(if $(NATIVE_ENABLED), .cmx), $(FILES))

# Turn off unused variable warning only for the lexer; needed for
# dummy variables created by ulex / camlp4
OCAMLFLAGS += -w z
lexer: $(addsuffixes $(if $(BYTE_ENABLED), .cmo) $(if $(NATIVE_ENABLED), .cmx), lexer)
