Anonymous avatar Anonymous committed 3fef1d0

Change default build to put files in a build directory.

Comments (0)

Files changed (1)

 #  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
+BUILDDIR=build
 
 
-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)
+$(BUILDDIR):	
+	mkdir $(BUILDDIR)
+
+$(BUILDDIR)/$(BASENAME).ihx: $(BUILDDIR) $(SOURCES) $(A51_SOURCES) $(FX2LIBDIR)/lib/fx2.lib $(DEPS) 
 # 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
+$(BUILDDIR)/$(BASENAME).bix: $(BUILDDIR)/$(BASENAME).ihx
 	objcopy -I ihex -O binary $< $@
-$(BASENAME).iic: $(BASENAME).ihx
+$(BUILDDIR)/$(BASENAME).iic: $(BUILDDIR)/$(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
 
 clean:
-	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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.