# Aszgard/MinGW-specific build file for scons
# Builds a basic Hello World using a vanilla
# build environment, then creates an build
# environment for building freeglut-based
# programs

import os

def aszgardPath( relPath ):
  return os.path.join( os.environ['ASZGARD'], relPath ).replace('\\','/')

# Create MinGW build environment.
basicEnv = Environment()

# GLUT path offsets from aszgard
glutInclude = aszgardPath( 'external/win32/glut-3.7-vc/include' )
glutLibPath = aszgardPath( 'external/win32/glut-3.7-vc/lib' )

# GLUT flags. Two sets, one for linking freeglut statically and one
# for using freeglut.dll.

# Flags for both cases...
glutFlags = {'CPPPATH':[glutInclude],
    'LIBPATH':[glutLibPath],
    }

# Libs for both cases...
commonLibs = ['glu32','opengl32','kernel32','user32','gdi32','winmm']

# dynamic
glutDllFlags = {
    'LIBS':['glut32']+commonLibs
    }

# We'll use the dll flags...(Makes smaller programs, but requires
# freeglut.dll be somewhere reachable, generally either in the
# current directory or on the PATH).
glutFlags.update( glutDllFlags )

# Create a clone of the build environment an stuff the new
# flags into it. Note that this entire script gets run before
# any of the targets are built. If we just stuffed the freeglut
# flags into env instead of cloning it, then hello.exe would
# get built with all the freeglut flags (which would work,
# but it's more instructive this way).
szgEnv = basicEnv.Clone()
szgEnv.MergeFlags( glutFlags )


Return('szgEnv')

