| 1 |
# Makefile fragment - requires GNU make |
| 2 |
# |
| 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 |
| 6 |
|
| 7 |
S := $(srcdir)/networking |
| 8 |
B := build/networking |
| 9 |
|
| 10 |
ifeq ($(ARCH),) |
| 11 |
all-networking check-networking install-networking clean-networking: |
| 12 |
@echo "*** Please set ARCH in config.mk. ***" |
| 13 |
@exit 1 |
| 14 |
else |
| 15 |
|
| 16 |
networking-lib-srcs := $(wildcard $(S)/*.[cS]) $(wildcard $(S)/$(ARCH)/*.[cS]) |
| 17 |
networking-test-srcs := $(wildcard $(S)/test/*.c) |
| 18 |
|
| 19 |
networking-includes := $(patsubst $(S)/%,build/%,$(wildcard $(S)/include/*.h)) |
| 20 |
|
| 21 |
networking-libs := \ |
| 22 |
build/lib/libnetworking.so \ |
| 23 |
build/lib/libnetworking.a \ |
| 24 |
|
| 25 |
networking-tools := \ |
| 26 |
build/bin/test/chksum |
| 27 |
|
| 28 |
networking-lib-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(networking-lib-srcs))) |
| 29 |
networking-test-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(networking-test-srcs))) |
| 30 |
|
| 31 |
networking-objs := \ |
| 32 |
$(networking-lib-objs) \ |
| 33 |
$(networking-lib-objs:%.o=%.os) \ |
| 34 |
$(networking-test-objs) \ |
| 35 |
|
| 36 |
networking-files := \ |
| 37 |
$(networking-objs) \ |
| 38 |
$(networking-libs) \ |
| 39 |
$(networking-tools) \ |
| 40 |
$(networking-includes) \ |
| 41 |
|
| 42 |
all-networking: $(networking-libs) $(networking-tools) $(networking-includes) |
| 43 |
|
| 44 |
$(networking-objs): $(networking-includes) |
| 45 |
$(networking-objs): CFLAGS_ALL += $(networking-cflags) |
| 46 |
|
| 47 |
build/lib/libnetworking.so: $(networking-lib-objs:%.o=%.os) |
| 48 |
$(CC) $(CFLAGS_ALL) $(LDFLAGS) -shared -o $@ $^ |
| 49 |
|
| 50 |
build/lib/libnetworkinglib.a: $(networking-lib-objs) |
| 51 |
rm -f $@ |
| 52 |
$(AR) rc $@ $^ |
| 53 |
$(RANLIB) $@ |
| 54 |
|
| 55 |
build/bin/test/%: $(B)/test/%.o build/lib/libnetworkinglib.a |
| 56 |
$(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS) |
| 57 |
|
| 58 |
build/include/%.h: $(S)/include/%.h |
| 59 |
cp $< $@ |
| 60 |
|
| 61 |
build/bin/%.sh: $(S)/test/%.sh |
| 62 |
cp $< $@ |
| 63 |
|
| 64 |
check-networking: $(networking-tools) |
| 65 |
$(EMULATOR) build/bin/test/chksum -i simple |
| 66 |
$(EMULATOR) build/bin/test/chksum -i scalar |
| 67 |
$(EMULATOR) build/bin/test/chksum -i simd || true # simd is not always available |
| 68 |
|
| 69 |
install-networking: \ |
| 70 |
$(networking-libs:build/lib/%=$(DESTDIR)$(libdir)/%) \ |
| 71 |
$(networking-includes:build/include/%=$(DESTDIR)$(includedir)/%) |
| 72 |
|
| 73 |
clean-networking: |
| 74 |
rm -f $(networking-files) |
| 75 |
endif |
| 76 |
|
| 77 |
.PHONY: all-networking check-networking install-networking clean-networking |