diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -11,6 +11,7 @@
 import Distribution.Text ( display )
 import Control.Monad
 import Data.List
+import Control.Applicative((<$>))
 import Distribution.Simple.Program
   ( Program(..), ConfiguredProgram(..), programPath
    , requireProgram, requireProgramVersion
diff --git a/fltkhs.cabal b/fltkhs.cabal
--- a/fltkhs.cabal
+++ b/fltkhs.cabal
@@ -1,5 +1,5 @@
 name : fltkhs
-version : 0.5.2.8
+version : 0.5.2.9
 synopsis : FLTK bindings
 description: Low level bindings for the FLTK GUI toolkit. For installation and quick start instruction please scroll all the way down to the README.
 license : MIT
diff --git a/src/Graphics/UI/FLTK/LowLevel/Fl_Enumerations.chs b/src/Graphics/UI/FLTK/LowLevel/Fl_Enumerations.chs
--- a/src/Graphics/UI/FLTK/LowLevel/Fl_Enumerations.chs
+++ b/src/Graphics/UI/FLTK/LowLevel/Fl_Enumerations.chs
@@ -43,12 +43,12 @@
      GlutWindowProperties(..),
      GlutCursor(..),
      glutCursorFullCrossHair,
+#endif
      -- * Various modes
      Mode(..),
      Modes(..),
      single,
      allModes,
-#endif
      -- * Alignment
      Alignments(..),
      AlignType(..),
@@ -510,9 +510,11 @@
  ModeMultisample = FL_MULTISAMPLE,
  ModeStereo      = FL_STEREO,
  ModeFakeSingle  = FL_FAKE_SINGLE
+#ifdef GLSUPPORT
 #if FLTK_API_VERSION >= 10304
  , ModeOpenGL3     = FL_OPENGL3
 #endif
+#endif
 };
 enum AlignType {
  AlignTypeCenter          = 0,
@@ -678,15 +680,12 @@
 -- | Only available if the 'opengl' flag is set (stack build --flag fltkhs:opengl).
 glutCursorFullCrossHair :: GlutCursor
 glutCursorFullCrossHair = GlutCursorCrosshair
--- | Only available if the 'opengl' flag is set (stack build --flag fltkhs:opengl).
+#endif /* GLSUPPORT */
 {#enum Mode   {} deriving (Show,Eq,Ord) #}
 -- Fl_Mode Aliases
--- | Only available if the 'opengl' flag is set (stack build --flag fltkhs:opengl).
 single :: Mode
 single = ModeRGB
--- | Only available if the 'opengl' flag is set (stack build --flag fltkhs:opengl).
 newtype Modes = Modes [Mode] deriving (Show,Eq,Ord)
--- | Only available if the 'opengl' flag is set (stack build --flag fltkhs:opengl).
 allModes :: [Mode]
 allModes =
   [
@@ -702,10 +701,11 @@
     ModeStereo,
     ModeFakeSingle
 #if FLTK_API_VERSION >= 10304
+#ifdef GLSUPPORT
     , ModeOpenGL3
 #endif
+#endif
   ]
-#endif /* GLSUPPORT */
 
 {#enum AlignType {} deriving (Show, Eq, Ord) #}
 newtype Alignments = Alignments [AlignType] deriving Show
diff --git a/src/Graphics/UI/FLTK/LowLevel/Fl_Types.chs b/src/Graphics/UI/FLTK/LowLevel/Fl_Types.chs
--- a/src/Graphics/UI/FLTK/LowLevel/Fl_Types.chs
+++ b/src/Graphics/UI/FLTK/LowLevel/Fl_Types.chs
@@ -412,7 +412,7 @@
 
 #ifdef CALLSTACK_AVAILABLE
 toRefPtr :: (?loc :: CallStack) => Ptr (Ptr a) -> IO (Ptr a)
-#elif HASCALLSTACK_AVAILABLE
+#elif defined(HASCALLSTACK_AVAILABLE)
 toRefPtr :: HasCallStack => Ptr (Ptr a) -> IO (Ptr a)
 #else
 toRefPtr :: Ptr (Ptr a) -> IO (Ptr a)
@@ -422,7 +422,7 @@
   if (refPtr == nullPtr)
 #ifdef CALLSTACK_AVAILABLE
    then error $ "Ref does not exist. " ++ (showCallStack ?loc)
-#elif HASCALLSTACK_AVAILABLE
+#elif defined(HASCALLSTACK_AVAILABLE)
    then error $ "Ref does not exist. " ++ (prettyCallStack callStack)
 #else
    then error "Ref does not exist. "
@@ -431,7 +431,7 @@
 
 #ifdef CALLSTACK_AVAILABLE
 withRef :: (?loc :: CallStack) => Ref a -> (Ptr b -> IO c) -> IO c
-#elif HASCALLSTACK_AVAILABLE
+#elif defined(HASCALLSTACK_AVAILABLE)
 withRef :: HasCallStack => Ref a -> (Ptr b -> IO c) -> IO c
 #else
 withRef :: Ref a -> (Ptr b -> IO c) -> IO c
@@ -454,7 +454,7 @@
 
 #ifdef CALLSTACK_AVAILABLE
 unsafeRefToPtr :: (?loc :: CallStack) => Ref a -> IO (Ptr ())
-#elif HASCALLSTACK_AVAILABLE
+#elif defined(HASCALLSTACK_AVAILABLE)
 unsafeRefToPtr :: HasCallStack => Ref a -> IO (Ptr ())
 #else
 unsafeRefToPtr :: Ref a -> IO (Ptr ())
diff --git a/src/Graphics/UI/FLTK/LowLevel/Hierarchy.hs b/src/Graphics/UI/FLTK/LowLevel/Hierarchy.hs
--- a/src/Graphics/UI/FLTK/LowLevel/Hierarchy.hs
+++ b/src/Graphics/UI/FLTK/LowLevel/Hierarchy.hs
@@ -8,7 +8,7 @@
 data Datatype a; \
 Method :: (?loc :: CallStack, Match r ~ FindOp a a (Datatype ()), Op (Datatype ()) r a impl) => Ref a -> impl; \
 Method aRef = (unsafePerformIO $ withRef aRef (\_ -> return ())) `seq` dispatch (undefined :: Datatype()) aRef
-#elif HASCALLSTACK_AVAILABLE
+#elif defined(HASCALLSTACK_AVAILABLE)
 #define MAKE_METHOD(Datatype, Method) \
 data Datatype a; \
 Method :: (HasCallStack, Match r ~ FindOp a a (Datatype ()), Op (Datatype ()) r a impl) => Ref a -> impl; \
diff --git a/src/Graphics/UI/FLTK/LowLevel/Utils.hs b/src/Graphics/UI/FLTK/LowLevel/Utils.hs
--- a/src/Graphics/UI/FLTK/LowLevel/Utils.hs
+++ b/src/Graphics/UI/FLTK/LowLevel/Utils.hs
@@ -267,7 +267,7 @@
 
 #ifdef CALLSTACK_AVAILABLE
 cStringToText :: (?loc :: CallStack) => CString -> IO T.Text
-#elif HASCALLSTACK_AVAILABLE
+#elif defined(HASCALLSTACK_AVAILABLE)
 cStringToText :: (HasCallStack) => CString -> IO T.Text
 #else
 cStringToText :: CString -> IO T.Text
