# MAKEFILE for ActiveX SDK sample control, IELnk   
#
# George Cross, Borland C++ Developer Support, January 1997
#
# Comments:  Makefile for Borland C++Builder.
#
#            Not dependent on BUILTINS.MAK, BCC32.CFG, TLINK.CFG, PATH or 
#            any other environment variables.
# 
# 
#    MAKE                  Debug info, warnings and no optimizations
#    MAKE -DRELEASE        No debug info, warnings, and optimizations turned on 
# 
#
# Requirements:
# ------------
# The following additional tools are needed to build the IELnk control using 
# Borland C++Builder. 
#
# 1. Obtain the latest MIDL compiler, MIDL.EXE v. 3.01 from the latest MS
#    Win32SDK found in the directory MSTOOLS\BIN\I386\. It is available on 
#    my websight for your convenience. Also in the BCB patch.
#
#
# 2. Obtain the .IDL files from the latest Microsoft Win32SDK in the
#    directory MSTOOLS\INCLUDE\.  Available on my website.  
#    Also in the BCB patch. 
#
#    If you downloaded the ActiveX SDK, you will already has several .IDL 
#    files in the INETSDK\INCLUDE\ directory, but you need the ones above also. 
#    If any file appears in both directories, please delete the older one.  
#    
# 3. CPP32.EXE from my website or the BCB patch.
#
# 4. To generate .h and .c files from .idl files using MIDL.EXE, use
#    for example,  
#    
#      midl.exe /cpp_cmd \bcb\bin\cpp32.exe
#               /cpp_opt "-P- -oCON"
#               /I \bcb\include 
#               inetsdk.idl
#     
#    For more information on using CPP32.EXE and MIDL.EXE, please see
#    BC5\HELP\BCTOOLS.HLP.
#
# 5. CTLFW32.LIB
#      This library is also and ActiveX sample found in the directory
#      INETSDK\SAMPLES\BASECTL\FRAMEWRK.
# 
# 6. IMPORT32.LIB from BC++ 5.02
#      The version on C++Builder will cause Access Violations.  You must 
#      get the newer one, also available on my website or in the BCB patch.
# 
#
# 
# Changes:
# --------
#
# The following are the changes to the IELnk sample source files in order 
# to build the OCX with Borland C++Builder.
#
# 1. cbuilder\include\win32\rpcndr.h
#    - the following lines were added to line 2630.  This is to accomodate
#      code generated from the new MIDL.EXE 3.01.  
#
#         #if _MSC_VER >= 1100
#         #define DECLSPEC_UUID(x)    __declspec(uuid(x))
#         #else
#         #define DECLSPEC_UUID(x)
#         #endif
#
# 2. BC++ 5.02 is missing 
#      comcat.h, docobj.h, servprov.h, urlmon.h, urlhlink.h, inet.lib
#
#    Just telling you for your information. This was an integration faulter. 
#
#


.autodepend                  #these directives tell MAKE to compare time/date
.cacheautodepend             #of ALL files (.h,.cpp,.c...) which build an obj.
                             #These are not effective if the obj is built 
                             #with the -X option
BASECTLDIR = ..              #parent of FrameWrk's Include and Lib dirs

BCC    = $(MAKEDIR)\bcc32.exe
TLINK  = $(MAKEDIR)\tlink32.exe
BRCC   = $(MAKEDIR)\brcc32.exe
CPP    = $(MAKEDIR)\cpp32.exe
REGSVR = $(MAKEDIR)\regsrvr.exe
MIDL   = $(MAKEDIR)\midl.exe


PROJ = IELnk  
OBJS = $(PROJ).obj guids.obj ielnkctl.obj \
       ielnkppg.obj cathelp.obj ielnk_i.obj       

RESES = $(PROJ).res
TYPEINFO = $(PROJ).tlb

CDEFINES =  -DSTRICT
PCH = # -Hc -H=$(PROJ).csm -H"ipserver.h"          
INCDIR = $(MAKEDIR)\..\include;$(BASECTLDIR)\include;   
LIBDIR = $(MAKEDIR)\..\lib;$(BASECTLDIR)\lib          
CFLAGS = $(CDEFINES) -I$(INCDIR) $(PCH) -c -VF -K    
LFLAGS = /Tpd /c  /L$(LIBDIR)                       
RFLAGS = -i$(INCDIR)                               

