summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile91
1 files changed, 91 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..cc18b7e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,91 @@
+SHELL = /bin/sh
+MCU = atmega16
+F_CPU=16000000
+
+CC = avr-gcc
+CFLAGS = -g -Os -mmcu=$(MCU) -DF_CPU=$(F_CPU) -Wall
+AS = avr-as
+ASFLAGS = $(CFLAGS)
+LD = avr-ld
+LDFLAGS =
+
+TARGETS := test img_mono blink fade pulse numtest
+MAINS := $(addsuffix .o, $(TARGETS))
+C_OBJS := base.o libleds.o chars/chars.o
+S_OBJS := libleds_asm.o
+OBJS := $(C_OBJS) $(S_OBJS)
+DEPS := Makefile libleds.h
+
+COLOR_TARGETS := c_black c_white c_red c_green c_blue
+COLOR_MAINS := $(addsuffix .o, $(COLOR_TARGETS))
+
+NUMBERS = $(shell seq 0 9)
+UPPERCASE = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
+LOWERCASE = $(call lc, $(UPPERCASE))
+SPECIAL_CHARS = space
+CHARS = $(NUMBERS) $(UPPERCASE) $(LOWERCASE) $(SPECIAL_CHARS)
+
+NUMBERS_DEP = chars/chars.o $(addprefix chars/, $(addsuffix .xbm, $(NUMBERS)))
+UPPERCASE_DEP = chars/chars.o $(addprefix chars/, $(addsuffix .xbm, $(UPPERCASE)))
+LOWERCASE_DEP = chars/chars.o $(addprefix chars/, $(addsuffix .xbm, $(LOWERCASE)))
+SPECIAL_CHARS_DEP = chars/chars.o $(addprefix chars/, $(addsuffix .xbm, $(SPECIAL_CHARS)))
+CHARS_DEP = chars/chars.o $(addprefix chars/, $(addsuffix .xbm, $(CHARS)))
+
+
+.PHONY: all all-normal all-colors
+all: all-core all-colors
+
+all-core: $(TARGETS)
+.PHONY: color
+all-colors color: $(COLOR_TARGETS)
+
+.PHONY: clean
+clean:
+ rm -f $(TARGETS) $(MAINS) $(OBJS) $(COLOR_TARGETS) $(COLOR_MAINS)
+ rm -f chars/chars.o
+
+.PHONY: list-targets _list-targets-core _list-targets-color
+list-targets: _list-targets-core _list-targets-color
+ @printf "\n"
+
+list-targets-core list-targets-color: % : _%
+ @printf "\n"
+
+_list-targets-core:
+ @printf "%s " "$(TARGETS)"
+
+_list-targets-color:
+ @printf "%s " "$(COLOR_TARGETS)"
+
+
+# Build targets
+
+
+chars/chars.c: %.c: %.h
+ @touch $@
+
+$(MAINS) $(C_OBJS): %.o : %.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(TARGETS) $(COLOR_TARGETS): % : $(OBJS) %.o
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
+
+numtest.o: $(NUMBERS_DEP)
+img_mono.o: %.o : %.xbm
+
+# Color Targets
+c_black.o: color.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $< \
+ -DCOLOR_RED=0x00 -DCOLOR_GREEN=0x00 -DCOLOR_BLUE=0x00
+c_white.o: color.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $< \
+ -DCOLOR_RED=0x00 -DCOLOR_GREEN=0xFF -DCOLOR_BLUE=0xFF
+c_red.o: color.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $< \
+ -DCOLOR_RED=0xFF -DCOLOR_GREEN=0x00 -DCOLOR_BLUE=0x00
+c_green.o: color.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $< \
+ -DCOLOR_RED=0x00 -DCOLOR_GREEN=0xFF -DCOLOR_BLUE=0x00
+c_blue.o: color.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $< \
+ -DCOLOR_RED=0x00 -DCOLOR_GREEN=0x00 -DCOLOR_BLUE=0xFF