
Disable requirement for X.

Based on:
http://home.att.net/~Tom.Horsley/tah-tc-5.0.tar.gz

Don't use internal wxUSE_GUI but force the state.

---

diff -urNp truecrypt-5.0a-source.base1/Main/Application.cpp truecrypt-5.0a-source.new1/Main/Application.cpp
--- truecrypt-5.0a-source.base1/Main/Application.cpp	2008-02-04 13:14:16.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/Application.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -22,11 +22,13 @@ namespace TrueCrypt
 		return mUserInterface;
 	} 
 
+#ifdef ENABLE_wxGUI
 	wxApp* Application::CreateGuiApp ()
 	{
 		mUserInterface = new GraphicUserInterface;
 		return mUserInterface;
 	} 
+#endif
 
 	FilePath Application::GetConfigFilePath (const wxString &configFileName, bool createConfigDir)
 	{
@@ -72,11 +74,13 @@ namespace TrueCrypt
 				wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) CreateConsoleApp);
 				break;
 			}
+#ifdef ENABLE_wxGUI
 		case UserInterfaceType::Graphic:
 			{
 				wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) CreateGuiApp);
 				break;
 			}
+#endif
 
 		default:
 			throw ParameterIncorrect (SRC_POS);
diff -urNp truecrypt-5.0a-source.base1/Main/FatalErrorHandler.cpp truecrypt-5.0a-source.new1/Main/FatalErrorHandler.cpp
--- truecrypt-5.0a-source.base1/Main/FatalErrorHandler.cpp	2008-02-04 13:14:16.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/FatalErrorHandler.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -90,6 +90,7 @@ namespace TrueCrypt
 
 #endif // wxUSE_STACKWALKER
 
+#ifdef ENABLE_wxGUI
 		wxString url = Gui->GetHomepageLinkURL (L"err-report", vars.str());
 		url.Replace (L"0x", L"");
 
@@ -109,6 +110,7 @@ namespace TrueCrypt
 
 		if (Gui->AskYesNo (msg, true))
 			wxLaunchDefaultBrowser (url, wxBROWSER_NEW_WINDOW);
+#endif
 
 		_exit (1);
 	}
@@ -155,6 +157,7 @@ namespace TrueCrypt
 			vars.Replace (L"::", L".");
 			vars.Replace (L":", L".");
 
+#ifdef ENABLE_wxGUI
 			wxString url = Gui->GetHomepageLinkURL (L"err-report", vars);
 
 			wxString msg = L"An unhandled exception has occured and TrueCrypt must be terminated. If this is caused by a bug in TrueCrypt, we would like to fix it. To help us, you can send us an automatically generated error report containing the following items:\n\n- Program version\n- Operating system version\n- Hardware architecture\n- Error description\n- Error location\n";
@@ -164,15 +167,20 @@ namespace TrueCrypt
 
 			if (Gui->AskYesNo (msg, true))
 				wxLaunchDefaultBrowser (url, wxBROWSER_NEW_WINDOW);
+#endif
 
 		}
 		catch (exception &e)
 		{
+#ifdef ENABLE_wxGUI
 			Gui->ShowError (e);
+#endif
 		}
 		catch (...)
 		{
+#ifdef ENABLE_wxGUI
 			Gui->ShowError (_("Unknown exception occurred."));
+#endif
 		}
 
 		_exit (1);
diff -urNp truecrypt-5.0a-source.base1/Main/GraphicUserInterface.cpp truecrypt-5.0a-source.new1/Main/GraphicUserInterface.cpp
--- truecrypt-5.0a-source.base1/Main/GraphicUserInterface.cpp	2008-02-07 17:48:16.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/GraphicUserInterface.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -19,6 +19,9 @@
 #include "Application.h"
 #include "GraphicUserInterface.h"
 #include "FatalErrorHandler.h"
+
+#ifdef ENABLE_wxGUI
+
 #include "Forms/DeviceSelectionDialog.h"
 #include "Forms/MainFrame.h"
 #include "Forms/MountOptionsDialog.h"
@@ -1039,3 +1042,4 @@ namespace TrueCrypt
 
 	GraphicUserInterface *Gui = nullptr;
 }
+#endif
diff -urNp truecrypt-5.0a-source.base1/Main/GraphicUserInterface.h truecrypt-5.0a-source.new1/Main/GraphicUserInterface.h
--- truecrypt-5.0a-source.base1/Main/GraphicUserInterface.h	2008-02-05 19:56:46.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/GraphicUserInterface.h	2008-02-15 09:42:18.000000000 +0200
@@ -14,6 +14,7 @@
 #include "Main.h"
 #include "UserInterface.h"
 
+#ifdef ENABLE_wxGUI
 namespace TrueCrypt
 {
 	class GraphicUserInterface : public UserInterface
@@ -128,5 +129,6 @@ namespace TrueCrypt
 
 	extern GraphicUserInterface *Gui;
 }
+#endif
 
 #endif // TC_HEADER_Main_GraphicUserInterface
