| 33 | # Invoke a ctags utility to generate Emacs and Vim's format tag file. |
| 34 | # The meaning of the flags: |
| 35 | # - `p` kind enables function prototypes, |
| 36 | # - `x` kind enables extern and forward variable declarations, |
| 37 | # - `S` field enables function signatures, |
| 38 | # - `properties` field enables static, volatile, etc. properties, |
| 39 | # - `macrodef` field enables macro definitions. |
| 40 | # |
| 41 | # Generate two formats at once: Emacs and Vim's. |
| 42 | tags: tags-emacs tags-vim |
| 43 | |
| 44 | # Build only the Emacs-style `TAGS` file. |
| 45 | tags-emacs: |
| 46 | @if type ctags >/dev/null 2>&1; then \ |
| 47 | if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \ |
| 48 | ctags -e -R --languages=C --langmap=C:.h.c --c-kinds=+px \ |
| 49 | --fields=+S --fields-c=+"{properties}" --fields-c=+"{macrodef}" \ |
| 50 | --extras=+qr; \ |
| 51 | else \ |
| 52 | ctags -e -R --languages=C --langmap=C:.h.c --c-kinds=+px \ |
| 53 | --fields=+S; \ |
| 54 | fi; \ |
| 55 | printf "Created the Emacs \`TAGS\` file.\\n"; \ |
| 56 | else \ |
| 57 | printf 'Error: Please install a Ctags (e.g.: either the Exuberant or Universal %b' \ |
| 58 | 'version) utility first.\n'; \ |
| 59 | fi |
| 60 | |
| 61 | # Build only the Vim-style `tags` file. |
| 62 | tags-vim: |
| 63 | @if type ctags >/dev/null 2>&1; then \ |
| 64 | if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \ |
| 65 | ctags -R --languages=C --langmap=C:.h.c --c-kinds=+px \ |
| 66 | --fields=+S --fields-c=+"{properties}" --fields-c=+"{macrodef}" \ |
| 67 | --extras=+qr; \ |
| 68 | else \ |
| 69 | ctags -R --languages=C --langmap=C:.h.c --c-kinds=+px \ |
| 70 | --fields=+S; \ |
| 71 | fi; \ |
| 72 | printf "Created the Vim's style \`tags\` file.\\n"; \ |
| 73 | else \ |
| 74 | printf 'Error: Please install a Ctags (e.g.: either the Exuberant or Universal %b' \ |
| 75 | 'version) utility first.\n'; \ |
| 76 | fi |