summaryrefslogtreecommitdiff
path: root/apps/plugins/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/Makefile')
-rw-r--r--apps/plugins/Makefile41
1 files changed, 38 insertions, 3 deletions
diff --git a/apps/plugins/Makefile b/apps/plugins/Makefile
index 0c90bde9b1..6af39327bc 100644
--- a/apps/plugins/Makefile
+++ b/apps/plugins/Makefile
@@ -24,16 +24,19 @@ LDS := plugin.lds
LINKFILE := $(OBJDIR)/pluginlink.lds
DEPFILE = $(OBJDIR)/dep-plugins
-SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) \
- $(INCLUDES) $(TARGET) $(DEFINES) -E -P -include "config.h" - )
+SRC := $(shell cat SOURCES | gcc -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \
+ $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
ROCKS := $(SRC:%.c=$(OBJDIR)/%.rock)
SOURCES = $(SRC)
ELFS := $(SRC:%.c=$(OBJDIR)/%.elf)
OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
+# as created by the cross-compiler for win32:
+DEFS := $(SRC:%.c=$(OBJDIR)/%.def)
DIRS = .
all: $(OBJDIR)/libplugin.a $(ROCKS) $(DEPFILE)
+ifndef SIMVER
$(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(OBJDIR)/libplugin.a
@echo "LD $@"
@$(CC) $(GCCOPTS) -O -nostdlib -o $@ $< -L$(OBJDIR) $(CODECLIBS) -lplugin -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$*.map
@@ -41,6 +44,37 @@ $(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(OBJDIR)/libplugin.a
$(OBJDIR)/%.rock : $(OBJDIR)/%.elf
@echo "OBJCOPY $<"
@$(OC) -O binary $< $@
+else
+
+ifeq ($(SIMVER), x11)
+###################################################
+# This is the X11 simulator version
+
+$(OBJDIR)/%.rock : $(OBJDIR)/%.o $(APPSDIR)/plugin.h
+ @echo "LD $@"
+ @$(CC) $(APPCFLAGS) -DPLUGIN -shared $< -L$(OBJDIR) -lplugin -o $@
+ifeq ($(UNAME),CYGWIN)
+# 'x' must be kept or you'll have "Win32 error 5"
+# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
+# #define ERROR_ACCESS_DENIED 5L
+else
+ @chmod -x $@
+endif
+
+else # end of x11-simulator
+###################################################
+# This is the win32 simulator version
+DLLTOOLFLAGS = --export-all
+DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin
+
+$(OBJDIR)/%.rock : $(OBJDIR)/%.o $(APPSDIR)/plugin.h
+ @echo "DLL $@"
+ @$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
+ @$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(OBJDIR)/libplugin.a -o $@
+ @chmod -x $@
+endif # end of win32-simulator
+
+endif # end of simulator section
include $(TOOLSDIR)/make.inc
@@ -56,7 +90,8 @@ $(LINKFILE): $(LDS)
clean:
@echo "cleaning plugins"
- @rm -f $(ROCKS) $(LINKFILE) $(OBJDIR)/*.rock $(DEPFILE) $(ELFS) $(OBJS)
+ @rm -f $(ROCKS) $(LINKFILE) $(OBJDIR)/*.rock $(DEPFILE) $(ELFS) \
+ $(OBJS) $(DEFS)
@$(MAKE) -C lib clean
-include $(DEPFILE)