OMakefile事始め

omakeは(g)makeに比べてデフォルトのコンパイルのルールとか少ない(CとOCamlTexだけ?)。なのでghdlを使ってvhdlを書いてるとき用のルールを作ってみることにした。基本的にAdditional build examplesのHandling new languagesだけを見ればルールは書ける。
http://omake.metaprl.org/manual/omake-build-examples.html#toc14

んでできたのがこれ。

VHDLC = ghdl
INCLUDES[] = 

#VHDL_FLAGS = "--ieee=synopsys"
VHDL_FLAGS = 

%.o: %.vhd
    $(VHDLC) -a $(VHDL_FLAGS) $<
# Optional link options
VHDL_LINK_FLAGS =

# The function that defines how to build a .dog program
VHDLProgram(program, files) =
#Add the suffixes
    file_names = $(addsuffix .o, $(files))
#   prog_name = $(addsuffix .dog, $(files))
    prog_name = $(program)
# The build rule
    $(prog_name): $(file_names)
        $(VHDLC) -e $(VHDL_FLAGS) $(VHDL_LINK_FLAGS)  $@
# Return the program name
    value $(prog_name)


# Build a rover.dog program from the source
# files neko.cat and chat.cat.
# Compile it by default.
.DEFAULT: $(VHDLProgram bcd_counter_drive, bcd_counter bcd_counter_drive)
deps =

.SCANNER: %.o: %.vhd
    section
# Scan the file
        deps[] =
        awk($<)
        case $'entity|component'
            deps[] += $2
            export
# Remove duplicates, and find the files in the include path
    deps = $(find-in-path $(INCLUDES), $(set $(deps)))
# Print the dependencies
    println($"$@: $(deps)")

ただ例のままだと.SCANNERでdepsが定義されてるのに定義されてないといわれるので外にdepsを定義した。正しい対策かどうかは知らない。あとシンタックス・ハイライトはmakeにしたけどいい感じに見えてるな。
しかし便利すぎて効率上がるな、こりゃ。