CC       = icc
CPPFLAGS = -D_OS2 -D_cplusplus -Q+ -W3 -Fd+ -C+ /Ti
LINKER   = link386
LFLAGS   = /packd /packc /exepack /align:4 /stack:360000 /pm:vio /noi /nol /de
OBJS     = foo.obj
LIBLIST  = os2386+somtk

all: $(SOMBASE)\include\somxh.bld SomTerm.lib Termtest.exe som.ir somdimpl

clean:  cleanimpl
	-del *.obj *.xih *.xh som.ir TermTest.exe SomTerm.dll SomTerm.lib >nul 2>&1

cleanimpl:
	-regimpl -D -i SomTermServer
	-del somdimpl >nul 2>&1


.SUFFIXES: .obj .cpp .xih .xh .idl .def

.cpp.obj:
	$(CC) $(CPPFLAGS) -Ge- $<

.c.obj:
	$(CC) $(CPPFLAGS) -Ge- $*.cpp

.idl.xih:
	sc -sxih $<

.idl.xh:
	sc -sxh $<

.idl.cpp:
	sc -sxc $<

.idl.def:
	sc -sdef $<


SomTerm.obj: SomTerm.xih SomTerm.xh SomTerm.cpp

SomTerm.xih: SomTerm.idl

SomTerm.cpp: SomTerm.idl

### -- Build the "import library" for the DLL.
SomTerm.lib: SomTerm.dll
	implib SomTerm.lib SomTerm.def

### -- Build the DLL.
SomTerm.dll: SomTerm.obj SomTerm.def
	$(LINKER) $(LFLAGS) SomTerm.obj,$@,NUL,$(LIBLIST),SomTerm.def;

### -- Build the executables.
Termtest.obj: SomTerm.xh Termtest.cpp
	$(CC) $(CPPFLAGS) -Ge+ Termtest.cpp

Termtest.exe: SomTerm.lib Termtest.obj
	$(LINKER) $(LFLAGS) Termtest.obj,$@,NUL,$(LIBLIST)+SomTerm;

### -- Put the IDL descriptions into the Interface Repository.
som.ir:
	sc $(SCFLAGS) -sir -u -mnolock *.idl

### -- Build the DSOM Implementation Repository.
somdimpl:
	-regimpl -A -i SomTermServer -p somdsvr.exe
	-regimpl -a -i SomTermServer -c SomTerm
	-regimpl -L -i SomTermServer
	@echo x > somdimpl
