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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
BUILD_TYPE = Release
BUILD_DEMOS = OFF
EXPORT_COMPILE_COMMANDS = OFF
GRDIR = /usr/local/gr
UNAME := $(shell uname)
ifneq (,$(filter self,$(MAKECMDGOALS)))
USE_BUNDLED_LIBRARIES = ON
else
USE_BUNDLED_LIBRARIES = OFF
endif
PREFERRED_CLANG_FORMAT_VERSION="13"
ifeq ($(shell command -v "clang-format-$(PREFERRED_CLANG_FORMAT_VERSION)"),)
CLANG_FORMAT="clang-format"
else
CLANG_FORMAT="clang-format-$(PREFERRED_CLANG_FORMAT_VERSION)"
endif
default: all
all: build
pre-check:
@lib/Precheck "${GRDIR}" || \
( echo "FATAL: Source and target directory are identical"; exit 1 )
configure: pre-check $(subst ON,bundled-libraries,$(filter ON,$(USE_BUNDLED_LIBRARIES)))
cmake \
-DCMAKE_INSTALL_PREFIX="$(GRDIR)" \
-DCMAKE_BUILD_TYPE="$(BUILD_TYPE)" \
-DGR_BUILD_DEMOS="$(BUILD_DEMOS)" \
-DGR_USE_BUNDLED_LIBRARIES="$(USE_BUNDLED_LIBRARIES)" \
-DCMAKE_EXPORT_COMPILE_COMMANDS="$(EXPORT_COMPILE_COMMANDS)" \
-S . \
-B build
build:
@if [ ! -d build ]; then \
$(MAKE) configure \
GRDIR="$(GRDIR)" \
BUILD_TYPE="$(BUILD_TYPE)" \
BUILD_DEMOS="$(BUILD_DEMOS)" \
USE_BUNDLED_LIBRARIES="$(USE_BUNDLED_LIBRARIES)" \
EXPORT_COMPILE_COMMANDS="$(EXPORT_COMPILE_COMMANDS)"; \
fi
cmake --build build -j
install:
@if [ ! -d build ]; then \
$(MAKE) build \
GRDIR="$(GRDIR)" \
BUILD_TYPE="$(BUILD_TYPE)" \
BUILD_DEMOS="$(BUILD_DEMOS)" \
USE_BUNDLED_LIBRARIES="$(USE_BUNDLED_LIBRARIES)" \
EXPORT_COMPILE_COMMANDS="$(EXPORT_COMPILE_COMMANDS)"; \
fi
cmake --install build
clean:
rm -rf build
$(MAKE) -C 3rdparty clean
rm -f gr.pkg
realclean: clean
$(MAKE) -C 3rdparty realclean
find packaging -type f \( -name '*.deb' -o -name '*.rpm' \) -exec rm \{\} \;
rm -rf tmp
bundled-libraries:
$(MAKE) -C 3rdparty default extras
self: build
osxpkg:
mkdir -p tmp/bin tmp/gr
rsync -a /usr/local/gr/ tmp/gr/
ln -s ../gr/bin/gr tmp/bin/gr
ln -s ../gr/Applications/glgr.app/Contents/MacOS/glgr tmp/bin/glgr
ln -s ../gr/Applications/gksqt.app/Contents/MacOS/gksqt tmp/bin/gksqt
@if [ -e ../gr/Applications/grplot.app/Contents/MacOS/grplot ]; then \
ln -s ../gr/Applications/grplot.app/Contents/MacOS/grplot tmp/bin/grplot; fi
sudo chown -R -h root:wheel tmp/
pkgbuild --identifier de.fz-juelich.gr --root tmp --install-location /usr/local --ownership preserve gr.pkg
sudo rm -rf tmp
code-format:
ifeq ($(UNAME), Darwin)
@find -E . -type f \
-regex '.*\.(c|cpp|cxx|m|h|hpp|hxx)' \
! -path './3rdparty/*' \
! -path './apps/*' \
! -path './build/*' \
-exec "$(CLANG_FORMAT)" -i -verbose -style=file {} \;
@CMAKE_FORMAT="$$(./.setup_cmakeformat.sh)" && \
find -E . -type f \
-regex '(.*/CMakeLists\.txt)|(.*\.cmake)' \
! -path './3rdparty/*' \
! -path './apps/*' \
! -path './build/*' \
-exec echo "Formatting "{} \; \
-exec "$${CMAKE_FORMAT}" -i {} \;
else
@find . -type f \
-regextype posix-extended \
-regex '.*\.(c|cpp|cxx|m|h|hpp|hxx)' \
! -path './3rdparty/*' \
! -path './apps/*' \
! -path './build/*' \
-exec "$(CLANG_FORMAT)" -i -verbose -style=file {} \;
@CMAKE_FORMAT="$$(./.setup_cmakeformat.sh)" && \
find . -type f \
-regextype posix-extended \
-regex '(.*/CMakeLists\.txt)|(.*\.cmake)' \
! -path './3rdparty/*' \
! -path './apps/*' \
! -path './build/*' \
-exec echo "Formatting "{} \; \
-exec "$${CMAKE_FORMAT}" -i {} \;
endif
.PHONY: default all pre-check configure build install clean realclean bundled-libraries self osxpkg code-format
|