[CMAKE] Fix problem with __RELFILE__ not working when compiler uses relative pathes
[reactos.git] / configure.sh
1 #!/bin/sh
2
3 if [ "x$ROS_ARCH" = "x" ]; then
4 echo Could not detect RosBE.
5 exit 1
6 fi
7
8 BUILD_ENVIRONMENT=MinGW
9 ARCH=$ROS_ARCH
10 REACTOS_SOURCE_DIR=$(cd `dirname $0` && pwd)
11 REACTOS_OUTPUT_PATH=output-$BUILD_ENVIRONMENT-$ARCH
12 USE_NEW_STYLE=1
13
14 usage() {
15 echo Invalid parameter given.
16 exit 1
17 }
18
19 CMAKE_GENERATOR="Ninja"
20 while [ $# -gt 0 ]; do
21 case $1 in
22 -D)
23 shift
24 if echo "x$1" | grep 'x?*=*' > /dev/null; then
25 ROS_CMAKEOPTS=$ROS_CMAKEOPTS" -D $1"
26 else
27 usage
28 fi
29 ;;
30
31 -D?*=*|-D?*)
32 ROS_CMAKEOPTS=$ROS_CMAKEOPTS" $1"
33 ;;
34 makefiles|Makefiles)
35 CMAKE_GENERATOR="Unix Makefiles"
36 ;;
37 with-host-tools)
38 USE_NEW_STYLE=0
39 ;;
40 *)
41 usage
42 esac
43
44 shift
45 done
46
47 if [ "$REACTOS_SOURCE_DIR" = "$PWD" ]; then
48 echo Creating directories in $REACTOS_OUTPUT_PATH
49 mkdir -p "$REACTOS_OUTPUT_PATH"
50 cd "$REACTOS_OUTPUT_PATH"
51 fi
52
53 mkdir -p reactos
54
55 #EXTRA_ARGS=""
56 if [ $USE_NEW_STYLE -eq 0 ]; then
57 mkdir -p host-tools
58 echo Preparing host tools...
59 cd host-tools
60 rm -f CMakeCache.txt
61
62 REACTOS_BUILD_TOOLS_DIR="$PWD"
63 cmake -G "$CMAKE_GENERATOR" -DARCH:STRING=$ARCH $ROS_CMAKEOPTS -DNEW_STYLE_BUILD:BOOL=0 "$REACTOS_SOURCE_DIR"
64
65 EXTRA_ARGS="$EXTRA_ARGS -DREACTOS_BUILD_TOOLS_DIR:PATH=$REACTOS_BUILD_TOOLS_DIR"
66
67 cd ..
68 fi
69
70 echo Preparing reactos...
71 cd reactos
72 rm -f CMakeCache.txt host-tools/CMakeCache.txt
73
74 cmake -G "$CMAKE_GENERATOR" -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-gcc.cmake -DARCH:STRING=$ARCH -DNEW_STYLE_BUILD:BOOL=$USE_NEW_STYLE $EXTRA_ARGS $ROS_CMAKEOPTS "$REACTOS_SOURCE_DIR"
75
76 echo Configure script complete! Enter directories and execute appropriate build commands \(ex: ninja, make, makex, etc...\).