From d352167fb49f3f2414a955ab9c58efe8c9738974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 28 Jul 2014 17:13:58 -0700 Subject: [PATCH] change Makefile to compile library --- pic/MDR/Makefile | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/pic/MDR/Makefile b/pic/MDR/Makefile index 8a661d8..7efaa4b 100644 --- a/pic/MDR/Makefile +++ b/pic/MDR/Makefile @@ -1,24 +1,43 @@ -# variables +# hex file to be flashed TARGET = MDR +# pic chip on which to flash the code PIC = 16f1847 +# source code +SRC := $(wildcard *.c) +# compiled code (assembly) +ASM := $(patsubst %.c,%.asm,$(SRC)) +# the object files +OBJ := $(patsubst %.c,%.o,$(SRC)) # software verion used: # pk2cmd: 1.21 # sdcc: 3.4.0 # gputils: 1.3.0 -all: flash +all: compile flash # flash program flash: $(TARGET).hex pk2cmd -PPIC$(PIC) -F$< -M -W -R -# compile program -compile: $(TARGET).hex +# compile stages +assembly: $(ASM) -# compile program C source code (includes a default code) -$(TARGET).hex: $(TARGET).c - sdcc --std-c99 --opt-code-size --use-non-free -mpic14 -p$(PIC) $< +objects: $(OBJ) + +hex: $(TARGET).hex + +compile: hex + +# compile steps +%.asm: %.c + sdcc -S --use-non-free -mpic14 -p$(PIC) -I. -o $@ $< + +%.o: %.asm + gpasm -I . -o $@ -c $< + +$(TARGET).hex: $(OBJ) + gplink -w -r -s /usr/share/gputils/lkr/$(PIC)_g.lkr -I/usr/share/sdcc/lib/pic14 -I/usr/share/sdcc/non-free/lib/pic14 -I. -o $@ libsdcce.lib pic$(PIC).lib $< # remove temporary files clean: - rm -f $(TARGET).hex $(TARGET).lst $(TARGET).asm $(TARGET).adb $(TARGET).o $(TARGET).cod + rm -f $(ASM) $(OBJ) $(TARGET).hex $(patsubst %.c,%.lst,$(SRC)) $(patsubst %.c,%.cod,$(SRC))