Skip to content

Commit

Permalink
first round... it compiles, and includes some essential plugins (FT2P…
Browse files Browse the repository at this point in the history
…lugin, etc.), along with his dependency libraries.

It does it also in "Pharo way" (putting plugins as dylibs under Contents/MacOS/Plugins)

but I still need to rewrite the links inside librares (a fix-libs.sh script will do it)

and I still need to add "generic" third party libraries: libgit2, libssh2, cairo...
  • Loading branch information
estebanlm committed Jul 8, 2016
1 parent 8c2935e commit 8ea1fbb
Show file tree
Hide file tree
Showing 23 changed files with 467 additions and 33 deletions.
30 changes: 25 additions & 5 deletions build.macos32x86/common/Makefile.app
Expand Up @@ -26,13 +26,19 @@
ifeq ($(APPNAME),)
APPNAME:=Cocoa
endif
ifeq ($(APPNAMEDEF),)
APPNAMEDEF:=$(APPNAME)Fast
endif
ifeq ($(USEPLUGINASDYLIB),)
USEPLUGINASDYLIB:=FALSE
endif

ifeq ($(CONFIGURATION),debug)
APP:=$(APPNAME)Debug.app
else ifeq ($(CONFIGURATION),assert)
APP:=$(APPNAME)Assert.app
else # default CONFIGURATION=product => $(APPNAME)Fast.app
APP:=$(APPNAME)Fast.app
else # default CONFIGURATION=product => $(APPNAMEDEF).app
APP:=$(APPNAMEDEF).app
endif

default: $(APP)
Expand All @@ -42,7 +48,7 @@ include ../common/Makefile.vm
cleanall: cleanapp cleanastapp cleandbgapp cleanallvm

cleanapp:
rm -rf $(APPNAME)Fast.app
rm -rf $(APPNAMEDEF).app

cleanastapp:
rm -rf $(APPNAME)Assert.app
Expand All @@ -52,7 +58,15 @@ cleandbgapp:

VMEXE:=$(APP)/Contents/MacOS/$(VM)
VMPLIST:=$(APP)/Contents/Info.plist

ifeq ($(USEPLUGINASDYLIB),FALSE)
VMBUNDLES:=$(addprefix $(APP)/Contents/Resources/, $(addsuffix .bundle, $(EXTERNAL_PLUGINS)))
else ifeq ($(USEPLUGINASDYLIB),TRUE)
VMPLUGINDYLIBS:=$(addprefix $(APP)/Contents/MacOS/Plugins/lib, $(addsuffix .dylib, $(EXTERNAL_PLUGINS)))
else
$(error USEPLUGINASDYLIB has to be TRUE or FALSE)
endif

OSXICONS:=$(OSXDIR)/$(VM).icns $(wildcard $(OSXDIR)/$(SYSTEM)*.icns)
VMICONS:=$(addprefix $(APP)/Contents/Resources/,$(notdir $(OSXICONS)))
VMMENUNIB:=$(APP)/Contents/Resources/English.lproj/MainMenu.nib
Expand All @@ -66,7 +80,7 @@ SOURCES:=$(SOURCES) $(APP)/Contents/Resources/$(APPSOURCE)
endif


$(APP): cleanbundles $(VMEXE) $(VMBUNDLES) \
$(APP): cleanbundles $(VMEXE) $(VMBUNDLES) $(VMPLUGINDYLIBS) \
$(VMPLIST) $(VMLOCALIZATION) $(VMMENUNIB) $(VMICONS) \
$(SOURCES) $(APPPOST) signapp touchapp

