summaryrefslogtreecommitdiff
path: root/device/lib/stm8-large/Makefile.in
blob: 7699d374330fabd0c822f589ffc17ea5f4315b84 (plain) (blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# libc/stm8-large Makefile

VPATH  = @srcdir@
srcdir = @srcdir@
top_builddir = @top_builddir@

LIB_TYPE     = @LIB_TYPE@

SCC = $(top_builddir)/bin/sdcc -mstm8 --model-large
SAS = $(top_builddir)/bin/sdasstm8

# override PORTDIR defined by super (parent) makefile
override PORTDIR = ../build/stm8-large

include $(srcdir)/../incl.mk

STM8_FLOAT = $(COMMON_FLOAT)

STM8_INT = $(COMMON_INT) \
  _mulint.c \
  _divsint.c \
  _modsint.c \
  _mulschar.c \
  _divschar.c \
  _modschar.c

STM8_LONG = $(COMMON_LONG) \
  _divulong.c \
  _mullong.c

STM8_LONGLONG = $(COMMON_LONGLONG) \
  _rrulonglong.c \
  _rrslonglong.c \
  _rlulonglong.c \
  _rlslonglong.c \
  _mullonglong.c \
  _divslonglong.c \
  _divulonglong.c \
  _modslonglong.c \
  _modulonglong.c

STM8_SDCC = $(COMMON_SDCC) \
  _itoa.c \
  _ltoa.c \
  _startup.c \
  _strcmp.c \
  _strcpy.c \
  _strlen.c \
  _memmove.c \
  sprintf.c \
  vprintf.c

STM8SOURCES = $(addprefix ../,$(STM8_FLOAT) $(STM8_INT) $(STM8_LONG) $(STM8_LONGLONG) $(STM8_SDCC))
STM8OBJECTS = $(patsubst %.c,%.rel,$(STM8_FLOAT) $(STM8_INT) $(STM8_LONG) $(STM8_LONGLONG) $(STM8_SDCC))

OBJ = setjmp.rel __mulsint2slong.rel heap.rel memcpy.rel

LIB = stm8.lib
CC = $(SCC)
AS = $(SAS)
ASFLAGS = -plosgff

CFLAGS = -I$(srcdir)/../../include -I. --std-c11

all: $(PORTDIR)/$(LIB)

$(PORTDIR)/$(LIB): $(OBJ) $(STM8OBJECTS) Makefile
ifeq ($(LIB_TYPE), SDCCLIB)
	rm -f $@; \
	$(top_builddir)/bin/sdcclib -a $@ $(OBJ) $(STM8OBJECTS)
else
  ifeq ($(LIB_TYPE), AR)
	$(top_builddir)/bin/sdar -rcSD $@ $(OBJ) $(STM8OBJECTS)
  else
    ifeq ($(LIB_TYPE), RANLIB)
	$(top_builddir)/bin/sdar -rcD $@ $(OBJ) $(STM8OBJECTS)
    else
	rm -f $@
	for i in $(basename $(OBJ) $(STM8OBJECTS)); do echo $$i >>$@; done
	cp $(OBJ) $(STM8OBJECTS) $(PORTDIR)
    endif
  endif
endif

%.rel: %.c
	$(CC) $(CFLAGS) -c $<

%.rel: %.s
	@# TODO: sdas should place it\'s output in the current dir
	test $(srcdir) = . || cp $< .
	-$(AS) $(ASFLAGS) $(notdir $<)
	test $(srcdir) = . || rm $(notdir $<)

%.rel: ../%.c
	$(CC) $(CFLAGS) -c $<

clean:
	rm -f *.rel *.sym *.lst *~ $(CLEANSPEC) *.dump* *.asm *.lib

distclean: clean
	rm -f Makefile