9884 cw(1) should use -fpic rather than -Kpic
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Andy Stormont <andyjstormont@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: John Levon <john.levon@joyent.com>
Approved by: Garrett D'Amore <garrett@damore.org>
diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master
index b2eb30e..e23b888 100644
--- a/usr/src/Makefile.master
+++ b/usr/src/Makefile.master
@@ -890,30 +890,31 @@
 # Handle different PIC models on different ISAs
 # (May be overridden by lower-level Makefiles)
 
-sparc_C_PICFLAGS =	-K pic
-sparcv9_C_PICFLAGS =	-K pic
-i386_C_PICFLAGS =	-K pic
-amd64_C_PICFLAGS =	-K pic
+sparc_C_PICFLAGS =	-fpic
+sparcv9_C_PICFLAGS =	-fpic
+i386_C_PICFLAGS =	-fpic
+amd64_C_PICFLAGS =	-fpic
 C_PICFLAGS =		$($(MACH)_C_PICFLAGS)
 C_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)
 
-sparc_C_BIGPICFLAGS =	-K PIC
-sparcv9_C_BIGPICFLAGS =	-K PIC
-i386_C_BIGPICFLAGS =	-K PIC
-amd64_C_BIGPICFLAGS =	-K PIC
+sparc_C_BIGPICFLAGS =	-fPIC
+sparcv9_C_BIGPICFLAGS =	-fPIC
+i386_C_BIGPICFLAGS =	-fPIC
+amd64_C_BIGPICFLAGS =	-fPIC
 C_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
 C_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)
 
 # CC requires there to be no space between '-K' and 'pic' or 'PIC'.
-sparc_CC_PICFLAGS =	-Kpic
-sparcv9_CC_PICFLAGS =	-KPIC
-i386_CC_PICFLAGS =	-Kpic
-amd64_CC_PICFLAGS =	-Kpic
+# and does not support -f
+sparc_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
+sparcv9_CC_PICFLAGS =	-_cc=-KPIC -_gcc=-fPIC
+i386_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
+amd64_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
 CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
 CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
 
-AS_PICFLAGS=		$(C_PICFLAGS)
-AS_BIGPICFLAGS=		$(C_BIGPICFLAGS)
+AS_PICFLAGS=		-K pic
+AS_BIGPICFLAGS=		-K PIC
 
 #
 # Default label for CTF sections
diff --git a/usr/src/cmd/sgs/Makefile.com b/usr/src/cmd/sgs/Makefile.com
index 6964761..9230fd9 100644
--- a/usr/src/cmd/sgs/Makefile.com
+++ b/usr/src/cmd/sgs/Makefile.com
@@ -66,8 +66,8 @@
 		$(CPPFLAGS.master) -I$(ELFCAP)
 
 # PICS64 is unique to our environment
-$(PICS64) :=	sparc_CFLAGS += -xregs=no%appl -K pic
-$(PICS64) :=	sparcv9_CFLAGS += -xregs=no%appl -K pic
+$(PICS64) :=	sparc_CFLAGS += -xregs=no%appl $(C_PICFLAGS)
+$(PICS64) :=	sparcv9_CFLAGS += -xregs=no%appl $(C_PICFLAGS)
 $(PICS64) :=	CPPFLAGS += -DPIC -D_REENTRANT
 
 LDFLAGS +=	$(ZIGNORE)
diff --git a/usr/src/cmd/sgs/rtld/sparc/Makefile b/usr/src/cmd/sgs/rtld/sparc/Makefile
index d2630c5..d3af26f 100644
--- a/usr/src/cmd/sgs/rtld/sparc/Makefile
+++ b/usr/src/cmd/sgs/rtld/sparc/Makefile
@@ -68,7 +68,7 @@
 
 CPPFLAGS +=	-I../../../../uts/sparc/krtld -DA_OUT
 CFLAGS +=	-xregs=no%appl
-ASFLAGS +=	-K pic
+ASFLAGS +=	$(AS_PICFLAGS)
 LINTFLAGS +=	-DA_OUT
 ADBGENCFLAGS +=	-erroff=%all
 ADBGENFLAGS +=	-milp32
diff --git a/usr/src/cmd/sgs/rtld/sparcv9/Makefile b/usr/src/cmd/sgs/rtld/sparcv9/Makefile
index 0093a7b..d986346 100644
--- a/usr/src/cmd/sgs/rtld/sparcv9/Makefile
+++ b/usr/src/cmd/sgs/rtld/sparcv9/Makefile
@@ -40,11 +40,11 @@
 
 CP_MACHOBJS=	common_sparc.o
 
-S_MACHOBJS=	
+S_MACHOBJS=
 
 P_ASOBJS=	boot.o		boot_elf.o	caller.o
 
-S_ASOBJS=	
+S_ASOBJS=
 
 CRTSRCS=	../../../../lib/crt/sparc
 CRTI=		pics/crti.o
@@ -68,7 +68,7 @@
 
 CPPFLAGS +=	-I../../../../uts/sparc/krtld
 CFLAGS +=	-xregs=no%appl
