Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Add FreeBSD (tested) and other BSD systems (not tested) to build and run.

Rozhuk Ivanac51abc2540a
diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt
index 56ecdc7c9..0d9c5e534 100644
--- a/toonz/sources/CMakeLists.txt
+++ b/toonz/sources/CMakeLists.txt
@@ -196,6 +196,11 @@ elseif(BUILD_ENV_UNIXLIKE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DLINUX)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly")
+ set(BUILD_TARGET_BSD ON)
+ add_definitions(-D_BSD_SOURCE -DFREEBSD)
+ include_directories("/usr/local/include/")
+ message(STATUS "Configuring for BSD system")
elseif(NOT BUILD_TARGET_WIN)
message(WARNING "Support for generic Unix (Not Apple or Linux) isn't yet working!")
endif()
@@ -421,7 +426,9 @@ elseif(BUILD_ENV_UNIXLIKE)
endif()
find_library(Z_LIB z)
- find_package(TIFF REQUIRED)
+ if(NOT BUILD_TARGET_BSD)
+ find_package(TIFF REQUIRED)
+ endif()
find_package(PNG REQUIRED)
set(PNG_LIB ${PNG_LIBRARY})
message("******* libpng:" ${PNG_LIB})
diff --git a/toonz/sources/common/tapptools/tenv.cpp b/toonz/sources/common/tapptools/tenv.cpp
index 1777ec546..ff229990f 100644
--- a/toonz/sources/common/tapptools/tenv.cpp
+++ b/toonz/sources/common/tapptools/tenv.cpp
@@ -507,7 +507,7 @@ void TEnv::setApplicationFileName(std::string appFileName) {
#ifdef MACOSX
if (fp.getWideName().find(L".app"))
for (int i = 0; i < 3; i++) fp = fp.getParentDir();
-#elif LINUX
+#elif defined(LINUX) || defined(FREEBSD)
if (fp.getWideName().find(L".appimage"))
for (int i = 0; i < 2; i++) fp = fp.getParentDir();
#endif
diff --git a/toonz/sources/common/tgl/tgl.cpp b/toonz/sources/common/tgl/tgl.cpp
index c4bcd70e4..3208b1e89 100644
--- a/toonz/sources/common/tgl/tgl.cpp
+++ b/toonz/sources/common/tgl/tgl.cpp
@@ -12,14 +12,14 @@
#ifdef _WIN32
#include <cstdlib>
#include <GL/glut.h>
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
#include <GL/glut.h>
#else
#include <GLUT/glut.h>
#endif
#endif
-#if defined(MACOSX) || defined(LINUX)
+#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
#include <QGLContext>
#endif
@@ -617,7 +617,7 @@ void tglMakeCurrent(TGlContext context) {
void tglDoneCurrent(TGlContext) { wglMakeCurrent(NULL, NULL); }
-#elif defined(LINUX) || defined(__sgi) || defined(MACOSX)
+#elif defined(LINUX) || defined(FREEBSD) || defined(__sgi) || defined(MACOSX)
TGlContext tglGetCurrentContext() {
return reinterpret_cast<TGlContext>(
diff --git a/toonz/sources/common/tiio/bmp/filebmp.h b/toonz/sources/common/tiio/bmp/filebmp.h
index d6911ffec..75be7add2 100644
--- a/toonz/sources/common/tiio/bmp/filebmp.h
+++ b/toonz/sources/common/tiio/bmp/filebmp.h
@@ -11,7 +11,7 @@ extern "C" {
typedef struct {unsigned char b,g,r,m;} LPIXEL;
#elif defined(__sgi)
typedef struct { unsigned char m,b,g,r; } LPIXEL;
-#elif defined (LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
typedef struct { unsigned char r,g,b,m; } LPIXEL;
#else
#error Not yet implemented
diff --git a/toonz/sources/common/tiio/compatibility/tfile_io.c b/toonz/sources/common/tiio/compatibility/tfile_io.c
index 8fabd3bc1..83c3ac1f1 100644
--- a/toonz/sources/common/tiio/compatibility/tfile_io.c
+++ b/toonz/sources/common/tiio/compatibility/tfile_io.c
@@ -58,7 +58,7 @@ char *convertWCHAR2CHAR(const wchar_t *wc) {
}
#endif
/*-----------------------------------*/
-#if defined(MACOSX) || defined(LINUX)
+#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
FILE *_wfopen(const wchar_t *fname, const wchar_t *mode) {
char *cfname = convertWCHAR2CHAR(fname);
diff --git a/toonz/sources/common/tiio/compatibility/tfile_io.h b/toonz/sources/common/tiio/compatibility/tfile_io.h
index 93233d902..f85b02278 100644
--- a/toonz/sources/common/tiio/compatibility/tfile_io.h
+++ b/toonz/sources/common/tiio/compatibility/tfile_io.h
@@ -9,13 +9,13 @@ extern "C" {
#include <stdio.h>
-#if defined(MACOSX) || defined(LINUX)
+#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
#include <stddef.h>
#endif
char *convertWCHAR2CHAR(const wchar_t *fname);
-#if defined(MACOSX) || defined(LINUX)
+#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/toonz/sources/common/tiio/movsettings.cpp b/toonz/sources/common/tiio/movsettings.cpp
index 98952d4de..07d43d3cd 100644
--- a/toonz/sources/common/tiio/movsettings.cpp
+++ b/toonz/sources/common/tiio/movsettings.cpp
@@ -7,7 +7,7 @@
#include "tproperty.h"
#include "tiio.h"
-#if !defined(x64) && !defined(__LP64__) && !defined(LINUX) && !(defined(__GNUC__) && defined(_WIN32))
+#if !defined(x64) && !defined(__LP64__) && !(defined(LINUX) || defined(FREEBSD)) && !(defined(__GNUC__) && defined(_WIN32))
//*******************************************************************************
// 32-bit version
diff --git a/toonz/sources/common/timage_io/timage_io.cpp b/toonz/sources/common/timage_io/timage_io.cpp
index 837fc561e..11eb5d0cd 100644
--- a/toonz/sources/common/timage_io/timage_io.cpp
+++ b/toonz/sources/common/timage_io/timage_io.cpp
@@ -24,7 +24,7 @@
#ifdef _WIN32
#include <io.h>
#endif
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
#include <unistd.h>
#endif
diff --git a/toonz/sources/common/tipc/tipc.cpp b/toonz/sources/common/tipc/tipc.cpp
index bc9cf1d70..bf2703a77 100644
--- a/toonz/sources/common/tipc/tipc.cpp
+++ b/toonz/sources/common/tipc/tipc.cpp
@@ -18,7 +18,7 @@
#elif defined(MACOSX)
#include <sys/sysctl.h>
#include <unistd.h>
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
#include <sys/time.h>
#include <unistd.h>
#endif
diff --git a/toonz/sources/common/trasterimage/tcachedlevel.cpp b/toonz/sources/common/trasterimage/tcachedlevel.cpp
index c05bb3a31..0e28ead5d 100644
--- a/toonz/sources/common/trasterimage/tcachedlevel.cpp
+++ b/toonz/sources/common/trasterimage/tcachedlevel.cpp
@@ -11,7 +11,7 @@
#include "tconvert.h"
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
#include "texception.h"
//#include "tsystem.h"
#include <unistd.h>
diff --git a/toonz/sources/common/trop/tresample.cpp b/toonz/sources/common/trop/tresample.cpp
index d6b588dd0..e7be26fbe 100644
--- a/toonz/sources/common/trop/tresample.cpp
+++ b/toonz/sources/common/trop/tresample.cpp
@@ -4597,7 +4597,7 @@ void rop_resample_rgbm_2(TRasterPT<T> rout, const TRasterCM32P &rin,
}
}
-#if defined(USE_SSE2) && defined(_MSC_VER)
+#if defined(USE_SSE2)
TRaster32P rout32 = rout;
if ((TSystem::getCPUExtensions() & TSystem::CpuSupportsSse2) && rout32)
resample_main_cm32_rgbm_SSE2<TPixel32>(
diff --git a/toonz/sources/common/tstream/tstream.cpp b/toonz/sources/common/tstream/tstream.cpp
index 631192401..f6a3cc5b7 100644
--- a/toonz/sources/common/tstream/tstream.cpp
+++ b/toonz/sources/common/tstream/tstream.cpp
@@ -26,7 +26,7 @@ string escape(string v) {
for (;;) {
// Removing escaping of apostrophe from Windows and OSX as it's not needed and
// causes problems
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
i = v.find_first_of("\\\'\"", i);
#else
i = v.find_first_of("\\\"", i);
diff --git a/toonz/sources/common/tsystem/tpluginmanager.cpp b/toonz/sources/common/tsystem/tpluginmanager.cpp
index 905c8b77d..a82fce845 100644
--- a/toonz/sources/common/tsystem/tpluginmanager.cpp
+++ b/toonz/sources/common/tsystem/tpluginmanager.cpp
@@ -15,10 +15,11 @@
#include <sys/param.h>
#include <unistd.h>
#include <sys/types.h>
-#include <sys/timeb.h> // for ftime
+#ifndef FREEBSD
+#include <dirent.h>
+#endif
#include <stdio.h>
#include <unistd.h>
-#include <dirent.h>
#include <sys/dir.h>
#include <sys/param.h> // for getfsstat
#ifdef MACOSX
@@ -94,7 +95,7 @@ void TPluginManager::unloadPlugins() {
for (PluginTable::iterator it = m_pluginTable.begin();
it != m_pluginTable.end(); ++it) {
Plugin::Handle handle = (*it)->getHandle();
-#ifndef LINUX
+#if !(defined(LINUX) || defined(FREEBSD))
#ifdef _WIN32
FreeLibrary(handle);
#else
@@ -171,7 +172,7 @@ void TPluginManager::loadPlugin(const TFilePath &fp) {
void TPluginManager::loadPlugins(const TFilePath &dir) {
#if defined(_WIN32)
const std::string extension = "dll";
-#elif defined(LINUX) || defined(__sgi)
+#elif defined(LINUX) || defined(FREEBSD) || defined(__sgi)
const std::string extension = "so";
#elif defined(MACOSX)
const std::string extension = "dylib";
diff --git a/toonz/sources/common/tsystem/tsystempd.cpp b/toonz/sources/common/tsystem/tsystempd.cpp
index 37e986c97..585fe743e 100644
--- a/toonz/sources/common/tsystem/tsystempd.cpp
+++ b/toonz/sources/common/tsystem/tsystempd.cpp
@@ -12,7 +12,6 @@
#include "tconvert.h"
#include <time.h>
-#include <sys/timeb.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -66,6 +65,27 @@
#include <QUrl>
#endif
+#ifdef FREEBSD
+#define PLATFORM FREEBSD
+#include <sys/param.h>
+#include <sys/sched.h>
+#include <sys/sysctl.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/proc.h>
+#include <sys/vmmeter.h>
+#include <vm/vm_param.h>
+#include <grp.h>
+#include <utime.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <sys/mount.h>
+#include <pwd.h>
+#include <dlfcn.h>
+#define pagetok(__nb) ((__nb) * (getpagesize()))
+#endif
+
+
#if defined(MACOSX)
#define PLATFORM MACOSX
#include <grp.h>
@@ -73,7 +93,6 @@
#include <sys/param.h>
#include <unistd.h>
#include <sys/types.h>
-#include <sys/timeb.h> // for ftime
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
@@ -192,6 +211,11 @@ bool TSystem::memoryShortage() {
// to be done...
return false;
+#elif defined(FREEBSD)
+
+ // to be done...
+ return false;
+
#else
@ @ @ERROR : PLATFORM NOT SUPPORTED
@@ -254,6 +278,31 @@ TINT64 TSystem::getFreeMemorySize(bool onlyPhisicalMemory) {
}
free(sysInfo);
+#elif defined(FREEBSD)
+
+ TINT64 ret = 0;
+ size_t size;
+#ifdef __OpenBSD__
+ int mib[] = {CTL_VM, VM_UVMEXP};
+ struct uvmexp uvmexp;
+#else
+ int mib[] = {CTL_VM, VM_TOTAL};
+ struct vmtotal vmtotal;
+#endif
+
+#ifdef __OpenBSD__
+ size = sizeof(uvmexp);
+ if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
+ return (ret);
+ ret = pagetok((guint64)uvmexp.free);
+#else
+ size = sizeof(vmtotal);
+ if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0)
+ return (ret);
+ ret = pagetok(vmtotal.t_free);
+#endif
+ return ret;
+
#elif defined(MACOSX)
// to be done...
@@ -385,6 +434,32 @@ TINT64 TSystem::getMemorySize(bool onlyPhisicalMemory) {
free(sysInfo);
return ret;
+#elif defined(FREEBSD)
+
+ TINT64 ret = 0;
+ size_t size;
+#ifdef __OpenBSD__
+ int mib[] = {CTL_VM, VM_UVMEXP};
+ struct uvmexp uvmexp;
+#else
+ int mib[] = {CTL_VM, VM_TOTAL};
+ struct vmtotal vmtotal;
+#endif
+
+#ifdef __OpenBSD__
+ size = sizeof(uvmexp);
+ if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
+ return (ret);
+ ret = pagetok((guint64)uvmexp.npages);
+#else
+ size = sizeof(vmtotal);
+ if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0)
+ return (ret);
+ /* cheat : rm = tot used, add free to get total */
+ ret = pagetok(vmtotal.t_rm + vmtotal.t_free);
+#endif
+ return ret;
+
#elif defined(MACOSX)
// to be done...
diff --git a/toonz/sources/common/ttest/ttest.cpp b/toonz/sources/common/ttest/ttest.cpp
index 8e6f53d40..fef6c02e2 100644
--- a/toonz/sources/common/ttest/ttest.cpp
+++ b/toonz/sources/common/ttest/ttest.cpp
@@ -16,7 +16,7 @@
#include <set>
#include <sstream>
-#if defined(LINUX)
+#if defined(LINUX) || defined(FREEBSD)
#include <typeinfo>
#endif
diff --git a/toonz/sources/common/tvectorimage/tvectorimage.cpp b/toonz/sources/common/tvectorimage/tvectorimage.cpp
index 1bd786bcb..5bd6df6ac 100644
--- a/toonz/sources/common/tvectorimage/tvectorimage.cpp
+++ b/toonz/sources/common/tvectorimage/tvectorimage.cpp
@@ -617,7 +617,7 @@ bool TVectorImage::getNearestStroke(const TPointD &p, double &outW,
//-----------------------------------------------------------------------------
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
void TVectorImage::render(const TVectorRenderData &rd, TRaster32P &ras) {
// hardRenderVectorImage(rd,ras,this);
}
diff --git a/toonz/sources/common/tvectorrenderer.cpp b/toonz/sources/common/tvectorrenderer.cpp
index 8ad85d6a5..0b4b1a31b 100644
--- a/toonz/sources/common/tvectorrenderer.cpp
+++ b/toonz/sources/common/tvectorrenderer.cpp
@@ -22,7 +22,7 @@
#include <stdlib.h>
#endif
-#if defined(LINUX) || defined(__sgi)
+#if defined(LINUX) || defined(FREEBSD) || defined(__sgi)
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -276,7 +276,7 @@ void hardRenderVectorImage(const TVectorRenderData &rd, TRaster32P &ras,
}
// end of WIN32
-#elif defined(__sgi) || defined(LINUX)
+#elif defined(__sgi) || defined(LINUX) || defined(FREEBSD)
//=============================================================================
@@ -431,7 +431,7 @@ void hardRenderVectorImage(const TVectorRenderData &rd, TRaster32P &ras,
glReadPixels(0, 0, ras->getLx(), ras->getLy(), GL_ABGR_EXT, GL_UNSIGNED_BYTE,
ras->getRawData());
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
glReadPixels(0, 0, ras->getLx(), ras->getLy(), GL_RGBA, GL_UNSIGNED_BYTE,
ras->getRawData());
diff --git a/toonz/sources/common/tvrender/qtofflinegl.cpp b/toonz/sources/common/tvrender/qtofflinegl.cpp
index b1561a813..5053c8af7 100644
--- a/toonz/sources/common/tvrender/qtofflinegl.cpp
+++ b/toonz/sources/common/tvrender/qtofflinegl.cpp
@@ -153,7 +153,7 @@ void QtOfflineGL::createContext(TDimension rasterSize,
fmt.setPlane(0);
fmt.setDirectRendering(false);
#endif
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
fmt = QGLFormat::defaultFormat();
// printf("GL Version: %s\n",glGetString(GL_VERSION));
fmt.setVersion(2, 1); /* XXX? */
@@ -299,7 +299,7 @@ SPECIFICHE MAC = depth_size 24, stencil_size 8, alpha_size 1
fmt.setStencil(true);
fmt.setAccum(false);
fmt.setPlane(0);
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
fmt.setAlphaBufferSize(1);
fmt.setAlpha(false);
fmt.setRgba(true);
diff --git a/toonz/sources/common/tvrender/tofflinegl.cpp b/toonz/sources/common/tvrender/tofflinegl.cpp
index 8783c0ab3..3e89013b9 100644
--- a/toonz/sources/common/tvrender/tofflinegl.cpp
+++ b/toonz/sources/common/tvrender/tofflinegl.cpp
@@ -11,7 +11,7 @@
#include "trop.h"
// Platform-specific includes
-#if defined(LINUX)
+#if defined(LINUX) || defined(FREEBSD)
#include "qtofflinegl.h"
#include <X11/Xlib.h>
@@ -304,10 +304,10 @@ static std::shared_ptr<TOfflineGL::Imp> defaultOfflineGLGenerator(
}
//=============================================================================
-// XImplementation : implementazione offlineGL Server X (MACOSX & LINUX)
+// XImplementation : implementazione offlineGL Server X (MACOSX & LINUX & BSD)
//-----------------------------------------------------------------------------
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
namespace {
// The XScopedLock stuff doesn't seem finished,
// why not just do the same as with win32 and use a Qt lock??
@@ -540,7 +540,7 @@ public:
//--------------------------------------------------
TOfflineGL::TOfflineGL(TDimension dim, const TOfflineGL *shared) : m_imp(0) {
-#if defined(LINUX)
+#if defined(LINUX) || defined(FREEBSD)
QMutexLocker locker(&linuxImpMutex);
#endif
@@ -558,7 +558,7 @@ TOfflineGL::TOfflineGL(TDimension dim, const TOfflineGL *shared) : m_imp(0) {
//-----------------------------------------------------------------------------
TOfflineGL::TOfflineGL(const TRaster32P &raster, const TOfflineGL *shared) {
-#if defined(LINUX)
+#if defined(LINUX) || defined(FREEBSD)
QMutexLocker locker(&linuxImpMutex);
#endif
diff --git a/toonz/sources/common/tvrender/ttessellator.cpp b/toonz/sources/common/tvrender/ttessellator.cpp
index ca049d435..a6ecdf866 100644
--- a/toonz/sources/common/tvrender/ttessellator.cpp
+++ b/toonz/sources/common/tvrender/ttessellator.cpp
@@ -16,7 +16,7 @@
#define CALLBACK
#endif
// To avoid linking problems with HP ZX2000
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
#ifdef GLU_VERSION_1_2
#undef GLU_VERSION_1_2
#endif
@@ -94,7 +94,7 @@ static void CALLBACK myCombine(GLdouble coords[3], GLdouble *d[4], GLfloat w[4],
typedef GLvoid(CALLBACK *GluCallback)(void);
#endif
-#if defined(MACOSX) || defined(LINUX)
+#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
typedef GLvoid (*GluCallback)();
diff --git a/toonz/sources/common/twain/twain.h b/toonz/sources/common/twain/twain.h
index 1bfe9d500..2788bf0c8 100644
--- a/toonz/sources/common/twain/twain.h
+++ b/toonz/sources/common/twain/twain.h
@@ -101,7 +101,7 @@ TWPT_BGR,
* Platform Dependent Definitions and Typedefs *
****************************************************************************/
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
#include <wchar.h>
#endif
diff --git a/toonz/sources/image/3gp/tiio_3gp_proxy.cpp b/toonz/sources/image/3gp/tiio_3gp_proxy.cpp
index 4fba3d815..e9dcc5772 100644
--- a/toonz/sources/image/3gp/tiio_3gp_proxy.cpp
+++ b/toonz/sources/image/3gp/tiio_3gp_proxy.cpp
@@ -1,6 +1,6 @@
-#if defined(x64) || defined(__LP64__) || defined(LINUX) || (defined(_WIN32) && defined(__GNUC__))
+#if defined(x64) || defined(__LP64__) || defined(LINUX) || defined(FREEBSD) || (defined(_WIN32) && defined(__GNUC__))
// Toonz includes
#include "tfilepath.h"
diff --git a/toonz/sources/image/3gp/tiio_3gp_proxy.h b/toonz/sources/image/3gp/tiio_3gp_proxy.h
index 744769e6a..d7778393d 100644
--- a/toonz/sources/image/3gp/tiio_3gp_proxy.h
+++ b/toonz/sources/image/3gp/tiio_3gp_proxy.h
@@ -3,7 +3,7 @@
#ifndef TIIO_3GP_PROXY_H
#define TIIO_3GP_PROXY_H
-#if defined(x64) || defined(__LP64__) || defined(LINUX) || (defined(_WIN32) && defined(__GNUC__))
+#if defined(x64) || defined(__LP64__) || defined(LINUX) || defined(FREEBSD) || (defined(_WIN32) && defined(__GNUC__))
// Qt includes
#include <QString>
diff --git a/toonz/sources/image/CMakeLists.txt b/toonz/sources/image/CMakeLists.txt
index 00d0a1758..dc8c60043 100644
--- a/toonz/sources/image/CMakeLists.txt
+++ b/toonz/sources/image/CMakeLists.txt
@@ -1,6 +1,5 @@
set(HEADERS
sgi/tiio_sgi.h
- tif/tiio_tif.h
pli/pli_io.h
pli/tiio_pli.h
tga/tiio_tga.h
@@ -13,9 +12,6 @@ set(HEADERS
png/tiio_png.h
psd/tiio_psd.h
svg/tiio_svg.h
- tzp/tiio_plt.h
- tzp/tiio_tzp.h
- tzp/toonztags.h
tzl/tiio_tzl.h
../include/tnzimage.h
mov/tiio_mov_proxy.h
@@ -31,7 +27,6 @@ set(HEADERS
set(SOURCES
tiio.cpp
sgi/filesgi.cpp
- tif/tiio_tif.cpp
pli/pli_io.cpp
pli/tags.cpp
pli/tiio_pli.cpp
@@ -45,9 +40,6 @@ set(SOURCES
png/tiio_png.cpp
psd/tiio_psd.cpp
svg/tiio_svg.cpp
- tzp/tiio_plt.cpp
- tzp/tiio_tzp.cpp
- tzp/avl.c
tzl/tiio_tzl.cpp
mov/tiio_mov_proxy.cpp
3gp/tiio_3gp_proxy.cpp
@@ -59,6 +51,25 @@ set(SOURCES
mesh/tiio_mesh.cpp
)
+
+# Can't build this on FreeBSD: libtiff requires internal API access.
+# Probably some one get luck to fix this.
+if(NOT BUILD_TARGET_BSD)
+ set(HEADERS ${HEADERS}
+ tif/tiio_tif.h
+ tzp/tiio_plt.h
+ tzp/tiio_tzp.h
+ tzp/toonztags.h
+ )
+ set(SOURCES ${SOURCES}
+ tif/tiio_tif.cpp
+ tzp/tiio_plt.cpp
+ tzp/tiio_tzp.cpp
+ tzp/avl.c
+ )
+endif()
+
+
if(BUILD_TARGET_WIN)
set(HEADERS ${HEADERS}
avi/tiio_avi.h
@@ -110,9 +121,15 @@ message("Bin: " ${CMAKE_CURRENT_BINARY_DIR})
include_directories(
SYSTEM
${TIFF_INCLUDE_DIR}
- ${SDKROOT}/LibJPEG/jpeg-9
)
+if(NOT BUILD_TARGET_BSD)
+ include_directories(
+ ${SDKROOT}/LibJPEG/jpeg-9
+ )
+endif()
+
+
if(BUILD_ENV_MSVC)
include_directories(
SYSTEM
diff --git a/toonz/sources/image/bmp/filebmp.h b/toonz/sources/image/bmp/filebmp.h
index 7d5785cc9..2d901d623 100644
--- a/toonz/sources/image/bmp/filebmp.h
+++ b/toonz/sources/image/bmp/filebmp.h
@@ -11,7 +11,7 @@ extern "C" {
typedef struct {unsigned char b,g,r,m;} LPIXEL;
#elif defined(__sgi)
typedef struct { unsigned char m,b,g,r; } LPIXEL;
-#elif defined (LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
typedef struct { unsigned char r,g,b,m; } LPIXEL;
#else
#error Not yet implemented
diff --git a/toonz/sources/image/compatibility/tfile_io.c b/toonz/sources/image/compatibility/tfile_io.c
index 8fabd3bc1..83c3ac1f1 100644
--- a/toonz/sources/image/compatibility/tfile_io.c
+++ b/toonz/sources/image/compatibility/tfile_io.c
@@ -58,7 +58,7 @@ char *convertWCHAR2CHAR(const wchar_t *wc) {
}
#endif
/*-----------------------------------*/
-#if defined(MACOSX) || defined(LINUX)
+#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
FILE *_wfopen(const wchar_t *fname, const wchar_t *mode) {
char *cfname = convertWCHAR2CHAR(fname);
diff --git a/toonz/sources/image/compatibility/tfile_io.h b/toonz/sources/image/compatibility/tfile_io.h
index d7a3fdd6d..fa8a9f7fc 100644
--- a/toonz/sources/image/compatibility/tfile_io.h
+++ b/toonz/sources/image/compatibility/tfile_io.h
@@ -13,13 +13,13 @@ extern "C" {
#include <stddef.h>
#endif
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
#include <wchar.h>
#endif
char *convertWCHAR2CHAR(const wchar_t *fname);
-#if defined(MACOSX) || defined(LINUX)
+#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/toonz/sources/image/compatibility/tnz4.h b/toonz/sources/image/compatibility/tnz4.h
index 9488ebec9..e903fadcb 100644
--- a/toonz/sources/image/compatibility/tnz4.h
+++ b/toonz/sources/image/compatibility/tnz4.h
@@ -34,7 +34,7 @@ TNZ_LITTLE_ENDIAN undefined !!
unsigned char b, g, r, m;
#elif defined(__sgi)
unsigned char m, b, g, r;
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
unsigned char r, g, b, m;
#elif defined(MACOSX)
unsigned char m, r, g, b;
@@ -48,7 +48,7 @@ typedef struct SPIXEL {
unsigned short b, g, r, m;
#elif defined(__sgi)
unsigned short m, b, g, r;
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
unsigned short r, g, b, m;
#elif defined(MACOSX)
unsigned char m, r, g, b;
diff --git a/toonz/sources/image/mov/tiio_mov_proxy.cpp b/toonz/sources/image/mov/tiio_mov_proxy.cpp
index 816171d90..b2743117d 100644
--- a/toonz/sources/image/mov/tiio_mov_proxy.cpp
+++ b/toonz/sources/image/mov/tiio_mov_proxy.cpp
@@ -1,6 +1,6 @@
-#if defined(x64) || defined(__LP64__) || defined(LINUX) || (defined(_WIN32) && defined(__GNUC__))
+#if defined(x64) || defined(__LP64__) || defined(LINUX) || defined(FREEBSD) || (defined(_WIN32) && defined(__GNUC__))
// Toonz includes
#include "tfilepath.h"
diff --git a/toonz/sources/image/mov/tiio_mov_proxy.h b/toonz/sources/image/mov/tiio_mov_proxy.h
index 68d0c88ae..fbd82130b 100644
--- a/toonz/sources/image/mov/tiio_mov_proxy.h
+++ b/toonz/sources/image/mov/tiio_mov_proxy.h
@@ -3,7 +3,7 @@
#ifndef TIIO_MOV_PROXY_H
#define TIIO_MOV_PROXY_H
-#if defined(x64) || defined(__LP64__) || defined(LINUX) || (defined(_WIN32) && defined(__GNUC__))
+#if defined(x64) || defined(__LP64__) || defined(LINUX) || defined(FREEBSD) || (defined(_WIN32) && defined(__GNUC__))
// Qt includes
#include <QString>
diff --git a/toonz/sources/image/pli/pli_io.cpp b/toonz/sources/image/pli/pli_io.cpp
index 8baa27e2f..e7b5f1384 100644
--- a/toonz/sources/image/pli/pli_io.cpp
+++ b/toonz/sources/image/pli/pli_io.cpp
@@ -435,7 +435,7 @@ void ParsedPli::setMaxThickness(double maxThickness) {
};
/* indirect inclusion of <math.h> causes 'abs' to return double on Linux */
-#if defined(LINUX) || (defined(_WIN32) && defined(__GNUC__))
+#if defined(LINUX) || defined(FREEBSD) || (defined(_WIN32) && defined(__GNUC__))
template <typename T>
T abs_workaround(T a) {
return (a > 0) ? a : -a;
@@ -473,7 +473,7 @@ static inline short complement2(USHORT val) {
return (val & 0x8000) ? -(val & 0x7fff) : (val & 0x7fff);
}
-#if defined(LINUX) || (defined(_WIN32) && defined(__GNUC__))
+#if defined(LINUX) || defined(FREEBSD) || (defined(_WIN32) && defined(__GNUC__))
#undef abs
#endif
diff --git a/toonz/sources/image/sgi/filesgi.cpp b/toonz/sources/image/sgi/filesgi.cpp
index 4621fe1a2..1a67279a4 100644
--- a/toonz/sources/image/sgi/filesgi.cpp
+++ b/toonz/sources/image/sgi/filesgi.cpp
@@ -11,7 +11,7 @@
#include "tsystem.h"
#include "tpixelgr.h"
#include "../compatibility/tfile_io.h"
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
//#define _XOPEN_SOURCE_EXTENDED
#include <string.h>
#endif
diff --git a/toonz/sources/image/tiio.cpp b/toonz/sources/image/tiio.cpp
index 4433ba5c5..671e0d938 100644
--- a/toonz/sources/image/tiio.cpp
+++ b/toonz/sources/image/tiio.cpp
@@ -53,7 +53,7 @@
#include "./mov/tiio_movM.h"
#include "./3gp/tiio_3gpM.h"
-#elif defined(LINUX) // No more supported by the way...
+#elif defined(LINUX) || defined(FREEBSD) // No more supported by the way...
// #include "./mov/tiio_movL.h"
#include "./mov/tiio_mov_proxy.h"
#include "./3gp/tiio_3gp_proxy.h"
@@ -64,9 +64,13 @@
#include "./sgi/tiio_sgi.h"
#include "./tga/tiio_tga.h"
#include "./png/tiio_png.h"
+/* Can't build this on FreeBSD: libtiff requires internal API access.
+ * Probably some one get luck to fix this. */
+#ifndef FREEBSD
#include "./tif/tiio_tif.h"
#include "./tzp/tiio_tzp.h"
#include "./tzp/tiio_plt.h"
+#endif
#include "./psd/tiio_psd.h"
#include "./avi/tiio_avi.h"
#include "./pli/tiio_pli.h"
@@ -102,6 +106,9 @@ void initImageIo(bool lightVersion) {
TLevelReader::define("tlv", TLevelReaderTzl::create);
TFileType::declare("tlv", TFileType::CMAPPED_LEVEL);
+/* Can't build this on FreeBSD: libtiff requires internal API access.
+ * Probably some one get luck to fix this. */
+#ifndef FREEBSD
Tiio::defineReaderMaker("tzp", Tiio::makeTzpReader);
Tiio::defineWriterMaker("tzp", Tiio::makeTzpWriter, false);
TFileType::declare("tzp", TFileType::CMAPPED_IMAGE);
@@ -116,6 +123,7 @@ void initImageIo(bool lightVersion) {
Tiio::defineReaderMaker("plt", Tiio::makePltReader);
Tiio::defineWriterMaker("plt", Tiio::makePltWriter, false);
TFileType::declare("plt", TFileType::RASTER_IMAGE);
+#endif
Tiio::defineReaderMaker("nol", Tiio::makePngReader);
Tiio::defineWriterMaker("nol", Tiio::makePngWriter, true);
@@ -143,6 +151,9 @@ void initImageIo(bool lightVersion) {
TFileType::declare("tga", TFileType::RASTER_IMAGE);
Tiio::defineWriterProperties("tga", new Tiio::TgaWriterProperties());
+/* Can't build this on FreeBSD: libtiff requires internal API access.
+ * Probably some one get luck to fix this. */
+#ifndef FREEBSD
Tiio::defineReaderMaker("tif", Tiio::makeTifReader);
Tiio::defineWriterMaker("tif", Tiio::makeTifWriter, true);
TFileType::declare("tif", TFileType::RASTER_IMAGE);
@@ -152,6 +163,7 @@ void initImageIo(bool lightVersion) {
Tiio::defineWriterMaker("tiff", Tiio::makeTifWriter, true);
TFileType::declare("tiff", TFileType::RASTER_IMAGE);
Tiio::defineWriterProperties("tiff", new Tiio::TifWriterProperties());
+#endif
Tiio::defineReaderMaker("sgi", Tiio::makeSgiReader);
Tiio::defineWriterMaker("sgi", Tiio::makeSgiWriter, true);
diff --git a/toonz/sources/include/movsettings.h b/toonz/sources/include/movsettings.h
index a152d18b7..9008f7df6 100644
--- a/toonz/sources/include/movsettings.h
+++ b/toonz/sources/include/movsettings.h
@@ -13,7 +13,7 @@
#define DVVAR DV_IMPORT_VAR
#endif
-#if !defined(x64) && !defined(__LP64__) && !defined(LINUX) && !(defined(__GNUC__) && defined(_WIN32))
+#if !defined(x64) && !defined(__LP64__) && !(defined(LINUX) || defined(FREEBSD)) && !(defined(__GNUC__) && defined(_WIN32))
#ifdef _WIN32
diff --git a/toonz/sources/include/tcg/hpp/triangulate.hpp b/toonz/sources/include/tcg/hpp/triangulate.hpp
index e77882476..3b5e5b3f8 100644
--- a/toonz/sources/include/tcg/hpp/triangulate.hpp
+++ b/toonz/sources/include/tcg/hpp/triangulate.hpp
@@ -14,7 +14,7 @@
#include <GL/glu.h>
#elif defined(MACOSX)
#include <GLUT/glut.h>
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
#include <GL/glut.h>
#include <cstring>
#endif
diff --git a/toonz/sources/include/tgl.h b/toonz/sources/include/tgl.h
index 6708e5b5d..538b8f617 100644
--- a/toonz/sources/include/tgl.h
+++ b/toonz/sources/include/tgl.h
@@ -21,7 +21,7 @@
#define GLUT_NO_WARNING_DISABLE
#endif
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
diff --git a/toonz/sources/include/tmachine.h b/toonz/sources/include/tmachine.h
index 21f07a6c1..b954c2726 100644
--- a/toonz/sources/include/tmachine.h
+++ b/toonz/sources/include/tmachine.h
@@ -7,7 +7,7 @@
#define TNZ_MACHINE_CHANNEL_ORDER_BGRM 1
#elif defined(__sgi)
#define TNZ_MACHINE_CHANNEL_ORDER_MBGR 1
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
#define TNZ_MACHINE_CHANNEL_ORDER_BGRM 1
#elif defined(MACOSX)
#define TNZ_MACHINE_CHANNEL_ORDER_MRGB 1
diff --git a/toonz/sources/include/tnztypes.h b/toonz/sources/include/tnztypes.h
index 58000dd35..6aaaf84d4 100644
--- a/toonz/sources/include/tnztypes.h
+++ b/toonz/sources/include/tnztypes.h
@@ -18,7 +18,7 @@ typedef uint32_t TUINT32;
typedef int64_t TINT64;
typedef uint64_t TUINT64;
-#elif defined(__LP64__) && (!defined(LINUX))
+#elif defined(__LP64__) && !(defined(LINUX) || defined(FREEBSD))
#define TINT32 \
; \
@@ -34,7 +34,7 @@ typedef unsigned __int32_t TUINT32;
typedef __int64_t TINT64;
typedef unsigned __int64_t TUINT64;
-#elif defined(LINUX) || defined(_WIN32)
+#elif defined(LINUX) || defined(FREEBSD) || defined(_WIN32)
#include <stdint.h>
typedef int32_t TINT32;
typedef uint32_t TUINT32;
diff --git a/toonz/sources/include/toonz4.6/machine.h b/toonz/sources/include/toonz4.6/machine.h
index e9bf6f691..176fa62b7 100644
--- a/toonz/sources/include/toonz4.6/machine.h
+++ b/toonz/sources/include/toonz4.6/machine.h
@@ -17,7 +17,7 @@
#define TNZ_MACHINE_CHANNEL_ORDER_BGRM 1
#elif defined(__sgi)
#define TNZ_MACHINE_CHANNEL_ORDER_MBGR 1
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(FREEBSD)
#define TNZ_MACHINE_CHANNEL_ORDER_BGRM 1
#elif defined(MACOSX)
#define TNZ_MACHINE_CHANNEL_ORDER_MRGB 1
diff --git a/toonz/sources/include/tpixel.h b/toonz/sources/include/tpixel.h
index 5dd25b09c..b3531cc9d 100644
--- a/toonz/sources/include/tpixel.h
+++ b/toonz/sources/include/tpixel.h
@@ -177,7 +177,7 @@ undefined machine order !!!!
TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue)
: r(rr), g(gg), b(bb), m(mm){};
#else
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
#ifdef powerpc
diff --git a/toonz/sources/include/trop.h b/toonz/sources/include/trop.h
index 29851476c..789632fe0 100644
--- a/toonz/sources/include/trop.h
+++ b/toonz/sources/include/trop.h
@@ -13,6 +13,9 @@
#define DVVAR DV_IMPORT_VAR
#endif
+/* FreeBSD defines atop() macro in standard includes. */
+#undef atop
+
//===============================================================
// Forward declarations
diff --git a/toonz/sources/include/tvectorimage.h b/toonz/sources/include/tvectorimage.h
index cb4c1c0fe..8af541a39 100644
--- a/toonz/sources/include/tvectorimage.h
+++ b/toonz/sources/include/tvectorimage.h
@@ -245,7 +245,7 @@ get the stroke nearest at point
// Gmt. VA TOLTO IL PRIMA POSSIBILE.
// E' una pessima cosa rendere platform dependent l'interfaccia pubblica di una
// classe cosi' importante come la VectorImage
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
void render(const TVectorRenderData &rd, TRaster32P &ras);
#endif
@@ -428,7 +428,7 @@ public:
//-----------------------------------------------------------------------------
// GMT: DA TOGLIERE. vedi sopra
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
DVAPI void hardRenderVectorImage(const TVectorRenderData &rd, TRaster32P &r,
const TVectorImageP &vimg);
#endif
diff --git a/toonz/sources/stdfx/calligraphicfx.cpp b/toonz/sources/stdfx/calligraphicfx.cpp
index d4e1e3e49..56dbe0e6f 100644
--- a/toonz/sources/stdfx/calligraphicfx.cpp
+++ b/toonz/sources/stdfx/calligraphicfx.cpp
@@ -15,7 +15,6 @@
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
-#include <sys/timeb.h>
#include <string.h>
#include <math.h>
diff --git a/toonz/sources/stdfx/igs_resource_msg_from_err_unix.cpp b/toonz/sources/stdfx/igs_resource_msg_from_err_unix.cpp
index fd902bf03..4a8c04751 100644
--- a/toonz/sources/stdfx/igs_resource_msg_from_err_unix.cpp
+++ b/toonz/sources/stdfx/igs_resource_msg_from_err_unix.cpp
@@ -1,5 +1,5 @@
-#define _POSIX_C_SOURCE 200809L /* int strerror_r() */
-#undef _GNU_SOURCE
+#define _XOPEN_SOURCE 700 /* isascii() */
+#undef _GNU_SOURCE /* int strerror_r() on glibc */
#include <cerrno>
#include <cstring> /* memset */
#include <vector>
diff --git a/toonz/sources/stdfx/offscreengl.h b/toonz/sources/stdfx/offscreengl.h
index 3a176058d..300c7ba97 100644
--- a/toonz/sources/stdfx/offscreengl.h
+++ b/toonz/sources/stdfx/offscreengl.h
@@ -2,7 +2,7 @@
#ifndef OFFSCREENGL_H
#define OFFSCREENGL_H
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
#include "tofflinegl.h"
#endif
@@ -71,7 +71,7 @@ public:
assert(ret == TRUE);
*/
#else
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
m_offlineGL = new TOfflineGL(TDimension(width, height));
#endif
#endif
@@ -93,7 +93,7 @@ public:
DeleteObject(m_offDIB);
DeleteObject(m_offHdc);
#else
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
delete m_offlineGL;
#endif
@@ -127,7 +127,7 @@ public:
HGLRC m_hglRC;
BITMAPINFO m_info;
#else
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
TOfflineGL *m_offlineGL;
#endif
#endif
diff --git a/toonz/sources/stdfx/pins.cpp b/toonz/sources/stdfx/pins.cpp
index 59206f02b..dc3f3fd88 100644
--- a/toonz/sources/stdfx/pins.cpp
+++ b/toonz/sources/stdfx/pins.cpp
@@ -141,7 +141,7 @@ void subCompute(TRasterFxPort &m_input, TTile &tile, double frame,
//#ifdef _WIN32
offScreenRendering.makeCurrent();
//#else
-//#if defined(LINUX) || defined(MACOSX)
+//#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX)
// offScreenRendering.m_offlineGL->makeCurrent();
//#endif
#endif
diff --git a/toonz/sources/t32bitsrv/main.cpp b/toonz/sources/t32bitsrv/main.cpp
index d272ed4fa..806904f4e 100644
--- a/toonz/sources/t32bitsrv/main.cpp
+++ b/toonz/sources/t32bitsrv/main.cpp
@@ -1,6 +1,6 @@
-#if (!(defined(x64) || defined(__LP64__) || defined(LINUX)))
+#if (!(defined(x64) || defined(__LP64__) || defined(LINUX) || defined(FREEBSD)))
// Toonz includes
#include "tiio_std.h"
diff --git a/toonz/sources/t32bitsrv/t323gpmsg.cpp b/toonz/sources/t32bitsrv/t323gpmsg.cpp
index 5892ab17a..84ead4474 100644
--- a/toonz/sources/t32bitsrv/t323gpmsg.cpp
+++ b/toonz/sources/t32bitsrv/t323gpmsg.cpp
@@ -1,6 +1,6 @@
-#if (!(defined(x64) || defined(__LP64__) || defined(LINUX)))
+#if (!(defined(x64) || defined(__LP64__) || defined(LINUX) || defined(FREEBSD)))
// Toonz stuff
#include "tiio.h"
diff --git a/toonz/sources/t32bitsrv/t32movmsg.cpp b/toonz/sources/t32bitsrv/t32movmsg.cpp
index 6372526db..9c8d49d20 100644
--- a/toonz/sources/t32bitsrv/t32movmsg.cpp
+++ b/toonz/sources/t32bitsrv/t32movmsg.cpp
@@ -1,6 +1,6 @@
-#if (!(defined(x64) || defined(__LP64__) || defined(LINUX)))
+#if (!(defined(x64) || defined(__LP64__) || defined(LINUX) || defined(FREEBSD)))
// Toonz stuff
#include "tiio.h"
diff --git a/toonz/sources/tconverter/tconverter.cpp b/toonz/sources/tconverter/tconverter.cpp
index a13361779..057d44abc 100644
--- a/toonz/sources/tconverter/tconverter.cpp
+++ b/toonz/sources/tconverter/tconverter.cpp
@@ -29,7 +29,7 @@
#include "tvectorrenderdata.h"
#include "tofflinegl.h"
-#if defined(LINUX)
+#if defined(LINUX) || defined(FREEBSD)
#include <QGuiApplication>
#endif
@@ -359,7 +359,7 @@ void convert(const TFilePath &source, const TFilePath &dest,
//------------------------------------------------------------------------
int main(int argc, char *argv[]) {
-#if defined(LINUX)
+#if defined(LINUX) || defined(FREEBSD)
QGuiApplication app(argc, argv);
#endif
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index edfbd25f8..4bbe8a244 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -1,5 +1,5 @@
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
#define GL_GLEXT_PROTOTYPES
#endif
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index ce21cc7e3..cfb52b7da 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -309,7 +309,7 @@ void SceneViewer::tabletEvent(QTabletEvent *e) {
m_tabletEvent = false;
#endif
-#ifdef LINUX
+#if defined(LINUX) || defined(FREEBSD)
// for Linux, create context menu on right click here.
// could possibly merge with OSX code above
if (e->button() == Qt::RightButton) {
diff --git a/toonz/sources/toonzfarm/tfarm/tlog.cpp b/toonz/sources/toonzfarm/tfarm/tlog.cpp
index 7cc875e1c..36ffe5504 100644
--- a/toonz/sources/toonzfarm/tfarm/tlog.cpp
+++ b/toonz/sources/toonzfarm/tfarm/tlog.cpp
@@ -18,7 +18,6 @@
#else
#include <syslog.h>
#include <unistd.h>
-#include <sys/timeb.h>
#endif
#include "tthreadmessage.h"
diff --git a/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp b/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp
index f75863804..d2ca50127 100644
--- a/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp
+++ b/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp
@@ -29,7 +29,6 @@ using namespace std;
#ifndef _WIN32
#include <sys/param.h>
#include <unistd.h>
-#include <sys/timeb.h>
#endif
int inline STRICMP(const QString &a, const QString &b) {
@@ -118,7 +117,11 @@ TFilePath getLocalRoot() {
".app/Contents/Resources/configfarmroot.txt";
#else
// set path to something suitable for most linux (Unix?) systems
+#ifdef FREEBSD
+ std::string unixpath = "/usr/local/etc/" + tver.getAppName() + "/opentoonz.conf";
+#else
std::string unixpath = "/etc/" + tver.getAppName() + "/opentoonz.conf";
+#endif
#endif
TFilePath name(unixpath);
Tifstream is(name);
diff --git a/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp b/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp
index 4acf98e56..fc10bc6e7 100644
--- a/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp
+++ b/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp
@@ -29,7 +29,6 @@ using namespace TVER;
#else
#include <sys/param.h>
#include <unistd.h>
-#include <sys/timeb.h>
#endif
//#define REDIRECT_OUPUT
@@ -116,7 +115,11 @@ TFilePath getLocalRoot() {
".app/Contents/Resources/configfarmroot.txt";
#else
// set path to something suitable for most linux (Unix?) systems
+#ifdef FREEBSD
+ std::string unixpath = "/usr/local/etc/" + tver.getAppName() + "/opentoonz.conf";
+#else
std::string unixpath = "/etc/" + tver.getAppName() + "/opentoonz.conf";
+#endif
#endif
TFilePath name(unixpath);
Tifstream is(name);
diff --git a/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp b/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp
index 49ecf6a4c..eda1ed436 100644
--- a/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp
+++ b/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp
@@ -12,7 +12,6 @@
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
-#include <sys/timeb.h>
#include <string.h>
#include <math.h>
diff --git a/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp b/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp
index 60bc34df8..335c76947 100644
--- a/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp
+++ b/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp
@@ -9,7 +9,6 @@
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
-#include <sys/timeb.h>
#include <string.h>
#include <math.h>
diff --git a/toonz/sources/toonzlib/studiopalette.cpp b/toonz/sources/toonzlib/studiopalette.cpp
index 5a9a959ce..b655f11a8 100644
--- a/toonz/sources/toonzlib/studiopalette.cpp
+++ b/toonz/sources/toonzlib/studiopalette.cpp
@@ -17,7 +17,6 @@
#include <time.h>
#include <stdio.h>
#include <sys/types.h>
-#include <sys/timeb.h>
#include <string.h>
#include <QSettings>
diff --git a/toonz/sources/toonzlib/tlog.cpp b/toonz/sources/toonzlib/tlog.cpp
index bc6241bfa..0eb8ab308 100644
--- a/toonz/sources/toonzlib/tlog.cpp
+++ b/toonz/sources/toonzlib/tlog.cpp
@@ -19,7 +19,6 @@
#else
#include <syslog.h>
#include <unistd.h>
-#include <sys/timeb.h>
#endif
#include "tthreadmessage.h"