2 from sys import platform
5 src_dll = ["basics.cpp","command_line.cpp","enabler.cpp","files.cpp",
6 "find_files_posix.cpp","graphics.cpp","init.cpp","interface.cpp",
7 "keybindings.cpp","music_and_sound_openal.cpp", "random.cpp",
8 "textlines.cpp","glew.c","enabler_input.cpp","ViewBase.cpp",
9 "KeybindingScreen.cpp", "win32_compat.cpp", "textures.cpp",
10 "resize++.cpp", "renderer_offscreen.cpp",
13 dll = '#libs/libgraphics.so'
24 M64 = False if libgraphics else True
26 # Propagate PATH. We'll just take our chances with non-repeatable builds.
27 env = Environment(ENV = {'PATH' : os.environ['PATH']})
35 env["STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME"]=True
38 env['CXXCOM']="$CXX -o $TARGET -emit-llvm -pipe -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
39 env['CCCOM']="$CC -o $TARGET -emit-llvm -pipe -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
40 env['SHCCCOM']=env['CCCOM']
41 env['SHCXXCOM']=env['CXXCOM']
42 env["OBJSUFFIX"]=".bc"
43 env["SHOBJSUFFIX"]=".so.bc"
44 env["ARCOM"]="llvm-link $SOURCES -o $TARGET"
45 env["RANLIBCOM"]="true"
47 env["SHLINKCOM"]="llvm-link $SOURCES | opt -disable-internalize -std-link-opts | llc -O3 | g++ -shared -xassembler - -o $TARGET $SHLINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
48 env["LINKCOM"]="llvm-link $SOURCES | opt -disable-internalize -std-link-opts | llc -O3 | g++ -xassembler -o $TARGET - $LINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
50 env["SHLINKCOM"]="llvm-link $SOURCES | llc | g++ -shared -xassembler -fPIC -o $TARGET - $SHLINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
51 env["LINKCOM"]="llvm-link $SOURCES | llc | g++ -xassembler -o $TARGET - $LINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
53 env.Replace(CXX = os.environ.get("CXX") or "g++")
56 if not conf.CheckCXX():
57 print('error: no working C++ compiler detected.')
60 disablegtk = ARGUMENTS.get('disable-gtk', 0)
61 if not int(disablegtk):
63 conf.env.ParseConfig('pkg-config gtk+-2.0 --cflags --libs')
64 env['CCFLAGS'].append('-DHAVE_GTK2')
66 print 'gtk+-2.0 not found!'
68 disablecurses = ARGUMENTS.get('disable-curses', 0)
69 if not int(disablecurses):
70 # ncurses has a plethora of different configs, but does not offer pkg-config support
71 have_ncursesw = conf.CheckCHeader('ncursesw/curses.h') and conf.CheckLib('ncursesw')
72 have_ncurses = conf.CheckCHeader('ncurses.h') and conf.CheckLib('ncurses')
73 if have_ncurses or have_ncursesw:
74 conf.env['CCFLAGS'].append('-DCURSES')
76 print('ncurses not found')
78 env['LINKFLAGS'].append('-lncursesw')
79 env['CCFLAGS'].append('-DHAVE_NCURSESW')
81 env['LINKFLAGS'].append('-lncurses')
83 disablegl = ARGUMENTS.get('disable-gl', 0)
84 if not int(disablegl):
86 env.ParseConfig('pkg-config glu --cflags --libs')
87 env["CCFLAGS"].append('-DWANT_GL')
89 print 'glu not found, disabling GL'
94 # Init variables, and make sure they're around for appending to
95 # These variables are the ones used by the actual compilation. We construct
96 # them from ccflags/libs in varying ways depending on which compiler is used,
98 env['CPPPATH'].append(["#g_src/fmodexinclude"])
99 env['CCFLAGS'].append("-Dunix")
100 env['CXXFLAGS'].append("-std=gnu++0x")
101 env['LIBS'].append(["SDL_image","z","SDL_ttf"])
102 # If there's a library in the libs folder it will get linked over a system one.
103 env['LIBPATH'].append(["#libs"])
105 env['LIBPATH'].append("/usr/lib32")
106 env['LINKFLAGS'].append("-Wl,--as-needed")
107 #env['LINKFLAGS'].append('-Wl,-rpath=\$$ORIGIN/libs')
110 env["CPPPATH"].append('#g_src/glext')
111 env["CCFLAGS"].append('-DGLEW_STATIC') # Should only be needed on windows, but can't hurt.
113 # Generic unix, including Linux
114 if not clang and not M64:
115 env['ASFLAGS']="--32"
116 env['LINKFLAGS'].append("-m32")
117 env["CCFLAGS"].append("-m32")
119 env.ParseConfig('pkg-config openal --cflags')
120 env.ParseConfig('pkg-config sndfile --cflags')
121 env.ParseConfig('pkg-config sdl --cflags --libs')
123 ldflags=Split(os.environ.get("LDFLAGS"))
124 env['LINKFLAGS'].append(ldflags)
127 env["CCFLAGS"].append("-pg")
128 env['LINKFLAGS'].append("-pg")
133 env["CCFLAGS"]+=["-fomit-frame-pointer"]
135 env["CCFLAGS"]+=["-O3","-march=pentium3","-mfpmath=sse"]
137 env["CCFLAGS"]+=["-O3"]
139 env["CCFLAGS"].append("-O2") # Only to reduce WPO time
142 env["CCFLAGS"].append("-ggdb")
143 env["CCFLAGS"].append("-DDEBUG")
145 # Finally, do the build
147 env.SharedLibrary(dll, src_dll)
150 env.Program("#tetris", src_dll + ["tetris.cpp"])