Revision 1017

trunk/scripts/admb/adlink.bat (revision 1017)
1 1
@echo off
2 2

  
3
setlocal EnableExtensions EnableDelayedExpansion
3
REM History:  24 May 2009  Arni Magnusson created
4
REM           22 May 2013  Chris Grandin made dll linking work (-d)
4 5

  
6
setlocal EnableExtensions EnableDelayedExpansion
5 7
if [%1]==[] goto HELP
6 8
if [%1]==[-help] goto HELP
7 9
if [%1]==[--help] goto HELP
8

  
9
rem Pop args until model=%1
10
set objects=
11
set sym=-s & rem space
12
set linker=g++
10
set OBJS=
13 11
for %%a in (%*) do (
14
if %%~xa==.obj (
15
set objects=!objects! %%a
16
if not defined model set model=%%~na
12
  set arg=%%a
13
  if "!arg:~0,1!"=="-" (
14
    if "!arg!"=="-s" (
15
      set LIBS="%ADMB_HOME%"\lib\admb.lib "%ADMB_HOME%"\contrib\lib\contrib.lib
16
    )
17
    if "!arg!"=="-g" (
18
      set DEBUG="/DEBUG"
19
    )
20
    if "!arg!"=="-d" (
21
      set DLL="/DLL"
22
      set FN="/OUT:%~n2.dll"
23
    )
24
  ) else (
25
    if "%%~xa"=="" (
26
      set OBJS=!OBJS! !arg!.obj
27
    ) else (
28
      set OBJS=!OBJS! !arg!
29
    )
30
  )
17 31
)
18
if %%a==-d set linker=dllwrap
19
if %%a==-g set sym=
20
if %%a==-r set r=
21
if %%a==-s (
22
  set libs="%ADMB_HOME%\contrib\lib\libcontrib.a" "%ADMB_HOME%\lib\libadmb.a" 
23
)
24
)
25
if not defined libs set libs="%ADMB_HOME%\contrib\lib\libcontribo.a" "%ADMB_HOME%\lib\libadmbo.a" 
26 32

  
27
if %linker%==g++ (set out=-o %model%) else (set def=-def %model%.def^
28
 --driver-name g++ & set out=--output-lib lib%model%.a -o %model%.dll)
33
if not defined LIBS set LIBS="%ADMB_HOME%"\lib\admbo.lib "%ADMB_HOME%"\contrib\lib\contribo.lib
34
set LIBPATH_MSSDK=/libpath:"%MSSDK%"\lib
29 35

  
30
set CMD=%linker% %sym% -static %def% %out% %objects% %libs%
31
echo %CMD%
32
%CMD%
36
@echo on
37
cl %OBJS% %LIBS% /link %DEBUG% %DLL% %FN%
38
@echo off
33 39

  
34 40
goto EOF
35 41

  
36 42
:HELP
37
echo Usage: adlink [-d] [-g] [-r] [-s] model
43
echo Usage: adlink [-d] [-r] [-s] model
38 44
echo.
39
echo Link AD Model Builder object code to executable, using the MinGW GCC^
40
 compiler.
45
echo Link AD Model Builder object code to executable, using the Microsoft Visual C++ compiler.
41 46
echo.
42 47
echo   -d     Create DLL
43
echo   -g     Insert debugging symbols
44 48
echo   -r     Create ADMB-RE
45
echo   -s     Enforce safe bounds
49
echo   -s     Use safe bounds and debugging symbols
46 50
echo   model  Filename prefix, e.g. simple
47 51
echo.
48 52

  
49 53
:EOF
50

  
51
REM r985 [2011-02-17] arnima  changed sym=-g to sym=[space], fixed spaces
52
REM r982 [2011-02-16] arnima  rewrite, fixed bug when user option is not
53
REM                           recognized, enabled strip and debug, fixed spaces
54
REM r917 [2010-12-24] johnoel pruned 'mingw' dir
55
REM r914 [2010-12-24] johnoel changed \\lib to \lib and echo off to @echo off,
56
REM                           moved to 'g++' dir
57
REM r629 [2010-05-20] johnoel changed .o to .obj
58
REM r623 [2010-05-20] johnoel changed /lib to \\lib, disabled strip
59
REM r593 [2010-04-20] johnoel quoted ADMB_HOME
60
REM r567 [2010-04-16] johnoel fixed bugs in r563
61
REM r564 [2010-04-15] johnoel fixed bugs in r563
62
REM r563 [2010-04-15] johnoel simplified echo, disabled -ldf1b2stub
63
REM r525 [2009-08-07] arnima  added support for filename extension like
64
REM                           simple.obj, unquoted ADMB_HOME, added -static
65
REM                   johnoel split -s option into separate -g and -s options
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff