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'
23 M64 = False if libgraphics else True
25 # Propagate PATH. We'll just take our chances with non-repeatable builds.
26 env = Environment(ENV = {'PATH' : os.environ['PATH']})
34 env["STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME"]=True
37 env['CXXCOM']="$CXX -o $TARGET -emit-llvm -pipe -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
38 env['CCCOM']="$CC -o $TARGET -emit-llvm -pipe -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
39 env['SHCCCOM']=env['CCCOM']
40 env['SHCXXCOM']=env['CXXCOM']
41 env["OBJSUFFIX"]=".bc"
42 env["SHOBJSUFFIX"]=".so.bc"
43 env["ARCOM"]="llvm-link $SOURCES -o $TARGET"
44 env["RANLIBCOM"]="true"
46 env["SHLINKCOM"]="llvm-link $SOURCES | opt -disable-internalize -std-link-opts | llc -O3 | g++ -shared -xassembler - -o $TARGET $SHLINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
47 env["LINKCOM"]="llvm-link $SOURCES | opt -disable-internalize -std-link-opts | llc -O3 | g++ -xassembler -o $TARGET - $LINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
49 env["SHLINKCOM"]="llvm-link $SOURCES | llc | g++ -shared -xassembler -fPIC -o $TARGET - $SHLINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
50 env["LINKCOM"]="llvm-link $SOURCES | llc | g++ -xassembler -o $TARGET - $LINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS"
52 env.Replace(CXX = os.environ.get("CXX") or "g++")
55 if not conf.CheckCXX():
56 print('error: no working C++ compiler detected.')
59 disabledebug = ARGUMENTS.get('disable-debug', 0)
66 disablegtk = ARGUMENTS.get('disable-gtk', 0)
67 if not int(disablegtk):
69 conf.env.ParseConfig('pkg-config gtk+-2.0 --cflags --libs')
70 env['CCFLAGS'].append('-DHAVE_GTK2')
72 print 'gtk+-2.0 not found!'
74 disablecurses = ARGUMENTS.get('disable-curses', 0)
75 if not int(disablecurses):
76 # ncurses has a plethora of different configs, but does not offer pkg-config support
77 have_ncursesw = conf.CheckLib('ncursesw')
78 have_ncursesw_curses_h = conf.CheckCHeader('ncursesw/curses.h')
79 have_ncurses = conf.CheckCHeader('ncurses.h') and conf.CheckLib('ncurses')
80 if have_ncurses or have_ncursesw:
81 conf.env['CCFLAGS'].append('-DCURSES')
83 print('ncurses not found')
85 env['LINKFLAGS'].append('-lncursesw')
86 env['CCFLAGS'].append('-DHAVE_NCURSESW')
88 env['LINKFLAGS'].append('-lncurses')
89 if have_ncursesw_curses_h:
90 env['CCFLAGS'].append('-DHAVE_NCURSESW_CURSES_H')
92 disablegl = ARGUMENTS.get('disable-gl', 0)
93 if not int(disablegl):
95 env.ParseConfig('pkg-config glu --cflags --libs')
96 env["CCFLAGS"].append('-DWANT_GL')
98 print 'glu not found, disabling GL'
103 # Init variables, and make sure they're around for appending to
104 # These variables are the ones used by the actual compilation. We construct
105 # them from ccflags/libs in varying ways depending on which compiler is used,
107 env['CPPPATH'].append(["#g_src/fmodexinclude"])
108 env['CCFLAGS'].append("-Dunix")
109 env['CXXFLAGS'].append("-std=gnu++0x")
110 env['LIBS'].append(["SDL_image","z","SDL_ttf"])
111 # If there's a library in the libs folder it will get linked over a system one.
112 env['LIBPATH'].append(["#libs"])
114 env['LIBPATH'].append("/usr/lib32")
115 env['LINKFLAGS'].append("-Wl,--as-needed")
116 #env['LINKFLAGS'].append('-Wl,-rpath=\$$ORIGIN/libs')
119 env["CPPPATH"].append('#g_src/glext')
120 env["CCFLAGS"].append('-DGLEW_STATIC') # Should only be needed on windows, but can't hurt.
122 # Generic unix, including Linux
123 if not clang and not M64:
124 env['ASFLAGS']="--32"
125 env['LINKFLAGS'].append("-m32")
126 env["CCFLAGS"].append("-m32")
128 env.ParseConfig('pkg-config openal --cflags')
129 env.ParseConfig('pkg-config sndfile --cflags')
130 env.ParseConfig('pkg-config sdl --cflags --libs')
132 ldflags=Split(os.environ.get("LDFLAGS"))
133 env['LINKFLAGS'].append(ldflags)
136 env["CCFLAGS"].append("-pg")
137 env['LINKFLAGS'].append("-pg")
142 env["CCFLAGS"]+=["-fomit-frame-pointer"]
144 env["CCFLAGS"]+=["-O3","-march=pentium3","-mfpmath=sse"]
146 env["CCFLAGS"]+=["-O3"]
148 env["CCFLAGS"].append("-O2") # Only to reduce WPO time
151 env["CCFLAGS"].append("-ggdb")
152 env["CCFLAGS"].append("-DDEBUG")
154 # Finally, do the build
156 env.SharedLibrary(dll, src_dll)
159 env.Program("#tetris", src_dll + ["tetris.cpp"])