1# Copyright (c) 2002, Reinhard Jessich  <reinhard.jessich@telering.at>
2# Copyright (c) 2009  Dmitry Xmelkov
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7#
8# * Redistributions of source code must retain the above copyright
9#   notice, this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above copyright
11#   notice, this list of conditions and the following disclaimer in
12#   the documentation and/or other materials provided with the
13#   distribution.
14# * Neither the name of the copyright holders nor the names of
15#   contributors may be used to endorse or promote products derived
16#   from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29
30# $Id: Rules.am 2475 2015-05-07 06:45:38Z pitchumani $
31
32include $(top_srcdir)/libc/misc/Files.am
33
34if !HAS_DEV_LIB
35# Example:
36#   eeprom_asm_sources --> eerd_byte.S eerd_word.S
37#   basename           --> eerd_byte eerd_word
38#   addsuffix          --> eerd_byte_ eerd_word_
39#   foreach            --> eerd_byte_atmega48 eerd_byte_atmega8
40#                          eerd_word_atmega48 eerd_word_atmega8
41#   addsuffix          --> eerd_byte_atmega48.o eerd_byte_atmega8.o
42#                          eerd_word_atmega48.o eerd_word_atmega8.o
43#
44eeprom_asm_basenames = $(basename $(eeprom_asm_sources))
45eeprom_asm_basenames2 = $(addsuffix _,$(eeprom_asm_basenames))
46eeprom_asm_baselist = $(foreach dev,$(AVRLIB_DEVLIST),\
47    $(addsuffix $(dev),$(eeprom_asm_basenames2)))
48eeprom_asm_objlist = $(addsuffix .o,$(eeprom_asm_baselist))
49
50misc_a_libadd = \
51	$(eeprom_asm_objlist)
52
53# Example of '-mmcu' arg generation:
54#   $@          --> eerd_byte_atmega48.o
55#   basename    --> eerd_byte_atmega48
56#   subst       --> eerd byte atmega48
57#   lastword    --> atmega48
58#
59# Example of source file generation:
60#   $@          --> eerd_byte_atmega48.o
61#   basename    --> eerd_byte_atmega48
62#   subst       --> eerd.byte.atmega48
63#   basename    --> eerd.byte
64#   subst       --> eerd_byte
65#   addsuffix   --> eerd_byte.S
66#
67$(eeprom_asm_objlist):	$(eeprom_asm_sources)
68	$(filter-out -mmcu=%,$(COMPILE) $(AVRLIB_ASFLAGS)) -c -o $@	\
69	    -mmcu=$(lastword $(subst _, ,$(basename $@)))		\
70	    $(<D)/$(addsuffix .S,\
71	    	    $(subst .,_,$(basename $(subst _,.,$(basename $@)))))
72endif
73
74# vim: set ft=make:
75