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