Makefile (2043B)
1 # Copyright (C) 2023-2026 |Méso|Star> (contact@meso-star.com) 2 # 3 # This program is free software: you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation, either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 .POSIX: 17 .SUFFIXES: # Clean up default inference rules 18 19 include config.mk 20 21 MK = $(BUILD).mk 22 23 install: makefile prefix 24 @prefix=$$(cat .prefix) && \ 25 LD_LIBRARY_PATH="$${prefix}/lib:$${LD_LIBRARY_PATH}" \ 26 PATH="$${prefix}/bin:$${PATH}" \ 27 PKG_CONFIG_PATH="$${prefix}/lib/pkgconfig:$${PKG_CONFIG_PATH}" \ 28 TEXINPUTS="$${prefix}/share/tex:$${TEXINPUTS}" \ 29 $(MAKE) -f Makefile -f $(MK) install_all 30 31 clean: makefile 32 @$(MAKE) -f Makefile -f $(MK) clean_all 33 rm -rf .prefix $(MK) 34 35 purge: 36 rm -rf "$(CACHE)" .prefix 37 find src -name "*.sh.mk" -exec rm {} +; 38 39 uninstall: makefile 40 @$(MAKE) -f Makefile -f $(MK) uninstall_all 41 42 mirror: makefile 43 mkdir -p "$(MIRROR)" 44 @$(MAKE) -f Makefile -f $(MK) mirror_all 45 46 # Generate the Makefile of the build 47 makefile: cache 48 @echo "Setup $(MK)" 49 @rm -f $(MK) 50 @{ \ 51 build="$(BUILD)"; \ 52 if [ "$${build}" = "$${build#/}" ]; then \ 53 build="$${PWD}/$${build}"; \ 54 fi; \ 55 cd src; \ 56 PATH=$${PATH} \ 57 SIMD_WIDTH=$(SIMD_WIDTH) \ 58 MAKE=$(MAKE) \ 59 $(SHELL) "$${build}"; \ 60 } > "$(MK)" 61 62 prefix: 63 @# store in .prefix the absolute prefix path 64 @(p=$$(echo $(PREFIX)) && mkdir -p -- "$${p}" && cd -- "$${p}" && pwd) \ 65 > .prefix 66 67 cache: 68 mkdir -p "$(CACHE)" 69 70 lint: 71 @find src -name "*.sh" | sort | xargs -I {} sh -c \ 72 "printf 'check %s\n' \"\$$1\"; \ 73 shellcheck -o all -x -P src \"\$$1\"" -- {}