1 # Makefile - requires GNU make
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 libdir = $(prefix)/lib
11 includedir = $(prefix)/include
13 # Configure these in config.mk, do not make changes in this file.
14 SUBS
= math string networking
16 HOST_CFLAGS
= -std
=c99
-O2
23 CFLAGS_ALL
= -Ibuild
/include $(CPPFLAGS
) $(CFLAGS
)
26 AR
= $(CROSS_COMPILE
)ar
27 RANLIB
= $(CROSS_COMPILE
)ranlib
34 $(foreach sub
,$(SUBS
),$(eval
include $(srcdir)/$(sub
)/Dir.mk
))
36 # Required targets of subproject foo:
41 # Required make variables of subproject foo:
42 # foo-files: Built files (all in build/).
43 # Make variables used by subproject foo:
44 # foo-...: Variables defined in foo/Dir.mk or by config.mk.
48 ALL_FILES
= $(foreach sub
,$(SUBS
),$($(sub
)-files
))
49 DIRS
= $(sort $(patsubst %/,%,$(dir $(ALL_FILES
))))
50 $(ALL_FILES
): |
$(DIRS
)
54 $(filter %.os
,$(ALL_FILES
)): CFLAGS_ALL
+= $(CFLAGS_SHARED
)
56 build
/%.o
: $(srcdir)/%.S
57 $(CC
) $(CFLAGS_ALL
) -c
-o
$@
$<
59 build
/%.o
: $(srcdir)/%.c
60 $(CC
) $(CFLAGS_ALL
) -c
-o
$@
$<
62 build
/%.os
: $(srcdir)/%.S
63 $(CC
) $(CFLAGS_ALL
) -c
-o
$@
$<
65 build
/%.os
: $(srcdir)/%.c
66 $(CC
) $(CFLAGS_ALL
) -c
-o
$@
$<
68 clean: $(SUBS
:%=clean-
%)
74 $(DESTDIR
)$(bindir)/%: build
/bin
/%
77 $(DESTDIR
)$(libdir)/%.so
: build
/lib
/%.so
80 $(DESTDIR
)$(libdir)/%: build
/lib
/%
81 $(INSTALL
) -m
644 -D
$< $@
83 $(DESTDIR
)$(includedir)/%: build
/include/%
84 $(INSTALL
) -m
644 -D
$< $@
86 install: $(SUBS
:%=install-
%)
88 check: $(SUBS
:%=check-
%)
90 .PHONY
: all clean distclean install check