!if $d(RELEASE)    
  CFLAGS = $(CFLAGS) -O1 -k- -w-
  LFLAGS = $(LFLAGS) 
!else  
  CFLAGS = $(CFLAGS) -v -r- -Od
  LFLAGS = $(LFLAGS) /v
!endif


$(PROJ).ocx: bcc.cfg $(TYPEINFO) $(OBJS) $(RESES)   
  $(TLINK) @&&| 
        $(LFLAGS)  +                   
	c0d32 $(OBJS)                          #Startup and objs
	$.                                     #Target
                                               #Map file 
        ctlfw32 cw32mt import32 inet           #Static and import libraries
        $&                                     #Module definition file
        $(RESES)                               #Resources
|




#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
#  ** NOTE **
#
# MIDL will be used from now on instead of MKTYPLIB !!   
#
# But I can't bring myself to delete all the work I did figuring out 
# MKTYPLIB.  
#
#
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
#
# MKTYPLIB is such a pain !  
#
# Weird MKTYPLIB Stuff:
# --------------------
#
# - MKTYPLIB does not take response files. :(
#
# - It will be fixed soon, but presently, CPP32 has a problem with some uuids.
#   See Borland C++Builder, \HELP\BCTOOLS.HLP for details.  As a consequence
#   the following is what you need to do to use CPP32 with MKTYPLIB.
#
#   1. Preprocess the .odl file first to an .i file.  Use,
#
#        cpp32 -D__MKTYPLIB__ -P- -I\bcb\include somefile.odl
#
#   2. Search the .i file for the word 'error' and put quotations around 
#      any uuids on which the preprocessor had errors. 
#
#   3. Preprocess the .odl file again.
#
#   4. Now open the new .i file and remove the quotations you just put into 
#      the .odl file.
#
#   5. Run MKTYPLIB on the .i file. Use,
#
#         mktyplib /nocpp /h hdrfile.h somefile.i 
#
# - Alternatively, you could use MS VC++ for the preprocessor. No changes
#   are necessary to the .odl file.
#  
#     mktyplib /h hdrfile.h /I \bcb\include 
#              /cpp_cmd \msdev\bin\cl.exe
#              /cpp_opt "/E /C /I \bcb\include"
#              /D__MKTYPLIB__
#              /D__FLAT__
#              somefile.odl
#      
#   The files you need for MS VC++ 4.1 command line compiler are,
#     
#     cl.exe,cl.err,c1.exe,c1.err,c1xx.exe,cl32.msg,mspdb41.dll    
#
#   Or from MS VC++ 5.0 you need 
#
#     cl.exe,c1xx.dll,c1.dll,mspdb50.dll
#
#   If you use MS VC++ for the preprocessor, you can use Borland's include
#   path for the headers but you MUST define __FLAT__ because MS VC++ 
#   doesn't by default (but we do).
#
# - Options to MKTYPLIB which take filenames or paths MUST have a space 
#   between the option and the file or path name.
#
# - You MUST specify -D__MKTYPLIB__ to the pre-processor.
#
# - You MUST specify the include directory for the pre-processor.
#
# - Below is the newest method: MIDL and CPP32.  The .odl still needed to
#   be hacked, since CPP32 still can't handle some UUIDs, but at least after
#   that MIDL can process the UUIDs with quotations. 
#

.odl.tlb:                          
  $(MIDL) @&&| 
    /I$(MAKEDIR)\..\include\idl 
    /h $(PROJ)ifc.h  
    /cpp_cmd $(CPP)  
    /cpp_opt "-P- -oCON -I$(MAKEDIR)\..\include -D__MKTYPLIB__"  
    $.
|

bcc.cfg:
  copy &&|
    $(CFLAGS)
| $.

.cpp.obj:
  $(BCC) +bcc.cfg { $& }
.c.obj:
  $(BCC) +bcc.cfg { $. }
.rc.res:
  $(BRCC) $(RFLAGS) $<


clean:
  @del $(PROJ).ocx *.obj *.map *.res *.csm *.tlb \
       $(PROJ)ifc.h $(PROJ)_i.c *.cfg *.?0?
