brintos

brintos / linux-shallow public Read only

0
0
Text · 2.7 KiB · 8703ab4 Raw
121 lines · plain
1# SPDX-License-Identifier: GPL-2.02include ../../scripts/Makefile.include3include ../../scripts/utilities.mak		# QUIET_CLEAN4 5ifeq ($(srctree),)6srctree := $(patsubst %/,%,$(dir $(CURDIR)))7srctree := $(patsubst %/,%,$(dir $(srctree)))8srctree := $(patsubst %/,%,$(dir $(srctree)))9#$(info Determined 'srctree' to be $(srctree))10endif11 12CC ?= $(CROSS_COMPILE)gcc13LD ?= $(CROSS_COMPILE)ld14AR ?= $(CROSS_COMPILE)ar15 16RM = rm -f17 18MAKEFLAGS += --no-print-directory19 20INSTALL = install21 22# Use DESTDIR for installing into a different root directory.23# This is useful for building a package. The program will be24# installed in this directory as if it was the root directory.25# Then the build tool can move it later.26DESTDIR ?=27DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'28 29LIBFILE = $(OUTPUT)libsubcmd.a30 31CFLAGS := -ggdb3 -Wall -Wextra -std=gnu99 -fPIC32 33ifeq ($(DEBUG),0)34  ifeq ($(feature-fortify-source), 1)35    CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=236  endif37endif38 39ifeq ($(DEBUG),1)40  CFLAGS += -O041else42  CFLAGS += -O343endif44 45# Treat warnings as errors unless directed not to46ifneq ($(WERROR),0)47  CFLAGS += -Werror48endif49 50CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE51 52CFLAGS += -I$(srctree)/tools/include/53 54CFLAGS += $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)55 56SUBCMD_IN := $(OUTPUT)libsubcmd-in.o57 58ifeq ($(LP64), 1)59  libdir_relative = lib6460else61  libdir_relative = lib62endif63 64prefix ?=65libdir = $(prefix)/$(libdir_relative)66 67# Shell quotes68libdir_SQ = $(subst ','\'',$(libdir))69 70all:71 72export srctree OUTPUT CC LD CFLAGS V73include $(srctree)/tools/build/Makefile.include74 75all: fixdep $(LIBFILE)76 77$(SUBCMD_IN): fixdep FORCE78	@$(MAKE) $(build)=libsubcmd79 80$(LIBFILE): $(SUBCMD_IN)81	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)82 83define do_install_mkdir84	if [ ! -d '$(DESTDIR_SQ)$1' ]; then             \85		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \86	fi87endef88 89define do_install90	if [ ! -d '$2' ]; then             \91		$(INSTALL) -d -m 755 '$2'; \92	fi;                                             \93	$(INSTALL) $1 $(if $3,-m $3,) '$2'94endef95 96install_lib: $(LIBFILE)97	$(call QUIET_INSTALL, $(LIBFILE)) \98		$(call do_install_mkdir,$(libdir_SQ)); \99		cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ)100 101HDRS := exec-cmd.h help.h pager.h parse-options.h run-command.h102INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/include/subcmd103INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX)/, $(HDRS))104 105$(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h106	$(call QUIET_INSTALL, $@) \107		$(call do_install,$<,$(INSTALL_HDRS_PFX)/,644)108 109install_headers: $(INSTALL_HDRS)110	$(call QUIET_INSTALL, libsubcmd_headers)111 112install: install_lib install_headers113 114clean:115	$(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \116	find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)117 118FORCE:119 120.PHONY: clean FORCE121