fa7a7fbedfd81d76360bc4a38f0e4db9916eab3d
[platform/upstream/curl.git] / projects / checksrc.bat
1 @echo off
2 rem ***************************************************************************
3 rem *                                  _   _ ____  _
4 rem *  Project                     ___| | | |  _ \| |
5 rem *                             / __| | | | |_) | |
6 rem *                            | (__| |_| |  _ <| |___
7 rem *                             \___|\___/|_| \_\_____|
8 rem *
9 rem * Copyright (C) 2014 - 2015, Steve Holme, <steve_holme@hotmail.com>.
10 rem *
11 rem * This software is licensed as described in the file COPYING, which
12 rem * you should have received as part of this distribution. The terms
13 rem * are also available at http://curl.haxx.se/docs/copyright.html.
14 rem *
15 rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 rem * copies of the Software, and permit persons to whom the Software is
17 rem * furnished to do so, under the terms of the COPYING file.
18 rem *
19 rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 rem * KIND, either express or implied.
21 rem *
22 rem ***************************************************************************
23
24 :begin
25   rem Check we are running on a Windows NT derived OS
26   if not "%OS%" == "Windows_NT" goto nodos
27
28   rem Set our variables
29   setlocal
30
31 :parseArgs
32   if "%~1" == "" goto prerequisites
33
34   if /i "%~1" == "-?" (
35     goto syntax
36   ) else if /i "%~1" == "-h" (
37     goto syntax
38   ) else if /i "%~1" == "-help" (
39     goto syntax
40   ) else (
41     if not defined SRC_DIR (
42       set SRC_DIR=%~1%
43     ) else (
44       goto unknown
45     )
46   )
47
48   shift & goto parseArgs
49
50 :prerequisites
51   rem Check we have Perl installed
52   echo %PATH% | findstr /I /C:"\Perl" 1>nul
53   if errorlevel 1 (
54     if not exist "%SystemDrive%\Perl" (
55       if not exist "%SystemDrive%\Perl64" goto noperl
56     )
57   )
58
59 :configure
60   if "%SRC_DIR%" == "" set SRC_DIR=..
61   if not exist "%SRC_DIR%" goto nosrc
62
63 :start
64   rem Check the src directory
65   if exist %SRC_DIR%\src (
66     for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\src" -Wtool_hugehelp.c "%%i"
67     for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\src" "%%i"
68   )
69
70   rem Check the lib directory
71   if exist %SRC_DIR%\lib (
72     for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib" "%%i"
73     for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib" -Wcurl_config.h.cmake "%%i"
74   )
75
76   rem Check the lib\vtls directory
77   if exist %SRC_DIR%\lib\vtls (
78     for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i"
79     for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i"
80   )
81
82   goto success
83
84 :syntax
85   rem Display the help
86   echo.
87   echo Usage: checksrc [directory]
88   echo.
89   echo directory - Specifies the curl source directory
90   goto success
91
92 :unknown
93   echo.
94   echo Error: Unknown argument '%1'
95   goto error
96
97 :nodos
98   echo.
99   echo Error: Only a Windows NT based Operating System is supported
100   goto error
101
102 :noperl
103   echo.
104   echo Error: Perl is not installed
105   goto error
106
107 :nosrc
108   echo.
109   echo Error: "%SRC_DIR%" does not exist
110   goto error
111
112 :error
113   if "%OS%" == "Windows_NT" endlocal
114   exit /B 1
115
116 :success
117   endlocal
118   exit /B 0