# %POSIX var in sys.mk not effect expected, how to do with it ?



## fcgoo (Aug 25, 2011)

hi
i've read make(1) manpage, and i read system makefiles now.

The sys.mk, the make system initial file, there's %POSIX variable in it.
According to docs/mans, %POSIX variable is made by defining a special target .POSIX at the top of Makefiles.

i wrote a test Makefile for test, here's code:

```
> cat Makefile
.POSIX:

target1:
        echo %POSIX=${%POSIX}
        echo CC=${CC}

> make target1
echo %POSIX=1003.2
%POSIX=1003.2
echo CC=cc
CC=cc
```
The CC var is set to 'cc', but in the sys.mk, there's a conditional to set CC to 'c89' when defining %POSIX var. snippet:

```
.if defined(%POSIX)
CC		?=	c89
CFLAGS		?=	-O
.else
CC		?=	cc
...
```
i think because sys.mk is read before the user's Makefile, it doesn't have set %POSIX yet althrough Makefile defines .POSIX special target.x(

when doing a trick like this: make -D%POSIX , however , doing this will result in a lot of conditional warnings/errors in bsd.cpu.mk because it depends on the var MACHINE_CPUARCH, which also depends on %POSIX var.

when and how to let sys.mk behavior according to .POSIX in the user's Makefile?


----------

