Permalink
Browse files

More build fixes for FreeBSD.

Adds BSD sysdep.
Adds support for MAKE variable, overriding make command in our build scripts.
Fixes more files not ending with newline.

git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@10994 3db68df2-c116-0410-a063-a993310a9797
  • Loading branch information...
1 parent 0be31b6 commit b2f86a62b7483b949b6ca87c73e99f6caf3245c0 ben committed Jan 31, 2012
@@ -617,6 +617,7 @@ function setup_all_libs ()
-- note: don't add "lib/sysdep/os/win/aken.cpp" because that must be compiled with the DDK.
windows = { "lib/sysdep/os/win", "lib/sysdep/os/win/wposix", "lib/sysdep/os/win/whrt" },
macosx = { "lib/sysdep/os/osx", "lib/sysdep/os/unix" },
+ bsd = { "lib/sysdep/os/bsd", "lib/sysdep/os/unix", "lib/sysdep/os/unix/x" },
}
for i,v in pairs(sysdep_dirs[os.get()]) do
table.insert(source_dirs, v);
@@ -1,5 +1,14 @@
#!/bin/sh
+# FreeBSD's make is different than GNU make, so we allow overriding the make command.
+# If not set, MAKE will default to "gmake" on FreeBSD, or "make" on other OSes
+if [ "`uname -s`" = "FreeBSD" ]
+then
+ MAKE=${MAKE:="gmake"}
+else
+ MAKE=${MAKE:="make"}
+fi
+
# (We don't attempt to clean up every last file here - output in
# binaries/system/ will still be there, etc. This is mostly just
# to quickly fix problems in the bundled dependencies.)
@@ -14,7 +23,7 @@ echo "Cleaning bundled third-party dependencies..."
(cd ../../libraries/spidermonkey && rm -rf ./js-1.8.5)
(cd ../../libraries/nvtt/src && rm -rf ./build)
-(cd ../premake/premake4/build/gmake.unix && make clean)
+(cd ../premake/premake4/build/gmake.unix && ${MAKE} clean)
echo "Cleaning build output..."
@@ -8,6 +8,15 @@ die()
JOBS=${JOBS:="-j2"}
+# FreeBSD's make is different than GNU make, so we allow overriding the make command.
+# If not set, MAKE will default to "gmake" on FreeBSD, or "make" on other OSes
+if [ "`uname -s`" = "FreeBSD" ]
+then
+ MAKE=${MAKE:="gmake"}
+else
+ MAKE=${MAKE:="make"}
+fi
+
# Parse command-line options:
premake_args=""
@@ -44,24 +53,24 @@ echo "Updating bundled third-party dependencies..."
echo
# Build/update bundled external libraries
-(cd ../../libraries/fcollada/src && make ${JOBS}) || die "FCollada build failed"
+(cd ../../libraries/fcollada/src && ${MAKE} ${JOBS}) || die "FCollada build failed"
echo
if [ "$with_system_mozjs185" = "false" ]; then
- (cd ../../libraries/spidermonkey && JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed"
+ (cd ../../libraries/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed"
fi
echo
if [ "$with_system_nvtt" = "false" ]; then
- (cd ../../libraries/nvtt && JOBS=${JOBS} ./build.sh) || die "NVTT build failed"
+ (cd ../../libraries/nvtt && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "NVTT build failed"
fi
echo
if [ "$with_system_enet" = "false" ]; then
- (cd ../../libraries/enet && JOBS=${JOBS} ./build.sh) || die "ENet build failed"
+ (cd ../../libraries/enet && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "ENet build failed"
fi
echo
# Now build premake and run it to create the makefiles
cd ../premake/premake4
-make -C build/gmake.unix ${JOBS} || die "Premake build failed"
+${MAKE} -C build/gmake.unix ${JOBS} || die "Premake build failed"
echo
View
@@ -3,15 +3,16 @@
set -e
JOBS=${JOBS:="-j2"}
+MAKE=${MAKE:="make"}
echo "Building libenet..."
echo
cd src/
-./configure
+./configure SET_MAKE=${MAKE}
-make ${JOBS}
+${MAKE} ${JOBS}
cd ../
View
@@ -3,6 +3,7 @@
set -e
JOBS=${JOBS:="-j2"}
+MAKE=${MAKE:="make"}
echo "Building NVTT..."
echo
@@ -12,7 +13,7 @@ cd src/build/
cmake .. -DNVTT_SHARED=1 -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"
-make nvtt ${JOBS}
+${MAKE} nvtt ${JOBS}
cd ../../
@@ -18,6 +18,7 @@ echo "Building SpiderMonkey..."
echo
JOBS=${JOBS:="-j2"}
+MAKE=${MAKE:="make"}
MAKE_OPTS="${JOBS}"
@@ -56,14 +57,14 @@ perl -i.bak -pe 's/^(LIBRARY_NAME\s+= mozjs185)(-ps-debug|-ps-release)?/$1-ps-de
mkdir -p build-debug
cd build-debug
../configure ${CONF_OPTS} --enable-debug --disable-optimize
-make ${MAKE_OPTS}
+${MAKE} ${MAKE_OPTS}
cd ..
perl -i.bak -pe 's/^(LIBRARY_NAME\s+= mozjs185)(-ps-debug|-ps-release)?/$1-ps-release/' Makefile.in
mkdir -p build-release
cd build-release
../configure ${CONF_OPTS} # --enable-gczeal --enable-debug-symbols
-make ${MAKE_OPTS}
+${MAKE} ${MAKE_OPTS}
cd ..
# Remove the library suffixes to avoid spurious SVN diffs
@@ -89,4 +89,4 @@ void CModelAbstract::CalcSelectionBox()
objBounds.Transform(GetTransform(), m_SelectionBox);
}
-}
+}
@@ -102,4 +102,4 @@ void CTerrainTextureEntry::BuildBaseColor()
const float* CTerrainTextureEntry::GetTextureMatrix()
{
return &m_TextureMatrix._11;
-}
+}
@@ -216,4 +216,4 @@ std::vector<STerritoryBoundary> CTerritoryBoundaryCalculator::ComputeBoundaries(
}
return boundaries;
-}
+}
@@ -64,4 +64,4 @@ class CTextRenderer
std::vector<SBatch> m_Batches;
};
-#endif // INCLUDED_TEXTRENDERER
+#endif // INCLUDED_TEXTRENDERER
@@ -0,0 +1,124 @@
+/* Copyright (c) 2012 Wildfire Games
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "precompiled.h"
+
+#include "lib/sysdep/os_cpu.h"
+#include "lib/alignment.h"
+#include "lib/bits.h"
+#include "lib/module_init.h"
+
+#include "valgrind.h"
+#include <sys/sysctl.h>
+
+size_t os_cpu_NumProcessors()
+{
+ static size_t numProcessors;
+
+ if(numProcessors == 0)
+ {
+ // Valgrind reports the number of real CPUs, but only emulates a single CPU.
+ // That causes problems when we expect all those CPUs to be distinct, so
+ // just pretend there's only one CPU
+ if (RUNNING_ON_VALGRIND)
+ numProcessors = 1;
+ else
+ {
+ long res = sysconf(_SC_NPROCESSORS_CONF);
+ ENSURE(res != -1);
+ numProcessors = (size_t)res;
+ }
+ }
+
+ return numProcessors;
+}
+
+
+uintptr_t os_cpu_ProcessorMask()
+{
+ static uintptr_t processorMask;
+
+ if(!processorMask)
+ processorMask = bit_mask<uintptr_t>(os_cpu_NumProcessors());
+
+ return processorMask;
+}
+
+
+size_t os_cpu_PageSize()
+{
+ static size_t pageSize;
+
+ if(!pageSize)
+ pageSize = (size_t)sysconf(_SC_PAGESIZE);
+
+ return pageSize;
+}
+
+
+size_t os_cpu_LargePageSize()
+{
+ // assume they're unsupported.
+ return 0;
+}
+
+
+size_t os_cpu_QueryMemorySize()
+{
+ size_t memorySize = 0;
+ size_t len = sizeof(memorySize);
+ // Argh, the API doesn't seem to be const-correct
+ /*const*/ int mib[2] = { CTL_HW, HW_PHYSMEM };
+ sysctl(mib, 2, &memorySize, &len, 0, 0);
+ memorySize /= MiB;
+ return memorySize;
+}
+
+
+size_t os_cpu_MemoryAvailable()
+{
+ size_t memoryAvailable = 0;
+ size_t len = sizeof(memoryAvailable);
+ // Argh, the API doesn't seem to be const-correct
+ /*const*/ int mib[2] = { CTL_HW, HW_USERMEM };
+ sysctl(mib, 2, &memoryAvailable, &len, 0, 0);
+ memoryAvailable /= MiB;
+ return memoryAvailable;
+}
+
+uintptr_t os_cpu_SetThreadAffinityMask(uintptr_t UNUSED(processorMask))
+{
+ // not yet implemented
+ return os_cpu_ProcessorMask();
+}
+
+Status os_cpu_CallByEachCPU(OsCpuCallback cb, uintptr_t cbData)
+{
+ for(size_t processor = 0; processor < os_cpu_NumProcessors(); processor++)
+ {
+ const uintptr_t processorMask = uintptr_t(1) << processor;
+ os_cpu_SetThreadAffinityMask(processorMask);
+ cb(processor, cbData);
+ }
+
+ return INFO::OK;
+}
Oops, something went wrong.

0 comments on commit b2f86a6

Please sign in to comment.