| 1 | #!/bin/sh |
|---|
| 2 | # |
|---|
| 3 | # check-build - check build system and source code for inconsistencies |
|---|
| 4 | # Copyright (c) 2009-2010 Sam Hocevar <sam@hocevar.net> |
|---|
| 5 | # All Rights Reserved |
|---|
| 6 | # |
|---|
| 7 | # This program is free software. It comes without any warranty, to |
|---|
| 8 | # the extent permitted by applicable law. You can redistribute it |
|---|
| 9 | # and/or modify it under the terms of the Do What The Fuck You Want |
|---|
| 10 | # To Public License, Version 2, as published by Sam Hocevar. See |
|---|
| 11 | # http://sam.zoy.org/wtfpl/COPYING for more details. |
|---|
| 12 | # |
|---|
| 13 | |
|---|
| 14 | ret=0 |
|---|
| 15 | |
|---|
| 16 | # |
|---|
| 17 | # Check that the Win32 config.h is in sync with config.h.in |
|---|
| 18 | # |
|---|
| 19 | |
|---|
| 20 | config_h_in=$(dirname "$0")/../config.h.in |
|---|
| 21 | msvc_config_h=$(dirname "$0")/../msvc/config.h |
|---|
| 22 | |
|---|
| 23 | failure=0 |
|---|
| 24 | for key in $(sed -ne 's/.*#undef *\([A-Za-z0-9_]*\).*/\1/p' "$config_h_in"); |
|---|
| 25 | do |
|---|
| 26 | if ! grep "[ef] $key[ (]" "$msvc_config_h" >/dev/null 2>&1; then |
|---|
| 27 | echo "error: $key missing from msvc/config.h" |
|---|
| 28 | failure=1 |
|---|
| 29 | fi |
|---|
| 30 | done |
|---|
| 31 | if test "$failure" != "0"; then |
|---|
| 32 | ret=1 |
|---|
| 33 | else |
|---|
| 34 | echo "0 errors in Win32 config.h" |
|---|
| 35 | fi |
|---|
| 36 | |
|---|
| 37 | # |
|---|
| 38 | # Check that we have no tabs or trailing spaces in the source code |
|---|
| 39 | # |
|---|
| 40 | failure=0 |
|---|
| 41 | for dir in src test; do |
|---|
| 42 | (cd $(dirname "$0")/../$dir |
|---|
| 43 | for x in $(make -s echo-sources); do |
|---|
| 44 | if grep '[[:space:]]$' "$x" >/dev/null 2>&1; then |
|---|
| 45 | echo "error: $dir/$x contains trailing spaces" |
|---|
| 46 | failure=1 |
|---|
| 47 | fi |
|---|
| 48 | if grep ' ' "$x" >/dev/null 2>&1; then |
|---|
| 49 | echo "error: $dir/$x contains tabs" |
|---|
| 50 | failure=1 |
|---|
| 51 | fi |
|---|
| 52 | done) |
|---|
| 53 | done |
|---|
| 54 | if test "$failure" != "0"; then |
|---|
| 55 | ret=1 |
|---|
| 56 | else |
|---|
| 57 | echo "0 errors in source code" |
|---|
| 58 | fi |
|---|
| 59 | |
|---|
| 60 | if test "$ret" != "0"; then |
|---|
| 61 | exit 1 |
|---|
| 62 | fi |
|---|
| 63 | |
|---|
| 64 | exit 0 |
|---|
| 65 | |
|---|