# Control the name of the dist directory



## pieside (Jun 28, 2016)

I'm trying to port Grass7 on the ports tree. The `make` command creates two folders:

/usr/ports/../work/grass-7/dist.amd64

/usr/ports/../work/grass-7/dist.amd64-portbld-freebsd10.3
All the includes files are located in the first directory. The second one is empty. A lot of main.c are looking for includes in this second directory but there's nothing there. Everything is in the first directory.

Do you know why does `make` create the dist.amd64-portbld-freebsd10.3 empty directory?


----------



## SirDice (Jun 28, 2016)

Aren't these directories simply part of the extracted archive? Do a `make clean` followed by `make extract`. The extract only does the extraction of the source distribution files, nothing else. Then have a look if the directories exist or not.


----------



## pieside (Jun 28, 2016)

SirDice said:


> Aren't these directories simply part of the extracted archive? Do a `make clean` followed by `make extract`. The extract only does the extraction of the source distribution files, nothing else. Then have a look if the directories exist or not.



The directories aren't created after `make extract`. They are created during `make build`: dist.amd64 first. The dist.amd64-portbld-freebsd10.3 directory second.

Here is another finding. `make configure` creates ${WRKSRC}/include/Make/Platform.make. This file contains the the RUN_GISBASE environment variable which is assigned the value of dist.amd64-portbld-freebsd10.3.

Do you think the next step is to change this value?


----------



## kpa (Jun 28, 2016)

Read the Makefile in the extracted source directory, it might have rules that creates those directories as part of the build.


----------



## SirDice (Jun 29, 2016)

Since there's an existing databases/grass, have a look how that's working. The files directory contains a bunch of FreeBSD specific patches, including one for the port's Makefile. They may not work as-is but you can certainly use them as an example.


----------



## pieside (Jul 7, 2016)

kpa said:


> Read the Makefile in the extracted source directory, it might have rules that creates those directories as part of the build.


I presume the ports framework overrides the value of the ARCH variable. This variable is defined in the Grass.make file. Here's what I found:

`make` in databases/grass creates only the dist.amd64 directory;

`gmake` in databases/grass7/work/grass7.0.4 creates only the dist.amd64-portbld-freebsd10.3 directory.
I don't understand the first case. Why does the ports tree create this directory while the ARCH variable is set to amd.64-portbld-freebsd10.3? 

The post hereafter suggests that "issue may be with build system" and the previous findings strengthens this hypothesis (https://trac.osgeo.org/grass/ticket/3091).


----------



## pieside (Jul 7, 2016)

SirDice said:


> Since there's an existing databases/grass, have a look how that's working. The files directory contains a bunch of FreeBSD specific patches, including one for the port's Makefile. They may not work as-is but you can certainly use them as an example.


Unfortunately, I didn't find anything in the existing patches that is modifying the value of the ARCH variable.


----------



## cpm@ (Jul 9, 2016)

bsd.port.mk defines

```
CONFIGURE_TARGET?=      ${ARCH}-portbld-${OPSYS:tl}${OSREL}
```

To workaround this issue that you're experiencing, many ports hack the CONFIGURE_TARGET variable so that it contains the ``--build='' prefix.

https://www.freebsd.org/doc/en/books/porters-handbook/building.html#using-configure


----------



## pieside (Jul 19, 2016)

cpm@ said:


> bsd.port.mk defines
> 
> ```
> CONFIGURE_TARGET?=      ${ARCH}-portbld-${OPSYS:tl}${OSREL}
> ...


Could you please give me an example of a port using this technique?


----------



## SirDice (Jul 19, 2016)

pieside said:


> Could you please give me an example of a port using this technique?


`find /usr/ports -name 'Makefile' -exec grep -H 'CONFIGURE_TARGET' {} \;`


----------



## tobik@ (Jul 19, 2016)

For example devel/llvm38


----------



## cpm@ (Jul 19, 2016)

pieside said:


> Could you please give me an example of a port using this technique?



SirDice correctly answered your question.

Please, note the ``--build'' prefix used in some examples to suit your needs.

Here is an example:

```
CONFIGURE_TARGET=--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
```


----------



## pieside (Sep 3, 2016)

To force the compilation to look for includes into the dist.amd64 directory, I tried:

```
CONFIGURE_TARGET=--build=dist.${MACHINE_ARCH}
```
Which raises: Invalid configuration `dist.amd64': machine `dist.amd64' not recognized. I'm not able to identify the source of the problem. The Makefile of the previous version of Grass (/usr/ports/databases/grass/Makefile) does not have the CONFIGURE_TARGET variable modified.

What could have happen between these two versions?


----------

