Files
pmt/Makefile
2024-03-11 22:34:21 +03:00

117 lines
3.5 KiB
Makefile

include mka/config.mk
# By YZBruh
# Copyright 2024 YZBruh - 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.
# speficy
VERSION := 1.5.0
VERSION_CODE := 150
SOURCE_DIR := binary
TARGET := pmt
LANG := en
ARCH := $(shell uname -m)
CUR_DIR := $(shell pwd)
# code list
SRCS := $(SOURCE_DIR)/$(TARGET).c
SRCS += $(SOURCE_DIR)/error.c
SRCS += $(SOURCE_DIR)/checkers.c
SRCS += $(SOURCE_DIR)/lister.c
SRCS += $(SOURCE_DIR)/flash.c
SRCS += $(SOURCE_DIR)/backup.c
OBJS := $(SOURCE_DIR)/$(TARGET).o
OBJS += $(SOURCE_DIR)/error.o
OBJS += $(SOURCE_DIR)/checkers.o
OBJS += $(SOURCE_DIR)/lister.o
OBJS += $(SOURCE_DIR)/flash.o
OBJS += $(SOURCE_DIR)/backup.o
OUT_DIR := $(CUR_DIR)/out
BINARY_DIR := $(OUT_DIR)/binary
PACKAGE_DIR := $(OUT_DIR)/package
# display
all:
@printf " --- Building Partition Manager --- \n"; \
printf "Version: $(VERSION)\n"; \
printf "Version code: $(VERSION_CODE)\n"; \
printf " \n"; \
printf " ------------------------------------- \n"; \
printf " \n"; \
printf "Starting build... Please waith.\n"; \
sleep 2; \
printf "Make running with silent mode...\n"; \
make -s pmt;
# build progress
.PHONY: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)
@mkdir -p $(OUT_DIR); \
mkdir -p $(BINARY_DIR); \
mkdir -p $(PACKAGE_DIR); \
mv pmt $(BINARY_DIR); \
printf "Generating gzip package...\n"; \
cp $(BINARY_DIR)/pmt $(PACKAGE_DIR); \
gzip -f $(PACKAGE_DIR)/pmt; \
mv $(PACKAGE_DIR)/pmt.gz $(PACKAGE_DIR)/pmt-$(ARCH)-$(LANG).gz; \
printf " \n"; \
printf " ------------------------------------- \n";
# cleaner functions
.PHONY: clean
clean:
@printf "Cleaning (builded files [.o extended])...\n"; \
sleep 2; \
rm -rf $(OBJS); \
printf "Success\n";
.PHONY: clean-all
clean-all:
@printf "Cleaning (builded files [.o extended] and binary)...\n"; \
sleep 2; \
rm -rf $(OBJS) $(OUT_DIR); \
printf "Success\n";
# helper function
.PHONY: help
help:
@printf " --------- Partition Manager help ---------\n"; \
printf " \n"; \
printf " Commands;\n"; \
printf " make ==> Build Partition Manager\n"; \
printf " make clean ==> Clear files (Builded binaries are not deleted)\n"; \
printf " make clean-all ==> Clear files (Builded binaries are deleted)\n"; \
printf " make install-termux ==> If you are using termux, it installs the compiled pmt into termux. So it allows you to use it like a normal command.\n"; \
printf " make help ==> Display help message\n"; \
printf " \n";
.PHONY: install-termux
install-termux:
@if [ -f /data/data/com.termux/files/usr/bin/termux-open ]; then \
printf " ------------------------------------- \n"; \
printf " pmt installer \n"; \
printf " ------------------------------------- \n"; \
cp $(BINARY_DIR)/pmt /data/data/com.termux/files/usr/bin/pmt || exit 1; \
chmod 777 /data/data/com.termux/files/usr/bin/pmt || exit 1; \
printf " \n"; \
printf "Success.\n"; \
printf " \n"; \
else \
printf "This function is only available on Termux Android devices using aarch64 (64-bit) and armv7l (32-bit)\n"; \
fi