xref: /openbmc/linux/tools/lib/api/Makefile (revision 4ef92c2e)
1include ../../scripts/Makefile.include
2include ../../perf/config/utilities.mak		# QUIET_CLEAN
3
4CC = $(CROSS_COMPILE)gcc
5AR = $(CROSS_COMPILE)ar
6
7# guard against environment variables
8LIB_H=
9LIB_OBJS=
10
11LIB_H += fs/debugfs.h
12LIB_H += fs/tracefs.h
13LIB_H += fs/findfs.h
14LIB_H += fs/fs.h
15# See comment below about piggybacking...
16LIB_H += fd/array.h
17
18LIB_OBJS += $(OUTPUT)fs/debugfs.o
19LIB_OBJS += $(OUTPUT)fs/tracefs.o
20LIB_OBJS += $(OUTPUT)fs/findfs.o
21LIB_OBJS += $(OUTPUT)fs/fs.o
22# XXX piggybacking here, need to introduce libapikfd, or rename this
23# to plain libapik.a and make it have it all api goodies
24LIB_OBJS += $(OUTPUT)fd/array.o
25
26LIBFILE = libapikfs.a
27
28CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
29EXTLIBS = -lelf -lpthread -lrt -lm
30ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
31ALL_LDFLAGS = $(LDFLAGS)
32
33RM = rm -f
34
35$(LIBFILE): $(LIB_OBJS)
36	$(QUIET_AR)$(RM) $@ && $(AR) rcs $(OUTPUT)$@ $(LIB_OBJS)
37
38$(LIB_OBJS): $(LIB_H)
39
40libapi_dirs:
41	$(QUIET_MKDIR)mkdir -p $(OUTPUT)fd $(OUTPUT)fs
42
43$(OUTPUT)%.o: %.c libapi_dirs
44	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
45$(OUTPUT)%.s: %.c libapi_dirs
46	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
47$(OUTPUT)%.o: %.S libapi_dirs
48	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
49
50clean:
51	$(call QUIET_CLEAN, libapi) $(RM) $(LIB_OBJS) $(LIBFILE)
52
53.PHONY: clean
54