# By YZBruh # Copyright 2024 Partition Manager # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # generate any text based empty file. Usage: $(call touch,) define touch $(hide)[ ! "$(FORCE_GEN)" = "true" ] || rm -f "$1" $(hide)touch "$1" || exit 1 endef # copy files. Usage: $(call copy,,) define copy cp "$1" "$2" || exit 1 endef # copy dirs. Usage: $(call copydir,,) define copydir cp -r "$1" "$2" || exit 1 endef # file/dir are deleted. usage: $(call erase,) define erase rm -rf "$1" endef # make directories. usage: $(call mdir,,) define mdir [ -z $2 ] || printf " - Generating `basename $1` dir...\n"; \ mkdir -p "$1" || exit 1; endef # make status. usage: $(call m_stat,"",) define m_stat printf " $1 $2" endef # make status (not newline and using make functions). usage: $(call m_stat_nn,"") define m_stat_nn $(info ==> $(1)) endef # Get file content and if speficed write target, write speficed file. Usage: $(call cat,,) define cat [ -z "$2" ] && cat "$1" || exit 1 [ -n "$2" ] && cat "$1" >> "$2" || exit 1 endef