#!/bin/sh

# BUG:
# Symbols acquired via a doxytag file are not linked correctly when
# referenced from within a comment, though they are linked properly
# when linked from within the code itself.

# When running doxygen on App, the following warnings are generated:

# App/App.c:11: warning: explicit link request to 'Lib_variable' 
#   could not be resolved
# App/App.c:11: warning: explicit link request to 'Lib_function' 
#   could not be resolved
# App/App.c:11: warning: explicit link request to 'LIB_MACRO' 
#   could not be resolved

rm -rf doxytag_bug
mkdir -p doxytag_bug/Lib doxytag_bug/App

cat << EOF > doxytag_bug/Lib/Lib.h
/** @file */

/** Library macro. */
#define LIB_MACRO  1

/** Library variable. */
extern int Lib_variable;

/** Library function. */
void
Lib_function(void);
EOF

cat << EOF > doxytag_bug/Lib/Doxyfile
QUIET                  = YES
GENERATE_TAGFILE       = Lib.doxytag
EOF

cat << EOF > doxytag_bug/App/App.c
/** @file */

#include "Lib.h"

/** @brief Application macro. */
#define APP_MACRO   1

/** @brief Application variable. */
int App_variable;

/** @brief Main application.

    Makes use of ::Lib_variable, ::Lib_function, and ::LIB_MACRO
    (none of which are linked correctly in this comment),
    as well as ::App_variable, ::App_function, and ::APP_MACRO
    (all of which are linked correctly in this comment).

    All of the symbols are linked correctly in the code itself.
*/
void
App_function(void)
{
    Lib_function();
    Lib_variable = LIB_MACRO;

    App_function();
    App_variable = APP_MACRO;
}
EOF

cat << EOF > doxytag_bug/App/Doxyfile
QUIET                  = YES
TAGFILES               = ../Lib/Lib.doxytag=../../Lib/html
INCLUDE_PATH           = ../Lib
SOURCE_BROWSER         = YES
EOF

(cd doxytag_bug/Lib; doxygen)
(cd doxytag_bug/App; doxygen)
