OSDN Git Service

Merge pull request #2579 from Hourier/Make-Deceleration-Class
[hengbandforosx/hengbandosx.git] / src / gcc-wrap
1 #!/bin/sh
2
3 jp=$(grep "#define JP" autoconf.h | wc -l)
4
5 if test $jp -eq 1; then
6     # Prepare the various file paths.
7     eval SRC_FILE=\${$#}
8     OBJ_FILE=$(echo $SRC_FILE | sed -E 's/\.[^./]+$/\.o/')
9     SRC_DIR=$(
10         cd $(dirname $0)
11         pwd
12     )
13     SRC_SUBDIR=$(dirname $SRC_DIR/$SRC_FILE)
14     BUILD_DIR=$SRC_DIR/../build
15     BUILD_SUBDIR=$(dirname $BUILD_DIR/$SRC_FILE)
16
17     # Create a build directory and generate a symbolic link to the .deps directory.
18     mkdir -p $BUILD_SUBDIR
19     ln -sf $SRC_SUBDIR/.deps $BUILD_SUBDIR/.deps
20
21     # Delete source and object files when interrupted.
22     trap 'rm -f ${BUILD_DIR}/${SRC_FILE} ${BUILD_DIR}/${OBJ_FILE}' INT
23
24     # Copy the source file to the build directory while converting its character encoding to EUC-JP.
25     nkf -e $SRC_DIR/$SRC_FILE >$BUILD_DIR/$SRC_FILE
26
27     # Compile the source file
28     cd $BUILD_DIR
29     $@
30     BUILD_STATUS=$?
31     cd $SRC_DIR
32
33     # Delete the source file in the build directory and move the object file to the source directory.
34     rm -f $BUILD_DIR/$SRC_FILE
35     if [ -f $BUILD_DIR/$OBJ_FILE ]; then
36         mv -f $BUILD_DIR/$OBJ_FILE $SRC_DIR/$OBJ_FILE
37     fi
38 else
39     $@
40     BUILD_STATUS=$?
41 fi
42
43 exit $BUILD_STATUS