Loading...
1# SPDX-License-Identifier: GPL-2.0
2include ../../scripts/Makefile.include
3include ../../scripts/utilities.mak # QUIET_CLEAN
4
5ifeq ($(srctree),)
6srctree := $(patsubst %/,%,$(dir $(CURDIR)))
7srctree := $(patsubst %/,%,$(dir $(srctree)))
8srctree := $(patsubst %/,%,$(dir $(srctree)))
9#$(info Determined 'srctree' to be $(srctree))
10endif
11
12CC ?= $(CROSS_COMPILE)gcc
13AR ?= $(CROSS_COMPILE)ar
14LD ?= $(CROSS_COMPILE)ld
15
16MAKEFLAGS += --no-print-directory
17
18INSTALL = install
19
20
21# Use DESTDIR for installing into a different root directory.
22# This is useful for building a package. The program will be
23# installed in this directory as if it was the root directory.
24# Then the build tool can move it later.
25DESTDIR ?=
26DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
27
28LIBFILE = $(OUTPUT)libsymbol.a
29
30CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
31CFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_FORTIFY_SOURCE -fPIC
32
33ifeq ($(DEBUG),0)
34ifeq ($(CC_NO_CLANG), 0)
35 CFLAGS += -O3
36else
37 CFLAGS += -O6
38endif
39endif
40
41ifeq ($(DEBUG),0)
42 CFLAGS += -D_FORTIFY_SOURCE
43endif
44
45# Treat warnings as errors unless directed not to
46ifneq ($(WERROR),0)
47 CFLAGS += -Werror
48endif
49
50CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
51
52CFLAGS += -I$(srctree)/tools/lib
53CFLAGS += -I$(srctree)/tools/include
54
55RM = rm -f
56
57SYMBOL_IN := $(OUTPUT)libsymbol-in.o
58
59ifeq ($(LP64), 1)
60 libdir_relative = lib64
61else
62 libdir_relative = lib
63endif
64
65prefix ?=
66libdir = $(prefix)/$(libdir_relative)
67
68# Shell quotes
69libdir_SQ = $(subst ','\'',$(libdir))
70
71all:
72
73export srctree OUTPUT CC LD CFLAGS V
74include $(srctree)/tools/build/Makefile.include
75include $(srctree)/tools/scripts/Makefile.include
76
77all: fixdep $(LIBFILE)
78
79$(SYMBOL_IN): FORCE
80 @$(MAKE) $(build)=libsymbol
81
82$(LIBFILE): $(SYMBOL_IN)
83 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SYMBOL_IN)
84
85define do_install_mkdir
86 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
87 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \
88 fi
89endef
90
91define do_install
92 if [ ! -d '$2' ]; then \
93 $(INSTALL) -d -m 755 '$2'; \
94 fi; \
95 $(INSTALL) $1 $(if $3,-m $3,) '$2'
96endef
97
98install_lib: $(LIBFILE)
99 $(call QUIET_INSTALL, $(LIBFILE)) \
100 $(call do_install_mkdir,$(libdir_SQ)); \
101 cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ)
102
103HDRS := kallsyms.h
104INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/include/symbol
105INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX)/, $(HDRS))
106
107$(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h
108 $(call QUIET_INSTALL, $@) \
109 $(call do_install,$<,$(INSTALL_HDRS_PFX)/,644)
110
111install_headers: $(INSTALL_HDRS)
112 $(call QUIET_INSTALL, libsymbol_headers)
113
114install: install_lib install_headers
115
116clean:
117 $(call QUIET_CLEAN, libsymbol) $(RM) $(LIBFILE); \
118 find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
119
120FORCE:
121
122.PHONY: clean FORCE
1# SPDX-License-Identifier: GPL-2.0
2include ../../scripts/Makefile.include
3include ../../scripts/utilities.mak # QUIET_CLEAN
4
5ifeq ($(srctree),)
6srctree := $(patsubst %/,%,$(dir $(CURDIR)))
7srctree := $(patsubst %/,%,$(dir $(srctree)))
8srctree := $(patsubst %/,%,$(dir $(srctree)))
9#$(info Determined 'srctree' to be $(srctree))
10endif
11
12CC ?= $(CROSS_COMPILE)gcc
13AR ?= $(CROSS_COMPILE)ar
14LD ?= $(CROSS_COMPILE)ld
15
16MAKEFLAGS += --no-print-directory
17
18INSTALL = install
19
20
21# Use DESTDIR for installing into a different root directory.
22# This is useful for building a package. The program will be
23# installed in this directory as if it was the root directory.
24# Then the build tool can move it later.
25DESTDIR ?=
26DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
27
28LIBFILE = $(OUTPUT)libsymbol.a
29
30CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
31CFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_FORTIFY_SOURCE -fPIC
32
33ifeq ($(DEBUG),0)
34 CFLAGS += -O3
35endif
36
37ifeq ($(DEBUG),0)
38 CFLAGS += -D_FORTIFY_SOURCE
39endif
40
41# Treat warnings as errors unless directed not to
42ifneq ($(WERROR),0)
43 CFLAGS += -Werror
44endif
45
46CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
47
48CFLAGS += -I$(srctree)/tools/lib
49CFLAGS += -I$(srctree)/tools/include
50
51RM = rm -f
52
53SYMBOL_IN := $(OUTPUT)libsymbol-in.o
54
55ifeq ($(LP64), 1)
56 libdir_relative = lib64
57else
58 libdir_relative = lib
59endif
60
61prefix ?=
62libdir = $(prefix)/$(libdir_relative)
63
64# Shell quotes
65libdir_SQ = $(subst ','\'',$(libdir))
66
67all:
68
69export srctree OUTPUT CC LD CFLAGS V
70include $(srctree)/tools/build/Makefile.include
71include $(srctree)/tools/scripts/Makefile.include
72
73all: fixdep $(LIBFILE)
74
75$(SYMBOL_IN): FORCE
76 @$(MAKE) $(build)=libsymbol
77
78$(LIBFILE): $(SYMBOL_IN)
79 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SYMBOL_IN)
80
81define do_install_mkdir
82 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
83 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \
84 fi
85endef
86
87define do_install
88 if [ ! -d '$2' ]; then \
89 $(INSTALL) -d -m 755 '$2'; \
90 fi; \
91 $(INSTALL) $1 $(if $3,-m $3,) '$2'
92endef
93
94install_lib: $(LIBFILE)
95 $(call QUIET_INSTALL, $(LIBFILE)) \
96 $(call do_install_mkdir,$(libdir_SQ)); \
97 cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ)
98
99HDRS := kallsyms.h
100INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/include/symbol
101INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX)/, $(HDRS))
102
103$(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h
104 $(call QUIET_INSTALL, $@) \
105 $(call do_install,$<,$(INSTALL_HDRS_PFX)/,644)
106
107install_headers: $(INSTALL_HDRS)
108 $(call QUIET_INSTALL, libsymbol_headers)
109
110install: install_lib install_headers
111
112clean:
113 $(call QUIET_CLEAN, libsymbol) $(RM) $(LIBFILE); \
114 find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
115
116FORCE:
117
118.PHONY: clean FORCE