Make SELinux automatic if present
diff --git a/Android.mk b/Android.mk
index 4cee5c7..8fc99b2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -79,13 +79,15 @@
     LOCAL_C_INCLUDES += system/extras/ext4_utils
     LOCAL_SHARED_LIBRARIES += libext4_utils
 endif
-
-ifeq ($(HAVE_SELINUX), true)
+ifneq ($(wildcard external/libselinux/Android.mk),)
+    TWHAVE_SELINUX := true
+endif
+ifeq ($(TWHAVE_SELINUX), true)
   #LOCAL_C_INCLUDES += external/libselinux/include
   #LOCAL_STATIC_LIBRARIES += libselinux
   #LOCAL_CFLAGS += -DHAVE_SELINUX -g
 endif # HAVE_SELINUX
-ifeq ($(HAVE_SELINUX), true)
+ifeq ($(TWHAVE_SELINUX), true)
     LOCAL_C_INCLUDES += external/libselinux/include
     LOCAL_SHARED_LIBRARIES += libselinux
     LOCAL_CFLAGS += -DHAVE_SELINUX -g
diff --git a/libtar/Android.mk b/libtar/Android.mk
index 9070f70..f936e96 100644
--- a/libtar/Android.mk
+++ b/libtar/Android.mk
@@ -11,7 +11,7 @@
 					external/zlib
 LOCAL_SHARED_LIBRARIES += libz libc
 
-ifeq ($(HAVE_SELINUX), true)
+ifeq ($(TWHAVE_SELINUX), true)
 	LOCAL_C_INCLUDES += external/libselinux/include
 	LOCAL_SHARED_LIBRARIES += libselinux
 	LOCAL_CFLAGS += -DHAVE_SELINUX
diff --git a/minzip/Android.mk b/minzip/Android.mk
index 3dd97ff..68485ab 100644
--- a/minzip/Android.mk
+++ b/minzip/Android.mk
@@ -35,7 +35,7 @@
 	external/zlib \
 	external/safe-iop/include
 
-ifeq ($(HAVE_SELINUX),true)
+ifeq ($(TWHAVE_SELINUX),true)
 LOCAL_C_INCLUDES += external/libselinux/include
 LOCAL_STATIC_LIBRARIES += libselinux
 LOCAL_CFLAGS += -DHAVE_SELINUX
diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk
index 08e09ac..0169fb8 100644
--- a/prebuilt/Android.mk
+++ b/prebuilt/Android.mk
@@ -51,7 +51,7 @@
 endif
 RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libaosprecovery.so
 RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libjpeg.so
-ifeq ($(HAVE_SELINUX), true)
+ifeq ($(TWHAVE_SELINUX), true)
     RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libselinux.so
     ifneq ($(TARGET_USERIMAGES_USE_EXT4), true)
         RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext4_utils.so