Resolve emulator opengl dependencies.

Test: lunch aosp_arm; mma -j BOARD_VNDK_VERSION=current
Test: builds

Bug: 37342627

Change-Id: I1dfb4a5cd3121ee83fc15cb885cdf4dad1317aa6
diff --git a/system/OpenglSystemCommon/Android.mk b/system/OpenglSystemCommon/Android.mk
index 71d851f..9305119 100644
--- a/system/OpenglSystemCommon/Android.mk
+++ b/system/OpenglSystemCommon/Android.mk
@@ -17,6 +17,11 @@
 $(call emugl-export,HEADER_LIBRARIES,libnativebase_headers)
 endif
 
+ifdef IS_AT_LEAST_OPD1
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+$(call emugl-export,HEADER_LIBRARIES,libhardware_headers)
+endif
+
 $(call emugl-export,C_INCLUDES,$(LOCAL_PATH) bionic/libc/private)
 
 $(call emugl-end-module)
diff --git a/system/egl/Android.mk b/system/egl/Android.mk
index 0c7317a..2d7a559 100644
--- a/system/egl/Android.mk
+++ b/system/egl/Android.mk
@@ -19,6 +19,11 @@
 LOCAL_SHARED_LIBRARIES += libdl
 endif
 
+ifdef IS_AT_LEAST_OPD1
+LOCAL_SHARED_LIBRARIES += libui
+LOCAL_HEADER_LIBRARIES += libnativebase_headers
+endif
+
 # Used to access the Bionic private OpenGL TLS slot
 LOCAL_C_INCLUDES += bionic/libc/private
 
diff --git a/system/egl/goldfish_sync.h b/system/egl/goldfish_sync.h
index 4667a77..6b30fe5 100644
--- a/system/egl/goldfish_sync.h
+++ b/system/egl/goldfish_sync.h
@@ -18,6 +18,10 @@
 #include <linux/ioctl.h>
 #include <linux/types.h>
 #include <sys/cdefs.h>
+#ifdef EMULATOR_OPENGL_POST_O
+#include <sys/ioctl.h>
+#include <sys/unistd.h>
+#endif
 #include <fcntl.h>
 
 // Make it conflict with ioctls that are not likely to be used