xref: /freebsd/contrib/arm-optimized-routines/Makefile (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
1# Makefile - requires GNU make
2#
3# Copyright (c) 2018-2024, 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# Detect OS.
29# Assume Unix environment: Linux, Darwin, or Msys.
30OS := $(shell uname -s)
31OS := $(patsubst MSYS%,Msys,$(OS))
32# Following math dependencies can be adjusted in config file
33# if necessary, e.g. for Msys.
34libm-libs = -lm
35libc-libs = -lc
36mpfr-libs = -lmpfr
37gmp-libs = -lgmp
38mpc-libs = -lmpc
39
40all:
41
42-include config.mk
43
44$(foreach sub,$(SUBS),$(eval include $(srcdir)/$(sub)/Dir.mk))
45
46# Required targets of subproject foo:
47#   all-foo
48#   check-foo
49#   clean-foo
50#   install-foo
51# Required make variables of subproject foo:
52#   foo-files: Built files (all in build/).
53# Make variables used by subproject foo:
54#   foo-...: Variables defined in foo/Dir.mk or by config.mk.
55
56all: $(SUBS:%=all-%)
57
58ALL_FILES = $(foreach sub,$(SUBS),$($(sub)-files))
59DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_FILES))))
60$(ALL_FILES): | $(DIRS)
61$(DIRS):
62	mkdir -p $@
63
64$(filter %.os,$(ALL_FILES)): CFLAGS_ALL += $(CFLAGS_SHARED)
65
66build/%.o: $(srcdir)/%.S
67	$(CC) $(CFLAGS_ALL) -c -o $@ $<
68
69build/%.o: $(srcdir)/%.c
70	$(CC) $(CFLAGS_ALL) -c -o $@ $<
71
72build/%.os: $(srcdir)/%.S
73	$(CC) $(CFLAGS_ALL) -c -o $@ $<
74
75build/%.os: $(srcdir)/%.c
76	$(CC) $(CFLAGS_ALL) -c -o $@ $<
77
78clean: $(SUBS:%=clean-%)
79	rm -rf build
80
81distclean: clean
82	rm -f config.mk
83
84$(DESTDIR)$(bindir)/%: build/bin/%
85	$(INSTALL) -D $< $@
86
87$(DESTDIR)$(libdir)/%.so: build/lib/%.so
88	$(INSTALL) -D $< $@
89
90$(DESTDIR)$(libdir)/%: build/lib/%
91	$(INSTALL) -m 644 -D $< $@
92
93$(DESTDIR)$(includedir)/%: build/include/%
94	$(INSTALL) -m 644 -D $< $@
95
96install: $(SUBS:%=install-%)
97
98check: $(SUBS:%=check-%)
99
100.PHONY: all clean distclean install check
101