From 848972b5ad8361f54dc4dbc55f6c392925eaef33 Mon Sep 17 00:00:00 2001
From: patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>
Date: Wed, 28 Sep 2011 14:59:54 +0000
Subject: [PATCH] Fix sim build under Ubuntu 9.09

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3988 42af7a65-404d-4744-a932-0658087f49c3
---
 TODO                   | 12 ++----------
 arch/sim/src/Makefile  | 17 ++---------------
 configs/sim/README.txt | 37 ++++++++++++++++++++++++++++++++-----
 3 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/TODO b/TODO
index 71cba95235..028dca512e 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-NuttX TODO List (Last updated September 12, 2011)
+NuttX TODO List (Last updated September 28, 2011)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 This file summarizes known NuttX bugs, limitations, inconsistencies with 
@@ -21,7 +21,7 @@ nuttx/
   (1)  Pascal add-on (pcode/)
   (1)  Documentation (Documentation/)
   (5)  Build system / Toolchains
-  (7)  Linux/Cywgin simulation (arch/sim)
+  (6)  Linux/Cywgin simulation (arch/sim)
   (4)  ARM (arch/arm/)
   (1)  ARM/C5471 (arch/arm/src/c5471/)
   (3)  ARM/DM320 (arch/arm/src/dm320/)
@@ -622,14 +622,6 @@ o Linux/Cywgin simulation (arch/sim)
   Status:      Open
   Priority:    Low (unless you want to test networking features on the simulation).
   
-  Description: There is an X11-based framebuffer driver that you can use exercise
-               the NuttX graphics subsystem on the simulator.  But I am not much
-               of an X11 programmer so I did not use X11 autoconfiguration stuff.
-               As a result, it builds on old X11 installations, but not on current
-               versions.
-  Status:      Open
-  Priority:    Low (unless you want to test graphics features on the simulation).
-
   Description: Since the simulation is not pre-emptible, you can't use round-robin
                scheduling (no time slicing).  Currently, the timer interrupts are
                "faked" during IDLE loop processing and, as a result, there is no
diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index 808388410a..f7844a1d90 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -35,19 +35,6 @@
 
 -include $(TOPDIR)/Make.defs
 
-# The X11 stuff only builds on Linux (but not Ubuntu -- Ubuntu needs
-# some work).
-
-ifneq ($(HOSTOS),Cygwin)
-ifeq ($(CONFIG_SIM_X11FB),y)
-  USEX = y
-else
-  USEX = n
-endif
-else
-  USEX = n
-endif
-
 CFLAGS += -I$(TOPDIR)/sched
 
 ASRCS = up_setjmp.S
@@ -64,7 +51,7 @@ ifeq ($(CONFIG_NX_LCDDRIVER),y)
   CSRCS += up_lcd.c
 else
   CSRCS += up_framebuffer.c
-ifeq ($(USEX),y)
+ifeq ($(CONFIG_SIM_X11FB),y)
   HOSTSRCS += up_x11framebuffer.c
 endif
 endif
@@ -97,7 +84,7 @@ SRCS = $(ASRCS) $(CSRCS) $(HOSTSRCS)
 OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS)
 
 LDFLAGS = $(ARCHSCRIPT)
-ifeq ($(USEX),y)
+ifeq ($(CONFIG_SIM_X11FB),y)
   STDLIBS = -lX11 -lXext -lc
 else
   STDLIBS = -lc
diff --git a/configs/sim/README.txt b/configs/sim/README.txt
index aa12da3369..9d16abc37d 100644
--- a/configs/sim/README.txt
+++ b/configs/sim/README.txt
@@ -68,10 +68,20 @@ X11 Issues
 ^^^^^^^^^^
 
 There is an X11-based framebuffer driver that you can use exercise the NuttX graphics
-subsystem on the simulator (see the sim/nx configuration below).  But I am not much
-of an X11 programmer so I did not use X11 autoconfiguration stuff. As a result, the X11
-support builds on old X11 installations, but not on current versions.  This needs to
-get fixed someday.
+subsystem on the simulator (see the sim/nx configuration below).  This may require a
+lot of tinkering to get working, depending upon where your X11 installation stores
+libraries and header files and how it names libraries.
+
+For example, on UBuntu 9.09, I had to do the following to get a clean build:
+
+    cd /usr/lib/
+    sudo ln -s libXext.so.6.4.0 libXext.so
+
+(I also get a segmentation fault at the conclusion of the NX test -- that will need
+to get looked into as well).
+
+The X11 examples builds on Cygwin, but does not run.  The last time I tried it,
+XOpenDisplay() aborted the program.
 
 Configurations
 ^^^^^^^^^^^^^^
@@ -137,18 +147,35 @@ nx
 
     My system has 24-bit color, but packed into 32-bit words so
     the correct seeting of CONFIG_SIM_FBBPP is 32.
+
   - For whatever value of CONFIG_SIM_FBBPP is selected, then
     the corresponidng CONFIG_NX_DISABLE_*BPP setting must
     not be disabled.
+
   - The default in defconfig is to use a generic memory buffer
     for the framebuffer.  defconfig-x11 is an example with X11
-    support enabled.
+    support enabled.  To use this configuration you have to
+    configure as follows:
+
+    cd tools
+    ./configure.sh sim/nx
+    cd ..
+    cp configs/sim/nx/defconfig-x11 .config
+
   - The default is the single-user NX implementation.  To select
     the multi-user NX implementation:
 
       CONFG_NX_MULTIUSER=y
       CONFIG_DISABLE_MQUEUE=n
 
+  - To get the system to compile under various X11 installations
+    you may have to modify a few things.  For example, in order
+    to find libXext, I had to make the following change under
+    Ubuntu 9.09:
+
+    cd /usr/lib/
+    sudo ln -s libXext.so.6.4.0 libXext.so
+
 ostest
 
   The "standard" NuttX examples/ostest configuration.  This
-- 
GitLab