Browse code

fixes for mingw compilation

Nat! authored on 03-09-2017 20:44:15
Showing 12 changed files
... ...
@@ -30,6 +30,27 @@ mulle-bootstrap
30 30
 mulle-bootstrap-dotdump
31 31
 )
32 32
 
33
+
34
+if(MINGW)
35
+   set( SCRIPTS
36
+${SCRIPTS}
37
+mulle-mingw-cmake.sh
38
+mulle-mingw-make.sh
39
+mulle-mingw-cpp.sh
40
+mulle-mingw-dumpdef.sh*
41
+)
42
+
43
+#
44
+# Todo need to preprocess this to replace SH_PATH with /usr/bin/sh.exe or some such
45
+#
46
+   set( BATS
47
+mulle-mingw-dumpdef.bat
48
+)
49
+
50
+endif()
51
+
52
+
53
+
33 54
 set( LIBRARY_SCRIPTS
34 55
 src/mulle-bootstrap-array.sh
35 56
 src/mulle-bootstrap-auto-update.sh
... ...
@@ -72,6 +93,13 @@ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
72 93
             WORLD_EXECUTE WORLD_READ
73 94
 DESTINATION "bin")
74 95
 
96
+
97
+INSTALL( FILES ${BATS}
98
+PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
99
+            GROUP_EXECUTE GROUP_READ
100
+            WORLD_EXECUTE WORLD_READ
101
+DESTINATION "bin")
102
+
75 103
 #
76 104
 # future: install into libexec/mulle-bootstrap/${MULLE_BOOTSTRAP_VERSION}
77 105
 #         allows multiple versions to co-exist (does it really ?)
... ...
@@ -188,8 +188,9 @@ main()
188 188
 
189 189
          for i in mulle-mingw-*bat
190 190
          do
191
-
192
-            sed -e "s|SH_PATH|${SH_PATH}|g" -e "s|INSTALL_PATH|${INSTALL_PATH}|g" < "${i}" > "${bin}/$i" || exit 1
191
+            cat "${i}" \
192
+               | sed -e 's|C:\\Program\ Files\\Git\\usr\\bin\\shx\.exe|'"${SH_PATH}|g" \
193
+               | sed -e 's|mulle-mingw-dumpdef.sh|'"${INSTALL_PATH}/mulle-mingw-dumpdef.sh|g" > "${bin}/$i" || exit 1
193 194
             chmod "${mode}" "${bin}/${i}" || exit 1
194 195
             printf "install: ${C_MAGENTA}${C_BOLD}%s${C_RESET}\n" "$bin/$i" >&2
195 196
          done
... ...
@@ -254,6 +254,15 @@ bootstrap_libexec_path()
254 254
       libexecpath="${exedirpath}/src"
255 255
    fi
256 256
 
