aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/Makefile
blob: ff51b7d7d8afc9590009a6c296ddaf5f510474c9 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
include ../Makefile.config

.PRECIOUS: .s

CFLAGS=-O1 -Wall

ifeq ($(ARCH),x86)
ifeq ($(MODEL),64)
ARCH=x86_64
else
ARCH=x86_32
endif
endif

ifeq ($(ARCH),powerpc)
ifeq ($(MODEL),ppc64)
ARCH=powerpc64
else ifeq ($(MODEL),e5500)
ARCH=powerpc64
endif
endif

ifeq ($(ARCH),x86_64)
OBJS=i64_dtou.o i64_utod.o i64_utof.o vararg.o
else ifeq ($(ARCH),powerpc64)
OBJS=i64_dtou.o i64_stof.o i64_utod.o i64_utof.o vararg.o
else ifeq ($(ARCH),kvx)
OBJS=i64_umod.o i64_udiv.o i64_udivmod.o i64_sdiv.o i64_smod.o \
     i64_udivmod_stsud.o i32_divmod.o \
     i64_utod.o i64_utof.o i64_stod.o i64_stof.o \
     vararg.o
DOMAKE:=$(shell (cd kvx && make))
else ifeq ($(ARCH),aarch64)
OBJS=vararg.o
else
OBJS=i64_dtos.o i64_dtou.o i64_sar.o i64_sdiv.o i64_shl.o \
  i64_shr.o i64_smod.o i64_stod.o i64_stof.o \
  i64_udivmod.o i64_udiv.o i64_umod.o i64_utod.o i64_utof.o \
  i64_smulh.o i64_umulh.o \
  vararg.o
endif

AR=ar

OBJS+=write_profiling_table.o

LIB=libcompcert.a

INCLUDES=include/float.h include/stdarg.h include/stdbool.h \
  include/stddef.h include/varargs.h include/stdalign.h \
  include/stdnoreturn.h
ifeq ($(ARCH),kvx)
INCLUDES += include/ccomp_kvx_fixes.h include/math.h
endif

VPATH=$(ARCH)

ifeq ($(strip $(HAS_RUNTIME_LIB)),true)
all: $(LIB)
else
all:
endif

$(LIB): $(OBJS)
	rm -f $(LIB)
	$(AR) rcs $(LIB) $(OBJS)

%.o: %.s
	$(CASMRUNTIME) -o $@ $^

%.o: %.S
	$(CASMRUNTIME) -DMODEL_$(MODEL) -DABI_$(ABI) -DENDIANNESS_$(ENDIANNESS) -DSYS_$(SYSTEM) -o $@ $^

# If no asm implementation available, compile the portable C implementation
# with CompCert.  Since CompCert rejects the "__compcert_i64_" identifiers, the C
# implementation uses "i64_" identifiers, and we rename them in the
# generated assembly

%.o: c/%.c c/i64.h ../ccomp
	../ccomp -g -O2 -S -o $*.s -I./c c/$*.c
	sed -i -e 's/i64_/__compcert_i64_/g' $*.s
	$(CASMRUNTIME) -o $*.o $*.s
	@rm $*.s

clean::
	rm -f *.o $(LIB) *.tmp?.s

ifeq ($(strip $(HAS_RUNTIME_LIB)),true)
install::
	install -d $(DESTDIR)$(LIBDIR)
	install -m 0644 $(LIB) $(DESTDIR)$(LIBDIR)
else
install::
endif

ifeq ($(strip $(HAS_STANDARD_HEADERS)),true)
install::
	install -d $(DESTDIR)$(LIBDIR)/include
	install -m 0644 $(INCLUDES) $(DESTDIR)$(LIBDIR)/include
else
install::
endif

test/test_int64: test/test_int64.c $(LIB)
	$(CC) -g -o $@ test/test_int64.c $(LIB)

clean::
	rm -f test/test_int64

.PHONY: test

test: FORCE test/test_int64
	test/test_int64

FORCE: