Skip to content

Commit 2c3da0c

Browse files
committed
add top level Makefile and build samples
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 92479cd commit 2c3da0c

5 files changed

Lines changed: 78 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
*.a
1+
*.a
2+
*.o
3+
lib/__pycache__/

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
all: generated lib samples
4+
5+
lib:
6+
$(MAKE) -C $@
7+
8+
generated:
9+
$(MAKE) -C $@
10+
11+
samples:
12+
$(MAKE) -C $@
13+
14+
libynl.a: ynl.o generated
15+
@echo -e "\tAR $@"
16+
@ar rcs $@ ynl.o $(GENERATED)
17+
18+
clean:
19+
rm -f *.o *.d *~
20+
$(MAKE) -C generated $@
21+
22+
distclean: clean
23+
rm -f *.a
24+
25+
.PHONY: all clean generated lib samples
26+
.DEFAULT_GOAL=all

README.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ YNL CPP is a best effort port of YNL C. Like YNL C is only supports
55
static linking (because structs are auto-generated and may change
66
version to version).
77

8-
The best way of using it in your project is probably git submodule.
8+
The best way of using it in your project is probably git submodule,
9+
or possibly just copying in the right source files (YNL code is BSD
10+
licensed).
11+
12+
Dependencies
13+
------------
14+
15+
This repo uses a Python code generator to turn the Netlink specs in YAML
16+
into C++ classes. Python support for YAML and JSON Schema are required.
17+
(``python3-jsonschema python3-yaml`` packages on Fedora).
918

1019
Building ynl-cpp
1120
----------------
@@ -14,10 +23,16 @@ The repo supports building code for a specific family::
1423

1524
make -C generated/ netdev_lib.a
1625

17-
or a big archive with code for all families::
26+
or a big archive with code for all families (``libynl.a``)::
1827

1928
make -C generated/
2029

30+
Building samples
31+
----------------
32+
33+
Running ``make`` in the main directory will build a couple of simple
34+
sample apps under the ``samples/`` directory.
35+
2136
Updating to latest kernel versions
2237
----------------------------------
2338

samples/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ethtool
2+
netdev

samples/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
include ../Makefile.deps
4+
5+
LDLIBS=../lib/ynl.a ../lib/ynl-cpp.a
6+
7+
CPPFLAGS += -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
8+
-I../lib/ -I../generated/ -idirafter $(UAPI_PATH)
9+
10+
SRCS=$(wildcard *.cpp)
11+
BINS=$(patsubst %.cpp,%,${SRCS})
12+
PROTOS=$(wildcard ../generated/*.a)
13+
14+
include $(wildcard *.d)
15+
16+
all: $(BINS)
17+
18+
$(BINS): ../lib/ynl.a $(PROTOS) $(SRCS)
19+
@echo -e '\tCXX sample $@ '
20+
@$(COMPILE.cpp) $(CPPFLAGS_$@) $@.cpp -o $@.o
21+
@$(LINK.cpp) $@.o -o $@ ../generated/$(patsubst %,%_lib.a,$@) $(LDLIBS)
22+
23+
clean:
24+
rm -f *.o *.d *~
25+
26+
distclean: clean
27+
rm -f $(BINS)
28+
29+
.PHONY: all clean distclean
30+
.DEFAULT_GOAL=all

0 commit comments

Comments
 (0)