aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2014-07-28 17:13:58 -0700
committerKing Kévin <kingkevin@cuvoodoo.info>2014-07-28 17:13:58 -0700
commitd352167fb49f3f2414a955ab9c58efe8c9738974 (patch)
treebc856f6b00020ac24ab838a49476a2b1117cf18a
parentdf5e3f7521937a3bb13d3fae35943edabba6c3d1 (diff)
change Makefile to compile library
-rw-r--r--pic/MDR/Makefile35
1 files 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))