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