blob: 714ff17937ed4d0140dbe2dacdb40f61987dd12f [file] [log] [blame]
Szabolcs Nagy78892282018-04-24 17:10:05 +01001# Makefile - requires GNU make
2#
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +01003# Copyright (c) 2018-2019, Arm Limited.
Szabolcs Nagy11253b02018-11-12 11:10:57 +00004# SPDX-License-Identifier: MIT
Szabolcs Nagy78892282018-04-24 17:10:05 +01005
6srcdir = .
7prefix = /usr
8bindir = $(prefix)/bin
9libdir = $(prefix)/lib
10includedir = $(prefix)/include
11
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010012# Build targets
13ALL_OBJS = $(math-objs)
14ALL_INCLUDES = $(math-includes)
15ALL_LIBS = $(math-libs)
16ALL_TOOLS = $(math-tools)
17HOST_TOOLS = $(math-host-tools)
Szabolcs Nagy78892282018-04-24 17:10:05 +010018
19# Configure these in config.mk, do not make changes in this file.
20HOST_CC = cc
Szabolcs Nagya2027462018-07-27 11:14:11 +010021HOST_CFLAGS = -std=c99 -O2
22HOST_LDFLAGS =
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010023HOST_LDLIBS =
Szabolcs Nagy78892282018-04-24 17:10:05 +010024EMULATOR =
25CFLAGS = -std=c99 -O2
26LDFLAGS =
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010027LDLIBS =
Szabolcs Nagy78892282018-04-24 17:10:05 +010028CPPFLAGS =
29AR = $(CROSS_COMPILE)ar
30RANLIB = $(CROSS_COMPILE)ranlib
31INSTALL = install
32
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010033CFLAGS_ALL = -Ibuild/include $(CPPFLAGS) $(CFLAGS)
Szabolcs Nagy78892282018-04-24 17:10:05 +010034LDFLAGS_ALL = $(LDFLAGS)
35
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010036all:
37
Szabolcs Nagy78892282018-04-24 17:10:05 +010038-include config.mk
39
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010040include math/Dir.mk
41
42all: all-math
Szabolcs Nagy78892282018-04-24 17:10:05 +010043
Szabolcs Nagyc5a80422018-07-11 10:01:24 +010044DIRS = $(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_INCLUDES))
Szabolcs Nagy78892282018-04-24 17:10:05 +010045ALL_DIRS = $(sort $(DIRS:%/=%))
46
Szabolcs Nagyc5a80422018-07-11 10:01:24 +010047$(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_OBJS:%.o=%.os) $(ALL_INCLUDES): | $(ALL_DIRS)
Szabolcs Nagy78892282018-04-24 17:10:05 +010048
49$(ALL_DIRS):
50 mkdir -p $@
51
52$(ALL_OBJS:%.o=%.os): CFLAGS_ALL += -fPIC
53
Szabolcs Nagy78892282018-04-24 17:10:05 +010054build/%.o: $(srcdir)/%.S
55 $(CC) $(CFLAGS_ALL) -c -o $@ $<
56
57build/%.o: $(srcdir)/%.c
58 $(CC) $(CFLAGS_ALL) -c -o $@ $<
59
60build/%.os: $(srcdir)/%.S
61 $(CC) $(CFLAGS_ALL) -c -o $@ $<
62
63build/%.os: $(srcdir)/%.c
64 $(CC) $(CFLAGS_ALL) -c -o $@ $<
65
Szabolcs Nagy78892282018-04-24 17:10:05 +010066clean:
67 rm -rf build
68
69distclean: clean
70 rm -f config.mk
71
72$(DESTDIR)$(bindir)/%: build/bin/%
73 $(INSTALL) -D $< $@
74
75$(DESTDIR)$(libdir)/%.so: build/lib/%.so
76 $(INSTALL) -D $< $@
77
78$(DESTDIR)$(libdir)/%: build/lib/%
79 $(INSTALL) -m 644 -D $< $@
80
81$(DESTDIR)$(includedir)/%: build/include/%
82 $(INSTALL) -m 644 -D $< $@
83
84install-tools: $(ALL_TOOLS:build/bin/%=$(DESTDIR)$(bindir)/%)
85
86install-libs: $(ALL_LIBS:build/lib/%=$(DESTDIR)$(libdir)/%)
87
88install-headers: $(ALL_INCLUDES:build/include/%=$(DESTDIR)$(includedir)/%)
89
90install: install-libs install-headers
91
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010092check: check-math
Szabolcs Nagy78892282018-04-24 17:10:05 +010093
Szabolcs Nagy0af9fce2019-07-18 10:21:43 +010094.PHONY: all clean distclean install install-tools install-libs install-headers check