#
# Makefile for IBM VisualAge C++ J3.0
# This version is LHA 2.02b+2.11 Release 2.05pre.
# (NOT supported self-extract option)
#
FIRST = #-DFIRST_COMPILATION
DEFS = -D__SUPPORT_HPFS__ -D__SUPPORT_EA__ -D__SUPPORT_GID_UID__ \
-D__SUPPORT_CTIME_ATIME__ -DLITTLE_ENDIAN $(FIRST) \
 -D__LHA__ #-D__EXTGLOB__
WARNING = -W3 -Wpor -Wrea -Wret -Wund
CCDEBUG = -Ti -Tm -Tx -D__DEBUG__ -De_malloc=malloc -De_realloc=realloc
LDDEBUG = -de

CC = icc
CFLAGS = -c -G4 -Gl -O -J -q -Sn -Sp4 -Ss $(DEFS) $(WARNING) -Fo$@
#CFLAGS = -c -G4 -Gl -J -q -Sn -Sp4 -Ss $(DEFS) $(CCDEBUG) $(WARNING) -Fo$@
LD = ilink
LDFLAGS = -nologo -e:1 -optf -noi -noe -a:32 -pm:vio $(LDDEBUG)
INSTALLPROG = cp

installdir = d:/usr/local/bin

# common objects
OBJ1 = mn.o files.o match.o util.o header.o getopt.o list.o \
append.o extract.o dosio.o error.o path.o #security.o

# for C version (2.02b+2.11)
OBJ2 = slide.o huf.o dhuf.o maketree.o maketbl.o crcio.o \
larc.o shuf.o disp.o

# for error messege objects
OBJ3 = mes_j.o mes_e.o

# for usage messege objects
# If first compilation (you have not LHA for OS/2), remove next line.
OBJ4 = use_j.o use_e.o

# for porting objects
OBJ5 = port2.o #expargs.o

# all objects
OBJS = $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ5)

.c.o:
	$(CC) $(CFLAGS) $<

lha.exe: $(OBJS) lha.def
	$(LD) $(LDFLAGS) -o:$@ $(OBJS) lha.def

use_j.c: use_j.txt lzh2c.exe
	@rm -f use_j.lzh
	lha a -n2 use_j use_j.txt
	lzh2c use_j.lzh use_j.c

use_e.c: use_e.txt lzh2c.exe
	@rm -f use_e.lzh
	lha a -n2 use_e use_e.txt
	lzh2c use_e.lzh use_e.c

lzh2c.exe : lzh2c.c
	$(CC) $(CFLAGS) -Folzh2c.o lzh2c.c
	$(LD) $(LDFLAGS) -o:$@ lzh2c.o

install : lha.exe
	$(INSTALLPROG) lha.exe $(installdir)/lha.exe

clean :
	rm -f *.exe *.o *.lzh use_j.c use_e.c *.lnk *.orig *~


mn.o: lh.h typedef.h port2.h errmes.h intrface.h disp.h header.h Makefile
append.o: lh.h intrface.h typedef.h port2.h slidehuf.h errmes.h disp.h header.h
extract.o: lh.h intrface.h typedef.h port2.h slidehuf.h errmes.h disp.h header.h
list.o: lh.h typedef.h header.h
match.o: lh.h typedef.h port2.h errmes.h
header.o: lh.h intrface.h typedef.h port2.h errmes.h header.h
files.o: lh.h typedef.h port2.h errmes.h
getopt.o: lh.h typedef.h
util.o: lh.h intrface.h typedef.h port2.h slidehuf.h errmes.h
dosio.o: lh.h typedef.h port2.h
error.o: lh.h typedef.h errmes.h header.h
path.o: lh.h typedef.h port2.h
shuf.o: slidehuf.h typedef.h
dhuf.o: slidehuf.h typedef.h
larc.o: slidehuf.h typedef.h
maketbl.o: slidehuf.h typedef.h errmes.h intrface.h
maketree.o: slidehuf.h typedef.h
crcio.o: slidehuf.h intrface.h typedef.h errmes.h disp.h header.h
disp.o: lh.h intrface.h typedef.h header.h
huf.o: lh.h slidehuf.h typedef.h
slide.o: lh.h intrface.h slidehuf.h typedef.h errmes.h
use_j.o: use_j.c
use_e.o: use_e.c
port2.o: port2.h Makefile
#expargs.o: expargs.h