# System architecture



## NewGuy (Jun 18, 2013)

I'm working on a port which will have to download/use different files depending on which architecture is in use. For example, if the host system is 32-bit x86 I need to access file blob-32.tar.gz, but on 64-bit x86_64 I need to access blob-54.tar.gz.

I've been looking through the Porter's Handbook and performing separate tasks based on architecture doesn't appear to be covered. I suppose I could run `uname` and `grep` for the architecture, but that feels clumsy. Has anyone tackled this? In the Makefile I think I'm going to need something like:


```
if i386
  work with file a
else if amd64
  work with file b
else
  echo arch not supported
```


----------



## bkouhi (Jun 18, 2013)

Hi.

The ${ARCH} variable contains the architecture of the target machine. So you can do something like:


```
ONLY_FOR_ARCHS= amd64 i386
ONLY_FOR_ARCHS_REASON=  It is a binary blob

.include <bsd.port.pre.mk>

.if ${ARCH} == "amd64"
DISTNAME= ${PORTNAME}-54${EXTRACT_SUFX}
.else
DISTNAME= ${PORTNAME}-32${EXTRACT_SUFX}
.endif

.include <bsd.port.post.mk>
```

The /usr/ports/Mk/bsd.port.mk contains more information.

Hope this helps.


----------



## NewGuy (Jun 19, 2013)

This is exactly what I needed, @bkouhi, thank you!


----------

