xref: /freebsd/contrib/arm-optimized-routines/Makefile (revision ba3c1f5972d7b90feb6e6da47905ff2757e0fe57)
1# Makefile - requires GNU make
2#
3# Copyright (c) 2018-2022, 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
14PLSUBS = math
15HOST_CC = cc
16HOST_CFLAGS = -std=c99 -O2
17HOST_LDFLAGS =
18HOST_LDLIBS =
19EMULATOR =
20CPPFLAGS =
21CFLAGS = -std=c99 -O2
22CFLAGS_SHARED = -fPIC
23CFLAGS_ALL = -Ibuild/include $(CPPFLAGS) $(CFLAGS)
24CFLAGS_PL = -Ibuild/pl/include $(CPPFLAGS) $(CFLAGS) -DPL
25LDFLAGS =
26LDLIBS =
27AR = $(CROSS_COMPILE)ar
28RANLIB = $(CROSS_COMPILE)ranlib
29INSTALL = install
30
31all:
32
33-include config.mk
34
35$(foreach sub,$(SUBS),$(eval include $(srcdir)/$(sub)/Dir.mk))
36
37# Required targets of subproject foo:
38#   all-foo
39#   check-foo
40#   clean-foo
41#   install-foo
42# Required make variables of subproject foo:
43#   foo-files: Built files (all in build/).
44# Make variables used by subproject foo:
45#   foo-...: Variables defined in foo/Dir.mk or by config.mk.
46
47all: $(SUBS:%=all-%)
48
49ALL_FILES = $(foreach sub,$(SUBS),$($(sub)-files))
50DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_FILES))))
51$(ALL_FILES): | $(DIRS)
52$(DIRS):
53	mkdir -p $@
54
55$(filter %.os,$(ALL_FILES)): CFLAGS_ALL += $(CFLAGS_SHARED)
56$(filter %.os,$(ALL_FILES)): CFLAGS_PL += $(CFLAGS_SHARED)
57
58build/%.o: $(srcdir)/%.S
59	$(CC) $(CFLAGS_ALL) -c -o $@ $<
60
61build/%.o: $(srcdir)/%.c
62	$(CC) $(CFLAGS_ALL) -c -o $@ $<
63
64build/%.os: $(srcdir)/%.S
65	$(CC) $(CFLAGS_ALL) -c -o $@ $<
66
67build/%.os: $(srcdir)/%.c
68	$(CC) $(CFLAGS_ALL) -c -o $@ $<
69
70clean: $(SUBS:%=clean-%)
71	rm -rf build
72
73distclean: clean
74	rm -f config.mk
75
76$(DESTDIR)$(bindir)/%: build/bin/%
77	$(INSTALL) -D $< $@
78
79$(DESTDIR)$(libdir)/%.so: build/lib/%.so
80	$(INSTALL) -D $< $@
81
82$(DESTDIR)$(libdir)/%: build/lib/%
83	$(INSTALL) -m 644 -D $< $@
84
85$(DESTDIR)$(includedir)/%: build/include/%
86	$(INSTALL) -m 644 -D $< $@
87
88install: $(SUBS:%=install-%)
89
90check: $(SUBS:%=check-%)
91
92.PHONY: all clean distclean install check
93