1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#
# Copyright (C) 2017 Milan Kupcevic
#
# You can redistribute and/or modify this software under the
# terms of the GNU General Public License version 3, or any later
# version as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# GPLv3+
#
.SUFFIXES:
.SUFFIXES: .c .o .avro .axf .hex
ifndef LIBS
LIBS = $(shell pkg-config --libs simavr)
endif
ifndef CFLAGS
CFLAGS = $(shell pkg-config --cflags simavr)
endif
CFLAGS += -I. -I../parts
ifndef AVR_LIBS
AVR_LIBS = $(shell pkg-config --libs simavr-avr)
endif
ifndef AVR_CFLAGS
AVR_CFLAGS = $(shell pkg-config --cflags simavr-avr)
endif
AVR_CFLAGS += -I. -I../shared -DF_CPU=$(F_CPU)
ifndef AVR_CC
AVR_CC = avr-gcc -Os -mmcu=$(MCU) $(AVR_DEBUG_FLAG) $(AVR_CC_FLAG)
endif
ifndef AVR_OBJCOPY
AVR_OBJCOPY = avr-objcopy
endif
ifndef STRIP
STRIP = strip
endif
ifndef AVR_STRIP
AVR_STRIP = avr-strip
endif
strip: bins-strip avr-bins-strip
bins-strip: $(BINS)
$(STRIP) $^
avr-bins-strip: $(AVR_BINS)
$(AVR_STRIP) $^
.c.o:
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(BINS):
$(CC) -o $@ $(LDFLAGS) $^ $(LIBS) $(ADD_LIBS)
.c.avro:
$(AVR_CC) $(AVR_CPPFLAGS) $(AVR_CFLAGS) -c -o $@ $<
.axf.hex:
$(AVR_OBJCOPY) -j .text -j .data -j .eeporm -O ihex $< $@
$(AVR_BINS):
$(AVR_CC) -o $@ $(AVR_LDFLAGS) $^ $(AVR_LIBS) $(AVR_ADD_LIBS)
clean:
rm -f -- $(BINS) $(AVR_BINS) $(OBJS)
|