File: camlidldll.tpl

package info (click to toggle)
camlidl 1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 1,592 kB
  • sloc: ml: 5,238; ansic: 945; cpp: 908; makefile: 358; xml: 213; sh: 74
file content (107 lines) | stat: -rw-r--r-- 3,133 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
# This is a Bash script 

#***********************************************************************
#*                                                                     *
#*                              CamlIDL                                *
#*                                                                     *
#*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         *
#*                                                                     *
#*  Copyright 1999 Institut National de Recherche en Informatique et   *
#*  en Automatique.  All rights reserved.  This file is distributed    *
#*  under the terms of the GNU Library General Public License.         *
#*                                                                     *
#***********************************************************************

#* $Id: camlidldll.tpl,v 1.6 2002-04-22 11:50:47 xleroy Exp $

# Automates the creation of a DLL for a Caml component

# camllib=%%CAMLLIB%%
output=caml.dll
linkopts=''
camlopts=''
linkobjs=''
camlobjs=''
camlnativeobjs=''
camlobjfile="caml$$.obj"
resourcefile="caml$$.rc"
resfile=''
tlbcounter=0

rm -f $resourcefile

# Parse the command line

while : ; do
  case "$1" in
    "") break;;
# my options
    -o) output=$2; shift;;
    -linkopt)
        linkopts="$linkopts $2"; shift;;
# ocamlc options
    -cc|-ccopt|-I|-w)
        camlopts="$camlopts $1 $2"; shift;;
    -cclib)
        lib=`echo $2 | sed -e 's/^-l\(.*\)$/lib\1.lib/'`
        linkobjs="$linkobjs $lib"
        shift;;
    -linkall|-verbose)
        camlopts="$camlopts $1";;
# other options
    -*) echo "Unknown option \"$1\", ignored" 1>&2;;
# files
    *.cm[oa])
        camlobjs="$camlobjs $1";;
    *.cmx|*.cmxa)
        camlnativeobjs="$camlnativeobjs $1";;
    *.obj|*.lib)
        linkobjs="$linkobjs $1";;
    *.tlb)
        tlbcounter=`expr $tlbcounter + 1`
        echo "$tlbcounter typelib $1" >> $resourcefile;;
    *)  echo "Don't know what to do with \"$1\", ignored" 1>&2;;
  esac
  shift
done

if test -n "$camlobjs" -a -n "$camlnativeobjs"; then
  echo "Both bytecode object files and native object files given, cannot proceed" 1>&2
  exit 2
fi

if test $tlbcounter -ne 0; then
  echo "1 num_typelibs { $tlbcounter }" >> $resourcefile
  resfile="caml$$.res"
  rc /fo$resfile $resourcefile || { exit $?; }
  rm -f $resourcefile
fi

if test -z "$camlnativeobjs"; then
  ocamlc -custom -output-obj -o $camlobjfile $camlopts com.cma $camlobjs
  exitcode=$?
  runtimelib=libcamlrun.lib
else
  ocamlopt -output-obj -o $camlobjfile $camlopts com.cmxa $camlnativeobjs
  exitcode=$?
  runtimelib=libasmrun.lib
fi

if test "$exitcode" -eq 0; then
  link /nologo /incremental:no /dll /machine:ix86 \
    /out:${output} /libpath:$camllib \
    /export:DllGetClassObject,PRIVATE \
    /export:DllCanUnloadNow,PRIVATE \
    /export:DllRegisterServer,PRIVATE \
    /export:DllUnregisterServer,PRIVATE \
    $resfile \
    $linkopts $camlobjfile $linkobjs \
    ${camllib}\\cfactory.obj libcamlidl.lib \
    $runtimelib \
    advapi32.lib ole32.lib oleaut32.lib
  exitcode=$?
fi

rm -f $resfile $camlobjfile
exit $exitcode