-ASFLAGS +=	-s -K pic -D__sparcv9 -D_ELF64 $(sparcv9_XARCH)
+ASFLAGS +=	-s $(AS_PICFLAGS) -D__sparcv9 -D_ELF64 $(sparcv9_XARCH)
 ADBGENFLAGS +=	-mlp64
 ADBGENCFLAGS +=	-erroff=%all
 ADBSUB=		$(ADBSUB64)
diff --git a/usr/src/lib/c_synonyms/amd64/Makefile b/usr/src/lib/c_synonyms/amd64/Makefile
index 5cfacdb..f7402f3 100644
--- a/usr/src/lib/c_synonyms/amd64/Makefile
+++ b/usr/src/lib/c_synonyms/amd64/Makefile
@@ -22,10 +22,8 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
-ASFLAGS=	-K pic -P -D__STDC__ -D_ASM $(amd64_AS_XARCH)
+ASFLAGS=	$(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(amd64_AS_XARCH)
 
 include ../Makefile.com
 include ../../Makefile.lib.64
diff --git a/usr/src/lib/c_synonyms/i386/Makefile b/usr/src/lib/c_synonyms/i386/Makefile
index 0670d30..56e547b 100644
--- a/usr/src/lib/c_synonyms/i386/Makefile
+++ b/usr/src/lib/c_synonyms/i386/Makefile
@@ -22,10 +22,8 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
-ASFLAGS=	-K pic -P -D__STDC__ -D_ASM $(i386_AS_XARCH)
+ASFLAGS=	$(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(i386_AS_XARCH)
 
 include ../Makefile.com
 
diff --git a/usr/src/lib/c_synonyms/sparc/Makefile b/usr/src/lib/c_synonyms/sparc/Makefile
index f9643fd..93df1b1 100644
--- a/usr/src/lib/c_synonyms/sparc/Makefile
+++ b/usr/src/lib/c_synonyms/sparc/Makefile
@@ -22,10 +22,8 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
-ASFLAGS=	-K pic -P -D__STDC__ -D_ASM $(sparc_AS_XARCH)
+ASFLAGS=	$(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(sparc_AS_XARCH)
 
 include ../Makefile.com
 
diff --git a/usr/src/lib/c_synonyms/sparcv9/Makefile b/usr/src/lib/c_synonyms/sparcv9/Makefile
index 13d51d1..0f5ccee 100644
--- a/usr/src/lib/c_synonyms/sparcv9/Makefile
+++ b/usr/src/lib/c_synonyms/sparcv9/Makefile
@@ -22,10 +22,8 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
-ASFLAGS=	-K pic -P -D__STDC__ -D_ASM $(sparcv9_AS_XARCH)
+ASFLAGS=	$(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(sparcv9_AS_XARCH)
 
 include ../Makefile.com
 include ../../Makefile.lib.64
diff --git a/usr/src/lib/efcode/engine/sparcv9/Makefile b/usr/src/lib/efcode/engine/sparcv9/Makefile
index af568ee..3673ac4 100644
--- a/usr/src/lib/efcode/engine/sparcv9/Makefile
+++ b/usr/src/lib/efcode/engine/sparcv9/Makefile
@@ -23,12 +23,10 @@
 # Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
 include ../Makefile.com
 include $(SRC)/lib/Makefile.lib.64
 
-sparcv9_C_PICFLAGS = -KPIC
+sparcv9_C_PICFLAGS = $(C_BIGPICFLAGS64)
 
 install: all $(ROOTLIBS64)
diff --git a/usr/src/lib/fm/libmdesc/Makefile.com b/usr/src/lib/fm/libmdesc/Makefile.com
index 7d3f814..c09447e 100644
--- a/usr/src/lib/fm/libmdesc/Makefile.com
+++ b/usr/src/lib/fm/libmdesc/Makefile.com
@@ -50,8 +50,8 @@
 SRCDIR =	../common
 
 CPPFLAGS += -I../common -I.
-CFLAGS += $(CCVERBOSE) -K PIC
-CFLAGS64 += $(CCVERBOSE) -K PIC
+CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
+CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS64)
 LDLIBS += -lc
 
 LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN -v
diff --git a/usr/src/lib/gss_mechs/mech_krb5/Makefile b/usr/src/lib/gss_mechs/mech_krb5/Makefile
index 6d5fa74..c725934 100644
--- a/usr/src/lib/gss_mechs/mech_krb5/Makefile
+++ b/usr/src/lib/gss_mechs/mech_krb5/Makefile
@@ -39,7 +39,7 @@
 
 GREP= find . \( -name SCCS -prune -o -name '*.[ch]' \) -print | sort | xargs grep
 
-sparcv9_C_PICFLAGS =  -K PIC
+sparcv9_C_PICFLAGS =  $(sparcv9_C_BIGPICFLAGS)
 TEXT_DOMAIN = SUNW_OST_NETRPC
 POFILE = mech_krb5.po
 POFILES = generic.po
diff --git a/usr/src/lib/libast/amd64/Makefile b/usr/src/lib/libast/amd64/Makefile
index 0419980..baa5997 100644
--- a/usr/src/lib/libast/amd64/Makefile
+++ b/usr/src/lib/libast/amd64/Makefile
@@ -38,7 +38,7 @@
 include ../Makefile.com
 include ../../Makefile.lib.64
 
-# Use -KPIC since libast is too big for -Kpic on 64bit
+# Use big PIC since libast is too big for pic on 64bit
 # (and on 32bit it is close to the barrier)
 amd64_C_PICFLAGS = $(C_BIGPICFLAGS)
 
diff --git a/usr/src/lib/libast/i386/Makefile b/usr/src/lib/libast/i386/Makefile
index 309ec29..f601e12 100644
--- a/usr/src/lib/libast/i386/Makefile
+++ b/usr/src/lib/libast/i386/Makefile
@@ -37,7 +37,7 @@
 
 include ../Makefile.com
 
-# Use -KPIC since libast is too big for -Kpic on 64bit
+# Use big PIC since libast is too big for pic on 64bit
 # (and on 32bit it is close to the barrier)
 i386_C_PICFLAGS  = $(C_BIGPICFLAGS)
 
diff --git a/usr/src/lib/libast/sparc/Makefile b/usr/src/lib/libast/sparc/Makefile
index 63d22de..54f6ad2 100644
--- a/usr/src/lib/libast/sparc/Makefile
+++ b/usr/src/lib/libast/sparc/Makefile
@@ -38,7 +38,7 @@
 
 include ../Makefile.com
 
-# Use -KPIC since libast is too big for -Kpic on 64bit
+# Use big PIC since libast is too big for pic on 64bit
 # (and on 32bit it is close to the barrier)
 sparc_C_PICFLAGS = $(C_BIGPICFLAGS)
 
diff --git a/usr/src/lib/libast/sparcv9/Makefile b/usr/src/lib/libast/sparcv9/Makefile
index 6a680ee..ec43708 100644
--- a/usr/src/lib/libast/sparcv9/Makefile
+++ b/usr/src/lib/libast/sparcv9/Makefile
@@ -39,7 +39,7 @@
 include ../Makefile.com
 include ../../Makefile.lib.64
 
-# Use -KPIC since libast is too big for -Kpic on 64bit
+# Use big PIC since libast is too big for pic on 64bit
 # (and on 32bit it is close to the barrier)
 sparcv9_C_PICFLAGS  = $(C_BIGPICFLAGS)
 
diff --git a/usr/src/lib/libbc/sparc/Makefile b/usr/src/lib/libbc/sparc/Makefile
index c624b62..b35b87a 100644
--- a/usr/src/lib/libbc/sparc/Makefile
+++ b/usr/src/lib/libbc/sparc/Makefile
@@ -44,7 +44,7 @@
 
 COMPAT4.1=\
 ftime.o     nice.o      rand.o      vlimit.o    vtimes.o    getpw.o times.o
- 
+
 COMPATSYS5=\
 nice.o      rand.o      getpw.o     times.o
 
@@ -97,14 +97,14 @@
 getpass.o localtime.o ttyslot.o
 
 GENCOMSPARC=\
-alloca.o   ffs.o insque.o    remque.o    isinf.o     base_conv.o 
+alloca.o   ffs.o insque.o    remque.o    isinf.o     base_conv.o
 
 GEN4.2=\
 nlist.o     timezone.o  sleep.o  system.o
 
 GENSYS5=\
 assert.o    nlist.o     sgetl.o    sleep.o      sputl.o     system.o \
-sighold.o   
+sighold.o
 
 STDIOCOM=\
 clrerr.o    ctermid.o   cuserid.o   doprnt.o    doscan.o    fdopen.o \
@@ -150,7 +150,7 @@
 mknod.o     open.o      readlink.o  rename.o    rmdir.o  \
 setpgrp.o   stat.o      symlink.o   truncate.o  unlink.o     \
 statfs.o    fcntl.o     read.o      write.o     readv.o \
-writev.o    setjmp.o	mount.o 
+writev.o    setjmp.o	mount.o
 
 SYS4.2SPARC=\
 getgroups.o setgroups.o
@@ -340,9 +340,9 @@
 $(DYNLIB4X) :=	SONAME = $(DYNLIB4X)
 $(DYNLIBS5) :=	SONAME = $(DYNLIBS5)
 
-pics/%.o:= ASFLAGS += -K pic -DPIC
-pics/%.o:= CPPFLAGS += -K pic -DPIC
-s5pics/%.o:= ASFLAGS += -K pic -DPIC
+pics/%.o:= ASFLAGS += $(AS_PICFLAGS) -DPIC
+pics/%.o:= CPPFLAGS += $(C_PICFLAGS) -DPIC
+s5pics/%.o:= ASFLAGS += $(AS_PICFLAGS) -DPIC
 DYNFLAGS += $(ZINTERPOSE)
 
 BUILD.s=  $(AS) $(ASFLAGS) $< -o $@
@@ -352,14 +352,14 @@
 	$(AR) q $@ $(OBJECTS:%=$(DIR)/%)
 
 # the TXTS macro is used for NSE bootstrapping.
-TXTS=	inc/SYS.h inc/PIC.h inc/machine/asm_linkage.h 
+TXTS=	inc/SYS.h inc/PIC.h inc/machine/asm_linkage.h
 
 LIBS = $(DYNLIB4X) $(DYNLIBS5)
 
 OBJECTS= $(COMPATCOM) $(COMPAT4.1) $(CRTSPARC) $(GENCOM) \
 $(GENCOMSPARC) $(GEN4.2) $(STDIOCOM) $(STDIO4.2) \
 $(INET) $(NET) $(NETSPARC) $(YP) \
-$(SYSCOM) $(SYSCOMSPARC) $(SYS4.2) 
+$(SYSCOM) $(SYSCOMSPARC) $(SYS4.2)
 
 #
 # Since this library is strictly for binary compability with ancient
@@ -381,7 +381,7 @@
 CLOBBERFILES= ../libc/compat/sys5/mkepoch
 
 # conditional assignments
-s5pics/%.o:= CPPFLAGS = -Dsparc -DS5EMUL -K pic -DPIC -I. -Iinc \
+s5pics/%.o:= CPPFLAGS = -Dsparc -DS5EMUL $(C_PICFLAGS) -DPIC -I. -Iinc \
 	-I../inc/5include -I../inc/include -I../inc/include/sys \
 	$(CPPFLAGS.master)
 
@@ -414,7 +414,7 @@
 
 # special cases
 PSEUDO_POBJS= $(PSEUDO_SRCS:%.s=pics/%.o)
-PSEUDO_PS5OBJS= $(PSEUDO_SRCS:%.s=s5pics/%.o) 
+PSEUDO_PS5OBJS= $(PSEUDO_SRCS:%.s=s5pics/%.o)
 
 $(PSEUDO_POBJS) $(PSEUDO_PS5OBJS):
 	@(echo '#include "SYS.h"'; \
@@ -451,7 +451,7 @@
 	$(POST_PROCESS_O)
 
 pics/ypupdate_prot.o s5pics/ypupdate_prot.o : ../inc/include/rpcsvc/ypupdate_prot.h\
-				../libc/yp/ypupdate_prot.c 
+				../libc/yp/ypupdate_prot.c
 	$(COMPILE.c) -o $@ ../libc/yp/ypupdate_prot.c
 	$(POST_PROCESS_O)
 
diff --git a/usr/src/lib/libc/capabilities/sun4u-opl/Makefile.com b/usr/src/lib/libc/capabilities/sun4u-opl/Makefile.com
index 0080c16..c505326 100644
--- a/usr/src/lib/libc/capabilities/sun4u-opl/Makefile.com
+++ b/usr/src/lib/libc/capabilities/sun4u-opl/Makefile.com
@@ -37,4 +37,4 @@
 		-I$(ROOT)/usr/platform/$(GEN_PLATFORM)/include
 
 AS_CPPFLAGS +=	-D__STDC__ -D_ASM -DPIC -D_REENTRANT -D$(MACH) $(IFLAGS)
-ASFLAGS =	-P -K pic
+ASFLAGS =	-P $(AS_PICFLAGS)
diff --git a/usr/src/lib/libc/capabilities/sun4u-us3-hwcap1/Makefile.com b/usr/src/lib/libc/capabilities/sun4u-us3-hwcap1/Makefile.com
index b459a6a..1dab8da 100644
--- a/usr/src/lib/libc/capabilities/sun4u-us3-hwcap1/Makefile.com
+++ b/usr/src/lib/libc/capabilities/sun4u-us3-hwcap1/Makefile.com
@@ -39,4 +39,4 @@
 
 AS_CPPFLAGS +=	-D__STDC__ -D_ASM -DPIC -D_REENTRANT -D$(MACH) $(IFLAGS) \
 		-DBSTORE_SIZE=256
-ASFLAGS =	-P -K pic
+ASFLAGS =	-P $(AS_PICFLAGS)
diff --git a/usr/src/lib/libc/capabilities/sun4u-us3-hwcap2/Makefile.com b/usr/src/lib/libc/capabilities/sun4u-us3-hwcap2/Makefile.com
index 039b502..6620a80 100644
--- a/usr/src/lib/libc/capabilities/sun4u-us3-hwcap2/Makefile.com
+++ b/usr/src/lib/libc/capabilities/sun4u-us3-hwcap2/Makefile.com
@@ -39,4 +39,4 @@
 
 AS_CPPFLAGS +=	-D__STDC__ -D_ASM -DPIC -D_REENTRANT -D$(MACH) $(IFLAGS) \
 		-DBSTORE_SIZE=65536 -DPANTHER_ONLY
-ASFLAGS =	-P -K pic
+ASFLAGS =	-P $(AS_PICFLAGS)
diff --git a/usr/src/lib/libc/capabilities/sun4u/Makefile.com b/usr/src/lib/libc/capabilities/sun4u/Makefile.com
index 0d8a28b..033f0dc 100644
--- a/usr/src/lib/libc/capabilities/sun4u/Makefile.com
+++ b/usr/src/lib/libc/capabilities/sun4u/Makefile.com
@@ -36,7 +36,7 @@
 		-I$(ROOT)/usr/platform/$(GEN_PLATFORM)/include
 
 AS_CPPFLAGS +=	-D__STDC__ -D_ASM -DPIC -D_REENTRANT -D$(MACH) $(IFLAGS)
-ASFLAGS =	-P -K pic
+ASFLAGS =	-P $(AS_PICFLAGS)
 
 # memcpy.s provides __align_cpy_1 as an alias for memcpy.  However, this isn't
 # a WEAK symbol, and hence ld(1)'s ability to cull duplicate local symbols with
diff --git a/usr/src/lib/libc/capabilities/sun4v-hwcap1/Makefile.com b/usr/src/lib/libc/capabilities/sun4v-hwcap1/Makefile.com
index 0b1a16b..8e7800a 100644
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap1/Makefile.com
+++ b/usr/src/lib/libc/capabilities/sun4v-hwcap1/Makefile.com
@@ -38,7 +38,7 @@
 
 AS_CPPFLAGS +=	-D__STDC__ -D_ASM -DPIC -D_REENTRANT -D$(MACH) $(IFLAGS) \
 		-DNIAGARA_IMPL
-ASFLAGS =	-P -K pic
+ASFLAGS =	-P $(AS_PICFLAGS)
 
 # memcpy.s provides __align_cpy_1 as an alias for memcpy.  However, this isn't
 # a WEAK symbol, and hence ld(1)'s ability to cull duplicate local symbols with
diff --git a/usr/src/lib/libc/capabilities/sun4v-hwcap2/Makefile.com b/usr/src/lib/libc/capabilities/sun4v-hwcap2/Makefile.com
index af12732..a652b28 100644
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap2/Makefile.com
+++ b/usr/src/lib/libc/capabilities/sun4v-hwcap2/Makefile.com
@@ -38,7 +38,7 @@
 
 AS_CPPFLAGS +=	-D__STDC__ -D_ASM -DPIC -D_REENTRANT -D$(MACH) $(IFLAGS) \
 		-DNIAGARA2_IMPL
-ASFLAGS =	-P -K pic
+ASFLAGS =	-P $(AS_PICFLAGS)
 
 # memcpy.s provides __align_cpy_1 as an alias for memcpy.  However, this isn't
 # a WEAK symbol, and hence ld(1)'s ability to cull duplicate local symbols with
diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com
index 92efd03..3513856 100644
--- a/usr/src/lib/libc/sparc/Makefile.com
+++ b/usr/src/lib/libc/sparc/Makefile.com
@@ -1130,7 +1130,7 @@
 CFLAGS +=	$(EXTN_CFLAGS)
 CPPFLAGS=	-D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
 		-I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
-ASFLAGS=	$(EXTN_ASFLAGS) -K pic -P -D__STDC__ -D_ASM $(CPPFLAGS) $(sparc_AS_XARCH)
+ASFLAGS=	$(EXTN_ASFLAGS) $(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(CPPFLAGS) $(sparc_AS_XARCH)
 
 # As a favor to the dtrace syscall provider, libc still calls the
 # old syscall traps that have been obsoleted by the *at() interfaces.
@@ -1382,7 +1382,7 @@
 	$(POST_PROCESS_O)
 
 $(LIBCBASE)/crt/_rtbootld.s:	$(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.c
-	$(CC) $(CPPFLAGS) $(CTF_FLAGS) -O -S -K pic \
+	$(CC) $(CPPFLAGS) $(CTF_FLAGS) -O -S $(C_PICFLAGS) \
 	    $(LIBCBASE)/crt/_rtld.c -o $(LIBCBASE)/crt/_rtld.s
 	$(CAT) $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.s > $@
 	$(RM) $(LIBCBASE)/crt/_rtld.s
diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com
index b756ad5..39f4b4b 100644
--- a/usr/src/lib/libc/sparcv9/Makefile.com
+++ b/usr/src/lib/libc/sparcv9/Makefile.com
@@ -1067,11 +1067,11 @@
 
 MAPFILES =	$(LIBCDIR)/port/mapfile-vers
 
-sparcv9_C_PICFLAGS= -K PIC
+sparcv9_C_PICFLAGS= $(sparcv9_C_BIGPICFLAGS)
 CFLAGS64 +=	$(EXTN_CFLAGS)
 CPPFLAGS=	-D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
 		-I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
-ASFLAGS=	$(EXTN_ASFLAGS) -K PIC -P -D__STDC__ -D_ASM -D__sparcv9 $(CPPFLAGS) \
+ASFLAGS=	$(EXTN_ASFLAGS) $(AS_BIGPICFLAGS) -P -D__STDC__ -D_ASM -D__sparcv9 $(CPPFLAGS) \
 		$(sparcv9_AS_XARCH)
 
 # As a favor to the dtrace syscall provider, libc still calls the
diff --git a/usr/src/lib/libdtrace/sparc/Makefile b/usr/src/lib/libdtrace/sparc/Makefile
index 6065e14..4c4ad06 100644
--- a/usr/src/lib/libdtrace/sparc/Makefile
+++ b/usr/src/lib/libdtrace/sparc/Makefile
@@ -23,7 +23,7 @@
 # Use is subject to license terms.
 #
 
-ASFLAGS += -D_ASM -K PIC -P
+ASFLAGS += -D_ASM $(AS_BIGPICFLAGS) -P
 
 include ../Makefile.com
 
diff --git a/usr/src/lib/libdtrace/sparcv9/Makefile b/usr/src/lib/libdtrace/sparcv9/Makefile
index a45f315..d22653c 100644
--- a/usr/src/lib/libdtrace/sparcv9/Makefile
+++ b/usr/src/lib/libdtrace/sparcv9/Makefile
@@ -23,7 +23,7 @@
 # Use is subject to license terms.
 #
 
-ASFLAGS += -D_ASM -K PIC -P
+ASFLAGS += -D_ASM $(AS_BIGPICFLAGS) -P
 
 include ../Makefile.com
 include ../../Makefile.lib.64
diff --git a/usr/src/lib/libdtrace_jni/Makefile.com b/usr/src/lib/libdtrace_jni/Makefile.com
index 9d605b3..4717468 100644
--- a/usr/src/lib/libdtrace_jni/Makefile.com
+++ b/usr/src/lib/libdtrace_jni/Makefile.com
@@ -46,8 +46,8 @@
 CPPFLAGS += -I../common -I.
 CPPFLAGS += -I$(JAVA_ROOT)/include -I$(JAVA_ROOT)/include/solaris
 CPPFLAGS += -I../java/native
-CFLAGS += $(CCVERBOSE) -K PIC
-CFLAGS64 += $(CCVERBOSE) -K PIC
+CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
+CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS64)
 
 CERRWARN += -_gcc=-Wno-uninitialized
 
diff --git a/usr/src/lib/libndmp/sparcv9/Makefile b/usr/src/lib/libndmp/sparcv9/Makefile
index b84fb15..c0e1bf7 100644
--- a/usr/src/lib/libndmp/sparcv9/Makefile
+++ b/usr/src/lib/libndmp/sparcv9/Makefile
@@ -11,10 +11,10 @@
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
-# 	- Redistributions of source code must retain the above copyright
+#	- Redistributions of source code must retain the above copyright
 #	  notice, this list of conditions and the following disclaimer.
 #
-# 	- Redistributions in binary form must reproduce the above copyright
+#	- Redistributions in binary form must reproduce the above copyright
 #	  notice, this list of conditions and the following disclaimer in
 #	  the documentation and/or other materials provided with the
 #	  distribution.
@@ -39,6 +39,6 @@
 include ../Makefile.com
 include $(SRC)/lib/Makefile.lib.64
 
-sparcv9_C_PICFLAGS= -K PIC
+sparcv9_C_PICFLAGS= $(sparcv9_C_BIGPICFLAGS)
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libnsl/sparcv9/Makefile b/usr/src/lib/libnsl/sparcv9/Makefile
index da177794..249857b 100644
--- a/usr/src/lib/libnsl/sparcv9/Makefile
+++ b/usr/src/lib/libnsl/sparcv9/Makefile
@@ -23,8 +23,6 @@
 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
 include ../Makefile.com
 include ../../Makefile.lib.64
@@ -33,7 +31,6 @@
 # the whole 64-bit library with PIC instead of "generically" compiling
 # large parts of the 32-bit library with PIC unnecessarily.
 
-sparcv9_C_PICFLAGS = -K PIC
-sparcv9_CC_PICFLAGS = -KPIC
+sparcv9_C_PICFLAGS = $(sparcv9_C_BIGPICFLAGS)
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libresolv2/sparcv9/Makefile b/usr/src/lib/libresolv2/sparcv9/Makefile
index ceed393..2095629 100644
--- a/usr/src/lib/libresolv2/sparcv9/Makefile
+++ b/usr/src/lib/libresolv2/sparcv9/Makefile
@@ -22,17 +22,15 @@
 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
 #
 
 include ../Makefile.com
 include ../../Makefile.lib.64
 
 # With the adition of BIND 8.3.3, the symbol table for 64 bit went over
-# the limit for Kpic, so we've added -KPIC here, for just the 64 bit 
+# the limit for Kpic, so we've added -KPIC here, for just the 64 bit
 # library. This avoids compiling the 32-bit library with PIC unnecessarily.
 
-sparcv9_C_PICFLAGS = -K PIC
-sparcv9_CC_PICFLAGS = -KPIC
+sparcv9_C_PICFLAGS = $(sparcv9_C_BIGPICFLAGS)
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libtnfprobe/Makefile.com b/usr/src/lib/libtnfprobe/Makefile.com
index 9dd31dd..f0fe5a2 100644
--- a/usr/src/lib/libtnfprobe/Makefile.com
+++ b/usr/src/lib/libtnfprobe/Makefile.com
@@ -53,7 +53,7 @@
 ROOTHDRDIR=	$(ROOT)/usr/include/tnf
 ROOTHDRS=	$(HDRS:%=$(ROOTHDRDIR)/%)
 CHECKHDRS=	$(HDRS:%.h=%.check)
-$(ROOTHDRS) := 	FILEMODE = 0644
+$(ROOTHDRS) :=	FILEMODE = 0644
 CHECKHDRS =	$(HDRS:%.h=%.check)
 
 # Include .. first to pick up tnf_trace.h in current dir, Include UFSDIR to
@@ -87,7 +87,7 @@
 $(ROOTHDRDIR)/% : %
 	$(INS.file)
 
-#ASFLAGS=	-K pic -P -D_SYS_SYS_S -D_LOCORE -D_ASM -DPIC -DLOCORE $(CPPFLAGS)
+#ASFLAGS=	$(AS_PICFLAGS) -P -D_SYS_SYS_S -D_LOCORE -D_ASM -DPIC -DLOCORE $(CPPFLAGS)
 ASFLAGS=	-P -D_SYS_SYS_S -D_LOCORE -D_ASM -DPIC -DLOCORE $(CPPFLAGS)
 BUILD.s=	$(AS) $(ASFLAGS) $< -o $@
 
diff --git a/usr/src/lib/libzfs/sparcv9/Makefile b/usr/src/lib/libzfs/sparcv9/Makefile
index 24010f6..fc812ba 100644
--- a/usr/src/lib/libzfs/sparcv9/Makefile
+++ b/usr/src/lib/libzfs/sparcv9/Makefile
@@ -23,11 +23,10 @@
 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
 
 include ../Makefile.com
 include ../../Makefile.lib.64
 
-sparcv9_C_PICFLAGS= -K PIC
+sparcv9_C_PICFLAGS= $(sparcv9_C_BIGPICFLAGS)
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libzfs_core/sparcv9/Makefile b/usr/src/lib/libzfs_core/sparcv9/Makefile
index c5b6ca4..fc812ba 100644
--- a/usr/src/lib/libzfs_core/sparcv9/Makefile
+++ b/usr/src/lib/libzfs_core/sparcv9/Makefile
@@ -27,6 +27,6 @@
 include ../Makefile.com
 include ../../Makefile.lib.64
 
-sparcv9_C_PICFLAGS= -K PIC
+sparcv9_C_PICFLAGS= $(sparcv9_C_BIGPICFLAGS)
 
 install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile b/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile
index afc42f3..5f4cf20 100644
--- a/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile
+++ b/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile
@@ -26,8 +26,7 @@
 
 # With compiling with gcc, the symbol table goes over
 # the limit for Kpic, so we add -KPIC here.
-$(__GNUC)sparc_C_PICFLAGS =	-K PIC
-$(__GNUC)sparc_CC_PICFLAGS =	-KPIC
+$(__GNUC)sparc_C_PICFLAGS =	$(sparc_C_BIGPICFLAGS)
 
 DYNFLAGS +=	-R/usr/lib/smbsrv
 
diff --git a/usr/src/lib/smbsrv/libmlsvc/sparcv9/Makefile b/usr/src/lib/smbsrv/libmlsvc/sparcv9/Makefile
index e18b286..745535f 100644
--- a/usr/src/lib/smbsrv/libmlsvc/sparcv9/Makefile
+++ b/usr/src/lib/smbsrv/libmlsvc/sparcv9/Makefile
@@ -22,8 +22,6 @@
 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
 MACH_LDLIBS +=	-L$(ROOT)/usr/lib/smbsrv/$(MACH64)
 
@@ -33,8 +31,7 @@
 # With the adition of BIND 8.3.3, the symbol table for 64 bit went over
 # the limit for Kpic, so we add -KPIC here, for just the 64 bit SPARC
 # library. This avoids compiling the 32-bit library with PIC unnecessarily.
-sparcv9_C_PICFLAGS =	-K PIC
-sparcv9_CC_PICFLAGS =	-KPIC
+sparcv9_C_PICFLAGS =	$(sparcv9_C_BIGPICFLAGS)
 
 DYNFLAGS +=	-R/usr/lib/smbsrv/$(MACH64)
 
diff --git a/usr/src/lib/smbsrv/libsmbrp/sparcv9/Makefile b/usr/src/lib/smbsrv/libsmbrp/sparcv9/Makefile
index d138cfc..89460e9 100644
--- a/usr/src/lib/smbsrv/libsmbrp/sparcv9/Makefile
+++ b/usr/src/lib/smbsrv/libsmbrp/sparcv9/Makefile
@@ -29,8 +29,7 @@
 # With the adition of BIND 8.3.3, the symbol table for 64 bit went over
 # the limit for Kpic, so we add -KPIC here, for just the 64 bit SPARC
 # library. This avoids compiling the 32-bit library with PIC unnecessarily.
-sparcv9_C_PICFLAGS =	-K PIC
-sparcv9_CC_PICFLAGS =	-KPIC
+sparcv9_C_PICFLAGS =	$(sparcv9_C_BIGPICFLAGS)
 
 $(ROOTLIBDIR64):
 	$(INS.dir)
diff --git a/usr/src/tools/cw/cw.c b/usr/src/tools/cw/cw.c
index de3a57d..4e09752 100644
--- a/usr/src/tools/cw/cw.c
+++ b/usr/src/tools/cw/cw.c
@@ -71,8 +71,6 @@
  * -I<dir>	Add <dir> to preprocessor #include file search path
  * -i		Passed to linker to ignore any LD_LIBRARY_PATH setting
  * -keeptmp	Keep temporary files created during compilation
- * -KPIC	Compile position independent code with 32-bit addresses
- * -Kpic	Compile position independent code
  * -L<dir>	Pass to linker to add <dir> to the library search path
  * -l<name>	Link with library lib<name>.a or lib<name>.so
  * -mc		Remove duplicate strings from .comment section of output files
@@ -180,8 +178,6 @@
  * -I<dir>			pass-thru
  * -i				pass-thru
  * -keeptmp			-save-temps
- * -KPIC			-fPIC
- * -Kpic			-fpic
  * -L<dir>			pass-thru
  * -l<name>			pass-thru
  * -mc				error
@@ -567,7 +563,7 @@
 do_gcc(cw_ictx_t *ctx)
 {
 	int c;
-	int pic = 0, nolibc = 0;
+	int nolibc = 0;
 	int in_output = 0, seen_o = 0, c_files = 0;
 	cw_op_t op = CW_O_LINK;
 	char *model = NULL;
@@ -703,6 +699,14 @@
 			}
 			error(arg);
 			break;
+		case 'f':
+			if ((strcmp(arg, "-fpic") == 0) ||
+			    (strcmp(arg, "-fPIC") == 0)) {
+				newae(ctx->i_ae, arg);
+				break;
+			}
+			error(arg);
+			break;
 		case 'g':
 			newae(ctx->i_ae, "-gdwarf-2");
 			break;
@@ -819,27 +823,6 @@
 			}
 			error(arg);
 			break;
-		case 'K':
-			if (arglen == 1) {
-				if ((arg = *++ctx->i_oldargv) == NULL ||
-				    *arg == '\0')
-					error("-K");
-				ctx->i_oldargc--;
-			} else {
-				arg += 2;
-			}
-			if (strcmp(arg, "pic") == 0) {
-				newae(ctx->i_ae, "-fpic");
-				pic = 1;
-				break;
-			}
-			if (strcmp(arg, "PIC") == 0) {
-				newae(ctx->i_ae, "-fPIC");
-				pic = 1;
-				break;
-			}
-			error("-K");
-			break;
 		case 'm':
 			if (strcmp(arg, "-mt") == 0) {
 				newae(ctx->i_ae, "-D_REENTRANT");
@@ -986,8 +969,6 @@
 			}
 			if (strncmp(arg, "-Wc,-xcode=", 11) == 0) {
 				xlate(ctx->i_ae, arg + 11, xcode_tbl);
-				if (strncmp(arg + 11, "pic", 3) == 0)
-					pic = 1;
 				break;
 			}
 			if (strncmp(arg, "-Wc,-Qiselect", 13) == 0) {
@@ -1064,8 +1045,6 @@
 				}
 				if (strncmp(arg, "-xcode=", 7) == 0) {
 					xlate(ctx->i_ae, arg + 7, xcode_tbl);
-					if (strncmp(arg + 7, "pic", 3) == 0)
-						pic = 1;
 					break;
 				}
 				if (strncmp(arg, "-xcrossfile", 11) == 0)
@@ -1288,7 +1267,7 @@
 	    (ctx->i_flags & CW_F_SHADOW))
 		exit(0);
 
-	if (model && !pic)
+	if (model != NULL)
 		newae(ctx->i_ae, model);
 	if (!nolibc)
 		newae(ctx->i_ae, "-lc");
diff --git a/usr/src/ucbcmd/sbcp/Makefile b/usr/src/ucbcmd/sbcp/Makefile
index 8417665..ce1bf79 100644
--- a/usr/src/ucbcmd/sbcp/Makefile
+++ b/usr/src/ucbcmd/sbcp/Makefile
@@ -41,7 +41,7 @@
 LIBUCB=		../../ucblib/libucb/sparc/libucb.so.1
 
 # need libc/sparc/inc for PIC.h
-ASFLAGS=	-P -D_ASM -DPIC -K pic
+ASFLAGS=	-P -D_ASM -DPIC $(AS_PICFLAGS)
 LDFLAGS=	-R /usr/4lib:/usr/ucblib -e _start -G -t \
 		$(BLOCAL) $(ZNOVERSION) $(ZDEFS) $(ZTEXT) \
 		-I/usr/lib/ld.so.1