xref: /freebsd/contrib/arm-optimized-routines/Makefile (revision f3087bef11543b42e0d69b708f367097a4118d24)
131914882SAlex Richardson# Makefile - requires GNU make
231914882SAlex Richardson#
3*f3087befSAndrew Turner# Copyright (c) 2018-2024, Arm Limited.
4072a4ba8SAndrew Turner# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
531914882SAlex Richardson
631914882SAlex Richardsonsrcdir = .
731914882SAlex Richardsonprefix = /usr
831914882SAlex Richardsonbindir = $(prefix)/bin
931914882SAlex Richardsonlibdir = $(prefix)/lib
1031914882SAlex Richardsonincludedir = $(prefix)/include
1131914882SAlex Richardson
1231914882SAlex Richardson# Configure these in config.mk, do not make changes in this file.
1331914882SAlex RichardsonSUBS = math string networking
1431914882SAlex RichardsonHOST_CC = cc
1531914882SAlex RichardsonHOST_CFLAGS = -std=c99 -O2
1631914882SAlex RichardsonHOST_LDFLAGS =
1731914882SAlex RichardsonHOST_LDLIBS =
1831914882SAlex RichardsonEMULATOR =
1931914882SAlex RichardsonCPPFLAGS =
2031914882SAlex RichardsonCFLAGS = -std=c99 -O2
2131914882SAlex RichardsonCFLAGS_SHARED = -fPIC
2231914882SAlex RichardsonCFLAGS_ALL = -Ibuild/include $(CPPFLAGS) $(CFLAGS)
2331914882SAlex RichardsonLDFLAGS =
2431914882SAlex RichardsonLDLIBS =
2531914882SAlex RichardsonAR = $(CROSS_COMPILE)ar
2631914882SAlex RichardsonRANLIB = $(CROSS_COMPILE)ranlib
2731914882SAlex RichardsonINSTALL = install
28*f3087befSAndrew Turner# Detect OS.
29*f3087befSAndrew Turner# Assume Unix environment: Linux, Darwin, or Msys.
30*f3087befSAndrew TurnerOS := $(shell uname -s)
31*f3087befSAndrew TurnerOS := $(patsubst MSYS%,Msys,$(OS))
32*f3087befSAndrew Turner# Following math dependencies can be adjusted in config file
33*f3087befSAndrew Turner# if necessary, e.g. for Msys.
34*f3087befSAndrew Turnerlibm-libs = -lm
35*f3087befSAndrew Turnerlibc-libs = -lc
36*f3087befSAndrew Turnermpfr-libs = -lmpfr
37*f3087befSAndrew Turnergmp-libs = -lgmp
38*f3087befSAndrew Turnermpc-libs = -lmpc
3931914882SAlex Richardson
4031914882SAlex Richardsonall:
4131914882SAlex Richardson
4231914882SAlex Richardson-include config.mk
4331914882SAlex Richardson
4431914882SAlex Richardson$(foreach sub,$(SUBS),$(eval include $(srcdir)/$(sub)/Dir.mk))
4531914882SAlex Richardson
4631914882SAlex Richardson# Required targets of subproject foo:
4731914882SAlex Richardson#   all-foo
4831914882SAlex Richardson#   check-foo
4931914882SAlex Richardson#   clean-foo
5031914882SAlex Richardson#   install-foo
5131914882SAlex Richardson# Required make variables of subproject foo:
5231914882SAlex Richardson#   foo-files: Built files (all in build/).
5331914882SAlex Richardson# Make variables used by subproject foo:
5431914882SAlex Richardson#   foo-...: Variables defined in foo/Dir.mk or by config.mk.
5531914882SAlex Richardson
5631914882SAlex Richardsonall: $(SUBS:%=all-%)
5731914882SAlex Richardson
5831914882SAlex RichardsonALL_FILES = $(foreach sub,$(SUBS),$($(sub)-files))
5931914882SAlex RichardsonDIRS = $(sort $(patsubst %/,%,$(dir $(ALL_FILES))))
6031914882SAlex Richardson$(ALL_FILES): | $(DIRS)
6131914882SAlex Richardson$(DIRS):
6231914882SAlex Richardson	mkdir -p $@
6331914882SAlex Richardson
6431914882SAlex Richardson$(filter %.os,$(ALL_FILES)): CFLAGS_ALL += $(CFLAGS_SHARED)
6531914882SAlex Richardson
6631914882SAlex Richardsonbuild/%.o: $(srcdir)/%.S
6731914882SAlex Richardson	$(CC) $(CFLAGS_ALL) -c -o $@ $<
6831914882SAlex Richardson
6931914882SAlex Richardsonbuild/%.o: $(srcdir)/%.c
7031914882SAlex Richardson	$(CC) $(CFLAGS_ALL) -c -o $@ $<
7131914882SAlex Richardson
7231914882SAlex Richardsonbuild/%.os: $(srcdir)/%.S
7331914882SAlex Richardson	$(CC) $(CFLAGS_ALL) -c -o $@ $<
7431914882SAlex Richardson
7531914882SAlex Richardsonbuild/%.os: $(srcdir)/%.c
7631914882SAlex Richardson	$(CC) $(CFLAGS_ALL) -c -o $@ $<
7731914882SAlex Richardson
7831914882SAlex Richardsonclean: $(SUBS:%=clean-%)
7931914882SAlex Richardson	rm -rf build
8031914882SAlex Richardson
8131914882SAlex Richardsondistclean: clean
8231914882SAlex Richardson	rm -f config.mk
8331914882SAlex Richardson
8431914882SAlex Richardson$(DESTDIR)$(bindir)/%: build/bin/%
8531914882SAlex Richardson	$(INSTALL) -D $< $@
8631914882SAlex Richardson
8731914882SAlex Richardson$(DESTDIR)$(libdir)/%.so: build/lib/%.so
8831914882SAlex Richardson	$(INSTALL) -D $< $@
8931914882SAlex Richardson
9031914882SAlex Richardson$(DESTDIR)$(libdir)/%: build/lib/%
9131914882SAlex Richardson	$(INSTALL) -m 644 -D $< $@
9231914882SAlex Richardson
9331914882SAlex Richardson$(DESTDIR)$(includedir)/%: build/include/%
9431914882SAlex Richardson	$(INSTALL) -m 644 -D $< $@
9531914882SAlex Richardson
9631914882SAlex Richardsoninstall: $(SUBS:%=install-%)
9731914882SAlex Richardson
9831914882SAlex Richardsoncheck: $(SUBS:%=check-%)
9931914882SAlex Richardson
10031914882SAlex Richardson.PHONY: all clean distclean install check
101