File: GNUmakefile

package info (click to toggle)
fish 4.2.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,976 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (76 lines) | stat: -rw-r--r-- 1,847 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This is a very basic `make` wrapper around the CMake build toolchain.
#
# Supported arguments:
#   PREFIX: sets the installation prefix
#   GENERATOR: explicitly specifies the CMake generator to use

CMAKE ?= cmake

GENERATOR ?= $(shell (which ninja > /dev/null 2> /dev/null && echo Ninja) || \
			 echo 'Unix Makefiles')
prefix ?= /usr/local
PREFIX ?= $(prefix)

ifeq ($(GENERATOR), Ninja)
BUILDFILE = build.ninja
else
BUILDFILE = Makefile
endif


# If CMake has generated an in-tree Makefile, use that instead (issue #6264)
MAKE_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
ifeq ($(shell test -f $(MAKE_DIR)/Makefile && echo 1), 1)

all:
	@+$(MAKE) -f $(MAKE_DIR)/Makefile $(MAKECMDGOALS) --no-print-directory
%:
	@+$(MAKE) -f $(MAKE_DIR)/Makefile $(MAKECMDGOALS) --no-print-directory

else

all: .begin build/fish

.PHONY: .begin
.begin:
	@which $(CMAKE) > /dev/null 2> /dev/null || \
		 (echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false)

.PHONY: build/fish
build/fish: build/$(BUILDFILE)
	$(CMAKE) --build build

# Use build as an order-only dependency. This prevents the target from always being outdated
# after a make run, and more importantly, doesn't clobber manually specified CMake options.
build/$(BUILDFILE): | build
	cd build; $(CMAKE) .. -G "$(GENERATOR)" \
		-DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1

build:
	mkdir -p build

.PHONY: clean
clean:
	rm -rf build

.PHONY: test
test: build/fish
	$(CMAKE) --build build --target fish_run_tests

.PHONY: fish_run_tests
fish_run_tests: build/fish
	$(CMAKE) --build build --target fish_run_tests

.PHONY: install
install: build/fish
	$(CMAKE) --build build --target install

.PHONY: run
run: build/fish
	./build/fish || true

.PHONY: exec
exec: build/fish
	exec ./build/fish

endif # CMake in-tree build check