Extend the makefile to generate a library and documentation with doxygen

前端 未结 2 1311
悲&欢浪女
悲&欢浪女 2021-01-15 22:27

I have implemented a binary tree program which includes the tree.c with the functions, the tree.h with the declarations of them and a main.c for testing. Also, I have a mak

2条回答
  •  时光取名叫无心
    2021-01-15 23:04

    Well, I don't really know the syntax for the doxygen command, so I'll make a generic answer:

    in your Makefile, each

    term: [dep]
        action
    

    is a target.

    So if you add something like:

    doc: $(OBJ)
        doxygen with-correct-options
    

    You will be able to generate the documentation using:

    make doc
    

    (doc being here the name of the target)

    Now, if you add:

    all: tree doc
        @echo "Generating program and doc."
    

    you will have the program and the documentation generated with simply invoking

    make
    

    In the end, there is an additional statment your Makefile could have use of: .PHONY. It's "A way to mark one of many targets as not directly producing files, and ensure their execution even if a file having the same name as the target exists". In other terms, it's to make sure doc, clean or all will always be executed even if files named doc, clean or all exist.

    Its syntax is the following:

    .PHONY: all clean doc
    

    And is usually put at the end of the Makefile.

提交回复
热议问题