diff --git a/posix.mak b/posix.mak index 3ec4db77e7..5eed42ef24 100644 --- a/posix.mak +++ b/posix.mak @@ -29,13 +29,22 @@ INSTALL_DIR=../install DOCDIR=doc IMPDIR=import -# -fPIC is enabled by default and can be disabled with DISABLE_PIC=1 -ifeq (,$(DISABLE_PIC)) - PIC_FLAG:=-fPIC +OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov,) + +# default to PIC on x86_64, use PIC=1/0 to en-/disable PIC. +# Note that shared libraries and C files are always compiled with PIC. +ifeq ($(PIC),) + ifeq ($(MODEL),64) # x86_64 + PIC:=1 + else + PIC:=0 + endif +endif +ifeq ($(PIC),1) + override PIC:=-fPIC else - PIC_FLAG:= + override PIC:= endif -OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov,) ifeq (osx,$(OS)) DOTDLL:=.dylib @@ -60,7 +69,7 @@ ifeq (solaris,$(OS)) endif # Set DFLAGS -UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(PIC_FLAG) $(OPTIONAL_COVERAGE) +UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(PIC) $(OPTIONAL_COVERAGE) ifeq ($(BUILD),debug) UDFLAGS += -g -debug DFLAGS:=$(UDFLAGS)