Skip to content

Commit

Permalink
make use of make variable CURDIR instead of calling pwd
Browse files Browse the repository at this point in the history
make already provides the current working directory in a variable, so make
use of it instead of forking a shell. Also replace usage of PWD by
CURDIR. PWD is provided by most shells, but not all, so this makes the
build system more robust.

Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
Uwe Kleine-König authored and Michal Marek committed Dec 11, 2016
1 parent 76bee23 commit e19b7ce
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions samples/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ CLANG ?= clang

# Trick to allow make to be run from this directory
all:
$(MAKE) -C ../../ $$PWD/
$(MAKE) -C ../../ $(CURDIR)/

clean:
$(MAKE) -C ../../ M=$$PWD clean
$(MAKE) -C ../../ M=$(CURDIR) clean
@rm -f *~

# Verify LLVM compiler tools are available and bpf target is supported by llc
Expand Down
2 changes: 1 addition & 1 deletion samples/connector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ HOSTCFLAGS_ucon.o += -I$(objtree)/usr/include
all: modules

modules clean:
$(MAKE) -C ../.. SUBDIRS=$(PWD) $@
$(MAKE) -C ../.. SUBDIRS=$(CURDIR) $@
2 changes: 1 addition & 1 deletion tools/build/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif

Expand Down
2 changes: 1 addition & 1 deletion tools/gpio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ../scripts/Makefile.include
bindir ?= /usr/bin

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif

Expand Down
2 changes: 1 addition & 1 deletion tools/lib/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include ../../scripts/Makefile.include
include ../../scripts/utilities.mak # QUIET_CLEAN

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BPF_EXTRAVERSION = 1
MAKEFLAGS += --no-print-directory

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/lockdep/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ifndef VERBOSE
endif

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/subcmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include ../../scripts/Makefile.include
include ../../scripts/utilities.mak # QUIET_CLEAN

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/traceevent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ifndef VERBOSE
endif

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
Expand Down
4 changes: 2 additions & 2 deletions tools/objtool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ LD = ld
AR = ar

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif

SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/
LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(PWD)/)
LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/)
LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a

OBJTOOL := $(OUTPUT)objtool
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
endif
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/make
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
endif
Expand Down
3 changes: 0 additions & 3 deletions tools/power/cpupower/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ MKDIR = mkdir
# Now we set up the build system
#

# set up PWD so that older versions of make will work with our build.
PWD = $(shell pwd)

GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo $(OUTPUT)po/$$HLANG.gmo; done;}

export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS
Expand Down
3 changes: 1 addition & 2 deletions tools/power/cpupower/debug/kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
obj-m :=

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
KMISC := /lib/modules/$(shell uname -r)/cpufrequtils/

ifeq ("$(CONFIG_X86_TSC)", "y")
obj-m += cpufreq-test_tsc.o
endif

default:
$(MAKE) -C $(KDIR) M=$(PWD)
$(MAKE) -C $(KDIR) M=$(CURDIR)

clean:
- rm -rf *.o *.ko .tmp-versions .*.cmd .*.mod.* *.mod.c
Expand Down

0 comments on commit e19b7ce

Please sign in to comment.