Expand All @@ -76,7 +90,7 @@ $(APP): cleanbundles $(VMEXE) $(VMBUNDLES) \
# which the bundle build depends.
cleanbundles:
-rm -rf $(APP)/Contents/Resources/*.bundle
-touch $(OBJDIR)/*.ignore
-touch $(OBJDIR)/*.ignore

$(VMEXE): $(OBJDIR)/$(VM)
@mkdir -p $(APP)/Contents/MacOS
Expand All @@ -91,6 +105,11 @@ $(APP)/Contents/Resources/%.bundle: $(BLDDIR)/vm/%.bundle
echo cp -pR $< $(APP)/Contents/Resources; \
cp -pR $< $(APP)/Contents/Resources; \
fi

$(APP)/Contents/MacOS/Plugins/%.dylib: $(BLDDIR)/vm/%.dylib
@mkdir -p $(APP)/Contents/MacOS/Plugins
cp -p $< $(APP)/Contents/MacOS/Plugins


$(VMPLIST): $(OSXDIR)/$(SYSTEM)-Info.plist getversion
@mkdir -p $(APP)/Contents
Expand Down Expand Up @@ -142,6 +161,7 @@ print-app-settings:
@echo APP=$(APP)
@echo VMEXE=$(VMEXE)
@echo VMBUNDLES=$(VMBUNDLES)
@echo VMPLUGINDYLIBS=$(VMPLUGINDYLIBS)
@echo VMPLIST=$(VMPLIST)
@echo VMICONS=$(VMICONS)
@echo SIGNING_IDENTITY=$(SIGNING_IDENTITY)
Expand Down
15 changes: 15 additions & 0 deletions build.macos32x86/common/Makefile.extra
@@ -0,0 +1,15 @@
THIRDPARTYDIR:=$(BLDDIR)/third-party
THIRDPARTYOUTDIR:=$(abspath $(THIRDPARTYDIR)/out)
THIRDPARTYLIBDIR:=$(THIRDPARTYOUTDIR)/lib

ifeq ($(USEPLUGINASDYLIB),TRUE)
THIRDPARTYINSTALLDIR:=$(APP)/Contents/MacOS/Plugins
else
THIRDPARTYINSTALLDIR:=$(APP)/Contents/Resources
endif

$(THIRDPARTYDIR):
mkdir -p $(THIRDPARTYDIR)

$(THIRDPARTYOUTDIR): $(THIRDPARTYDIR)
mkdir -p $(THIRDPARTYOUTDIR)
4 changes: 4 additions & 0 deletions build.macos32x86/common/Makefile.flags
Expand Up @@ -34,6 +34,10 @@ BFLAGS:=-arch $(TARGET_ARCH) \
-bundle \
-isysroot $(SDK)

DYFLAGS:=-arch $(TARGET_ARCH) \
-shared \
-isysroot $(SDK)

WARNINGS:= -Wno-missing-field-initializers -Wno-missing-prototypes \
-Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function \
-Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value \
Expand Down
44 changes: 34 additions & 10 deletions build.macos32x86/common/Makefile.plugin
Expand Up @@ -18,6 +18,14 @@

$(info $$(LIBNAME): $(LIBNAME))

ifeq ($(USEPLUGINASDYLIB),TRUE)
# I do not like to use lib "as is" because that will strip all "lib" occurences, but I do not
# find any better solution :(
LIBDIR:=$(subst lib,,$(LIBNAME))
else
LIBDIR:=$(LIBNAME)
endif

# VM config flags.
ifeq ($(CONFIGURATION),product)
OFLAGS:= -g -Os
Expand Down Expand Up @@ -51,12 +59,13 @@ CFLAGS:= $(CFLAGS) $(OFLAGS) $(COGDEFS) $(DEBUGVM) $(XDEFS)
# BUILDDIR: The location where the plugin is built
#
#PLUGINSRCDIR:= ../../src/plugins
CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBNAME)

CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBDIR)
OSXDIR:= $(PLATDIR)/iOS/vm/OSX
OSXPLGDIR:= $(PLATDIR)/iOS/plugins/$(LIBNAME)
OSXPLGDIR:= $(PLATDIR)/iOS/plugins/$(LIBDIR)
UNIXDIR:= $(PLATDIR)/unix/vm
MAKERDIR:= $(PLUGINSRCDIR)/$(LIBNAME)
BUILDDIR:= $(BUILD)/$(LIBNAME)
MAKERDIR:= $(PLUGINSRCDIR)/$(LIBDIR)
BUILDDIR:= $(BUILD)/$(LIBDIR)

# Support directory locations
CROSSVMDIR:=$(PLATDIR)/Cross/vm
Expand All @@ -77,7 +86,6 @@ ifneq ($(EXCLUDESRC),)
LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC))
endif


#############################################################################
# bundle settings
#
Expand All @@ -97,6 +105,9 @@ VMDIR:= $(BUILD)/vm
PLUGINLIB:= $(VMDIR)/$(LIBNAME).lib
PLUGINBUNDLE:= $(VMDIR)/$(LIBNAME).bundle
PLUGINEXE:= $(PLUGINBUNDLE)/Contents/MacOS/$(LIBNAME)

PLUGINDYLIB:= $(VMDIR)/$(LIBNAME).dylib

# https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html
PLUGINPLIST:= $(PLUGINBUNDLE)/Contents/Info.plist
PLUGINICONS:= $(PLUGINBUNDLE)/Contents/Resources/SqueakPlugin.icns
Expand All @@ -114,7 +125,7 @@ $(BUILD)/$(LIBNAME)/$(LIBNAME).o: plugins.int plugins.ext

include ../common/Makefile.rules

all: $(PLUGINLIB) $(PLUGINBUNDLE)
all: $(PLUGINLIB) $(PLUGINBUNDLE) $(PLUGINDYLIB)

print-settings:
@echo ---------------- Makefile.plugin settings ------------------
Expand Down Expand Up @@ -153,15 +164,15 @@ $(VMDIR):
# If any prerequisites are declared all must exist to continue
ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES)))

$(PLUGINLIB): $(VMDIR) $(OBJDIR) $(LIBOBJ)
$(PLUGINLIB): $(PLUGINREQS) $(VMDIR) $(OBJDIR) $(LIBOBJ)
-rm $(PLUGINLIB)
ar -rc $(PLUGINLIB) $(LIBOBJ)

# Either link with normal compiler/linker or with cpp compiler/linker. If
# LINK_WITH_CPP is set, use e.g. clang++
$(PLUGINBUNDLE): $(PLUGINEXE) $(PLUGINICONS) $(PLUGINPLIST)
$(PLUGINBUNDLE): $(PLUGINREQS) $(PLUGINEXE) $(PLUGINICONS) $(PLUGINPLIST)

$(PLUGINEXE): $(VMDIR) $(OBJDIR) $(LIBOBJ)
$(PLUGINEXE): $(PLUGINREQS) $(VMDIR) $(OBJDIR) $(LIBOBJ)
mkdir -p $(PLUGINBUNDLE)/Contents/MacOS
ifneq ($(LINK_WITH_CPP),)
$(LDCXX) \
Expand All @@ -184,6 +195,19 @@ $(PLUGINPLIST): $(PLATDIR)/iOS/plugins/Info.plist getversion
sed "s/\$$(VERSION)/`./getversion VERSION_TAG`/" $< | \
sed "s/\$(LIBNAME)/$(LIBNAME)/" > $(PLUGINPLIST)

$(PLUGINDYLIB): $(PLUGINREQS) $(VMDIR) $(OBJDIR) $(LIBOBJ)
ifneq ($(LINK_WITH_CPP),)
$(LDCXX) \
$(DYFFLAGS) \
$(LIBOBJ) $(EXTRALIBS) \
-o $(VMDIR)/$(LIBNAME).dylib
else
$(LD) \
$(DYFLAGS) \
$(LIBOBJ) $(EXTRALIBS) \
-o $(VMDIR)/$(LIBNAME).dylib
endif

getversion:
make -f ../common/Makefile.vm getversion

Expand Down
23 changes: 21 additions & 2 deletions build.macos32x86/common/Makefile.vm
Expand Up @@ -88,7 +88,6 @@ include plugins.ext
LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS)))
BUNDLES:= $(addprefix $(OBJDIR)/, $(addsuffix .bundle, $(EXTERNAL_PLUGINS)))


# VM config flags.
ifeq ($(CONFIGURATION),debug)
OFLAGS:= -g -O0 -fno-omit-frame-pointer
Expand Down Expand Up @@ -206,9 +205,13 @@ endif
#############################################################################
# Building plugins
#
.PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.bundle
.PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.bundle $(OBJDIR)/%.dylib

ifeq ($(USEPLUGINASDYLIB),TRUE)
plugin-makefile = $(firstword $(realpath $(OSXPLUGINSDIR)/$(subst lib,,$(1))/Makefile ../common/Makefile.plugin))
else
plugin-makefile = $(firstword $(realpath $(OSXPLUGINSDIR)/$(1)/Makefile ../common/Makefile.plugin))
endif

# Internal plugin. Build as lib then link in lib
# Check for Makefile in iOS plugins directory otherwise use default Makefile
Expand Down Expand Up @@ -246,8 +249,24 @@ $(OBJDIR)/%.bundle: FORCE
CONFIGURATION=$(CONFIGURATION) ARCH=$(TARGET_ARCH) \
PLATDIR=$(PLATDIR) PLUGINSRCDIR=$(PLUGINSRCDIR) VMSRCDIR=$(VMSRCDIR) \
LIBNAME=$(*F) COGDEFS="$(COGDEFS)" \
APP=$(APP) BLDDIR=$(BLDDIR) \
$(PLUGINHACK) \
$(OBJDIR)/$(*F).bundle

# External plugin. Made in the "Pharo way": as a simple dylib to be included in
# Plugins directory
$(OBJDIR)/%.dylib: FORCE
@-mkdir -p $(BLDDIR)/$(*F)
test $@ -ot $(call plugin-makefile,$(*F)) && rm -rf $(BUILD)/vm/$(*F).* || true
rm -f $(BUILD)/vm/$(*F).ignore
$(MAKE) $(MFLAGS) BUILD=$(BUILD) \
-f $(call plugin-makefile,$(*F)) MAKEFILE=$(call plugin-makefile,$(*F)) \
CONFIGURATION=$(CONFIGURATION) ARCH=$(TARGET_ARCH) \
PLATDIR=$(PLATDIR) PLUGINSRCDIR=$(PLUGINSRCDIR) VMSRCDIR=$(VMSRCDIR) \
LIBNAME=$(*F) COGDEFS="$(COGDEFS)" \
APP=$(APP) BLDDIR=$(BLDDIR) USEPLUGINASDYLIB=TRUE \
$(PLUGINHACK) \
$(OBJDIR)/$(*F).dylib

# It would be nice to have this abbreviation but it creates havoc eem 2/2016
#%.bundle: $(OBJDIR)/%.bundle
Expand Down
10 changes: 9 additions & 1 deletion build.macos32x86/pharo.cog.spur/Makefile
Expand Up @@ -3,11 +3,19 @@
# Do make init to allow make -n to function.
#

VMSRCDIR:= ../../spursrc/vm
VMSRCDIR:=../../src/vm
PLUGINSRCDIR:=../../src/plugins
VM:=Pharo
COGDEFS:=-DPharoVM=1
APPNAME:=Pharo
APPNAMEDEF:=$(APPNAME)
USEPLUGINASDYLIB:=TRUE

APPPOST:=fix-libs

# Now include the Makefile proper, which is common to all Mac OS builds.
#
include ../common/Makefile.app

fix-libs:
# $(shell ./fix-libs.sh $(APP))
19 changes: 17 additions & 2 deletions build.macos32x86/pharo.cog.spur/plugins.ext
@@ -1,8 +1,23 @@
# Copied, perhaps edited, from ../src/examplePlugins.ext
EXTERNAL_PLUGINS = \
CroquetPlugin \
FloatArrayPlugin \
FT2Plugin \
FloatMathPlugin \
JPEGReadWriter2Plugin \
JPEGReaderPlugin \
LocalePlugin \
MIDIPlugin \
Mpeg3Plugin \
RePlugin \
SqueakSSL \
UnixOSProcessPlugin
SurfacePlugin \
UUIDPlugin \
SerialPlugin \
SDL2DisplayPlugin \
ObjectiveCPlugin \
# could work, but I don't know if relevant:
# TestOSAPlugin \
# not working (because of Cocoa vs Carbon):
# QuicktimePlugin \
# JoystickTabletPlugin \
# B3DAcceleratorPlugin \
22 changes: 9 additions & 13 deletions build.macos32x86/pharo.cog.spur/plugins.int
Expand Up @@ -4,32 +4,28 @@ ADPCMCodecPlugin \
AioPlugin \
AsynchFilePlugin \
B2DPlugin \
BitBltPlugin \
BMPReadWriterPlugin \
ZipPlugin \
DropPlugin \
BitBltPlugin \
ClipboardExtendedPlugin \
DSAPrims \
DropPlugin \
FFTPlugin \
FilePlugin \
FloatArrayPlugin \
GeniePlugin \
HostWindowPlugin \
IA32ABI \
JPEGReaderPlugin \
JPEGReadWriter2Plugin \
Klatt \
LargeIntegers \
LocalePlugin \
Matrix2x3Plugin \
MiscPrimitivePlugin \
RePlugin \
SecurityPlugin \
SocketPlugin \
SoundCodecPrims \
SoundGenerationPlugin \
SoundPlugin \
SqueakFFIPrims \
StarSqueakPlugin \
SurfacePlugin \
UUIDPlugin \
VMProfileMacSupportPlugin \
# SerialPlugin \
# JoystickTabletPlugin
UnixOSProcessPlugin \
ZipPlugin \
# IA32FFIPlugin \
# Klatt \
3 changes: 3 additions & 0 deletions build.macos32x86/third-party/freetype2/Makefile
@@ -0,0 +1,3 @@
include Makefile.lib

all: $(FREETYPE2LIB)
15 changes: 15 additions & 0 deletions build.macos32x86/third-party/freetype2/Makefile.lib
@@ -0,0 +1,15 @@
FREETYPE2URL:=http://files.pharo.org/vm/src/lib/freetype-2.4.9.tar.gz
FREETYPE2DIR:=$(THIRDPARTYDIR)/freetype-2.4.9
FREETYPE2LIB:=$(THIRDPARTYINSTALLDIR)/libfreetype.6.dylib

$(info $$(FREETYPE2LIB): $(FREETYPE2LIB))

$(FREETYPE2DIR): $(THIRDPARTYDIR)
curl $(FREETYPE2URL) | tar x -C $(THIRDPARTYDIR)

$(FREETYPE2LIB): $(THIRDPARTYINSTALLDIR) $(THIRDPARTYOUTDIR) $(FREETYPE2DIR)
cd $(FREETYPE2DIR) \
&& ./configure --prefix='$(THIRDPARTYOUTDIR)' CFLAGS='-arch i386' LDFLAGS='-arch i386' \
&& make \
&& make install
cp -f $(THIRDPARTYOUTDIR)/lib/libfreetype.6.dylib $(THIRDPARTYINSTALLDIR)
3 changes: 3 additions & 0 deletions build.macos32x86/third-party/libsdl2/Makefile
@@ -0,0 +1,3 @@
include Makefile.lib

all: $(FREETYPE2LIB)
13 changes: 13 additions & 0 deletions build.macos32x86/third-party/libsdl2/Makefile.lib
@@ -0,0 +1,13 @@
LIBSDL2URL:=http://www.libsdl.org/release/SDL2-2.0.4.tar.gz
LIBSDL2DIR:=$(THIRDPARTYDIR)/SDL2-2.0.4
LIBSDL2LIB:=$(THIRDPARTYINSTALLDIR)/libSDL2-2.0.0.dylib

$(LIBSDL2DIR): $(THIRDPARTYDIR)
curl $(LIBSDL2URL) | tar x -C $(THIRDPARTYDIR)

$(LIBSDL2LIB): $(THIRDPARTYINSTALLDIR) $(THIRDPARTYOUTDIR) $(LIBSDL2DIR)
cd $(LIBSDL2DIR) \
&& ./configure --prefix='$(THIRDPARTYOUTDIR)' CFLAGS='-arch i386' LDFLAGS='-arch i386' \
&& make \
&& make install
cp -f $(THIRDPARTYOUTDIR)/lib/libSDL2-2.0.0.dylib $(THIRDPARTYINSTALLDIR)

0 comments on commit 8ea1fbb

Please sign in to comment.