From 2c23b9754d8d2bb78cf73792715f310d23d5d828 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Sun, 22 Mar 2015 16:00:44 -0700 Subject: [PATCH] [ocaml] [sim] Switched to dynamic linking on OS X. An interesting lesson here is that ocamlc assumes that all .so files are shared libraries. It does not do the same for .dylib files. This is why we have to compile a dylib and save it away as a .so so that ocamlc is able to do the right thing. --- conf/Makefile.sim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/conf/Makefile.sim b/conf/Makefile.sim index 6da25557cf..c0687777e2 100644 --- a/conf/Makefile.sim +++ b/conf/Makefile.sim @@ -59,12 +59,14 @@ CFLAGS += $(shell pkg-config --cflags-only-I ivy-glib) LDFLAGS = -lm -# build sim in custom mode for Darwin and ARM systems for now... +LIBFLAGS = -shared + UNAME = $(shell uname -s) ifeq ($(UNAME),Darwin) -SIMSITLCUSTOM=TRUE +LIBFLAGS = -dynamiclib -undefined suppress -flat_namespace endif +# build sim in custom mode for ARM systems for now... MNAME = $(shell uname -m) ifneq (,$(findstring arm,$(MNAME))) SIMSITLCUSTOM=TRUE @@ -91,9 +93,12 @@ $(OBJDIR): @test -d $(OBJDIR) || mkdir -p $(OBJDIR) # shared library of the C autopilot part +# Note: On darwin the file should actually have the .dylib ending but ocamlc +# only assumes that .so files are shared libraries, even though this is only +# correct on linux. autopilot.so : $($(TARGET).objs) @echo BUILD $@ - $(Q)$(CC) -shared -o $(OBJDIR)/$@ $^ + $(Q)$(CC) $(LIBFLAGS) $^ -o $(OBJDIR)/$@ ifdef SIMSITLCUSTOM $(OBJDIR)/simsitl : $($(TARGET).objs) $(SITLCMA) $(SIMSITLML)