Skip to content

Commit

Permalink
Bugfix for 32bit FreeImage lib for OS X missing symbols. Closes #4993
Browse files Browse the repository at this point in the history
  • Loading branch information
ofTheo committed Mar 16, 2016
1 parent 33317e1 commit 7a7d522
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 50 deletions.
28 changes: 14 additions & 14 deletions libs/FreeImage/include/FreeImage.h
Expand Up @@ -150,22 +150,22 @@ FI_STRUCT (FIMULTIBITMAP) { void *data; };
#ifndef _MSC_VER
// define portable types for 32-bit / 64-bit OS
#include <inttypes.h>
#define BOOL int32_t
#define BYTE uint8_t
#define WORD uint16_t
#define DWORD uint32_t
#define LONG int32_t
#define INT64 int64_t
#define UINT64 uint64_t
typedef int32_t BOOL;
typedef uint8_t BYTE;
typedef uint16_t WORD;
typedef uint32_t DWORD;
typedef int32_t LONG;
typedef int64_t INT64;
typedef uint64_t UINT64;
#else
// MS is not C99 ISO compliant
#define BOOL long
#define BYTE unsigned char
#define WORD unsigned short
#define DWORD unsigned long
#define LONG long
#define INT64 signed __int64
#define UINT64 unsigned __int64
typedef long BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;
typedef signed __int64 INT64;
typedef unsigned __int64 UINT64;
#endif // _MSC_VER

#if (defined(_WIN32) || defined(__WIN32__))
Expand Down
Binary file modified libs/FreeImage/lib/osx/freeimage.a
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/apothecary/formulas/FreeImage/FreeImage.sh
Expand Up @@ -26,7 +26,7 @@ function download() {
rm FreeImage"$VER"Win32Win64.zip
elif [[ "${TYPE}" == "osx" || "${TYPE}" == "ios" || "${TYPE}" == "tvos" ]]; then
# Fixed issues for OSX / iOS for FreeImage compiling in git repo.
echo "Downloading from $GIT_URL for OSX/iOS"
echo "Downloading from $GIT_URL $GIT_TAG for OSX/iOS"
echo $GIT_URL
curl -Lk $GIT_URL/archive/$GIT_TAG.tar.gz -o FreeImage-$GIT_TAG.tar.gz
tar -xf FreeImage-$GIT_TAG.tar.gz
Expand Down
42 changes: 7 additions & 35 deletions scripts/apothecary/formulas/FreeImage/Makefile.osx
Expand Up @@ -12,26 +12,15 @@ MACOSX_MIN_SDK = 10.7
MACOSX_SYSROOT = $(shell xcode-select -print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOSX_SDK).sdk

# General configuration variables:
CC_I386 = $(shell xcrun -find clang)
CC_X86_64 = $(shell xcrun -find clang)
CPP_I386 = $(shell xcrun -find clang++)
CPP_X86_64 = $(shell xcrun -find clang++)

COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS -fPIC -DNDEBUG -D__ANSI__ -DDISABLE_PERF_MEASUREMENT -mmacosx-version-min=$(MACOSX_MIN_SDK)
COMPILERFLAGS = -arch x86_64 -arch i386 -Wno-ctor-dtor-privacy -stdlib=libc++ -Wc++11-narrowing -Os -fexceptions -fvisibility=hidden -DNO_LCMS -fPIC -DNDEBUG -D__ANSI__ -DDISABLE_PERF_MEASUREMENT -mmacosx-version-min=$(MACOSX_MIN_SDK)

COMPILERPPFLAGS_I386 = -arch i386 -Wno-ctor-dtor-privacy -stdlib=libc++ -Wc++11-narrowing
COMPILERPPFLAGS_X86_64 = -arch x86_64 -Wno-ctor-dtor-privacy -stdlib=libc++ -Wc++11-narrowing

INCLUDE_I386 = -isysroot $(MACOSX_SYSROOT)
INCLUDE_X86_64 = -isysroot $(MACOSX_SYSROOT)
CFLAGS_X86_64 = $(COMPILERFLAGS) $(INCLUDE) $(INCLUDE_X86_64)

CFLAGS_I386 = $(COMPILERFLAGS) $(COMPILERFLAGS_I386) $(INCLUDE) $(INCLUDE_I386)
CFLAGS_X86_64 = $(COMPILERFLAGS) $(COMPILERFLAGS_X86_64) $(INCLUDE) $(INCLUDE_X86_64)

CPPFLAGS_I386 = $(COMPILERPPFLAGS_I386) $(CFLAGS_I386)
CPPFLAGS_X86_64 = $(COMPILERPPFLAGS_X86_64) $(CFLAGS_X86_64)

LIBRARIES_I386 = -Wl,-syslibroot $(MACOSX_SYSROOT) -mmacosx-version-min=$(MACOSX_MIN_SDK)
CPPFLAGS_X86_64 = $(CFLAGS_X86_64)
LIBRARIES_X86_64 = -Wl,-syslibroot $(MACOSX_SYSROOT) -mmacosx-version-min=$(MACOSX_MIN_SDK)

LIBTOOL = libtool
Expand All @@ -42,11 +31,8 @@ STATICLIB = lib$(TARGET).a

HEADER = Source/FreeImage.h

.SUFFIXES: .o-i386 .o-x86_64
MODULES_PPC = $(SRCS:.c=.o-ppc)
MODULES_I386 = $(SRCS:.c=.o-i386)
.SUFFIXES: .o-x86_64
MODULES_X86_64 = $(SRCS:.c=.o-x86_64)
MODULES_I386 := $(MODULES_I386:.cpp=.o-i386)
MODULES_X86_64 := $(MODULES_X86_64:.cpp=.o-x86_64)

PREFIX = /usr/local
Expand All @@ -64,26 +50,12 @@ dist: FreeImage

FreeImage: $(STATICLIB)



$(STATICLIB): $(STATICLIB)-i386 $(STATICLIB)-x86_64
$(LIPO) -create $(STATICLIB)-i386 $(STATICLIB)-x86_64 -output $(STATICLIB)

$(STATICLIB)-i386: $(MODULES_I386)
$(LIBTOOL) -arch_only i386 -o $@ $(MODULES_I386)

$(STATICLIB)-x86_64: $(MODULES_X86_64)
$(LIBTOOL) -arch_only x86_64 -o $@ $(MODULES_X86_64)

.c.o-i386:
$(CC_I386) $(CFLAGS_I386) -c $< -o $@
$(STATICLIB): $(MODULES_X86_64)
$(LIBTOOL) -o $@ $(MODULES_X86_64)

.c.o-x86_64:
$(CC_X86_64) $(CFLAGS_X86_64) -c $< -o $@

.cpp.o-i386:
$(CPP_I386) $(CPPFLAGS_I386) -c $< -o $@

.cpp.o-x86_64:
$(CPP_X86_64) $(CPPFLAGS_X86_64) -c $< -o $@

Expand All @@ -94,5 +66,5 @@ install:
ranlib -sf $(INSTALLDIR)/$(STATICLIB)

clean:
rm -f core Dist/*.* u2dtmp* $(MODULES_I386) $(MODULES_X86_64) $(STATICLIB) $(STATICLIB)-i386
rm -f core Dist/*.* u2dtmp* $(MODULES_X86_64) $(STATICLIB)

0 comments on commit 7a7d522

Please sign in to comment.