# $Id: makefile,v 1.3 2001/09/11 18:20:56 tahola Exp $

#
# makefile:
#       makefile for src/wipengine directory.
#       For use with IBM NMAKE, which comes with the IBM compilers,
#       the Developer's Toolkit, and the DDK.
#
#       All the makefiles have been restructured with V1.0.0.
#
#       Called from:    main makefile
#
#       Input:          ./*.c
#
#       Output:         ../bin/*.obj
#
#       Edit "setup.in" to set up the make process.
#

# Say hello to yourself.
!if [@echo +++++ Entering $(MAKEDIR)]
!endif

# [tahola]: for some reason this is needed here!
PROJECT_BASE_DIR=$(CVS_WORK_ROOT)\warpin

!if [@echo makefile: PROJECT_BASE_DIR is $(PROJECT_BASE_DIR)]
!endif


# include setup (compiler options etc.)
!include ..\..\setup.in

# FIXED MACROS
# ------------
#
# You probably need not change the following.
#

# Define the suffixes for files which NMAKE will work on.
# .SUFFIXES is a reserved NMAKE keyword ("pseudotarget") for
# defining file extensions that NMAKE will recognize in inference
# rules.
.SUFFIXES: .cpp .obj .h

# OUTPUTDIR specifies the directory where all the output .OBJ
# files will be created in.
OUTPUTDIR = $(WIPENGINE_OUTPUT_DIR)
!if [@echo makefile: OUTPUTDIR is $(OUTPUTDIR)]
!endif

!if [@md $(OUTPUTDIR) 2> NUL]
!endif

# The OBJS macro contains all the .OBJ files which need to be
# created from the files in this directory.
# These will be put into BIN\.
OBJS = $(OUTPUTDIR)\mlu.obj $(OUTPUTDIR)\threadbase.obj $(OUTPUTDIR)\fdu.obj \
       $(OUTPUTDIR)\arcsubsys.obj $(OUTPUTDIR)\arcunit.obj

# The main target:
# If we're called from the main makefile, MAINMAKERUNNING is defined,
# and we'll set $(OBJS) as our targets (which will go on).
# Otherwise, we call the main makefile, which will again call ourselves later.
all:   \
!ifndef MAINMAKERUNNING
    callmainmake
    @echo ----- Exiting $(MAKEDIR)
!else
#    $(OBJS)
    $(OUTPUTDIR)\wipengine.lib
    @echo ----- Exiting $(MAKEDIR)
!endif

callmainmake:
    @echo $(MAKEDIR)\makefile: Recursing to main makefile.
    @cd ..\..
    @nmake
    @echo $(MAKEDIR)\makefile: Returned from main makefile. Done.


# Now define inference rules for what to do with certain file
# types, based on their file extension.
# The syntax we need here is ".fromext.toext".
# So whenever NMAKE encounters a .toext file, it
# executes what we specify here.
# The ugly {} brackets are some awkward syntax for specifying
# files in other directories.

# Special macros used here: $(@B) is the current target w/out ext.

# -- compile C files to .OBJ files, using the CC macro above.
#    The output will be placed in the directory specified by
#    the OUTPUTDIR variable (set above).

#.cpp.{$(OUTPUTDIR)}.obj:
#        @echo $(MAKEDIR)\makefile: Compiling $(@B).cpp
#!ifdef EMX
#        $(CC) $(INCLUDE) -o $(OUTPUTDIR)\$(@B).obj $(@B).cpp
#!else
#!ifndef PRECH
#        $(CC_C) /Ti+ -I$(INCLUDE) /Fo$(OUTPUTDIR)\$(@B).obj $(@B).cpp
#!else
#        $(CC_C) /fi"$(PRECH)\$(@B).pch" /Ti+ /si"$(PRECH)\$(@B).pch" -I$(INCLUDE) /Fo$(OUTPUTDIR)\$(@B).obj $(@B).cpp
#!endif
#!endif


.cpp.{$(OUTPUTDIR)}.obj:
        @echo $(MAKEDIR)\makefile: Compiling $(@B).cpp
!ifdef EMX
        $(CC) $(INCLUDE) -o $(OUTPUTDIR)\$(@B).obj $(@B).cpp
!else
!ifndef PRECH
        $(CC_C) /Ti+ /Fo$(OUTPUTDIR)\$(@B).obj $(@B).cpp
!else
        $(CC_C) /fi"$(PRECH)\$(@B).pch" /Ti+ /si"$(PRECH)\$(@B).pch" /Fo$(OUTPUTDIR)\$(@B).obj $(@B).cpp
!endif
!endif

# The "dep" target: run fastdep on the sources.
# "nmake dep" gets called from src\makefile if nmake dep
# is running on the main makefile.
dep:
    $(RUN_FASTDEP) *.cpp
    @echo ----- Leaving $(MAKEDIR)


# main include path
INC = ..\..\include
# frontend include path
FEINC = $(INC)\wipengine
# helpers include path
HLPINC = $(HELPERS_BASE)\include\helpers
# base include path
BSINC = $(INC)\base



# Make engine lib file. Seems that /convformat is needed
# because otherwice the linker craches when it tries to
# link wipengine.lib.
$(OUTPUTDIR)\wipengine.lib: $(OBJS)
!ifdef EMX
    emxomfar cr $* $(OBJS)
!else
    !ilib /nologo $* -+$?,,
!endif



# Now define dependencies for all our .OBJ files by telling NMAKE
# which .OBJ file depends on what. For each .OBJ we define what files
# will enforce a recompilation when they've been changed.
# This uses the inference rules defined above.

# Note that include\setup.h is specified with _all_ files, so
# you can enforce a complete recompile of XWorkplace if you update
# that file (just save it once).


!ifndef NOINCLUDEDEPEND
!include .depend
!endif

