• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Makefile - requires GNU make
2#
3# Copyright (c) 2018-2020, Arm Limited.
4# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
5
6srcdir = .
7prefix = /usr
8bindir = $(prefix)/bin
9libdir = $(prefix)/lib
10includedir = $(prefix)/include
11
12# Configure these in config.mk, do not make changes in this file.
13SUBS = math string networking
14HOST_CC = cc
15HOST_CFLAGS = -std=c99 -O2
16HOST_LDFLAGS =
17HOST_LDLIBS =
18EMULATOR =
19CPPFLAGS =
20CFLAGS = -std=c99 -O2
21CFLAGS_SHARED = -fPIC
22CFLAGS_ALL = -Ibuild/include $(CPPFLAGS) $(CFLAGS)
23LDFLAGS =
24LDLIBS =
25AR = $(CROSS_COMPILE)ar
26RANLIB = $(CROSS_COMPILE)ranlib
27INSTALL = install
28
29all:
30
31-include config.mk
32
33$(foreach sub,$(SUBS),$(eval include $(srcdir)/$(sub)/Dir.mk))
34
35# Required targets of subproject foo:
36#   all-foo
37#   check-foo
38#   clean-foo
39#   install-foo
40# Required make variables of subproject foo:
41#   foo-files: Built files (all in build/).
42# Make variables used by subproject foo:
43#   foo-...: Variables defined in foo/Dir.mk or by config.mk.
44
45all: $(SUBS:%=all-%)
46
47ALL_FILES = $(foreach sub,$(SUBS),$($(sub)-files))
48DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_FILES))))
49$(ALL_FILES): | $(DIRS)
50$(DIRS):
51	mkdir -p $@
52
53$(filter %.os,$(ALL_FILES)): CFLAGS_ALL += $(CFLAGS_SHARED)
54
55build/%.o: $(srcdir)/%.S
56	$(CC) $(CFLAGS_ALL) -c -o $@ $<
57
58build/%.o: $(srcdir)/%.c
59	$(CC) $(CFLAGS_ALL) -c -o $@ $<
60
61build/%.os: $(srcdir)/%.S
62	$(CC) $(CFLAGS_ALL) -c -o $@ $<
63
64build/%.os: $(srcdir)/%.c
65	$(CC) $(CFLAGS_ALL) -c -o $@ $<
66
67clean: $(SUBS:%=clean-%)
68	rm -rf build
69
70distclean: clean
71	rm -f config.mk
72
73$(DESTDIR)$(bindir)/%: build/bin/%
74	$(INSTALL) -D $< $@
75
76$(DESTDIR)$(libdir)/%.so: build/lib/%.so
77	$(INSTALL) -D $< $@
78
79$(DESTDIR)$(libdir)/%: build/lib/%
80	$(INSTALL) -m 644 -D $< $@
81
82$(DESTDIR)$(includedir)/%: build/include/%
83	$(INSTALL) -m 644 -D $< $@
84
85install: $(SUBS:%=install-%)
86
87check: $(SUBS:%=check-%)
88
89.PHONY: all clean distclean install check
90