2023-01-16 16:17:41 +08:00
|
|
|
SRC = $(shell pwd)
|
|
|
|
DEP = $(SRC)/dep_root
|
2023-01-18 01:30:20 +08:00
|
|
|
STRIP = strip
|
2023-01-21 18:27:07 +08:00
|
|
|
CC ?= cc
|
2023-10-30 17:31:54 +08:00
|
|
|
CFLAGS += -isystem $(DEP)/include -I$(SRC)/include -I$(SRC) -D_XOPEN_SOURCE=500
|
2024-11-14 13:37:55 +08:00
|
|
|
CFLAGS += -Wall -Wextra -Wno-unused-parameter -DPALERAIN_VERSION=\"2.1\" -DHAVE_LIBIMOBILEDEVICE
|
2023-03-25 13:35:44 +08:00
|
|
|
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=200112L
|
2023-01-29 01:02:47 +08:00
|
|
|
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a
|
2023-04-30 01:20:39 +08:00
|
|
|
LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread -lm
|
2023-01-18 16:09:51 +08:00
|
|
|
ifeq ($(TARGET_OS),)
|
|
|
|
TARGET_OS = $(shell uname -s)
|
2023-10-30 17:31:54 +08:00
|
|
|
UNAME = $(TARGET_OS)
|
|
|
|
else
|
|
|
|
UNAME = $(shell uname -s)
|
2023-01-18 16:09:51 +08:00
|
|
|
endif
|
|
|
|
ifeq ($(TARGET_OS),Darwin)
|
2023-02-07 17:17:16 +08:00
|
|
|
CFLAGS += -Wno-nullability-extension
|
2023-01-30 22:33:02 +08:00
|
|
|
ifeq (,$(findstring version-min=, $(CFLAGS)))
|
2023-01-21 18:27:07 +08:00
|
|
|
CFLAGS += -mmacosx-version-min=10.8
|
2023-01-24 15:46:50 +08:00
|
|
|
endif
|
2023-01-22 12:17:37 +08:00
|
|
|
LDFLAGS += -Wl,-dead_strip
|
2023-02-15 12:50:04 +08:00
|
|
|
LIBS += -framework CoreFoundation -framework IOKit
|
2023-01-21 18:27:07 +08:00
|
|
|
else
|
2023-01-22 12:17:37 +08:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
2023-10-30 17:31:54 +08:00
|
|
|
LDFLAGS += -Wl,--gc-sections
|
2023-01-18 16:09:51 +08:00
|
|
|
endif
|
2023-01-24 15:46:50 +08:00
|
|
|
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
|
2023-01-16 16:17:41 +08:00
|
|
|
|
2024-05-15 12:33:05 +08:00
|
|
|
ifeq ($(TUI),1)
|
|
|
|
ifeq ($(TARGET_OS),Linux)
|
|
|
|
LIBS += $(DEP)/lib/libgpm.a
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2023-03-29 18:46:01 +08:00
|
|
|
ifeq ($(DEV_BUILD),1)
|
2023-02-01 23:35:45 +08:00
|
|
|
CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer
|
|
|
|
ifeq ($(ASAN),1)
|
2023-02-01 23:58:56 +08:00
|
|
|
BUILD_STYLE=ASAN
|
|
|
|
CFLAGS += -fsanitize=address,undefined -fsanitize-address-use-after-return=runtime
|
2023-02-14 17:34:18 +08:00
|
|
|
else ifeq ($(TSAN),1)
|
|
|
|
BUILD_STYLE=TSAN
|
|
|
|
CFLAGS += -fsanitize=thread,undefined
|
2023-01-18 01:30:20 +08:00
|
|
|
else
|
2023-02-01 23:58:56 +08:00
|
|
|
BUILD_STYLE = DEVELOPMENT
|
2023-01-18 01:30:20 +08:00
|
|
|
endif
|
2023-02-01 23:35:45 +08:00
|
|
|
else
|
2023-02-01 23:58:56 +08:00
|
|
|
CFLAGS += -Os -g
|
|
|
|
BUILD_STYLE = RELEASE
|
2023-02-01 23:35:45 +08:00
|
|
|
endif
|
2023-02-25 00:09:07 +08:00
|
|
|
LIBS += -lc
|
2023-02-13 10:46:33 +08:00
|
|
|
|
2023-10-30 17:31:54 +08:00
|
|
|
ifeq ($(TARGET_OS),Linux)
|
|
|
|
ifneq ($(shell echo '$(BUILD_STYLE)' | grep -q '[A-Z]\+SAN' && echo 1),1)
|
|
|
|
LDFLAGS += -static -no-pie
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2023-02-13 11:07:42 +08:00
|
|
|
ifneq ($(BAKERAIN_DEVELOPE_R),)
|
|
|
|
CFLAGS += -DBAKERAIN_DEVELOPE_R="\"$(BAKERAIN_DEVELOPE_R)\""
|
2023-02-13 10:46:33 +08:00
|
|
|
endif
|
|
|
|
|
2023-03-22 12:10:19 +08:00
|
|
|
BUILD_NUMBER := $(shell git rev-list --count HEAD)
|
2023-02-01 23:58:56 +08:00
|
|
|
BUILD_TAG := $(shell git describe --dirty --tags --abbrev=7)
|
2023-03-22 12:10:19 +08:00
|
|
|
BUILD_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
BUILD_COMMIT := $(shell git rev-parse HEAD)
|
2023-01-18 01:30:20 +08:00
|
|
|
|
2024-08-09 23:07:00 +08:00
|
|
|
CFLAGS += -DBUILD_STYLE="\"$(BUILD_STYLE)\"" -DBUILD_TAG="\"$(BUILD_TAG)\""
|
2023-03-22 12:10:19 +08:00
|
|
|
CFLAGS += -DBUILD_NUMBER="\"$(BUILD_NUMBER)\"" -DBUILD_BRANCH="\"$(BUILD_BRANCH)\""
|
|
|
|
CFLAGS += -DBUILD_COMMIT="\"$(BUILD_COMMIT)\""
|
2023-02-01 23:58:56 +08:00
|
|
|
|
2024-04-06 00:21:40 +08:00
|
|
|
CPATH =
|
|
|
|
LIBRARY_PATH =
|
|
|
|
|
2023-10-30 17:31:54 +08:00
|
|
|
export SRC DEP UNAME CC CFLAGS LDFLAGS LIBS SHELL TARGET_OS DEV_BUILD BUILD_DATE BUILD_TAG BUILD_WHOAMI BUILD_STYLE BUILD_NUMBER BUILD_BRANCH
|
2023-01-16 16:17:41 +08:00
|
|
|
|
|
|
|
all: palera1n
|
|
|
|
|
2023-01-30 22:33:02 +08:00
|
|
|
palera1n: download-deps
|
2023-01-16 16:17:41 +08:00
|
|
|
$(MAKE) -C src
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(MAKE) -C src clean
|
2023-02-06 16:33:14 +08:00
|
|
|
$(MAKE) -C docs clean
|
2023-01-16 16:17:41 +08:00
|
|
|
|
2023-01-30 22:33:02 +08:00
|
|
|
download-deps:
|
2023-10-30 17:31:54 +08:00
|
|
|
$(MAKE) -C src $(patsubst %, resources/%, checkra1n-macos checkra1n-linux-arm64 checkra1n-linux-armel checkra1n-linux-x86 checkra1n-linux-x86_64 checkra1n-kpf-pongo ramdisk.dmg binpack.dmg Pongo.bin)
|
2023-01-21 16:19:33 +08:00
|
|
|
|
2023-02-06 16:33:14 +08:00
|
|
|
docs:
|
|
|
|
$(MAKE) -C docs
|
2023-02-06 15:53:02 +08:00
|
|
|
|
2023-01-16 17:53:38 +08:00
|
|
|
distclean: clean
|
2023-10-30 17:31:54 +08:00
|
|
|
$(MAKE) -C src distclean
|
2023-01-16 17:53:38 +08:00
|
|
|
|
2023-02-06 16:33:14 +08:00
|
|
|
.PHONY: all palera1n clean docs distclean
|
2023-01-22 12:17:37 +08:00
|
|
|
|