1. Kyösti Mälkki
  2. fx2lib


Dennis Muhlestein  committed 3fef1d0

Change default build to put files in a build directory.

  • Participants
  • Parent commits 8d43a3a
  • Branches master

Comments (0)

Files changed (1)

File lib/fx2.mk

View file
 #  CODE_SIZE:    Default --code-size 0x3c00
 #  XRAM_SIZE:    Default --xram-size 0x0200
 #  XRAM_LOC:     Default --xram-loc 0x3c00
+# BUILDDIR: build directory (default build)
 # These two can be changed to be blank if no device descriptor is being used.
 #  DSCR_AREA:    Default -Wl"-b DSCR_AREA=0x3e00"
 #  INT2JT:		Default -Wl"-b INT2JT=0x3f00"
 CODE_SIZE=--code-size 0x3c00
 XRAM_SIZE=--xram-size 0x0200
 XRAM_LOC=--xram-loc 0x3c00
-RELS=$(addsuffix .rel, $(notdir $(basename $(SOURCES) $(A51_SOURCES))))
+RELS=$(addprefix $(BUILDDIR)/, $(addsuffix .rel, $(notdir $(basename $(SOURCES) $(A51_SOURCES)))))
 # these are pretty good settings for most firmwares.  
 # Have to be careful with memory locations for 
 # firmwares that require more xram etc.
 .PHONY: ihx iic bix load clean clean-all
-ihx: $(BASENAME).ihx
-bix: $(BASENAME).bix
-iic: $(BASENAME).iic
+ihx: $(BUILDDIR)/$(BASENAME).ihx
+bix: $(BUILDDIR)/$(BASENAME).bix
+iic: $(BUILDDIR)/$(BASENAME).iic
 $(FX2LIBDIR)/lib/fx2.lib: $(FX2LIBDIR)/lib/*.c $(FX2LIBDIR)/lib/*.a51
 	make -C $(FX2LIBDIR)/lib
-$(BASENAME).ihx: $(SOURCES) $(A51_SOURCES) $(FX2LIBDIR)/lib/fx2.lib $(DEPS)
+	mkdir $(BUILDDIR)
 # can't use default target %.rel because there is no way
 # to differentiate the dependency.  (Is it %.rel: %.c or %.a51)
 	for a in $(A51_SOURCES); do \
-	 asx8051 -logs $$a; done
+	 cp $$a $(BUILDDIR)/; \
+	 cd $(BUILDDIR) && asx8051 -logs $$a && cd ..; done
 	for s in $(SOURCES); do \
 	 THISREL=$$(basename `echo "$$s" | sed -e 's/\.c$$/\.rel/'`); \
-	 $(CC) -c -I $(FX2LIBDIR)/include $$s -o $$THISREL ; done
-	$(CC) -o $(BASENAME).ihx $(RELS) fx2.lib -L $(FX2LIBDIR)/lib $(LIBS)
+	 $(CC) -c -I $(FX2LIBDIR)/include $$s -o $(BUILDDIR)/$$THISREL ; done
+	$(CC) -o $@ $(RELS) fx2.lib -L $(FX2LIBDIR)/lib $(LIBS)
-$(BASENAME).bix: $(BASENAME).ihx
 	objcopy -I ihex -O binary $< $@
-$(BASENAME).iic: $(BASENAME).ihx
 	$(FX2LIBDIR)/utils/ihx2iic.py -v $(VID) -p $(PID) $< $@
-load: $(BASENAME).bix
-	fx2load -v $(VID) -p $(PID) $(BASENAME).bix
+load: $(BUILDDIR)/$(BASENAME).bix
+	fx2load -v $(VID) -p $(PID) $(BUILDDIR)/$(BASENAME).bix
-	rm -f *.{asm,ihx,lnk,lst,map,mem,rel,rst,sym,adb,cdb,bix}
+	rm -f $(BUILDDIR)/*.{asm,ihx,lnk,lst,map,mem,rel,rst,sym,adb,cdb,bix}
 clean-all: clean
 	make -C $(FX2LIBDIR)/lib clean