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 ynltool tests 16 17all: $(SUBDIRS) libynl.a 18 19ynltool: | lib generated libynl.a 20samples: | lib generated 21libynl.a: | lib generated 22 @echo -e "\tAR $@" 23 @ar rcs $@ lib/ynl.o generated/*-user.o 24 25$(SUBDIRS): 26 @if [ -f "$@/Makefile" ] ; then \ 27 $(MAKE) -C $@ ; \ 28 fi 29 30clean distclean: 31 @for dir in $(SUBDIRS) ; do \ 32 if [ -f "$$dir/Makefile" ] ; then \ 33 $(MAKE) -C $$dir $@; \ 34 fi \ 35 done 36 rm -f libynl.a 37 rm -rf pyynl/__pycache__ 38 rm -rf pyynl/lib/__pycache__ 39 rm -rf pyynl.egg-info 40 rm -rf build 41 42install: libynl.a lib/*.h 43 @echo -e "\tINSTALL libynl.a" 44 @$(INSTALL) -d $(DESTDIR)$(libdir) 45 @$(INSTALL) -m 0644 libynl.a $(DESTDIR)$(libdir)/libynl.a 46 @echo -e "\tINSTALL libynl headers" 47 @$(INSTALL) -d $(DESTDIR)$(includedir)/ynl 48 @$(INSTALL) -m 0644 lib/*.h $(DESTDIR)$(includedir)/ynl/ 49 @echo -e "\tINSTALL pyynl" 50 @pip install --prefix=$(DESTDIR)$(prefix) . 51 @make -C generated install 52 @make -C tests install 53 54run_tests: 55 @$(MAKE) -C tests run_tests 56 57.PHONY: all clean distclean install run_tests $(SUBDIRS) 58