diff --git a/refpolicy/doc/Makefile.example b/refpolicy/doc/Makefile.example
index 1fec02b..9f2a8d5 100644
--- a/refpolicy/doc/Makefile.example
+++ b/refpolicy/doc/Makefile.example
@@ -1,6 +1,8 @@
 
-NAME ?= refpolicy
-SHAREDIR := /usr/share/selinux
+AWK ?= gawk
+
+NAME ?= $(shell $(AWK) -F= '/^SELINUXTYPE/{ print $$2 }' /etc/selinux/config)
+SHAREDIR ?= /usr/share/selinux
 HEADERDIR := $(SHAREDIR)/$(NAME)/include
 
 include $(HEADERDIR)/Makefile
diff --git a/refpolicy/support/Makefile.devel b/refpolicy/support/Makefile.devel
index a059f87..8ecc4fc 100644
--- a/refpolicy/support/Makefile.devel
+++ b/refpolicy/support/Makefile.devel
@@ -1,5 +1,16 @@
 
-HEADERDIR ?= /usr/share/selinux/refpolicy
+# helper tools
+AWK ?= gawk
+INSTALL ?= install
+M4 ?= m4
+SED ?= sed
+EINFO ?= echo
+PYTHON ?= python
+
+NAME ?= $(shell $(AWK) -F= '/^SELINUXTYPE/{ print $$2 }' /etc/selinux/config)
+SHAREDIR ?= /usr/share/selinux
+HEADERDIR ?= $(SHAREDIR)/$(NAME)/include
+
 include $(HEADERDIR)/build.conf
 
 # executables
@@ -11,17 +22,8 @@ SEMODULE := $(SBINDIR)/semodule
 SEMOD_PKG := $(BINDIR)/semodule_package
 XMLLINT := $(BINDIR)/xmllint
 
-# helper tools
-AWK ?= gawk
-INSTALL ?= install
-M4 ?= m4
-SED ?= sed
-EINFO ?= echo
-PYTHON ?= python
-
 # set default build options if missing
 TYPE ?= strict
-NAME ?= $(TYPE)
 DIRECT_INITRC ?= n
 POLY ?= n
 QUIET ?= y