--- /dev/null
+#!/bin/bash\r
+# Functions for the gendox script\r
+# \r
+# Gef, Aug 2001\r
+\r
+#------------------------------------------------------------------------\r
+# Set the doxygen output language from the system locale\r
+#------------------------------------------------------------------------\r
+get_language() {\r
+ if [ -n "$LANG" ] ; then\r
+ local LANG=`locale | grep LANG | cut -d= -f2`;\r
+ fi\r
+ case "$LANG" in\r
+ czech)\r
+ OUPUTLANGUAGE="Czech";\r
+ ;;\r
+ german)\r
+ OUPUTLANGUAGE="German";\r
+ ;;\r
+ spanish)\r
+ OUPUTLANGUAGE="Spanish";\r
+ ;;\r
+ finnish)\r
+ OUPUTLANGUAGE="Finnish";\r
+ ;;\r
+ french)\r
+ OUPUTLANGUAGE="French";\r
+ ;;\r
+ italian)\r
+ OUPUTLANGUAGE="Italian";\r
+ ;;\r
+ japanese*)\r
+ OUPUTLANGUAGE="Japanese";\r
+ ;;\r
+ dutch)\r
+ OUPUTLANGUAGE="Dutch";\r
+ ;;\r
+ swedish)\r
+ OUPUTLANGUAGE="Swedish";\r
+ ;;\r
+ *)\r
+ OUPUTLANGUAGE="English";\r
+ ;;\r
+ esac\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Output usage info & output help\r
+#------------------------------------------------------------------------\r
+output_usage() {\r
+ echo -e "Usage: $0 [<target(s)>] [-o <output_directory>]";\r
+ return;\r
+}\r
+\r
+output_help() {\r
+ output_usage;\r
+ echo -e "\nOptions:";\r
+ echo -e " [<target(s)>]";\r
+ echo -e " This is an optional parameter that specifies the directory, or multiple";\r
+ echo -e " directories from which to generate the documentation.";\r
+ echo -e "";\r
+ echo -e " [-o <output_directory>]";\r
+ echo -e " An optional parameter that specifies the output directory in which";\r
+ echo -e " to save the generated documentation.";\r
+ echo -e "";\r
+ echo -e " -q or --quiet";\r
+ echo -e " Prevents the output of status information"\r
+ echo -e ""\r
+ echo -e " --help, or -h";\r
+ echo -e " Displays this information";\r
+ echo -e ""\r
+ echo -e " -q or --quiet";\r
+ echo -e " Prevents the output of status information"\r
+ echo -e ""\r
+ echo -e " -k or --kill";\r
+ echo -e " kills running doxygen pids."\r
+ echo -e ""\r
+ echo -e "* Further information on using this script, can be found in README.doxygen";\r
+ echo -e "* in the current directory.";\r
+ \r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Set the target to what was passed on the command line\r
+#------------------------------------------------------------------------\r
+parse_commandline() {\r
+ # todo:\r
+ # need to add the ability to check for an auto gen'd version\r
+ # used for automatically generating new documentation for each commit\r
+ # to the cvs server\r
+\r
+ # funky bash shell array\r
+ declare -a OPTLIST[$#];\r
+\r
+ if [ $OPTCOUNT == 0 ] ; then\r
+ # No options on the command line so set the target list to the core\r
+ TARGETCOUNT=0;\r
+ OUTPUTDIR="../$(basename `pwd`)-doxygen";\r
+ else\r
+ # put all the command line options into an array\r
+ for f in $COMLINE ; do\r
+ OPTLIST[$COUNTER]="$f";\r
+ let COUNTER++;\r
+ done\r
+ \r
+ for (( COUNTER=0 ; $COUNTER < $OPTCOUNT; $[COUNTER++] )) ; do\r
+ if [ "${OPTLIST[$COUNTER]}" == "--help" ] ; then\r
+ # output usage information\r
+ output_help;\r
+ RETVAL=1;\r
+ return;\r
+ elif [ "${OPTLIST[$COUNTER]}" == "-h" ] ; then\r
+ # output usage information\r
+ output_help;\r
+ RETVAL=1;\r
+ return;\r
+ fi\r
+ \r
+ case ${OPTLIST[$COUNTER]} in\r
+ -q)\r
+ QUIETMODE=1;\r
+ ;;\r
+ --quiet)\r
+ QUIETMODE=1;\r
+ ;;\r
+ -k)\r
+ KILLON=1;\r
+ ;;\r
+ --kill)\r
+ KILLON=1;\r
+ ;;\r
+ -o)\r
+ # look for the -o switch, and get the next command line option as the output dir\r
+ if [ -z ${OPTLIST[$COUNTER + 1]} ] ; then\r
+ [ $QUIETMODE -gt 0 ] || echo -e " ** Output switch used, but no output dir passed...";\r
+ [ $QUIETMODE -gt 0 ] || echo -e " ** Setting default output dir.";\r
+ else\r
+ let COUNTER++;\r
+ OUTPUTDIR=${OPTLIST[$COUNTER]};\r
+ fi\r
+ break;\r
+ ;;\r
+ **)\r
+ # If the command line option is anything other that -o then assume it's a target \r
+ # Check to make sure the target exists first...\r
+ if [ -d ${OPTLIST[$COUNTER]} ] ; then\r
+ TARGETLIST[$COUNTER]=${OPTLIST[$COUNTER]};\r
+ else\r
+ output_usage;\r
+ echo -e " ** Error: Non-existent directory specified as a target.\nExiting.";\r
+ RETVAL=1;\r
+ return;\r
+ fi\r
+ let TARGETCOUNT++;\r
+ ;;\r
+ esac\r
+ done\r
+\r
+ fi # if [ $OPTCOUNT == 0 ] ;\r
+\r
+ if [ $TARGETCOUNT == 0 ] ; then\r
+ TARGETCOUNT=4;\r
+ TARGETLIST[0]="include";\r
+ TARGETLIST[1]="libs";\r
+ TARGETLIST[2]="radiant";\r
+ TARGETLIST[3]="plugins";\r
+ # Gef: outputdir for default core when no targets are passed on the command line\r
+ # TTimo problem still there, if -o used on command line, don't override\r
+ if [ -z $OUTPUTDIR ] ; then\r
+ OUTPUTDIR="../$(basename `pwd`)-doxygen";\r
+ fi\r
+ fi\r
+\r
+ # Add trailing slash's to the lines that need them\r
+ TARGETSTRING=`echo ${TARGETLIST[*]} | sed -e 's/" "/", "/'`\r
+ [ $QUIETMODE -gt 0 ] || echo -ne " -> Set Input to: ";\r
+ for (( COUNTER=0; COUNTER < $TARGETCOUNT ; $[COUNTER++] )) ; do\r
+ if [ $COUNTER == $[TARGETCOUNT - 1] ] ; then\r
+ [ $QUIETMODE -gt 0 ] || echo -ne "${TARGETLIST[$COUNTER]}\n";\r
+ TARGETLIST[$COUNTER]="${TARGETLIST[$COUNTER]}";\r
+ else\r
+ [ $QUIETMODE -gt 0 ] || echo -ne "${TARGETLIST[$COUNTER]}, ";\r
+ TARGETLIST[$COUNTER]="${TARGETLIST[$COUNTER]} \\";\r
+ fi\r
+ done\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Set Output Dir to: $OUTPUTDIR";\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Try to extract the version number\r
+# todo: find a better way to determine the version\r
+#------------------------------------------------------------------------\r
+get_version() {\r
+ VERSION=`grep PROJECT_NUMBER $DOXYCONFIG | grep -v \# | cut -d= -f2`;\r
+ if [ -z $VERSION ] ; then\r
+ if [ -f "./include/version.default" ] ; then # checks that we are in the right dir\r
+ VERSION=`cat ./include/version.default`;\r
+ else\r
+ VERSION="(Unknown)";\r
+ fi\r
+ fi\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Create a projectname from the tree name\r
+#------------------------------------------------------------------------\r
+get_projectname() {\r
+ PROJECTNAME=`grep PROJECT_NAME $DOXYCONFIG | grep -v \# | cut -d= -f2`;\r
+ if [ -z $PROJECTNAME ] ; then\r
+ # PROJECTNAME=`echo $TARGET | sed -e s/[^A-Za-z0-9]/!/ | cut -d! -f1`;\r
+ PROJECTNAME="$(basename `pwd`)";\r
+ fi\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# function to determine the path to the perl executable\r
+#------------------------------------------------------------------------\r
+get_perlpath() {\r
+ if [ -f "$DOXYCONFIG" ] ; then\r
+ PERLPATH=`grep PERL_PATH $DOXYCONFIG | grep = | cut -d= -f2`\r
+ fi\r
+\r
+ if [ 'basename $PERLPATH &2>/dev/null' != "perl" ] ; then\r
+ PERLPATH=`which perl 2>/dev/null | sed -e 's/perl//'`;\r
+ elif [ 'basename $PERLPATH &2>/dev/null' != "perl" ] ; then\r
+ PERLPATH="";\r
+ fi\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Function to determine the path to the dot executable\r
+#------------------------------------------------------------------------\r
+get_dotpath() {\r
+ if [ -f "$DOXYCONFIG" ] ; then\r
+ DOTPATH=`grep DOT_PATH $DOXYCONFIG | grep = | cut -d= -f2`\r
+ fi\r
+\r
+ if [ -z $DOTPATH ] || [ `basename $DOTPATH 2>/dev/null` != "dot" ] ; then\r
+ DOTPATH=`which dot 2>/dev/null`;\r
+ fi\r
+\r
+ if [ -z $DOTPATH ] || [ `basename $DOTPATH 2>/dev/null` != "dot" ] ; then\r
+ DOTPATH="";\r
+ HAVEDOT="No";\r
+ echo -e "** Warning: dot not found.";\r
+ [ $QUIETMODE -gt 0 ] || echo -e "** dot is part of the GraphVis package and is used to generate";\r
+ [ $QUIETMODE -gt 0 ] || echo -e "** dependancy/inheritance/include (etc) diagrams.";\r
+ [ $QUIETMODE -gt 0 ] || echo -e "** It's suggested that you install the GraphVis package for those";\r
+ [ $QUIETMODE -gt 0 ] || echo -e "** features.";\r
+ [ $QUIETMODE -gt 0 ] || echo -e "** GraphVis can be downloaded from www.graphvis.org";\r
+ else\r
+ HAVEDOT="Yes";\r
+ DOTPATH=`echo $DOTPATH | sed -e 's/dot//'`;\r
+ fi\r
+ \r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Function to move stuff around\r
+#------------------------------------------------------------------------\r
+# eg: move the images into the output directory & the reference doc into the\r
+# html directory.\r
+# called after doxygen has finished generating documentation\r
+move_stuff() {\r
+ [ $QUIETMODE -gt 0 ] || echo -ne " -> Move stuff.\n";\r
+ if [ ! -d $OUTPUTDIR ] ; then\r
+ mkdir $OUTPUTDIR;\r
+ fi\r
+ \r
+ if [ ! -d "$EXTRAS_PATH/images/" ] ; then\r
+ [ $QUIETMODE -gt 0 ] || echo -e " - Looking for images.";\r
+ [ $QUIETMODE -gt 0 ] || sleep 2;\r
+ [ $QUIETMODE -gt 0 ] || echo -e " - I can't find the images...";\r
+ [ $QUIETMODE -gt 0 ] || sleep 1;\r
+ [ $QUIETMODE -gt 0 ] || echo -e " - Where did you put the images!?";\r
+ [ $QUIETMODE -gt 0 ] || sleep 2;\r
+ [ $QUIETMODE -gt 0 ] || echo -e " - They have to be here somewhere...";\r
+ [ $QUIETMODE -gt 0 ] || sleep 1;\r
+ [ $QUIETMODE -gt 0 ] || echo -e " - Looking in /dev/null";\r
+ [ $QUIETMODE -gt 0 ] || sleep 3;\r
+ [ $QUIETMODE -gt 0 ] || echo -e " - YOU FOOL, YOU DELETED THE IMAGES!!!";\r
+ [ $QUIETMODE -gt 0 ] || sleep 1;\r
+ [ $QUIETMODE -gt 0 ] || echo -e " - I quit!";\r
+ RETVAL=666;\r
+ else\r
+ if [ ! -d $OUTPUTDIR/images ] ; then\r
+ mkdir $OUTPUTDIR/images ;\r
+ fi\r
+ cp $EXTRAS_PATH/images/* $OUTPUTDIR/images/ ;\r
+ RETVAL=0;\r
+ fi\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# clean_up() removes old versions of the documentation\r
+#------------------------------------------------------------------------\r
+clean_up() {\r
+ if [ -f $OUTPUTDIR/html/index.html ] ; then\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Trashing old dox.";\r
+ rm -f $OUTPUTDIR/html/*\r
+ fi\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Create a new genConf & Doxyfile\r
+#------------------------------------------------------------------------\r
+gen_doxyconfig() {\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Generating DoxyConfig.";\r
+ RETVAL=0;\r
+ # first need to make sure there is a Doxyfile here\r
+ if [ ! -f $DOXYFILE ] ; then\r
+ # what now? (could generate one with 'doxygen -e Doxyfile') but it would be screwed.\r
+ echo -e "No Doxyfile here...";\r
+ RETVAL=3;\r
+ return;\r
+ else\r
+ # Create a new doxyfile with the @INCLUDE statement including the generated stuff\r
+ echo "`cat $DOXYFILE | grep -v @INCLUDE`" > $NEWDOXYFILE\r
+ echo "@INCLUDE = $CONFIG_OUTPUT" >> $NEWDOXYFILE\r
+ fi\r
+ \r
+ # remove the old config file\r
+ rm -f $CONFIG_OUTPUT\r
+ \r
+ # create a new one\r
+ touch $CONFIG_OUTPUT\r
+ echo "# Generated configuration - Do Not Edit." >> $CONFIG_OUTPUT;\r
+ echo "# If you want to modify options, edit DoxyConfig and re-run genconf." >> $CONFIG_OUTPUT;\r
+ echo -e "\n" >> $CONFIG_OUTPUT;\r
+ echo -e "PROJECT_NAME=$PROJECTNAME" >> $CONFIG_OUTPUT;\r
+ echo -e "PROJECT_NUMBER=$VERSION" >> $CONFIG_OUTPUT;\r
+ echo -e "PERL_PATH=$PERLPATH" >> $CONFIG_OUTPUT;\r
+ echo -e "HAVE_DOT=$HAVEDOT" >> $CONFIG_OUTPUT;\r
+ echo -e "DOT_PATH=$DOTPATH" >> $CONFIG_OUTPUT;\r
+ echo -e "OUTPUT_LANGUAGE=$OUTPUTLANGUAGE" >> $CONFIG_OUTPUT;\r
+\r
+ echo -n "INPUT=" >> $CONFIG_OUTPUT;\r
+ for (( COUNTER=0 ; COUNTER < $TARGETCOUNT; $[COUNTER++] )) ; do\r
+ # echo -e "${TARGETLIST[$COUNTER]}";\r
+ echo -e "${TARGETLIST[$COUNTER]}" >> $CONFIG_OUTPUT\r
+ done\r
+ # echo -e "INPUT=$TARGET" >> $CONFIG_OUTPUT;\r
+\r
+ echo -e "OUTPUT_DIRECTORY=$OUTPUTDIR" >> $CONFIG_OUTPUT;\r
+ echo -e "\n" >> $CONFIG_OUTPUT;\r
+ return; \r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Build the reference page & index\r
+#------------------------------------------------------------------------\r
+build_extra_html() {\r
+ # file locations\r
+ REF_OUT="$OUTPUTDIR/reference/index.html"\r
+ INDEX_OUT="$OUTPUTDIR/index.html"\r
+ \r
+ # Make the output directory if it doesn't exist\r
+ if [ ! -d $OUTPUTDIR/reference/ ] ; then\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Making reference directory";\r
+ mkdir $OUTPUTDIR/reference\r
+ fi\r
+ \r
+ # cat the files together and output the result to each file\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Building reference document";\r
+ cat $EXTRAS_PATH/doxygen_reference_head.html $EXTRAS_PATH/reference1.html $EXTRAS_PATH/doxygen_reference_foot.html > $REF_OUT;\r
+\r
+ if [ ! -d $OUTPUTDIR/example/ ] ; then\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Making example dir";\r
+ mkdir $OUTPUTDIR/example\r
+ fi\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Moving example docs";\r
+ cp $EXTRAS_PATH/example/* $OUTPUTDIR/example/\r
+ cp $EXTRAS_PATH/doxygen_gtkradiant.css $OUTPUTDIR/example/\r
+\r
+ # Make a redirecting index.html\r
+ cat $EXTRAS_PATH/doxygen_index.html > $INDEX_OUT;\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# Execute doxygen\r
+#------------------------------------------------------------------------\r
+run_doxygen() {\r
+ # copy doxy_mainpage.h to the target directory\r
+ # pipe it through sed to add generation time/date and username - $machine\r
+ TEMPLOCATION=`echo $TARGETSTRING | cut -d' ' -f1`;\r
+ if [ X"$USERNAME" == "X" ] ; then\r
+ USERNAME=`whoami`;\r
+ fi\r
+ MACHINE=`uname -n`; # `uname -n` or `hostname` ??\r
+ cp $EXTRAS_PATH/doxy_mainpage.h temp.h\r
+ cat temp.h |\r
+ sed "s/+project+/$PROJECTNAME/" |\r
+ sed "s|+target+|$TARGETSTRING|" |\r
+ sed "s/+user+/$USERNAME/" |\r
+ sed "s/+machine+/$MACHINE/" |\r
+ sed "s/+date+/$(date '+%b %d %Y')/" > $TEMPLOCATION/doxy_mainpage.h ;\r
+\r
+ rm -f temp.h\r
+\r
+ # Start doxygen with the command "doxygen $DOXYFILE"\r
+ [ $QUIETMODE -gt 0 ] || echo -e " -> Executing doxygen.";\r
+ [ $QUIETMODE -gt 0 ] || echo -e "> doxygen $NEWDOXYFILE";\r
+ doxygen $NEWDOXYFILE\r
+ RETVAL=$?\r
+\r
+ # remove doxy_mainpage.h from the target directory\r
+ rm -f $TEMPLOCATION/doxy_mainpage.h\r
+ return;\r
+}\r
+\r
+#------------------------------------------------------------------------\r
+# End.\r
+\r