star-build

Automation tool for project installation
git clone git://git.meso-star.com/star-build.git
Log | Files | Refs | README | LICENSE

Makefile (2074B)


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