257
+   case "$libexecpath" in
258
+      /*|~*)
259
+      ;;
260
+
261
+      *)
262
+         libexecpath="$PWD/$libexecpath"
263
+      ;;
264
+   esac
265
+
257 266
    if [ -x "${libexecpath}/mulle-bootstrap-functions.sh" ]
258 267
    then
259 268
       echo "${libexecpath}"
... ...
@@ -679,6 +688,17 @@ bootstrap_main()
679 688
 #
680 689
 # service both names
681 690
 #
691
+MULLE_EXECUTABLE_PATH="$0"
692
+case "$MULLE_EXECUTABLE_PATH" in
693
+   /*|~*)
694
+   ;;
695
+
696
+   *)
697
+      MULLE_EXECUTABLE_PATH="$PWD/$MULLE_EXECUTABLE_PATH"
698
+   ;;
699
+esac
700
+
701
+
682 702
 MULLE_EXECUTABLE="`basename -- "$0"`"
683 703
 MULLE_ARGUMENTS="$@"
684 704
 MULLE_EXECUTABLE_ENV_PATH="$PATH"
... ...
@@ -1,5 +1,5 @@
1
- @ECHO OFF 
1
+@ECHO OFF 
2 2
 
3
-REM PATHs are replaced by install.sh 
3
+REM "C:\Program Files\Git\usr\bin\sh.exe" and "/usr/local/bin" are replaced by install.sh 
4 4
 
5
-"SH_PATH" "INSTALL_PATH\mulle-mingw-dumpdef.sh" %*
5
+"C:\Program Files\Git\usr\bin\sh.exe" "mulle-mingw-dumpdef.sh" %*
... ...
@@ -162,10 +162,10 @@ dump_library()
162 162
 
163 163
    local filename
164 164
 
165
-   filename="`find_library ${libraryname}`"
165
+   filename="`find_library "${libraryname}"`"
166 166
    if [ -z "${filename}" ]
167 167
    then
168
-      filename="`find_library ${libraryname}.lib`"
168
+      filename="`find_library "${libraryname}.lib"`"
169 169
       if [ -z "${filename}" ]
170 170
       then
171 171
          echo "${libraryname} ($PWD) not found" >&2 && exit 1
... ...
@@ -176,13 +176,13 @@ dump_library()
176 176
    then
177 177
       if [ ! -z "${VERBOSE}" ]
178 178
       then
179
-         echo "Dumping `basename -- ${filename}` symbols with prefixes ${prefixes}" >&2
179
+         echo "Dumping `basename -- "${filename}"` symbols with prefixes ${prefixes}" >&2
180 180
       fi
181 181
       dump_exports "${filename}" | egrep "${prefixes}"
182 182
    else
183 183
       if [ ! -z "${VERBOSE}" ]
184 184
       then
185
-         echo "Dumping all `basename -- ${filename}` symbols" >&2
185
+         echo "Dumping all `basename -- "${filename}"` symbols" >&2
186 186
       fi
187 187
       dump_exports "${filename}"
188 188
    fi
... ...
@@ -318,7 +318,7 @@ ${SEARCH_PATH}"
318 318
    then
319 319
       trap "rm ${outfile}" INT TERM
320 320
 
321
-      dump_libraries "${libname}" "${prefixes}" "$@"  | unix2dos > "${outfile}"
321
+      dump_libraries "${libname}" "${prefixes}" "$@" | unix2dos > "${outfile}"
322 322
       if [ ! -z "${VERBOSE}" ]
323 323
       then
324 324
          echo "Dumped to ${outfile}" >&2
... ...
@@ -181,6 +181,8 @@ tools_environment_common()
181 181
    # no problem if those are empty
182 182
    C_COMPILER="`find_compiler "${name}" "${srcdir}" CC`"
183 183
    CXX_COMPILER="`find_compiler "${name}" "${srcdir}" CXX`"
184
+   TR="`verify_binary "tr" "tr" "tr"`"
185
+   SED="`verify_binary "sed" "sed" "sed"`"
184 186
 }
185 187
 
186 188
 
... ...
@@ -231,9 +233,12 @@ tools_environment_cmake()
231 233
 
232 234
    local defaultgenerator
233 235
 
234
-   defaultgenerator="`platform_cmake_generator "${defaultmake}"`"
236
+   defaultgenerator="`platform_cmake_generator "${MAKE}"`"
237
+
235 238
    CMAKE="`find_cmake "${name}"`"
236 239
    CMAKE_GENERATOR="`read_build_setting "${name}" "cmake_generator" "${defaultgenerator}"`"
240
+
241
+   [ -z "${CMAKE_GENERATOR}" ]  && internal_fail "CMAKE_GENERATOR must not be empty"
237 242
 }
238 243
 
239 244
 
... ...
@@ -619,7 +624,7 @@ determine_build_subdir()
619 624
    [ -z "$configuration" ] && internal_fail "configuration must not be empty"
620 625
    [ -z "$sdk" ]           && internal_fail "sdk must not be empty"
621 626
 
622
-   sdk=`echo "${sdk}" | sed 's/^\([a-zA-Z]*\).*$/\1/g'`
627
+   sdk=`echo "${sdk}" | "${SED:-sed}" 's/^\([a-zA-Z]*\).*$/\1/g'`
623 628
 
624 629
    if [ "${sdk}" = "Default" ]
625 630
    then
... ...
@@ -645,7 +650,7 @@ determine_dependencies_subdir()
645 650
    [ -z "$sdk" ]           && internal_fail "sdk must not be empty"
646 651
    [ -z "$BUILD_SDKS" ]    && internal_fail "BUILD_SDKS must not be empty"
647 652
 
648
-   sdk=`echo "${sdk}" | sed 's/^\([a-zA-Z]*\).*$/\1/g'`
653
+   sdk=`echo "${sdk}" | "${SED}" 's/^\([a-zA-Z]*\).*$/\1/g'`
649 654
 
650 655
    if [ "${style}" = "auto" ]
651 656
    then
... ...
@@ -854,8 +859,8 @@ _build_flags()
854 859
          ;;
855 860
 
856 861
          mingw)
857
-            native_includelines="`echo "${native_includelines}" | tr '/' '\\'  2> /dev/null`"
858
-            native_librarylines="`echo "${native_librarylines}" | tr '/' '\\'  2> /dev/null`"
862
+            native_includelines="`echo "${native_includelines}" | "${TR}" '/' '\\'  2> /dev/null`"
863
+            native_librarylines="`echo "${native_librarylines}" | "${TR}" '/' '\\'  2> /dev/null`"
859 864
             libraryprefix="/LIBPATH:"
860 865
             includeprefix="/I"
861 866
             frameworklines=
... ...
@@ -878,7 +883,7 @@ _build_flags()
878 883
       for path in ${native_includelines}
879 884
       do
880 885
          IFS="${DEFAULT_IFS}"
881
-         path="$(sed 's/ /\\ /g' <<< "${path}")"
886
+         path="$("${SED}" 's/ /\\ /g' <<< "${path}")"
882 887
          cppflags="`concat "${cppflags}" "${includeprefix}${path}"`"
883 888
       done
884 889
 
... ...
@@ -886,7 +891,7 @@ _build_flags()
886 891
       for path in ${native_librarylines}
887 892
       do
888 893
          IFS="${DEFAULT_IFS}"
889
-         path="$(sed 's/ /\\ /g' <<< "${path}")"
894
+         path="$("${SED}" 's/ /\\ /g' <<< "${path}")"
890 895
          ldflags="`concat "${ldflags}" "${libraryprefix}${path}"`"
891 896
       done
892 897
 
... ...
@@ -894,7 +899,7 @@ _build_flags()
894 899
       for path in ${native_frameworklines}
895 900
       do
896 901
          IFS="${DEFAULT_IFS}"
897
-         path="$(sed 's/ /\\ /g' <<< "${path}")"
902
+         path="$("${SED}" 's/ /\\ /g' <<< "${path}")"
898 903
          cppflags="`concat "${cppflags}" "${frameworkprefix}${path}"`"
899 904
          ldflags="`concat "${ldflags}" "${frameworkprefix}${path}"`"
900 905
       done
... ...
@@ -1020,12 +1025,12 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1020 1025
    local frameworklines
1021 1026
    local dependenciesdir
1022 1027
 
1023
-   cppflags="`echo "${flaglines}"        | sed -n '1p'`"
1024
-   ldflags="`echo "${flaglines}"         | sed -n '2p'`"
1025
-   includelines="`echo "${flaglines}"    | sed -n '6p'`"
1026
-   librarylines="`echo "${flaglines}"    | sed -n '7p'`"
1027
-   frameworklines="`echo "${flaglines}"  | sed -n '8p'`"
1028
-   dependenciesdir="`echo "${flaglines}" | sed -n '9p'`"
1028
+   cppflags="`echo "${flaglines}"        | "${SED}" -n '1p'`"
1029
+   ldflags="`echo "${flaglines}"         | "${SED}" -n '2p'`"
1030
+   includelines="`echo "${flaglines}"    | "${SED}" -n '6p'`"
1031
+   librarylines="`echo "${flaglines}"    | "${SED}" -n '7p'`"
1032
+   frameworklines="`echo "${flaglines}"  | "${SED}" -n '8p'`"
1033
+   dependenciesdir="`echo "${flaglines}" | "${SED}" -n '9p'`"
1029 1034
 
1030 1035
    local addictionsdir
1031 1036
    local binpath
... ...
@@ -1161,7 +1166,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1161 1166
       relative_srcdir="`relative_path_between "${owd}/${srcdir}" "${PWD}"`"
1162 1167
       case "${UNAME}" in
1163 1168
          mingw)
1164
-            relative_srcdir="`echo "${relative_srcdir}" | tr '/' '\\'  2> /dev/null`"
1169
+            relative_srcdir="`echo "${relative_srcdir}" | "${TR}" '/' '\\'  2> /dev/null`"
1165 1170
       esac
1166 1171
 
1167 1172
       logging_redirect_eval_exekutor "${logfile1}" "'${CMAKE}'" \
... ...
@@ -1265,9 +1270,9 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1265 1270
    local ldflags
1266 1271
    local dependenciesdir
1267 1272
 
1268
-   cppflags="`echo "${flaglines}" | sed -n '1p'`"
1269
-   ldflags="`echo "${flaglines}"  | sed -n '2p'`"
1270
-   dependenciesdir="`echo "${flaglines}"  | sed -n '9p'`"
1273
+   cppflags="`echo "${flaglines}"        | "${SED}" -n '1p'`"
1274
+   ldflags="`echo "${flaglines}"         | "${SED}" -n '2p'`"
1275
+   dependenciesdir="`echo "${flaglines}" | "${SED}" -n '9p'`"
1271 1276
 
1272 1277
    local addictionsdir
1273 1278
    local binpath
... ...
@@ -1291,7 +1296,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1291 1296
    local sdkpath
1292 1297
 
1293 1298
    sdkpath="`gcc_sdk_parameter "${sdk}"`"
1294
-   sdkpath="`echo "${sdkpath}" | sed -e 's/ /\\ /g'`"
1299
+   sdkpath="`echo "${sdkpath}" | "${SED}" -e 's/ /\\ /g'`"
1295 1300
 
1296 1301
    if [ ! -z "${sdkpath}" ]
1297 1302
    then
... ...
@@ -94,11 +94,15 @@ suggest_binary_install()
94 94
 
95 95
 platform_make()
96 96
 {
97
-   local compiler="$1"
97
+   local compilerpath="$1"
98
+
99
+   local name
100
+
101
+   name="`basename -- "${compilerpath}"`"
98 102
 
99 103
    case "${UNAME}" in
100 104
       mingw)
101
-         case "${compiler}" in
105
+         case "${name}" in
102 106
             ""|cl|cl.exe)
103 107
                echo "nmake"
104 108
             ;;
... ...
@@ -117,19 +121,24 @@ platform_make()
117 121
 
118 122
 platform_cmake_generator()
119 123
 {
120
-   local make="$1"
124
+   local makepath="$1"
125
+
126
+   local name
121 127
 
128
+   name="`basename -- "${makepath}"`"
122 129
    case "${UNAME}" in
123 130
       mingw)
124
-         case "${make}" in
125
-            n*|N*)
126
-               defaultgenerator="NMake Makefiles"
131
+         case "${name}" in
132
+            nmake|*nmake.exe)
133
+               echo "NMake Makefiles"
127 134
             ;;
135
+
128 136
             mingw*|MINGW*)
129
-               defaultgenerator="MinGW Makefiles"
137
+               echo "MinGW Makefiles"
130 138
             ;;
139
+
131 140
             *)
132
-               defaultgenerator="MSYS Makefiles"
141
+               echo "MSYS Makefiles"
133 142
             ;;
134 143
          esac
135 144
       ;;
... ...
@@ -250,7 +259,7 @@ verify_binary()
250 259
    path=`which_binary "${toolname}"`
251 260
    if [ ! -z "${path}" ]
252 261
    then
253
-      echo "`basename ${path}`"
262
+      echo "${path}"
254 263
       return 0
255 264
    fi
256 265
 
... ...
@@ -177,7 +177,17 @@ build_complete_environment()
177 177
          setup_mingw_buildenvironment
178 178
 
179 179
          BUILDPATH="`mingw_buildpath "${BUILDPATH}"`"
180
+         # if mulle-bootstrap is not properly installed pickup .bat path 
181
+         # this way
182
+         local pretty
183
+
184
+         pretty="`dirname -- "${MULLE_EXECUTABLE_PATH}"`"
185
+         pretty="`simplified_path "$pretty"`"
186
+
187
+         BUILDPATH="$pretty:${BUILDPATH}"
180 188
          BUILD_PWD_OPTIONS="-PW"
189
+
190
+         log_fluff "MINGW buildpath is \"${BUILDPATH}\""
181 191
       ;;
182 192
 
183 193
       "")
... ...
@@ -43,7 +43,7 @@ tar_remove_extension()
43 43
             echo "-s/\.$1\$//"
44 44
          ;;
45 45
 
46
-         linux)
46
+         linux|mingw)
47 47
             echo "--transform s/\.$1\$//"
48 48
          ;;
49 49
 
... ...
@@ -901,7 +901,7 @@ ${i}"
901 901
       return
902 902
    fi
903 903
 
904
-   printf "%s" "${result}" | tr -d '|' | tr '\012' '/'
904
+   printf "%s" "${result}" | "${TR:-tr}" -d '|' | "${TR:-tr}" '\012' '/'
905 905
    echo
906 906
 }
907 907
 
... ...
@@ -139,7 +139,7 @@ mingw_buildpath()
139 139
 
140 140
       if [ -x "${i}/sh.exe" ]
141 141
       then
142
-         log_fluff "Remove \"$i\" from build PATH because it contains sh"
142
+         log_fluff "Removed \"$i\" from build PATH because it contains sh"
143 143
          continue
144 144
       fi
145 145
 
... ...
@@ -709,6 +709,7 @@ _archive_test()
709 709
    case "${archive}" in
710 710
       *.zip)
711 711
          redirect_exekutor /dev/null unzip -t "${archive}" || return 1
712
+	 archive="${archive%.*}"
712 713
       ;;
713 714
    esac
714 715
 
... ...
@@ -752,6 +753,7 @@ _archive_unpack()
752 753
    case "${archive}" in
753 754
       *.zip)
754 755
          exekutor unzip "${archive}" || return 1
756
+	 archive="${archive%.*}"
755 757
       ;;
756 758
    esac
757 759
 
... ...
@@ -1079,4 +1081,4 @@ scm_initialize()
1079 1081
 
1080 1082
 scm_initialize
1081 1083
 
1082
-:
1083 1084
\ No newline at end of file
1085
+: