Makefile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # SPDX-License-Identifier: GPL-2.0
  2. CC=gcc
  3. CFLAGS=-std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
  4. -I../lib/ -idirafter $(UAPI_PATH)
  5. ifeq ("$(DEBUG)","1")
  6. CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
  7. endif
  8. include ../Makefile.deps
  9. YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \
  10. --exclude-op stats-get
  11. TOOL:=../ynl-gen-c.py
  12. GENS_PATHS=$(shell grep -nrI --files-without-match \
  13. 'protocol: netlink' \
  14. ../../../../Documentation/netlink/specs/)
  15. GENS=$(patsubst ../../../../Documentation/netlink/specs/%.yaml,%,${GENS_PATHS})
  16. SRCS=$(patsubst %,%-user.c,${GENS})
  17. HDRS=$(patsubst %,%-user.h,${GENS})
  18. OBJS=$(patsubst %,%-user.o,${GENS})
  19. all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI)
  20. protos.a: $(OBJS)
  21. @echo -e "\tAR $@"
  22. @ar rcs $@ $(OBJS)
  23. %-user.h: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
  24. @echo -e "\tGEN $@"
  25. @$(TOOL) --mode user --header --spec $< -o $@ $(YNL_GEN_ARG_$*)
  26. %-user.c: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
  27. @echo -e "\tGEN $@"
  28. @$(TOOL) --mode user --source --spec $< -o $@ $(YNL_GEN_ARG_$*)
  29. %-user.o: %-user.c %-user.h
  30. @echo -e "\tCC $@"
  31. @$(COMPILE.c) $(CFLAGS_$*) -o $@ $<
  32. clean:
  33. rm -f *.o
  34. distclean: clean
  35. rm -f *.c *.h *.a
  36. regen:
  37. @../ynl-regen.sh
  38. .PHONY: all clean distclean regen
  39. .DEFAULT_GOAL: all