#
# $Header: D:/ext2-os2/RCS/makefile,v 6.0 1996/01/23 23:56:54 Willm Exp Willm $
#

# Linux ext2 file system driver for OS/2 2.x and WARP - Allows OS/2 to
# access your Linux ext2fs partitions as normal drive letters.
# Copyright (C) 1995, 1996  Matthieu WILLM
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#
# makefile.inc contains configuration dependant definitions (base directories)
#
!include makefile.inc

MAKEFILE = makefile
DEF  = ext2-os2.def
OBJS = vfs\buffer2.o16 \
       fs_fsctl.o16  \
       fs_misc.o16   \
       fs_rw.o16     \
       banner.o16    \
       fs_dir.o16    \
       fs_find.o16   \
       fs_cmmit.o16  \
       DevHelp.o16   \
       DevHelp2.o16  \
       log.o16       \
       vfs\rw.o16    \
       pathutil.o16  \
       isfat.o16     \
       ext2\inode.o16     \
       ext2\balloc.o16    \
       ext2\super.o16    \
       ext2\bitmap.o16    \
       ext2\file.o16    \
       ext2\dir.o16    \
       ext2\namei.o16    \
       ext2\ialloc.o16    \
       ext2\truncate.o16    \
       ext2\fsync.o16    \
       volume.o16    \
       files.o16     \
       fs_unsup.o16      \
       vfs\inode.o16     \
       vfs\misc.o16      \
       vfs\ll_rwblk.o16      \
       vfs\dcache.o16        \
       vfs\sched.o16         \
       vfs\strat2.o16        \
       vfs\f_table.o16       \
       util.o16              \
       attr.o16		     \
       vsprintf.o16          \
       maperr.o16            \
       panic.o16             \
       case.o16

#
# 16 bits compiler to build the IFS - I use MS Visual C++ 1.51 in a DOS box
#
CC16      = cl

#
# INCL16 : include file search path - modify it whenever needed
#
INCL16    = /I$(DDKPATH)\h /I$(IFSTKTPATH) /I$(EXT2OS2_BASE)\include

#
# IFS compiler optimization options :
#     /G3 : use 386 instruction set
#     /O2 : optimize code
#     /On : disable 'unsafe' optimization (I'm not sure it is really necessary)
#
# FS_TRACE       : output to ext2-os2 debug console enabled
# FS_TRACE_LOCKS : useful to track deadlocks .....
#
#CC16OPT  = /G3 /O2 /On /DFS_DEBUG /DFS_TRACE
CC16OPT  = /O2 /G3 /DFS_DEBUG
CC32OPT  = -O

#
# Defined macros :
#     OS2         : needed almost everywhere
#     __KERNEL__  : needed in some Linux include files
#
OS2_DEFINES = /DOS2 /D__KERNEL__

#
# 16 bits compiler options
#     /nologo : no banner
#     /c      : compile only
#     /AL     : use large memory model  (IT IS ABSOLUTELY NECESSARY)
#     /Zp     : pack structures on one byte boundaries
#     /Gs     : remove stack check calls
#     /Gx-    : assume that data is far (IT IS ABSOLUTELY NECESSARY)
#     /W3     : all warnings enabled
#     /Aw     :
#     /Au     :
#     /Lp     : protected mode executable
CC16FLAGS = /nologo /c $(INCL16) /DCCHMAXPATH=260 /AL /Zp /Gs /Gx- /W3 /Aw /Au $(CC16OPT) /Ld $(OS2_DEFINES) /Lp

#
# 16 bits library search path - modify it whenever needed
#
!if "$(CC)" == "cl"
LIB       = $(DDKPATH)\lib;$(IFSTKTPATH);$(MSVCPATH)\lib
!endif

#
# 16 bits linker - I use Microsoft link 5.60.220 (the one shipped with MSVC 1.51) in a DOS box
#
LD        = link

#
# 16 bits linker options
#     /noi      : case sensitive link
#     /map      : linker map file (necessary to produce a .sym file)
#     /noe      : no extended dictionary
LDFLAGS   =  /map /noe

#
# 32 bits C compiler for building ext2-os2.exe - Currently IBM Visualage C++ beta 2 compiler
#
CC32       = icc


CC32FLAGS  = -Ss+ -I$(EXT2OS2_BASE)\include -Gm+


TESTDIR=e:\mwfs

.asm.o16:
!if "$(CC)" == "cl"
	$(DDKPATH)\tools\masm -I$(DDKPATH)\inc -ml $?,$@;
