aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2019-11-20 18:05:06 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2019-11-22 14:19:52 +0000
commit1fd2aaae0fcb13f3a53be8de50b68d269145a0a4 (patch)
treef660fe35f8ed542dc2763a1f676518bc5a178bbb /Makefile
parent4f4e530b2fda475a37e583bc113ad2fd3e83dc7f (diff)
downloadarm-optimized-routines-1fd2aaae0fcb13f3a53be8de50b68d269145a0a4.tar.gz
Build system refactoring
Reorganise the makefiles so subprojects can be more separately used and maintained. Still kept the single toplevel Makefile and config.mk. Subproject Dir.mk is expected to provide all-X, check-X, clean-X and install-X targets where X is the subproject name and it may use generic make variables set in config.mk, like CFLAGS_ALL and CC, or subproject specific variables like X-cflags.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile56
1 files changed, 25 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index 53a1801..c661b33 100644
--- a/Makefile
+++ b/Makefile
@@ -9,31 +9,23 @@ bindir = $(prefix)/bin
libdir = $(prefix)/lib
includedir = $(prefix)/include
-# Build targets
-ALL_OBJS = $(math-objs) $(string-objs)
-ALL_INCLUDES = $(math-includes) $(string-includes)
-ALL_LIBS = $(math-libs) $(string-libs)
-ALL_TOOLS = $(math-tools) $(string-tools)
-HOST_TOOLS = $(math-host-tools)
-
# Configure these in config.mk, do not make changes in this file.
+SUBS = math string
HOST_CC = cc
HOST_CFLAGS = -std=c99 -O2
HOST_LDFLAGS =
HOST_LDLIBS =
EMULATOR =
+CPPFLAGS =
CFLAGS = -std=c99 -O2
+CFLAGS_SHARED = -fPIC
+CFLAGS_ALL = -Ibuild/include $(CPPFLAGS) $(CFLAGS)
LDFLAGS =
LDLIBS =
-CPPFLAGS =
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
INSTALL = install
-CFLAGS_SHARED = -fPIC
-CFLAGS_ALL = -Ibuild/include $(CPPFLAGS) $(CFLAGS)
-LDFLAGS_ALL = $(LDFLAGS)
-
all:
-include config.mk
@@ -41,17 +33,25 @@ all:
include $(srcdir)/math/Dir.mk
include $(srcdir)/string/Dir.mk
-all: all-math all-string
-
-DIRS = $(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_INCLUDES))
-ALL_DIRS = $(sort $(DIRS:%/=%))
-
-$(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_OBJS:%.o=%.os) $(ALL_INCLUDES): | $(ALL_DIRS)
-
-$(ALL_DIRS):
+# Required targets of subproject foo:
+# all-foo
+# check-foo
+# clean-foo
+# install-foo
+# Required make variables of subproject foo:
+# foo-files: Built files (all in build/).
+# Make variables used by subproject foo:
+# foo-...: Variables defined in foo/Dir.mk or by config.mk.
+
+all: $(SUBS:%=all-%)
+
+ALL_FILES = $(foreach sub,$(SUBS),$($(sub)-files))
+DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_FILES))))
+$(ALL_FILES): | $(DIRS)
+$(DIRS):
mkdir -p $@
-$(ALL_OBJS:%.o=%.os): CFLAGS_ALL += $(CFLAGS_SHARED)
+$(filter %.os,$(ALL_FILES)): CFLAGS_ALL += $(CFLAGS_SHARED)
build/%.o: $(srcdir)/%.S
$(CC) $(CFLAGS_ALL) -c -o $@ $<
@@ -65,7 +65,7 @@ build/%.os: $(srcdir)/%.S
build/%.os: $(srcdir)/%.c
$(CC) $(CFLAGS_ALL) -c -o $@ $<
-clean:
+clean: $(SUBS:%=clean-%)
rm -rf build
distclean: clean
@@ -83,14 +83,8 @@ $(DESTDIR)$(libdir)/%: build/lib/%
$(DESTDIR)$(includedir)/%: build/include/%
$(INSTALL) -m 644 -D $< $@
-install-tools: $(ALL_TOOLS:build/bin/%=$(DESTDIR)$(bindir)/%)
-
-install-libs: $(ALL_LIBS:build/lib/%=$(DESTDIR)$(libdir)/%)
-
-install-headers: $(ALL_INCLUDES:build/include/%=$(DESTDIR)$(includedir)/%)
-
-install: install-libs install-headers
+install: $(SUBS:%=install-%)
-check: check-math check-string
+check: $(SUBS:%=check-%)
-.PHONY: all clean distclean install install-tools install-libs install-headers check
+.PHONY: all clean distclean install check