59 lines
1.6 KiB
Makefile
Executable File
59 lines
1.6 KiB
Makefile
Executable File
# 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,<PATH>)
|
|
define touch
|
|
@ [ ! "$(FORCE_GEN)" = "true" ] || rm -f "$1"
|
|
@ touch "$1" || exit 1
|
|
endef
|
|
|
|
# copy files. Usage: $(call copy,<SOURCE>,<COPY_PATH>)
|
|
define copy
|
|
cp "$1" "$2" || exit 1
|
|
endef
|
|
|
|
# copy dirs. Usage: $(call copydir,<SOURCE>,<COPY_PATH>)
|
|
define copydir
|
|
cp -r "$1" "$2" || exit 1
|
|
endef
|
|
|
|
# file/dir are deleted. usage: $(call erase,<file/directory>)
|
|
define erase
|
|
rm -rf "$1"
|
|
endef
|
|
|
|
# make directories. usage: $(call mdir,<PATH>,<PRINTSTATUS=y/NULL>)
|
|
define mdir
|
|
[ -z $2 ] || printf " - Generating `basename $1` dir...\n"; \
|
|
mkdir -p "$1" || exit 1;
|
|
endef
|
|
|
|
# make status. usage: $(call m_stat,"<MESSAGE>",<NEW_LINE_STATE: RANDOM>)
|
|
define m_stat
|
|
printf " $1 $2"
|
|
endef
|
|
|
|
# make status (not newline and using make functions). usage: $(call m_stat_nn,"<MESSAGE>")
|
|
define m_stat_nn
|
|
$(info ==> $(1))
|
|
endef
|
|
|
|
# Get file content and if speficed write target, write speficed file. Usage: $(call cat,<SOURCE>,<WRITE_PATH>)
|
|
define cat
|
|
[ -z "$2" ] && cat "$1" || exit 1
|
|
[ -n "$2" ] && cat "$1" >> "$2" || exit 1
|
|
endef
|