nowsecure / fsmon

monitor filesystem on iOS / OS X / Android / FirefoxOS / Linux
https://www.nowsecure.com
MIT License
906 stars 154 forks source link

Makefile should be modified to support iOS on-device compiling #50

Open Torrekie opened 3 years ago

Torrekie commented 3 years ago

When trying to build on iOS, it uses macos method by default

iPhone:~/proj mobile$ cd fsmon/
iPhone:~/proj/fsmon mobile$ make
cc -I. -Wall -DFSMON_VERSION=\"1.8.4\" -g -ggdb -mmacosx-version-min=10.12 -DTARGET_OSX=1 -o fsmon-macos main.c util.c backend/*.c -framework CoreServices

When passing "-mmacosx-version-min" to clang on iOS, it will build for macos but link for iOS, then causes the binary file could not be executed or building failure.

But when attempting make ios to compile, it will give some errors that tells xcrun not exist.

iPhone:~/proj/fsmon mobile$ make ios
make: xcrun: Command not found
make: xcrun: Command not found
arch armv7 -arch arm64 -isysroot  -fembed-bitcode -flto -target arm64-apple-ios10.0 -miphoneos-version-min=10.0 -O3 -Wall -fembed-bitcode -I. -Wall -DFSMON_VERSION=\"1.8.4\" -g -ggdb -DTARGET_IOS=1 -o fsmon-ios main.c util.c backend/*.c \
        -framework CoreFoundation \
        -weak_framework MobileCoreServices \
        -weak_framework CoreServices
arch: Can't find armv7 in PATH
make: [Makefile:80: ios] Error 1 (ignored)
xcrun --sdk iphoneos strip fsmon-ios
make: xcrun: Command not found
make: *** [Makefile:81: ios] Error 127

Unless we can simulate xcrun's behavior, we should swap sysroot to / (or some specific path that stores iphoneos sdk, I poured it in to my system paths so I will no need to specify sysroot path when compiling other source codes) and use native toolchain.

trufae commented 3 years ago

Probably using make ios CC=gcc is enough to make it work. Can you try?

On 4 Jul 2021, at 10:51, Torrekie @.***> wrote:

 When trying to build on iOS, it uses macos method in default

iPhone:~/proj mobile$ cd fsmon/ iPhone:~/proj/fsmon mobile$ make cc -I. -Wall -DFSMON_VERSION=\"1.8.4\" -g -ggdb -mmacosx-version-min=10.12 -DTARGET_OSX=1 -o fsmon-macos main.c util.c backend/*.c -framework CoreServices When passing "-mmacosx-version-min" to clang on iOS, it will build for macos but link for iOS, then causes the binary file could not be executed or building failure.

But when attempting make ios to compile, it will give some errors that tells xcrun not exist.

iPhone:~/proj/fsmon mobile$ make ios make: xcrun: Command not found make: xcrun: Command not found arch armv7 -arch arm64 -isysroot -fembed-bitcode -flto -target arm64-apple-ios10.0 -miphoneos-version-min=10.0 -O3 -Wall -fembed-bitcode -I. -Wall -DFSMON_VERSION=\"1.8.4\" -g -ggdb -DTARGET_IOS=1 -o fsmon-ios main.c util.c backend/*.c \ -framework CoreFoundation \ -weak_framework MobileCoreServices \ -weak_framework CoreServices arch: Can't find armv7 in PATH make: [Makefile:80: ios] Error 1 (ignored) xcrun --sdk iphoneos strip fsmon-ios make: xcrun: Command not found make: *** [Makefile:81: ios] Error 127 Unless we can simulate xcrun's behavior, we should swap sysroot to / (or some specific path that stores iphoneos sdk, I poured it in to my system paths so I will no need to specify sysroot path when compiling other source codes) and use native toolchain.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Torrekie commented 3 years ago

Probably using make ios CC=gcc is enough to make it work. Can you try?

On 4 Jul 2021, at 10:51, Torrekie @.***> wrote:

 When trying to build on iOS, it uses macos method in default

iPhone:~/proj mobile$ cd fsmon/ iPhone:~/proj/fsmon mobile$ make cc -I. -Wall -DFSMON_VERSION=\"1.8.4\" -g -ggdb -mmacosx-version-min=10.12 -DTARGET_OSX=1 -o fsmon-macos main.c util.c backend/*.c -framework CoreServices When passing "-mmacosx-version-min" to clang on iOS, it will build for macos but link for iOS, then causes the binary file could not be executed or building failure.

But when attempting make ios to compile, it will give some errors that tells xcrun not exist.

iPhone:~/proj/fsmon mobile$ make ios make: xcrun: Command not found make: xcrun: Command not found arch armv7 -arch arm64 -isysroot -fembed-bitcode -flto -target arm64-apple-ios10.0 -miphoneos-version-min=10.0 -O3 -Wall -fembed-bitcode -I. -Wall -DFSMON_VERSION=\"1.8.4\" -g -ggdb -DTARGET_IOS=1 -o fsmon-ios main.c util.c backend/*.c \ -framework CoreFoundation \ -weak_framework MobileCoreServices \ -weak_framework CoreServices arch: Can't find armv7 in PATH make: [Makefile:80: ios] Error 1 (ignored) xcrun --sdk iphoneos strip fsmon-ios make: xcrun: Command not found make: *** [Makefile:81: ios] Error 127 Unless we can simulate xcrun's behavior, we should swap sysroot to / (or some specific path that stores iphoneos sdk, I poured it in to my system paths so I will no need to specify sysroot path when compiling other source codes) and use native toolchain.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

I've created a pull request to fix this