Imported Upstream version 7.48.0
[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 - 2016, 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 https://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   set CHECK_LIB=TRUE
31   set CHECK_SRC=TRUE
32
33 :parseArgs
34   if "%~1" == "" goto prerequisites
35
36   if /i "%~1" == "-?" (
37     goto syntax
38   ) else if /i "%~1" == "-h" (
39     goto syntax
40   ) else if /i "%~1" == "-help" (
41     goto syntax
42   ) else if /i "%~1" == "lib" (
43     set CHECK_LIB=TRUE
44     set CHECK_SRC=FALSE
45   ) else if /i "%~1" == "src" (
46     set CHECK_LIB=FALSE
47     set CHECK_SRC=TRUE
48   ) else (
49     if not defined SRC_DIR (
50       set SRC_DIR=%~1%
51     ) else (
52       goto unknown
53     )
54   )
55
56   shift & goto parseArgs
57
58 :prerequisites
59   rem Check we have Perl in our path
60   echo %PATH% | findstr /I /C:"\Perl" 1>nul
61   if errorlevel 1 (
62     rem It isn't so check we have it installed and set the path if it is
63     if exist "%SystemDrive%\Perl" (
64       set "PATH=%SystemDrive%\Perl\bin;%PATH%"
65     ) else (
66       if exist "%SystemDrive%\Perl64" (
67         set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
68       ) else (
69         goto noperl
70       )
71     )
72   )
73
74 :configure
75   if "%SRC_DIR%" == "" set SRC_DIR=..
76   if not exist "%SRC_DIR%" goto nosrc
77
78 :start
79   if "%CHECK_SRC%" == "TRUE" (
80     rem Check the src directory
81     if exist %SRC_DIR%\src (
82       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"
83       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"
84     )
85   )
86
87   if "%CHECK_LIB%" == "TRUE" (
88     rem Check the lib directory
89     if exist %SRC_DIR%\lib (
90       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"
91       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"
92     )
93
94     rem Check the lib\vtls directory
95     if exist %SRC_DIR%\lib\vtls (
96       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"
97       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"
98     )
99   )
100
101   goto success
102
103 :syntax
104   rem Display the help
105   echo.
106   echo Usage: checksrc [product] [directory]
107   echo.
108   echo Product:
109   echo.
110   echo lib       - Scan the libcurl source
111   echo src       - Scan the command-line tool source
112   echo.
113   echo directory - Specifies the curl source directory
114   goto success
115
116 :unknown
117   echo.
118   echo Error: Unknown argument '%1'
119   goto error
120
121 :nodos
122   echo.
123   echo Error: Only a Windows NT based Operating System is supported
124   goto error
125
126 :noperl
127   echo.
128   echo Error: Perl is not installed
129   goto error
130
131 :nosrc
132   echo.
133   echo Error: "%SRC_DIR%" does not exist
134   goto error
135
136 :error
137   if "%OS%" == "Windows_NT" endlocal
138   exit /B 1
139
140 :success
141   endlocal
142   exit /B 0