]> git.cameronkatri.com Git - ldid.git/commitdiff
Cleanup and switch to a Makefile (#7)
author1Conan <7620342+1Conan@users.noreply.github.com>
Thu, 4 Nov 2021 17:47:21 +0000 (01:47 +0800)
committerGitHub <noreply@github.com>
Thu, 4 Nov 2021 17:47:21 +0000 (13:47 -0400)
16 files changed:
.github/workflows/build.yml
.gitignore
.gitmodules [deleted file]
Makefile [new file with mode: 0644]
control [deleted file]
control.sh [deleted file]
deb.sh [deleted file]
docs/ldid.1 [moved from ldid.1 with 100% similarity]
docs/ldid.1.zh_TW [moved from ldid.1.zh_TW with 100% similarity]
ios.sh [deleted file]
libplist [deleted submodule]
make.sh [deleted file]
plist.sh [deleted file]
sha1.h [deleted file]
sysroot.sh [deleted file]
version.sh [deleted file]

index 37252ddfb0ba41e3b0b208389b0b96a67f519feb..1fe67fb42c8eea592930f2775dc67f13de58f66a 100644 (file)
@@ -109,9 +109,9 @@ jobs:
     - name: build
       run: |
         export LDID_VERSION=$(echo "$(git describe --tags --abbrev=0)")
-        ${CC} ${CFLAGS} -c -o lookup2.o lookup2.c
-        ${CXX} ${CFLAGS} -c -o ldid.o ldid.cpp -std=c++11 -DLDID_VERSION=\"${LDID_VERSION}\"
-        ${CXX} ${CFLAGS} -std=c++11 ldid.o lookup2.o ${LIBPLIST_LIB} ${LIBCRYPTO_LIB} -o ldid
+        make -j$(nproc) \
+          VERSION="${LDID_VERSION}" \
+          LIBS="${LIBPLIST_LIB} ${LIBCRYPTO_LIB}"
         ${TRIPLE}-strip ldid
 
     - uses: actions/upload-artifact@v1
@@ -207,9 +207,10 @@ jobs:
     - name: build
       run: |
         export LDID_VERSION=$(echo "$(git describe --tags --abbrev=0)")
-        ${CC} ${CFLAGS} -flto=thin -Os -c -o lookup2.o lookup2.c
-        ${CXX} ${CFLAGS} -flto=thin -Os -c -o ldid.o ldid.cpp -std=c++11 -DLDID_VERSION=\"${LDID_VERSION}\"
-        ${CXX} ${LIBPLIST_LIB} ${LIBCRYPTO_LIB} -flto=thin -Os -std=c++11 ldid.o lookup2.o -o ldid
+        make -j$(sysctl -n hw.ncpu) \
+          CFLAGS="${CFLAGS} -flto=thin" \
+          VERSION="${LDID_VERSION}" \
+          LIBS="${LIBPLIST_LIB} ${LIBCRYPTO_LIB}"
         strip ldid
 
     - uses: actions/upload-artifact@v1
index edf9bc582bf0f47412f9c05a47f9b4294a2128fe..994aaa892ef8a1a5bdb6a423530fe67719acc1b6 100644 (file)
@@ -1,9 +1,2 @@
-ios
-out
 ldid
-ldid.deb
-debs
 *.o
-_
-sysroot32
-sysroot64
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644 (file)
index 5b41a81..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "libplist"]
-       path = libplist
-       url = https://github.com/libimobiledevice/libplist.git
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..6efccc4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+VERSION  ?= 2.1.5
+
+CC       ?= cc
+CXX      ?= c++
+INSTALL  ?= install
+LN       ?= ln
+
+CFLAGS   ?= -O2 -pipe
+CXXFLAGS ?= $(CFLAGS)
+LDFLAGS  ?=
+
+PREFIX   ?= /usr/local
+
+BINDIR   ?= $(PREFIX)/bin
+MANDIR   ?= $(PREFIX)/share/man
+
+SRC      := $(wildcard *.c) $(wildcard *.cpp)
+LIBS     ?= -lcrypto -lplist-2.0
+
+all: ldid
+
+%.c.o: %.c
+       $(CC) -c $(CFLAGS) -I. $< -o $@
+
+%.cpp.o: %.cpp
+       $(CXX) -c -std=c++11 $(CXXFLAGS) -I. -DLDID_VERSION=\"$(VERSION)\" $< -o $@
+
+ldid: $(SRC:%=%.o)
+       $(CXX) $^ $(LDFLAGS) $(LIBS) -o ldid
+
+install: all
+       $(INSTALL) -D -m755 ldid $(DESTDIR)$(BINDIR)/ldid
+       $(LN) -sf ldid $(DESTDIR)$(BINDIR)/ldid2
+       $(INSTALL) -D -m644 docs/ldid.1 $(DESTDIR)$(MANDIR)/man1/ldid.1
+       $(INSTALL) -D -m644 docs/ldid.1.zh_TW $(DESTDIR)$(MANDIR)/zh_TW/man1/ldid.1
+
+clean:
+       rm -rf ldid *.o
+
+.PHONY: all clean install
diff --git a/control b/control
deleted file mode 100644 (file)
index 73136be..0000000
--- a/control
+++ /dev/null
@@ -1,12 +0,0 @@
-Package: ldid
-Priority: optional
-Section: Development
-Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
-Architecture: iphoneos-arm
-Version: 
-Description: pseudo-codesign Mach-O files
-Name: Link Identity Editor
-Author: Jay Freeman (saurik) <saurik@saurik.com>
-Depiction: http://cydia.saurik.com/info/ldid/
-Depends: libplist (>= 2.0.0), openssl
-Tag: purpose::console, role::developer
diff --git a/control.sh b/control.sh
deleted file mode 100755 (executable)
index 7a11d56..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-dir=$1
-dir=${dir:=_}
-sed -e "s@^\(Version:.*\)@\1$(./version.sh)@" control
-echo "Installed-Size: $(du -s "${dir}" | cut -f 1)"
diff --git a/deb.sh b/deb.sh
deleted file mode 100755 (executable)
index 3fb31a5..0000000
--- a/deb.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-rm -rf _
-mkdir -p _/usr/bin
-cp -a ios/ldid _/usr/bin/ldid
-mkdir -p _/DEBIAN
-./control.sh _ >_/DEBIAN/control
-mkdir -p debs
-ln -sf debs/ldid_$(./version.sh)_iphoneos-arm.deb ldid.deb
-dpkg-deb -b _ ldid.deb
-readlink ldid.deb
similarity index 100%
rename from ldid.1
rename to docs/ldid.1
similarity index 100%
rename from ldid.1.zh_TW
rename to docs/ldid.1.zh_TW
diff --git a/ios.sh b/ios.sh
deleted file mode 100755 (executable)
index f4c112c..0000000
--- a/ios.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-./make.sh true
diff --git a/libplist b/libplist
deleted file mode 160000 (submodule)
index 9ca25d2..0000000
--- a/libplist
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 9ca25d293fe7f8aca8d952fc7bb91464fe2d34ab
diff --git a/make.sh b/make.sh
deleted file mode 100755 (executable)
index 9c5361b..0000000
--- a/make.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/bash
-
-set -e
-shopt -s extglob
-
-if [[ $# == 0 ]]; then
-    ios=false
-else
-    ios=$1
-    shift
-fi
-
-export DEVELOPER_DIR=/Applications/Xcode-5.1.1.app
-
-os=()
-
-if "${ios}"; then
-
-out=ios
-flags=(cycc -- -miphoneos-version-min=2.0 -arch armv6 -arch arm64)
-
-flags+=(-Xarch_armv6 -Isysroot32/usr/include)
-flags+=(-Xarch_arm64 -Isysroot64/usr/include)
-
-flags+=(-Xarch_armv6 -Lsysroot32/usr/lib)
-flags+=(-Xarch_arm64 -Lsysroot64/usr/lib)
-
-static=false
-flags+=(-framework CoreFoundation)
-
-flags+=(-lplist)
-flags+=(-lcrypto)
-
-else
-
-out=out
-
-if which xcrun &>/dev/null; then
-    flags=(xcrun -sdk macosx g++)
-    flags+=(-mmacosx-version-min=10.4)
-
-    for arch in i386 x86_64; do
-        flags+=(-arch "${arch}")
-    done
-else
-    flags=(g++)
-fi
-
-#flags+=(-L../../lib-osx/openssl)
-
-# XXX: cannot redistribute
-static=true
-flags+=(-Isysroot64/usr/include)
-flags+=(-lcrypto)
-#flags+=(-Wl,/usr/lib/libcrypto.42.dylib)
-
-fi
-
-sdk=$(xcodebuild -sdk iphoneos -version Path)
-
-flags+=(-I.)
-
-if ${static}; then
-
-flags+=(-I"${sdk}"/usr/include/libxml2)
-flags+=(-Ilibplist/include)
-flags+=(-Ilibplist/libcnary/include)
-
-for c in libplist/libcnary/!(cnary).c libplist/src/*.c; do
-    o=${c%.c}.o
-    o="${out}"/${o##*/}
-    os+=("${o}")
-    if [[ "${c}" -nt "${o}" ]]; then
-        "${flags[@]}" -c -o "${o}" -x c "${c}"
-    fi
-done
-
-fi
-
-flags+=("$@")
-
-mkdir -p "${out}"
-set -x
-
-"${flags[@]}" -O3 -g0 -c -std=c++11 -o "${out}"/ldid.o ldid.cpp
-"${flags[@]}" -O3 -g0 -o "${out}"/ldid "${out}"/ldid.o "${os[@]}" -x c lookup2.c -lxml2 -framework Security
-
-if ! "${ios}"; then
-    ln -sf out/ldid .
-fi
diff --git a/plist.sh b/plist.sh
deleted file mode 100755 (executable)
index bda6327..0000000
--- a/plist.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-./configure CC='clang -mmacosx-version-min=10.4 -arch i386 -arch x86_64' CXX='clang++ -mmacosx-version-min=10.4 -arch i386 -arch x86_64' CPP='clang -E' CXXCPP='clang++ -E' libxml2_LIBS=-lxml2 libxml2_CFLAGS=-I/usr/include/libxml2 --enable-static --disable-shared
diff --git a/sha1.h b/sha1.h
deleted file mode 100644 (file)
index 32a62a3..0000000
--- a/sha1.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*\r
- *  sha1.h\r
- *\r
- *  Description:\r
- *      This is the header file for code which implements the Secure\r
- *      Hashing Algorithm 1 as defined in FIPS PUB 180-1 published\r
- *      April 17, 1995.\r
- *\r
- *      Many of the variable names in this code, especially the\r
- *      single character names, were used because those were the names\r
- *      used in the publication.\r
- *\r
- *      Please read the file sha1.c for more information.\r
- *\r
- */\r
-\r
-#ifndef _SHA1_H_\r
-#define _SHA1_H_\r
-\r
-#include <stdint.h>\r
-\r
-#ifndef _SHA_enum_\r
-#define _SHA_enum_\r
-enum\r
-{\r
-    shaSuccess = 0,\r
-    shaNull,            /* Null pointer parameter */\r
-    shaInputTooLong,    /* input data too long */\r
-    shaStateError       /* called Input after Result */\r
-};\r
-#endif\r
-#define SHA1HashSize 20\r
-\r
-/*\r
- *  This structure will hold context information for the SHA-1\r
- *  hashing operation\r
- */\r
-typedef struct SHA1Context\r
-{\r
-    uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest  */\r
-\r
-    uint32_t Length_Low;            /* Message length in bits      */\r
-    uint32_t Length_High;           /* Message length in bits      */\r
-\r
-                               /* Index into message block array   */\r
-    int_least16_t Message_Block_Index;\r
-    uint8_t Message_Block[64];      /* 512-bit message blocks      */\r
-\r
-    int Computed;               /* Is the digest computed?         */\r
-    int Corrupted;             /* Is the message digest corrupted? */\r
-} SHA1Context;\r
-\r
-/*\r
- *  Function Prototypes\r
- */\r
-\r
-int SHA1Reset(  SHA1Context *);\r
-int SHA1Input(  SHA1Context *,\r
-                const uint8_t *,\r
-                unsigned int);\r
-int SHA1Result( SHA1Context *,\r
-                uint8_t Message_Digest[SHA1HashSize]);\r
-\r
-#endif\r
diff --git a/sysroot.sh b/sysroot.sh
deleted file mode 100755 (executable)
index e595621..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-set -e
-
-rm -rf sysroot32 sysroot64
-mkdir -p sysroot32 sysroot64
-
-function merge() {
-    wget --no-check-certificate "${apt}/$1"
-    dpkg-deb -x "$1" .
-}
-
-pushd sysroot32
-apt=http://apt.saurik.com/debs
-merge openssl_0.9.8zg-13_iphoneos-arm.deb
-merge libplist_2.0.0-1_iphoneos-arm.deb
-popd
-
-pushd sysroot64
-apt=https://apt.bingner.com/debs/1443.00
-merge libssl1.0_1.0.2q-1_iphoneos-arm.deb
-merge libssl-dev_1.0.2q-1_iphoneos-arm.deb
-merge libplist_2.0.0-1_iphoneos-arm.deb
-popd
-
-for lib in libplist libcrypto; do
-    for dylib in sysroot*/usr/lib/"${lib}".*.dylib; do
-        echo install_name_tool -id /usr/lib/"${lib}".dylib "${dylib}"
-        chmod 755 "${dylib}"
-        install_name_tool -id /usr/lib/"${lib}".dylib "${dylib}"
-    done
-done
diff --git a/version.sh b/version.sh
deleted file mode 100755 (executable)
index 19212f3..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-echo "$(git describe --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$@+\1.\2@;s@^v@2:@')"