[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.
This commit is contained in:
Piotr Esden-Tempski
2015-03-22 16:00:44 -07:00
committed by Felix Ruess
parent 181b0da47b
commit 2c23b9754d
+8 -3
View File
@@ -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)