Makefile
1.41 KB
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
# Makefile for building libm/openlibm library
$(info >>> L-openlibm <<< T=$(TOP) D=$(DSTPATH) I=$(INCPATH) B=$(BLDPATH) CF=$(CFLAGS) F=$(FPUCFG) )
PWD:=$(shell pwd)
SOURCE_DIR?=$(PWD)
EXPHDRS=openlibm_math.h sfmath.h extmath.h
SOURCES=$(wildcard *.c)
OBJS=$(SOURCES:%.c=$(BLDPATH)/%.o)
DISS=$(SOURCES:%.c=$(BLDPATH)/%.dis)
LIBRARY=libm
SFDIR=../softfloat
ifeq ($(TOOL),llvm)
CC=clang
TOOLCHAIN=sparc-daiteq-elf
#CFLAGS=-msoft-float -O3
CFLAGS+=-target $(TOOLCHAIN) -mcpu=leon2
# TODO: asm options according to selected type of FPU
CFLAGS+=-Xassembler --has-fhalf -Xassembler --has-fpack -Xassembler -Aleon
endif
ifeq ($(TOOL),gcc)
TOOLCHAIN=sparc-gaisler-elf
CC=$(TOOLCHAIN)-gcc
CFLAGS+=-mcpu=leon -qbsp=leon2 -mfix-at697f
endif
CFLAGS+=-ffunction-sections -fdata-sections
CFLAGS+=-I. -I$(SFDIR)/source/include
FPUTYPE=$(FPUCFG:%=-daiteq-fpu-type=%)
AR=$(TOOLCHAIN)-ar
.PHONY: all clean export
all: export
@echo "Library is created"
$(BLDPATH):
@mkdir -p $(BLDPATH)
$(BLDPATH)/$(LIBRARY).a: $(OBJS)
@$(AR) crs $@ $^
$(BLDPATH)/%.o:%.c
@$(CC) $(FPUTYPE) $(CFLAGS) -c $< -o $@
$(BLDPATH)/%.dis:$(BLDPATH)/%.o
@$(TOOLCHAIN)-objdump -S $< > $@
clean:
rm -rf $(BLDPATH)
export: $(DSTPATH)/$(LIBRARY).a $(DISS) $(EXPHDRS:%=$(INCPATH)/%)
@echo "Library is exported"
$(DSTPATH)/$(LIBRARY).a: $(BLDPATH) $(BLDPATH)/$(LIBRARY).a
@cp $(BLDPATH)/$(LIBRARY).a $(DSTPATH)
$(INCPATH)/%: $(SOURCE_DIR)/%
ln -sf $< $@