puzzles: fix makefile producing temporary files in the build directory (sorry!)

- thanks to Michael Sevakis for catching this

Change-Id: Ia02ba7a06a55bc0741df9ce2c21f868d7e0abdd4
diff --git a/apps/plugins/puzzles/puzzles.make b/apps/plugins/puzzles/puzzles.make
index 6f63f0a..8780986 100644
--- a/apps/plugins/puzzles/puzzles.make
+++ b/apps/plugins/puzzles/puzzles.make
@@ -44,7 +44,7 @@
 
 PUZZLESOPTIMIZE := -O2
 ifeq ($(MODELNAME), sansac200v2)
-PUZZLESOPTIMIZE := -Os
+PUZZLESOPTIMIZE := -Os # tiny plugin buffer
 endif
 
 # we suppress all warnings
@@ -72,11 +72,11 @@
 	$(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
 else
 $(PUZZLES_OBJDIR)/sgt-%.rock: $(PUZZLES_OBJDIR)/%.o $(PUZZLES_SHARED_OBJ) $(TLSFLIB)
-	$(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
+	$(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(PUZZLES_OBJDIR)/$*.elf \
 		$(filter %.o, $^) \
 		$(filter %.a, $+) \
-		-lgcc $(PLUGINLDFLAGS)
-	$(SILENT)$(call objcopy,$(BUILDDIR)/$*.elf,$@)
+		-lgcc $(filter-out -Wl%.map, $(PLUGINLDFLAGS)) -Wl,-Map,$(PUZZLES_OBJDIR)/$*.map
+	$(SILENT)$(call objcopy,$(PUZZLES_OBJDIR)/$*.elf,$@)
 endif
 
 # special pattern rule for compiling puzzles with extra flags