]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/sys/scons/SConscript.gl
hello world
[icculus/iodoom3.git] / neo / sys / scons / SConscript.gl
1 # -*- mode: python -*-
2 # DOOM build script
3 # TTimo <ttimo@idsoftware.com>
4 # http://scons.sourceforge.net
5
6 # various GL-related code:
7 # GL logging functions (used on all platforms)
8 # GLimp code (Linux only)
9 #   The C code is generated using M4 macros from a description of the GL API
10 #   on win32, the logging functions are generated ones and kept in the source
11 #   on other platforms, scons generates on the fly at build time
12
13 import time
14 Import('GLOBALS')
15 Import(GLOBALS)
16
17 # NOTE: make sure the .api files are in LF line endings, CRLF isn't working so well
18 def build_logfuncs(env, target, source):
19         import os, sys
20         # search for the module - source repository might make things harder
21         gllog_path = 'sys/gllog'
22         if ( not os.path.exists( gllog_path + '/logfunc.py' ) ):
23                 gllog_path = '/var/local/Doom/neo/sys/gllog'
24         sys.path.append( gllog_path )
25         from logfunc import do_logfunc
26         f_out = open('%s' % target[0], 'w')
27         f_out.write('// generated file, do not modify!\n')
28         f_out.write('// ' + time.asctime() + '\n')
29         f_out.write('// see SConscript.gl and sys/gllog/\n\n')
30
31         f_in = open( gllog_path + '/gl.api', 'r')
32         do_logfunc(f_in, f_out)
33         f_in.close()
34         
35         f_out.write('\n#ifdef __linux__\n\n')
36         f_in = open( gllog_path + '/glX.api', 'r')
37         do_logfunc(f_in, f_out)
38         f_in.close()
39         f_out.write('\n#endif\n\n')
40         
41         f_out.write('\n#ifdef WIN32\n\n')
42         f_in = open( gllog_path + '/wgl.api', 'r')
43         do_logfunc(f_in, f_out)
44         f_in.close()
45         f_out.write('\n#endif\n\n')
46         
47         f_out.close()
48         
49         print 'Generated %s' % target[0]
50
51 gl_env = g_env.Clone()
52 gl_env.Append( CPPPATH = '#' )
53 gl_env.Append( CPPFLAGS = '-DGLIMP' )
54
55 if ( local_dedicated == 1 ):
56         gl_env.Append( CPPFLAGS = '-DID_DEDICATED' )
57
58 # general M4 builder setup
59 # files we are going to generate from their M4 counterparts
60
61 m4_list = (
62         '../gllog/gl_extensions.cpp',
63         '../linux/glimp_dlopen.cpp',
64         '../linux/glimp_logging.cpp',
65         '../linux/glimp_stub.cpp',
66         '../linux/glimp_local.h' )
67
68 for i_m4 in m4_list:
69         gl_env.M4( i_m4, i_m4 + '.m4' )
70         gl_env.Depends( i_m4, '../gllog/gl_def.m4' )
71
72 # enable if you need to generate again
73 # FIXME: conflicts when several environements are used. move that to seperate script
74 #enforce = gl_env.M4( '#sys/linux/qgl_enforce.h', '../linux/qgl_enforce.h.m4' )
75 #gl_env.Depends( enforce, '../gllog/gl_def.m4' )
76
77 # logging functions, python generated ( that's beyond my m4-fu )
78
79 gl_env.Depends( '../linux/glimp_logging.cpp', '../linux/glimp_logfuncs.cpp' )
80
81 logfuncs = gl_env.Command( '../linux/glimp_logfuncs.cpp', '../gllog/logfunc.py', build_logfuncs )
82 gl_env.Depends( logfuncs, '../gllog/gl_def.m4' )
83
84 sources = []
85 sources.append( '../gllog/gl_extensions.cpp' )
86
87 if ( local_dedicated == 1 ):
88         sources.append( '../linux/glimp_stub.cpp' )
89 else:
90         sources.append( '../linux/glimp_dlopen.cpp' )
91         sources.append( '../linux/glimp_logging.cpp' )
92
93 #if ( DEDICATED != '0' ):
94 #       sources.append( '../linux/glimp_stub.cpp' )
95 #
96 #if ( GL_HARDLINK == '0' ):
97 #       sources.append( '../linux/glimp_dlopen.cpp' )
98 #       sources.append( '../linux/glimp_logging.cpp' )
99
100 lib = gl_env.StaticLibrary( 'glimp', sources )
101 #gl_env.Install( '../..', lib )