-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_makefile.sh
executable file
·52 lines (37 loc) · 1 KB
/
create_makefile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SOURCE_DIR=$1
OUTPUT_DIR=target
RETRO68_DIR=${SCRIPT_DIR}/Retro68-build
# check if user input a path to the source they wish to compile
if [ $# -ne 1 ]
then
echo "provide source directory. example below:"
echo "./create_makefile.sh path/to/project"
exit
fi
# check if the directory the user input actually exists
if ! [ -d "$SOURCE_DIR" ]
then
echo $SOURCE_DIR
echo "the project directory does not exist"
exit
fi
PROJECT_NAME=$(basename $SOURCE_DIR)
pushd "$SOURCE_DIR" &>/dev/null
if ! [ -f CMakeLists.txt ]
then
echo "CMakeLists.txt file does not exist. exiting."
exit
fi
popd &>/dev/null
FINAL_DIR=${OUTPUT_DIR}/makefile_$PROJECT_NAME
if [ -d $FINAL_DIR ]
then
rm -rf $FINAL_DIR
fi
mkdir -p $FINAL_DIR
pushd $FINAL_DIR &>/dev/null
cmake ../../$SOURCE_DIR -DCMAKE_TOOLCHAIN_FILE=$RETRO68_DIR/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake
popd
echo "Makefile created in: $FINAL_DIR"