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