78 lines · plain
1# Makefile fragment - requires GNU make2#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-exception6 7S := $(srcdir)/networking8B := build/networking9 10ifeq ($(ARCH),)11all-networking check-networking install-networking clean-networking:12 @echo "*** Please set ARCH in config.mk. ***"13 @exit 114else15 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/chksum27 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.a56 $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)57 58build/include/%.h: $(S)/include/%.h59 cp $< $@60 61build/bin/%.sh: $(S)/test/%.sh62 cp $< $@63 64check-networking: $(networking-tools)65 $(EMULATOR) build/bin/test/chksum -i simple66 $(EMULATOR) build/bin/test/chksum -i scalar67 $(EMULATOR) build/bin/test/chksum -i simd || true # simd is not always available68 69install-networking: \70 $(networking-libs:build/lib/%=$(DESTDIR)$(libdir)/%) \71 $(networking-includes:build/include/%=$(DESTDIR)$(includedir)/%)72 73clean-networking:74 rm -f $(networking-files)75endif76 77.PHONY: all-networking check-networking install-networking clean-networking78