!else
	@echo Please run nmake in a DOSbox
	@exit 255
!endif

.c.obj:;

.c.o16:
!if "$(CC)"== "cl"
	@echo Compilation de $(@:.o16=.c)
	@$(CC16) $(CC16FLAGS) -Fo$@ -Fl$(@:.o16=.l) $(@:.o16=.c)
!else
	@echo Please run nmake in a DOS box
	@exit 255
!endif

.c.o32:
!if "$(CC)" == "icc"
        $(CC32) -Fo$@ $(CC32FLAGS) $(CC32OPT) -c $<
!else
	@echo Please run nmake in an OS/2 session
	@exit 1
!endif

all : ext2-os2.ifs     \
      sync.exe         \
      ext2_lw.exe

ext2-os2.ifs :         \
        $(OBJS)        \
        $(DEF)         \
        $(MAKEFILE)
!if "$(CC)" == "cl"
       @echo Compilation de banner.c
        @$(CC16) $(CC16FLAGS) banner.c
        @echo Edition des liens de $@
#        @$(LD) $(LDFLAGS) $(OBJS), $@, $(@:.ifs=.map), os2286 + fshelper, $(DEF)
	@$(LD) $(LDFLAGS) @<<
       vfs\buffer2.o16      +
       fs_misc.o16          +
       fs_fsctl.o16         +
       banner.o16           +
       fs_rw.o16            +
       fs_dir.o16           +
       fs_find.o16          +
       fs_cmmit.o16         +
       DevHelp.o16          +
       DevHelp2.o16         +
       log.o16              +
       pathutil.o16         +
       isfat.o16            +
       ext2\inode.o16       +
       ext2\balloc.o16      +
       ext2\super.o16       +
       ext2\bitmap.o16      +
       ext2\file.o16        +
       ext2\dir.o16         +
       ext2\namei.o16       +
       ext2\ialloc.o16      +
       ext2\truncate.o16    +
       ext2\fsync.o16       +
       volume.o16           +
       files.o16            +
       fs_unsup.o16         +
       attr.o16             +
       vfs\inode.o16        +
       vfs\dcache.o16       +
       vfs\ll_rwblk.o16     +
       vfs\misc.o16         +
       vfs\rw.o16           +
       vfs\sched.o16        +
       vfs\strat2.o16       +
       vfs\f_table.o16      +
       vsprintf.o16         +
       util.o16             +
       maperr.o16           +
       panic.o16            +
       case.o16
$@
$(@:.ifs=.map)
os2286  +
os2286p +
fshelper
$(DEF)
<<
        @mapsym $(@:.ifs=.map)
        @copy $@ $(TESTDIR)
        @copy $(@:.ifs=.sym) $(TESTDIR)
!else
	@echo Please run "nmake" in a DOS box
!endif


sync.exe : sync.o32
!if "$(CC)" == "icc"
	copy sync.o32 sync.obj
        $(CC32) -Fe$@ sync.obj vfsapi/vfsapi.lib
!else
	@echo Please run "nmake" in an OS/2 session
	@exit 1
!endif

ext2_lw.exe : ext2_lw.o32
!if "$(CC)" == "icc"
	copy ext2_lw.o32 ext2_lw.obj
        $(CC32) -Fe$@ ext2_lw.obj
!else
	@echo Please run "nmake" in an OS/2 session
	@exit 1
!endif




clean:
	-@del *.obj
	-@del *.o16
	-@del *.o32
	-@del *.map
	-@del *.sym
	-@del *.s
	-@del *.l
	-@del vfs\*.obj
	-@del vfs\*.o16
	-@del vfs\*.s
	-@del vfs\*.l
        -@del ext2\*.obj
        -@del ext2\*.o16
        -@del ext2\*.s
        -@del ext2\*.l
        -@del ext2-os2.ifs
        -@del sync.exe
        -@del ext2_lw.exe
	@cd vfsapi
	@nmake clean
	@cd ..\doc
	@nmake clean
	@cd ..\distrib
	@nmake clean
	@cd ..\ext2flt
	@nmake -f makefile.msc clean
	@cd ..\console
	@nmake clean

install:
 	mapsym ext2-os2.map
        -@copy ext2-os2.ifs $(TESTDIR)
        -@copy sync.exe $(TESTDIR)
        -@copy ext2_lw.exe $(TESTDIR)
        -@copy ext2-os2.sym $(TESTDIR)



