From f62961882b08eb20dd18970329002a79d798438a Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Sat, 21 Jan 2023 18:27:07 +0800 Subject: [PATCH] fixes --- Makefile | 13 +++++++++---- src/Makefile | 4 ++++ src/main.c | 17 +++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 24261e4..0b57051 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,22 @@ SRC = $(shell pwd) DEP = $(SRC)/dep_root STRIP = strip -CC = cc -CFLAGS += -mmacosx-version-min=10.8 -I$(DEP)/include -I/opt/procursus/include -I$(SRC)/include -I$(SRC) -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" +CC ?= cc +CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" LIBS = $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a $(DEP)/lib/libplist-2.0.a $(DEP)/lib/libimobiledevice-glue-1.0.a -pthread -LIBS += $(DEP)/lib/libcrypto.35.tbd $(DEP)/lib/libssl.35.tbd $(DEP)/lib/libusb-1.0.a ifeq ($(TARGET_OS),) TARGET_OS = $(shell uname -s) endif ifeq ($(TARGET_OS),Darwin) +CFLAGS += -mmacosx-version-min=10.8 +LIBS += $(DEP)/lib/libcrypto.35.tbd $(DEP)/lib/libssl.35.tbd $(DEP)/lib/libusb-1.0.a LIBS += -framework CoreFoundation -framework SystemConfiguration -framework IOKit -framework Security +else +LDFLAGS += -static -fuse-ld=lld +LIBS += $(DEP)/lib/libcrypto.a $(DEP)/lib/libssl.a endif -LDFLAGS = $(LIBS) +LIBS += $(DEP)/lib/libusb-1.0.a +LDFLAGS += $(LIBS) ifeq ($(DEV_BUILD),1) CFLAGS += -O0 -g diff --git a/src/Makefile b/src/Makefile index 8723a52..5cbe908 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,6 +9,7 @@ checkra1n-%: chmod 755 $@ checkra1n: checkra1n-macos +ifeq ($(TARGET_OS),Darwin) ifneq (,$(findstring arm64, $(CFLAGS))) $(LIPO) -thin arm64 -output checkra1n checkra1n-macos else ifneq (,$(findstring x86_64, $(CFLAGS))) @@ -16,6 +17,9 @@ else ifneq (,$(findstring x86_64, $(CFLAGS))) else $(LIPO) -thin $(shell arch) -output checkra1n checkra1n-macos endif +else + cp checkra1n-$(CHECKRA1N_NAME) checkra1n +endif checkra1n.c: checkra1n checkra1n-kpf-pongo ramdisk.dmg binpack.dmg xxd -iC checkra1n > checkra1n.c diff --git a/src/main.c b/src/main.c index c17009a..3044feb 100644 --- a/src/main.c +++ b/src/main.c @@ -26,8 +26,8 @@ #include #include #else -#define MH_MAGIC 0xfeedface -#define MH_CIGAM 0xcefaedfe +#define MH_MAGIC_64 0xfeedfacf +#define MH_CIGAM_64 0xcffaedfe #define MH_KEXT_BUNDLE 0xb typedef int cpu_type_t; @@ -48,6 +48,7 @@ struct mach_header_64 uint32_t flags; /* flags */ uint32_t reserved; /* reserved */ }; + #endif #include "ANSI-color-codes.h" @@ -162,7 +163,7 @@ static struct option longopts[] = { {"override-kpf", required_argument, NULL, 'K'}, {NULL, 0, NULL, 0}}; -int usage(int e) +int usage(int e, char* prog_name) { fprintf(stderr, "Usage: %s [-DhpPvlds] [-e boot arguments] [-f root device] [-o overlay file] [-r ramdisk file] [-K KPF file]\n" @@ -184,7 +185,7 @@ int usage(int e) "\t-o, --override-overlay \t\tOverride overlay\n" "\t-r, --override-ramdisk \t\tOverride ramdisk\n" "\t-K, --override-kpf \t\tOverride kernel patchfinder\n", - getprogname()); + prog_name); exit(e); } @@ -270,7 +271,7 @@ int main(int argc, char *argv[]) dfuhelper_only = true; break; case 'h': - usage(0); + usage(0, argv[0]); assert(0); case 'v': verbose++; @@ -321,7 +322,7 @@ int main(int argc, char *argv[]) palerain_version = true; break; default: - usage(1); + usage(1, argv[0]); break; } } @@ -347,8 +348,8 @@ int main(int argc, char *argv[]) } else { - fprintf(stderr, "%s: unknown argument: %s\n", getprogname(), argv[index]); - usage(1); + fprintf(stderr, "%s: unknown argument: %s\n", argv[0], argv[index]); + usage(1, argv[0]); } } if (verbose >= 3)