diff -urNp truecrypt-5.0a-source.base1/Main/Main.make truecrypt-5.0a-source.new1/Main/Main.make
--- truecrypt-5.0a-source.base1/Main/Main.make	2008-02-15 09:25:30.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/Main.make	2008-02-15 09:42:18.000000000 +0200
@@ -21,6 +21,7 @@ OBJS += UserPreferences.o
 OBJS += VolumeHistory.o
 OBJS += Xml.o
 OBJS += Unix/Main.o
+ifeq "$(TC_BUILD_GUI)" "True"
 OBJS += Forms/AboutDialog.o
 OBJS += Forms/ChangePasswordDialog.o
 OBJS += Forms/DeviceSelectionDialog.o
@@ -47,6 +48,7 @@ OBJS += Forms/VolumeLocationWizardPage.o
 OBJS += Forms/VolumePasswordWizardPage.o
 OBJS += Forms/VolumeSizeWizardPage.o
 OBJS += Forms/WizardFrame.o
+endif
 OBJS += Resources.o
 
 PCH := SystemPrecompiled.h.gch
@@ -67,15 +69,21 @@ WX_CONFIG_EXTRA ?= --static
 
 #------ wxWidgets configuration ------
 
+ifeq "$(TC_BUILD_GUI)" "True"
+WX_ASK_LIBS=adv,core,base
+else
+WX_ASK_LIBS=core,base
+endif
+ 
 ifeq "$(TC_BUILD_CONFIG)" "Release"
 
 CXXFLAGS += $(shell $(WX_CONFIG) $(WX_CONFIG_EXTRA) --cxxflags)
-WX_LIBS = $(shell $(WX_CONFIG) $(WX_CONFIG_EXTRA) --libs adv,core,base)
+WX_LIBS = $(shell $(WX_CONFIG) $(WX_CONFIG_EXTRA) --libs $(WX_ASK_LIBS))
 
 else
 
 CXXFLAGS += $(shell $(WX_CONFIG) $(WX_CONFIG_EXTRA) --debug --cxxflags)
-WX_LIBS = $(shell $(WX_CONFIG) $(WX_CONFIG_EXTRA) --debug --libs adv,core,base)
+WX_LIBS = $(shell $(WX_CONFIG) $(WX_CONFIG_EXTRA) --debug --libs $(WX_ASK_LIBS))
 
 endif
 
diff -urNp truecrypt-5.0a-source.base1/Main/Resources.cpp truecrypt-5.0a-source.new1/Main/Resources.cpp
--- truecrypt-5.0a-source.base1/Main/Resources.cpp	2008-02-04 13:14:16.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/Resources.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -35,6 +35,7 @@ namespace TrueCrypt
 	}
 #endif // TC_WINDOWS
 
+#ifdef ENABLE_wxGUI
 	wxBitmap Resources::GetDriveIconBitmap ()
 	{
 #ifdef TC_WINDOWS
@@ -72,6 +73,7 @@ namespace TrueCrypt
 #	endif
 #endif
 	}
+#endif
 
 	string Resources::GetLanguageXml ()
 	{
@@ -111,6 +113,7 @@ namespace TrueCrypt
 #endif
 	}
 
+#ifdef ENABLE_wxGUI
 	wxBitmap Resources::GetLogoBitmap ()
 	{
 #ifdef TC_WINDOWS
@@ -173,4 +176,5 @@ namespace TrueCrypt
 		return wxBitmap (image);
 #endif
 	}
+#endif
 }
diff -urNp truecrypt-5.0a-source.base1/Main/Resources.h truecrypt-5.0a-source.new1/Main/Resources.h
--- truecrypt-5.0a-source.base1/Main/Resources.h	2008-02-04 13:14:14.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/Resources.h	2008-02-15 09:42:18.000000000 +0200
@@ -17,14 +17,18 @@ namespace TrueCrypt
 	class Resources
 	{
 	public:
+#ifdef ENABLE_wxGUI
 		static wxBitmap GetDriveIconBitmap ();
 		static wxBitmap GetDriveIconMaskBitmap ();
+#endif
 		static string GetLanguageXml ();
 		static string GetLegalNotices ();
+#ifdef ENABLE_wxGUI
 		static wxBitmap GetLogoBitmap ();
 		static wxBitmap GetTextualLogoBitmap ();
 		static wxIcon GetTrueCryptIcon ();
 		static wxBitmap GetVolumeCreationWizardBitmap (int height = -1);
+#endif
 
 	protected:
 	};
diff -urNp truecrypt-5.0a-source.base1/Main/SystemPrecompiled.h truecrypt-5.0a-source.new1/Main/SystemPrecompiled.h
--- truecrypt-5.0a-source.base1/Main/SystemPrecompiled.h	2008-02-04 13:22:08.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/SystemPrecompiled.h	2008-02-15 09:42:18.000000000 +0200
@@ -9,7 +9,9 @@
 #include <wx/wx.h>
 #include <wx/dnd.h>
 #include <wx/filename.h>
+#ifdef ENABLE_wxGUI
 #include <wx/imaglist.h>
+#endif
 #include <wx/listctrl.h>
 #include <wx/mstream.h>
 #include <wx/power.h>
