pmt: improve build system
This commit is contained in:
48
Makefile
48
Makefile
@@ -2,7 +2,7 @@ include mka/config.mk
|
||||
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 YZBruh - Partition Backupper
|
||||
# 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.
|
||||
@@ -21,7 +21,9 @@ 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
|
||||
@@ -38,12 +40,12 @@ OBJS += $(SOURCE_DIR)/lister.o
|
||||
OBJS += $(SOURCE_DIR)/flash.o
|
||||
OBJS += $(SOURCE_DIR)/backup.o
|
||||
|
||||
# gcc flags
|
||||
LDFLAGS :=
|
||||
LDLIBS := -lm
|
||||
OUT_DIR := $(CUR_DIR)/out
|
||||
BINARY_DIR := $(OUT_DIR)/binary
|
||||
PACKAGE_DIR := $(OUT_DIR)/package
|
||||
|
||||
# display
|
||||
all:
|
||||
all:
|
||||
@printf " --- Building Partition Manager --- \n"; \
|
||||
printf "Version: $(VERSION)\n"; \
|
||||
printf "Version code: $(VERSION_CODE)\n"; \
|
||||
@@ -58,15 +60,15 @@ all:
|
||||
# build progress
|
||||
.PHONY: $(TARGET)
|
||||
$(TARGET): $(OBJS)
|
||||
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
@mkdir -p out; \
|
||||
mkdir -p out/binary; \
|
||||
mkdir -p out/package; \
|
||||
mv pmt out/binary; \
|
||||
$(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 out/binary/pmt out/package; \
|
||||
gzip -f out/package/pmt; \
|
||||
mv out/package/pmt.gz out/package/pmt-$(ARCH)-en.gz; \
|
||||
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";
|
||||
|
||||
@@ -82,7 +84,7 @@ clean:
|
||||
clean-all:
|
||||
@printf "Cleaning (builded files [.o extended] and binary)...\n"; \
|
||||
sleep 2; \
|
||||
rm -rf $(OBJS) out; \
|
||||
rm -rf $(OBJS) $(OUT_DIR); \
|
||||
printf "Success\n";
|
||||
|
||||
# helper function
|
||||
@@ -91,7 +93,7 @@ help:
|
||||
@printf " --------- Partition Manager help ---------\n"; \
|
||||
printf " \n"; \
|
||||
printf " Commands;\n"; \
|
||||
printf " make ==> Build Partition Backupper\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"; \
|
||||
@@ -100,22 +102,12 @@ help:
|
||||
|
||||
.PHONY: install-termux
|
||||
install-termux:
|
||||
@arch=$$(uname -m); \
|
||||
if [ "$$arch" = "aarch64" ]; then \
|
||||
@if [ -f /data/data/com.termux/files/usr/bin/termux-open ]; then \
|
||||
printf " ------------------------------------- \n"; \
|
||||
printf " pmt installer \n"; \
|
||||
printf " ------------------------------------- \n"; \
|
||||
cp out/binary/pmt /data/data/com.termux/files/usr/bin/pmt; \
|
||||
chmod 777 /data/data/com.termux/files/usr/bin/pmt; \
|
||||
printf " \n"; \
|
||||
printf "Success.\n"; \
|
||||
printf " \n"; \
|
||||
elif [ "$$arch" = "armv7l" ]; then \
|
||||
printf " ------------------------------------- \n"; \
|
||||
printf " pmt installer \n"; \
|
||||
printf " ------------------------------------- \n"; \
|
||||
cp out/binary/pmt /data/data/com.termux/files/usr/bin/pmt; \
|
||||
chmod 777 /data/data/com.termux/files/usr/bin/pmt; \
|
||||
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"; \
|
||||
|
||||
Reference in New Issue
Block a user