xref: /openbmc/linux/tools/net/ynl/generated/Makefile (revision 86878f14)
1# SPDX-License-Identifier: GPL-2.0
2
3CC=gcc
4CFLAGS=-std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
5	-I../lib/
6ifeq ("$(DEBUG)","1")
7  CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
8endif
9
10TOOL:=../ynl-gen-c.py
11
12GENS:=
13SRCS=$(patsubst %,%-user.c,${GENS})
14HDRS=$(patsubst %,%-user.h,${GENS})
15OBJS=$(patsubst %,%-user.o,${GENS})
16
17all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI) regen
18
19protos.a: $(OBJS)
20	@echo -e "\tAR $@"
21	@ar rcs $@ $(OBJS)
22
23%-user.h: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
24	@echo -e "\tGEN $@"
25	@$(TOOL) --mode user --header --spec $< > $@
26
27%-user.c: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
28	@echo -e "\tGEN $@"
29	@$(TOOL) --mode user --source --spec $< > $@
30
31%-user.o: %-user.c %-user.h
32	@echo -e "\tCC $@"
33	@$(COMPILE.c) -c -o $@ $<
34
35clean:
36	rm -f *.o
37
38hardclean: clean
39	rm -f *.c *.h *.a
40
41regen:
42	@../ynl-regen.sh
43
44.PHONY: all clean hardclean regen
45.DEFAULT_GOAL: all
46