因工作需要,做了個簡單的 makefile
# # SDCC Makefile # # Memory Layout # Program Size: 4KB # Internal Mem: 256B # External Mem: 4KB # ------------------------------------------------------ # PATH INCDIR = ../inc SRCDIR = ./src OBJDIR = ./obj LIBDIR = # ------------------------------------------------------ # UTILITY UTILDIR = ../../util HEX2BIN = $(UTILDIR)/hex2bin/bin/hex2bin # ------------------------------------------------------ # Target and Source TARGET = prom OBJ = $(OBJDIR)/printf.c.rel $(OBJDIR)/debug.c.rel $(OBJDIR)/gpio.c.rel $(OBJDIR)/spi.c.rel $(OBJDIR)/s25fl040a.c.rel $(OBJDIR)/main.c.rel $(OBJDIR)/crtstart.asm.rel # ------------------------------------------------------ # SDCC CC = sdcc AS = sdas8051 # ------------------------------------------------------ # Memory Layout # PRG Size = 4K Bytes CODE_SIZE = --code-loc 0x0000 --code-size 4096 # INT-MEM Size = 256 Bytes IRAM_SIZE = --idata-loc 0x0000 --iram-size 256 # EXT-MEM Size = 4K Bytes XRAM_SIZE = --xram-loc 0x0000 --xram-size 4096 # ------------------------------------------------------ # MCS51 Options # Memory Model (small, medium, large, huge) MODEL = medium #LIBS = #LIBPATH = -L $(LIBDIR) #DEBUG = --debug AFLAGS = -l -s CFLAGS = -I./inc -I$(INCDIR) -mmcs51 --model-$(MODEL) --out-fmt-ihx --no-xinit-opt $(DEBUG) LFLAGS = $(LIBPATH) $(LIBS) -mmcs51 --model-$(MODEL) $(CODE_SIZE) $(IRAM_SIZE) $(XRAM_SIZE) --out-fmt-ihx $(DEBUG) # ------------------------------------------------------ # S = @ .PHONY: all util clean .SECONDARY: all: util $(OBJDIR)/$(TARGET).memh util: (cd $(UTILDIR)/hex2bin; make) %.memh: %.bin $(S) hexdump -v -e '"@%04.4_ax " 16/1 "%02x " "n"' $^ > $@ %.bin: %.hex $(S) $(HEX2BIN) -s 0 -l 1000 -p ff $^ %.hex: %.ihx $(S) packihx $^ > $@ %.ihx: $(OBJ) $(S) $(CC) -o $@ $(LFLAGS) $^ $(OBJDIR)/%.c.rel: $(SRCDIR)/%.c $(S) $(CC) -o $@ $(CFLAGS) -c $^ $(OBJDIR)/%.asm.rel: $(SRCDIR)/%.asm $(S) $(AS) $(AFLAGS) -o $@ $^ clean: $(S) rm -rf $(OBJDIR)/* (cd $(UTILDIR)/hex2bin; make clean)