1# SPDX-License-Identifier: GPL-2.0-only 2 3include ../Makefile.deps 4include ../../../scripts/Makefile.include 5 6INSTALL ?= install 7prefix ?= /usr 8 9CFLAGS += -Wall -Wextra -Werror -O2 10ifeq ("$(DEBUG)","1") 11 CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan 12endif 13CFLAGS += -I../lib -I../generated -I../../../include/uapi/ 14 15SRC_VERSION := \ 16 $(shell make --no-print-directory -sC ../../../.. kernelversion 2>/dev/null || \ 17 echo "unknown") 18 19CFLAGS += -DSRC_VERSION='"$(SRC_VERSION)"' 20 21SRCS := $(wildcard *.c) 22OBJS := $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) 23 24YNLTOOL := $(OUTPUT)ynltool 25 26include $(wildcard $(OUTPUT)*.d) 27 28all: $(YNLTOOL) 29 30$(YNLTOOL): ../libynl.a $(OBJS) 31 $(Q)echo -e "\tLINK $@" 32 $(Q)$(CC) $(CFLAGS) -o $@ $(OBJS) ../libynl.a -lm 33 34$(OUTPUT)%.o: %.c ../libynl.a 35 $(Q)echo -e "\tCC $@" 36 $(Q)$(COMPILE.c) -MMD -c -o $@ $< 37 38../libynl.a: 39 $(Q)$(MAKE) -C ../ 40 41clean: 42 rm -f *.o *.d *~ 43 44distclean: clean 45 rm -f $(YNLTOOL) 46 47bindir ?= /usr/bin 48 49install: $(YNLTOOL) 50 $(INSTALL) -m 0755 $(YNLTOOL) $(DESTDIR)$(bindir)/$(YNLTOOL) 51 52.PHONY: all clean distclean 53.DEFAULT_GOAL=all 54