change Makefile to compile library
This commit is contained in:
parent
df5e3f7521
commit
d352167fb4
|
@ -1,24 +1,43 @@
|
||||||
# variables
|
# hex file to be flashed
|
||||||
TARGET = MDR
|
TARGET = MDR
|
||||||
|
# pic chip on which to flash the code
|
||||||
PIC = 16f1847
|
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:
|
# software verion used:
|
||||||
# pk2cmd: 1.21
|
# pk2cmd: 1.21
|
||||||
# sdcc: 3.4.0
|
# sdcc: 3.4.0
|
||||||
# gputils: 1.3.0
|
# gputils: 1.3.0
|
||||||
|
|
||||||
all: flash
|
all: compile flash
|
||||||
|
|
||||||
# flash program
|
# flash program
|
||||||
flash: $(TARGET).hex
|
flash: $(TARGET).hex
|
||||||
pk2cmd -PPIC$(PIC) -F$< -M -W -R
|
pk2cmd -PPIC$(PIC) -F$< -M -W -R
|
||||||
|
|
||||||
# compile program
|
# compile stages
|
||||||
compile: $(TARGET).hex
|
assembly: $(ASM)
|
||||||
|
|
||||||
# compile program C source code (includes a default code)
|
objects: $(OBJ)
|
||||||
$(TARGET).hex: $(TARGET).c
|
|
||||||
sdcc --std-c99 --opt-code-size --use-non-free -mpic14 -p$(PIC) $<
|
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
|
# remove temporary files
|
||||||
clean:
|
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))
|
||||||
|
|
Loading…
Reference in New Issue