| 1 | function prepend(s, t) |
|---|
| 2 | for k, v in pairs(t) do t[k] = s .. v end |
|---|
| 3 | return t |
|---|
| 4 | end |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | -- Global variable _ACTION can be nil, for instance if you type `premake4 --help`. |
|---|
| 8 | BUILD_PATH = "build/" .. (_ACTION or "") |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | -- A solution contains projects, and defines the available configurations |
|---|
| 12 | solution "CafuEngine" |
|---|
| 13 | configurations { "Debug", "Release" } |
|---|
| 14 | location(BUILD_PATH) -- Generate solution files in this subdirectory. |
|---|
| 15 | |
|---|
| 16 | -- Global settings. |
|---|
| 17 | -- defines { "..." } |
|---|
| 18 | -- flags { "..." } -- TODO: Check which ones we need!! |
|---|
| 19 | |
|---|
| 20 | configuration { "vs20*" } |
|---|
| 21 | -- -- /GR Enable RTTI. |
|---|
| 22 | -- -- /EHsc Enable exception handling. |
|---|
| 23 | -- buildoptions { "/GR", "/EHsc" } -- TODO: Does premake4 set this by default? |
|---|
| 24 | defines { "_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_DEPRECATE" } |
|---|
| 25 | includedirs { "ExtLibs/libpng" } |
|---|
| 26 | includedirs { "ExtLibs/zlib" } |
|---|
| 27 | flags { "StaticRuntime", "No64BitChecks" } |
|---|
| 28 | |
|---|
| 29 | configuration "Debug" |
|---|
| 30 | -- envDebug.Append(CCFLAGS=Split("/MTd /Od /Z7 /RTC1")); |
|---|
| 31 | -- envDebug.Append(LINKFLAGS=["/debug"]); |
|---|
| 32 | flags { "Symbols" } |
|---|
| 33 | defines { "DEBUG", "SCONS_BUILD_DIR=" .. BUILD_PATH .. "/bin/Debug" } |
|---|
| 34 | targetdir(BUILD_PATH .. "/bin/Debug") |
|---|
| 35 | |
|---|
| 36 | configuration "Release" |
|---|
| 37 | -- envRelease.Append(CCFLAGS=Split("/MT /O2 /Ob2")); |
|---|
| 38 | flags { "OptimizeSpeed", "NoIncrementalLink" } |
|---|
| 39 | defines { "NDEBUG", "SCONS_BUILD_DIR=" .. BUILD_PATH .. "/bin/Release" } -- Need NDEBUG to have the assert macro generate no runtime code. |
|---|
| 40 | targetdir(BUILD_PATH .. "/bin/Release") |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | --[[ |
|---|
| 44 | #################################################### |
|---|
| 45 | ########### Build external libraries ########### |
|---|
| 46 | #################################################### |
|---|
| 47 | --]] |
|---|
| 48 | |
|---|
| 49 | project "alut" |
|---|
| 50 | kind "SharedLib" |
|---|
| 51 | language "C" |
|---|
| 52 | includedirs { "ExtLibs/freealut/include" } |
|---|
| 53 | files "ExtLibs/freealut/src/*.c" |
|---|
| 54 | |
|---|
| 55 | -- "defines" created using original VC++ project file as template (removed Windows specific defines for Linux build). |
|---|
| 56 | configuration "windows" |
|---|
| 57 | defines { "_WINDOWS", "_USRDLL", "ALUT_EXPORTS", "WIN32", "_MBCS", "ALUT_BUILD_LIBRARY", "HAVE__STAT", "HAVE_BASETSD_H", "HAVE_SLEEP", "HAVE_WINDOWS_H" } |
|---|
| 58 | includedirs { "ExtLibs/openal-win/include" } |
|---|
| 59 | links "OpenAL32" |
|---|
| 60 | libdirs { "ExtLibs/openal-win/libs/Win" .. (os.is64bit() and "64" or "32") } |
|---|
| 61 | |
|---|
| 62 | configuration "linux" |
|---|
| 63 | defines { "HAVE_STDINT_H", "ALUT_EXPORTS", "_MBCS", "ALUT_BUILD_LIBRARY", "HAVE_STAT", "HAVE_UNISTD_H", "HAVE_BASETSD_H", "HAVE_NANOSLEEP", "HAVE_TIME_H" } |
|---|
| 64 | includedirs { "ExtLibs/openal-soft/include" } |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | project "assimp" |
|---|
| 68 | kind "StaticLib" |
|---|
| 69 | language "C++" |
|---|
| 70 | -- Note that assimp currently uses the _DEBUG macro, that we never define (as opposed to DEBUG in debug builds). |
|---|
| 71 | defines { "ASSIMP_BUILD_BOOST_WORKAROUND", "ASSIMP_BUILD_NO_OWN_ZLIB", "ASSIMP_BUILD_NO_Q3BSP_IMPORTER" } |
|---|
| 72 | includedirs { "ExtLibs/assimp/include", "ExtLibs/assimp/code/BoostWorkaround", "ExtLibs/zlib" } |
|---|
| 73 | files { "ExtLibs/assimp/code/**.cpp", "ExtLibs/assimp/contrib/ConvertUTF/ConvertUTF.c", "ExtLibs/assimp/contrib/irrXML/irrXML.cpp" } |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | project "bulletmath" |
|---|
| 77 | kind "StaticLib" |
|---|
| 78 | language "C++" |
|---|
| 79 | includedirs { "ExtLibs/bullet/src" } |
|---|
| 80 | files "ExtLibs/bullet/src/LinearMath/**.cpp" |
|---|
| 81 | |
|---|
| 82 | project "bulletcollision" |
|---|
| 83 | kind "StaticLib" |
|---|
| 84 | language "C++" |
|---|
| 85 | includedirs { "ExtLibs/bullet/src" } |
|---|
| 86 | files "ExtLibs/bullet/src/BulletCollision/**.cpp" |
|---|
| 87 | |
|---|
| 88 | project "bulletdynamics" |
|---|
| 89 | kind "StaticLib" |
|---|
| 90 | language "C++" |
|---|
| 91 | includedirs { "ExtLibs/bullet/src" } |
|---|
| 92 | files "ExtLibs/bullet/src/BulletDynamics/**.cpp" |
|---|
| 93 | |
|---|
| 94 | project "bulletsoftbody" |
|---|
| 95 | kind "StaticLib" |
|---|
| 96 | language "C++" |
|---|
| 97 | includedirs { "ExtLibs/bullet/src" } |
|---|
| 98 | files "ExtLibs/bullet/src/BulletSoftBody/**.cpp" |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | -- TOOD: ONLY ON WINDOWS! |
|---|
| 102 | project "freetype" |
|---|
| 103 | kind "StaticLib" |
|---|
| 104 | language "C" |
|---|
| 105 | defines { "FT2_BUILD_LIBRARY" } |
|---|
| 106 | includedirs { "ExtLibs/freetype/include" } |
|---|
| 107 | -- The list of source files has been taken directly from the freetype/docs/INSTALL.ANY file. |
|---|
| 108 | files(prepend("ExtLibs/freetype/", string.explode([[src/base/ftsystem.c src/base/ftinit.c src/base/ftdebug.c |
|---|
| 109 | src/base/ftbase.c |
|---|
| 110 | src/base/ftbbox.c src/base/ftglyph.c src/base/ftbdf.c src/base/ftbitmap.c src/base/ftcid.c src/base/ftfstype.c |
|---|
| 111 | src/base/ftgasp.c src/base/ftgxval.c src/base/ftlcdfil.c src/base/ftmm.c src/base/ftotval.c src/base/ftpatent.c |
|---|
| 112 | src/base/ftpfr.c src/base/ftstroke.c src/base/ftsynth.c src/base/fttype1.c src/base/ftwinfnt.c src/base/ftxf86.c |
|---|
| 113 | |
|---|
| 114 | src/bdf/bdf.c src/cff/cff.c src/cid/type1cid.c src/pcf/pcf.c src/pfr/pfr.c src/sfnt/sfnt.c src/truetype/truetype.c |
|---|
| 115 | src/type1/type1.c src/type42/type42.c src/winfonts/winfnt.c |
|---|
| 116 | |
|---|
| 117 | src/raster/raster.c src/smooth/smooth.c |
|---|
| 118 | |
|---|
| 119 | src/autofit/autofit.c src/cache/ftcache.c src/gzip/ftgzip.c src/lzw/ftlzw.c src/gxvalid/gxvalid.c |
|---|
| 120 | src/otvalid/otvalid.c src/psaux/psaux.c src/pshinter/pshinter.c src/psnames/psnames.c]], "%s+"))) |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | project "cfs_jpeg" |
|---|
| 124 | kind "StaticLib" |
|---|
| 125 | language "C" |
|---|
| 126 | -- includedirs { "ExtLibs/lwo" } |
|---|
| 127 | files "ExtLibs/jpeg/j*.c" |
|---|
| 128 | excludes { "ExtLibs/jpeg/jpegtran.c", "ExtLibs/jpeg/jmemansi.c", "ExtLibs/jpeg/jmemname.c", "ExtLibs/jpeg/jmemdos.c", "ExtLibs/jpeg/jmemmac.c" } |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | project "lightwave" |
|---|
| 132 | kind "StaticLib" |
|---|
| 133 | language "C" |
|---|
| 134 | includedirs { "ExtLibs/lwo" } |
|---|
| 135 | files "ExtLibs/lwo/*.c" |
|---|
| 136 | excludes "ExtLibs/lwo/main.c" |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | project "lua" |
|---|
| 140 | kind "StaticLib" |
|---|
| 141 | language "C" |
|---|
| 142 | files { "ExtLibs/lua/src/l*.c" } |
|---|
| 143 | excludes { "ExtLibs/lua/src/lua*.c" } |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | project "minizip" |
|---|
| 147 | kind "StaticLib" |
|---|
| 148 | language "C" |
|---|
| 149 | files { "ExtLibs/minizip/unzip.c", "ExtLibs/minizip/ioapi.c" } |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | project "mpg123" |
|---|
| 153 | kind "SharedLib" |
|---|
| 154 | language "C" |
|---|
| 155 | defines { "OPT_GENERIC" } |
|---|
| 156 | files { "ExtLibs/mpg123/src/libmpg123/*.c" } |
|---|
| 157 | excludes { "ExtLibs/mpg123/src/libmpg123/dither.c", "ExtLibs/mpg123/src/libmpg123/*altivec.c", |
|---|
| 158 | "ExtLibs/mpg123/src/libmpg123/*86.c", "ExtLibs/mpg123/src/libmpg123/test*.c" } |
|---|
| 159 | |
|---|
| 160 | configuration "windows" |
|---|
| 161 | defines { "BUILD_MPG123_DLL" } |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | project "noise" |
|---|
| 165 | kind "StaticLib" |
|---|
| 166 | language "C++" |
|---|
| 167 | includedirs { "ExtLibs/noise/src" } |
|---|
| 168 | files "ExtLibs/noise/src/**.cpp" |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | project "ogg" |
|---|
| 172 | kind "StaticLib" |
|---|
| 173 | language "C" |
|---|
| 174 | includedirs { "ExtLibs/libogg/include" } |
|---|
| 175 | files "ExtLibs/libogg/src/*.c" |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | project "png" |
|---|
| 179 | kind "StaticLib" |
|---|
| 180 | language "C" |
|---|
| 181 | files "ExtLibs/libpng/*.c" |
|---|
| 182 | excludes { "ExtLibs/libpng/example.c", "ExtLibs/libpng/pngtest.c" } |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | project "vorbis" |
|---|
| 186 | kind "StaticLib" |
|---|
| 187 | language "C" |
|---|
| 188 | includedirs { "ExtLibs/libvorbis/include", "ExtLibs/libvorbis/lib", "ExtLibs/libogg/include" } |
|---|
| 189 | files "ExtLibs/libvorbis/lib/*.c" |
|---|
| 190 | excludes { "ExtLibs/libvorbis/lib/barkmel.c", "ExtLibs/libvorbis/lib/psytune.c", "ExtLibs/libvorbis/lib/tone.c", "ExtLibs/libvorbis/lib/vorbisfile.c" } |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | project "vorbisfile" |
|---|
| 194 | kind "StaticLib" |
|---|
| 195 | language "C" |
|---|
| 196 | includedirs { "ExtLibs/libvorbis/include", "ExtLibs/libvorbis/lib", "ExtLibs/libogg/include" } |
|---|
| 197 | files "ExtLibs/libvorbis/lib/vorbisfile.c" |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | project "z" |
|---|
| 201 | kind "StaticLib" |
|---|
| 202 | language "C" |
|---|
| 203 | files "ExtLibs/zlib/*.c" |
|---|
| 204 | excludes { "ExtLibs/zlib/example.c", "ExtLibs/zlib/minigzip.c" } |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | --[[ |
|---|
| 208 | ################################################ |
|---|
| 209 | ########### Build Cafu libraries ########### |
|---|
| 210 | ################################################ |
|---|
| 211 | --]] |
|---|
| 212 | |
|---|
| 213 | function cf_global() |
|---|
| 214 | includedirs { "Libs", "ExtLibs" } |
|---|
| 215 | flags { "FatalWarnings" } |
|---|
| 216 | configuration "windows" |
|---|
| 217 | buildoptions { "/J" } |
|---|
| 218 | configuration {} |
|---|
| 219 | end |
|---|
| 220 | |
|---|
| 221 | function cf_global_Libs() |
|---|
| 222 | includedirs { ".", "../ExtLibs" } |
|---|
| 223 | flags { "FatalWarnings" } |
|---|
| 224 | configuration "windows" |
|---|
| 225 | buildoptions { "/J" } |
|---|
| 226 | configuration {} |
|---|
| 227 | end |
|---|
| 228 | |
|---|
| 229 | include "Libs" |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | --[[ |
|---|
| 233 | ############################################### |
|---|
| 234 | ########### Build Cafu programs ########### |
|---|
| 235 | ############################################### |
|---|
| 236 | --]] |
|---|
| 237 | |
|---|
| 238 | project "CaBSP" |
|---|
| 239 | kind "ConsoleApp" |
|---|
| 240 | language "C++" |
|---|
| 241 | cf_global() |
|---|
| 242 | files { "CaBSP/CaBSP.cpp", "CaBSP/BspTreeBuilder/BspTreeBuilder.cpp", "Common/World.cpp" } -- TODO: Move Common/World.cpp into Libs/ ??? |
|---|
| 243 | links { "SceneGraph", "MatSys", "ClipSys", "cfsLib", "cfs_jpeg", "bulletcollision", "lua", "minizip", "lightwave", "png", "z" } |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | if _ACTION == "clean" then |
|---|
| 247 | for a in premake.action.each() do -- action trigger is "vs2008", "gmake", etc. |
|---|
| 248 | dir = "build/" .. a.trigger |
|---|
| 249 | if os.isdir(dir) then |
|---|
| 250 | local result, msg=os.rmdir(dir) |
|---|
| 251 | -- os.rmdir() always seems to return nil... |
|---|
| 252 | -- print("Removing directory " .. dir .. "... " .. (result and 'ok!' or msg)) |
|---|
| 253 | print("Removing directory " .. dir .. "...") |
|---|
| 254 | end |
|---|
| 255 | end |
|---|
| 256 | end |
|---|