# PORTDOCS and relative paths



## int19h (Sep 3, 2018)

I'm writing a port for a piece of software that has a bunch of docs scattered over the place - e.g. there's README at root level, and then there's a text file in doc/. I'm trying to avoid repeating myself unnecessary in the port, but it's not clear to me whether this is possible.

Initially, I tried using make makeplist and %%PORTDOCS%% entries in pkg-plist that it produces. But then it's not clear how to avoid repeating the same files in plist in the Makefile in do-install-DOCS-on, since there's no variable like PORTDOCS available there. I looked at some other ports, and it seems that they mostly get away with it by copying doc/ entirely (because for those ports, all documentation is under that) - which is not an option here. Alternatively, they ditch %%PORTDOCS%% in plist, and use PORTDOCS in Makefile. So I tried this:


```
PORTDOCS=COPYING Changelog README doc/motivation.txt

do-install-DOCS-on:
    @${MKDIR} ${STAGEDIR}${DOCSDIR}
    cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${STAGEDIR}${DOCSDIR}
```

But this breaks because the doc/ part is also used when packaging, and so it fails with something like:


> pkg-static: Unable to access file /usr/home/int19h/ports/devel/libtranscript/work/stage/usr/local/share/doc/libtranscript/doc/motivation.txt:No such file or directory


Since the file is actually installed to /usr/local/share/doc/libtranscript/motivation.txt (no second .../doc/...), it's not there. I can fix it by:


```
PORTDOCS=COPYING Changelog README motivation.txt

do-install-DOCS-on:
    @${MKDIR} ${STAGEDIR}${DOCSDIR}
    >cd ${WRKSRC} && ${INSTALL_DATA} COPYING Changelog README doc/motivation.txt ${STAGEDIR}${DOCSDIR}
```

but then I'm repeating the list of files again, same as with the plist %%PORTDOCS%% approach.

What's the recommended way to deal with issues like these? Is such repetition considered acceptable in this case, or am I missing some trick?


----------



## cpm@ (Sep 4, 2018)

Try the following in your Makefile

```
DOCS=        COPYING Changelog README doc/motivation.txt
PORTDOCS=    ${DOCS:T}

do-install-DOCS-on:
    @${MKDIR} ${STAGEDIR}${DOCSDIR}
    cd ${WRKSRC} && ${INSTALL_DATA} ${DOCS} ${STAGEDIR}${DOCSDIR}
```

Take in mind that you don't need to add these files to pkg-plist.


----------



## cederom (Jan 23, 2022)

Thank you cpm@ shame this solution is not in the Porter's Handbook


----------

