xref: /linux/tools/net/ynl/Makefile (revision 0ad9617c78acbc71373fb341a6f75d4012b01d69)
1# SPDX-License-Identifier: GPL-2.0
2
3include ../../scripts/Makefile.arch
4
5INSTALL	?= install
6prefix  ?= /usr
7ifeq ($(LP64), 1)
8  libdir_relative = lib64
9else
10  libdir_relative = lib
11endif
12libdir  ?= $(prefix)/$(libdir_relative)
13includedir ?= $(prefix)/include
14
15SUBDIRS = lib generated samples
16
17all: $(SUBDIRS) libynl.a
18
19samples: | lib generated
20libynl.a: | lib generated
21	@echo -e "\tAR $@"
22	@ar rcs $@ lib/ynl.o generated/*-user.o
23
24$(SUBDIRS):
25	@if [ -f "$@/Makefile" ] ; then \
26		$(MAKE) -C $@ ; \
27	fi
28
29clean distclean:
30	@for dir in $(SUBDIRS) ; do \
31		if [ -f "$$dir/Makefile" ] ; then \
32			$(MAKE) -C $$dir $@; \
33		fi \
34	done
35	rm -f libynl.a
36	rm -rf pyynl/__pycache__
37	rm -rf pyynl/lib/__pycache__
38	rm -rf pyynl.egg-info
39	rm -rf build
40
41install: libynl.a lib/*.h
42	@echo -e "\tINSTALL libynl.a"
43	@$(INSTALL) -d $(DESTDIR)$(libdir)
44	@$(INSTALL) -m 0644 libynl.a $(DESTDIR)$(libdir)/libynl.a
45	@echo -e "\tINSTALL libynl headers"
46	@$(INSTALL) -d $(DESTDIR)$(includedir)/ynl
47	@$(INSTALL) -m 0644 lib/*.h $(DESTDIR)$(includedir)/ynl/
48	@echo -e "\tINSTALL pyynl"
49	@pip install --prefix=$(DESTDIR)$(prefix) .
50	@make -C generated install
51
52.PHONY: all clean distclean install $(SUBDIRS)
53