diff -urNp truecrypt-5.0a-source.base1/Main/TextUserInterface.cpp truecrypt-5.0a-source.new1/Main/TextUserInterface.cpp
--- truecrypt-5.0a-source.base1/Main/TextUserInterface.cpp	2008-02-04 18:38:04.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/TextUserInterface.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -423,8 +423,9 @@ namespace TrueCrypt
 
 			InterfaceType = UserInterfaceType::Text;
 			Init();
-
+#ifdef ENABLE_wxGUI
 			SetExitOnFrameDelete (false);
+#endif
 		}
 		catch (exception &e)
 		{
diff -urNp truecrypt-5.0a-source.base1/Main/Unix/Main.cpp truecrypt-5.0a-source.new1/Main/Unix/Main.cpp
--- truecrypt-5.0a-source.base1/Main/Unix/Main.cpp	2008-02-12 22:21:58.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/Unix/Main.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -59,6 +59,9 @@ int main (int argc, char **argv)
 		if (!getenv ("DISPLAY"))
 			forceTextUI = true;
 #endif
+#ifndef ENABLE_wxGUI
+		forceTextUI = true;
+#endif
 
 		// Set user interface type
 		if (forceTextUI || (argc > 1 && (strcmp (argv[1], "-t") == 0 || strcmp (argv[1], "--text") == 0)))
diff -urNp truecrypt-5.0a-source.base1/Main/UserInterface.cpp truecrypt-5.0a-source.new1/Main/UserInterface.cpp
--- truecrypt-5.0a-source.base1/Main/UserInterface.cpp	2008-02-12 22:28:34.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/UserInterface.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -302,8 +302,10 @@ namespace TrueCrypt
 		{
 			wxString message = ExceptionTypeToString (typeid (ex));
 
+#ifdef ENABLE_wxGUI
 			if (wxGetKeyState (WXK_CAPITAL))
 				message += wxString (L"\n\n") + LangString["CAPSLOCK_ON"];
+#endif
 
 			return message;
 		}
diff -urNp truecrypt-5.0a-source.base1/Main/VolumeHistory.cpp truecrypt-5.0a-source.new1/Main/VolumeHistory.cpp
--- truecrypt-5.0a-source.base1/Main/VolumeHistory.cpp	2008-02-04 13:14:16.000000000 +0200
+++ truecrypt-5.0a-source.new1/Main/VolumeHistory.cpp	2008-02-15 09:42:18.000000000 +0200
@@ -10,6 +10,9 @@
 #include "Application.h"
 #include "GraphicUserInterface.h"
 #include "Xml.h"
+
+#ifdef ENABLE_wxGUI
+
 #include "VolumeHistory.h"
 
 namespace TrueCrypt
@@ -150,3 +153,5 @@ namespace TrueCrypt
 	Mutex VolumeHistory::AccessMutex;
 
 }
+
+#endif
diff -urNp truecrypt-5.0a-source.base1/Makefile truecrypt-5.0a-source.new1/Makefile
--- truecrypt-5.0a-source.base1/Makefile	2008-02-04 20:19:02.000000000 +0200
+++ truecrypt-5.0a-source.new1/Makefile	2008-02-15 09:47:23.000000000 +0200
@@ -11,6 +11,7 @@
 # DEBUGGER:		Enable debugging information for use by debuggers
 # NOSTRIP:		Do not strip release binaries
 # VERBOSE:		Enable verbose messages
+# NOGUI:		Do not build GUI truecrypt
 
 #------ Targets ------
 # all
@@ -30,6 +31,11 @@ TC_BUILD_CONFIG := Debug
 endif
 endif
 
+export TC_BUILD_GUI := True
+
+ifeq "$(origin NOGUI)" "command line"
+TC_BUILD_GUI := False
+endif
 
 #------ Build configuration ------
 
@@ -145,6 +151,9 @@ C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_F
 
 endif
 
+ifeq "$(TC_BUILD_GUI)" "True"
+C_CXX_FLAGS += -DENABLE_wxGUI
+endif
 
 CFLAGS := $(C_CXX_FLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
 CXXFLAGS := $(C_CXX_FLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS)
@@ -189,6 +198,12 @@ CXXFLAGS :=
 LFLAGS :=
 endif
 
+ifeq "$(TC_BUILD_GUI)" "True"
+WX_NO_GUI:=
+else
+WX_NO_GUI:=--disable-gui
+endif
+
 wxbuild:
 
 ifneq "$(shell test -f $(WX_ROOT)/configure || test -f $(WX_BUILD_DIR)/../configure && echo 1)" "1"
@@ -198,7 +213,7 @@ endif
 
 	mkdir -p $(WX_BUILD_DIR)
 	@echo Configuring wxWidgets library...
-	cd $(WX_BUILD_DIR) && $(WX_ROOT)/configure $(WX_CONFIGURE_FLAGS) >/dev/null
+	cd $(WX_BUILD_DIR) && $(WX_ROOT)/configure $(WX_NO_GUI) $(WX_CONFIGURE_FLAGS) >/dev/null
 	
 	@echo Building wxWidgets library...
 	cd $(WX_BUILD_DIR) && make
