1 # SPDX-License-Identifier: GPL-2.0
2 include ..
/..
/scripts
/Makefile.
include
3 include ..
/..
/scripts
/utilities.mak
# QUIET_CLEAN
6 srctree
:= $(patsubst %/,%,$(dir $(CURDIR
)))
7 srctree
:= $(patsubst %/,%,$(dir $(srctree
)))
8 srctree
:= $(patsubst %/,%,$(dir $(srctree
)))
9 #$(info Determined 'srctree' to be $(srctree))
12 CC ?
= $(CROSS_COMPILE
)gcc
13 AR ?
= $(CROSS_COMPILE
)ar
14 LD ?
= $(CROSS_COMPILE
)ld
16 MAKEFLAGS
+= --no-print-directory
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.
26 DESTDIR_SQ
= '$(subst ','\'',$(DESTDIR
))'
28 LIBFILE = $(OUTPUT)libsymbol.a
30 CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
31 CFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_FORTIFY_SOURCE -fPIC
38 CFLAGS += -D_FORTIFY_SOURCE
41 # Treat warnings as errors unless directed not to
46 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
48 CFLAGS += -I$(srctree)/tools/lib
49 CFLAGS += -I$(srctree)/tools/include
53 SYMBOL_IN := $(OUTPUT)libsymbol-in.o
56 libdir_relative = lib64
62 libdir = $(prefix)/$(libdir_relative)
65 libdir_SQ = $(subst ','\'',$(libdir))
69 export srctree OUTPUT CC LD CFLAGS V
70 include $(srctree
)/tools
/build
/Makefile.
include
71 include $(srctree
)/tools
/scripts
/Makefile.
include
73 all: fixdep
$(LIBFILE
)
76 @
$(MAKE
) $(build
)=libsymbol
78 $(LIBFILE
): $(SYMBOL_IN
)
79 $(QUIET_AR
)$(RM
) $@
&& $(AR
) rcs
$@
$(SYMBOL_IN
)
81 define do_install_mkdir
82 if
[ ! -d
'$(DESTDIR_SQ)$1' ]; then \
83 $(INSTALL
) -d
-m
755 '$(DESTDIR_SQ)$1'; \
88 if
[ ! -d
'$2' ]; then \
89 $(INSTALL
) -d
-m
755 '$2'; \
91 $(INSTALL
) $1 $(if
$3,-m
$3,) '$2'
94 install_lib
: $(LIBFILE
)
95 $(call QUIET_INSTALL
, $(LIBFILE
)) \
96 $(call do_install_mkdir
,$(libdir_SQ
)); \
97 cp
-fpR
$(LIBFILE
) $(DESTDIR
)$(libdir_SQ
)
100 INSTALL_HDRS_PFX
:= $(DESTDIR
)$(prefix)/include/symbol
101 INSTALL_HDRS
:= $(addprefix $(INSTALL_HDRS_PFX
)/, $(HDRS
))
103 $(INSTALL_HDRS
): $(INSTALL_HDRS_PFX
)/%.h
: %.h
104 $(call QUIET_INSTALL
, $@
) \
105 $(call do_install
,$<,$(INSTALL_HDRS_PFX
)/,644)
107 install_headers
: $(INSTALL_HDRS
)
108 $(call QUIET_INSTALL
, libsymbol_headers
)
110 install: install_lib install_headers
113 $(call QUIET_CLEAN
, libsymbol
) $(RM
) $(LIBFILE
); \
114 find
$(or
$(OUTPUT
),.
) -name \
*.o
-or
-name \
*.o.cmd
-or
-name \
*.o.d | xargs
$(RM
)