
O = lo

SOCKOBJS = socket.$(O) serial.$(O) inetserial.$(O) slp.$(O) padp.$(O) \
       dlp.$(O) cmp.$(O) syspkt.$(O) inet.$(O)

FILEOBJS = pi-file.$(O)

APPOBJS = datebook.$(O) memo.$(O) address.$(O) todo.$(O) expense.$(O) mail.$(O) sync.$(O) appinfo.$(O)

UTILOBJS = utils.$(O)

SERIAL = unixserial.$(O)

OBJS = $(SOCKOBJS) $(FILEOBJS) $(APPOBJS) $(UTILOBJS) $(SERIAL)

prefix = @prefix@
exec_prefix = ${prefix}
libdir = @libdir@
srcdir = @srcdir@
VPATH = @srcdir@

top_builddir = ..

CC = @CC@
CFLAGS = -I../include -I$(srcdir)/../include @CFLAGS@ @CWFLAG@
# -DPADP_TRACE
# -DDEBUG
# -DNO_DLP_TRACE
# -DNO_SERIAL_TRACE
AR = ar
ARFLAGS = @ARFLAGS@
RANLIB = @RANLIB@
RM = rm -f
LIBTOOL = @LIBTOOL@

.SUFFIXES: .c .lo .o

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

.c.lo:
	$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $<

all: libpisock.la

libpisock.a: $(OBJS)
	$(RM) libpisock.a
	$(AR) $(ARFLAGS) libpisock.a $(OBJS)
	$(RANLIB) libpisock.a

libpisock.la: $(OBJS)
	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) \
		-export-dynamic -rpath $(libdir) -version-info 2:0:0 \
		-o libpisock.la $(OBJS)

# OS/2 dll build rules,  This is somewhat of a hack.
# This target creates the OS/2 linker .def file dynanmically.
# Creates the import library libpisockdll.a from the .def file.
# Links the converted libpisock.lib into a DLL using the generated .def file.
# Copies libpisock.dll up one directory level so that the executables can 
#    find it when they are run.
# Converts libpisock.a into an OMF (Native) library.
# Then it cleans up.
# NOTE: You will need the OS/2 Linker, link386.exe, for this to work.
libpisockdll.a: libpisock.a
	echo ; AUTOMATICALLY GENERATED FROM Makefile.os2  DO NOT EDIT >pisock.def
	echo ; pisock.dll module definition file >>pisock.def
	echo LIBRARY pisock >>pisock.def
	echo DESCRIPTION >>pisock.def
	echo  'Pilot-link socket interface DLL' >>pisock.def
	echo CODE PRELOAD >>pisock.def
	echo EXPORTS >>pisock.def
	emxexp -o libpisock.a >>pisock.def
	emxomf libpisock.a
	gcc -Zdll -Zcrtdll -Zmt -Zomf pisock.def libpisock.lib -lsocket.lib
	emximp -o libpisockdll.a pisock.def
	cp pisock.dll ../
	$(RM) libpisock.def libpisock.lib


clean:
	$(RM) *.o *.lo *.a *.la core a.out *.orig
	$(RM) -rf .libs _libs

depend:
	perl -i~ -ne 'print if 1../^#Depend/' Makefile.in ; gcc -w -MM -I../include *.c | perl -pne 's/^(\S*)\.o/$$& $$1.lo/g' >> Makefile.in

#Dependencies
address.o address.lo: address.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-address.h ../include/pi-appinfo.h
appinfo.o appinfo.lo: appinfo.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-appinfo.h
cmp.o cmp.lo: cmp.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-padp.h ../include/pi-cmp.h ../include/pi-serial.h
datebook.o datebook.lo: datebook.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-datebook.h ../include/pi-appinfo.h
dlp.o dlp.lo: dlp.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-syspkt.h
expense.o expense.lo: expense.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-expense.h ../include/pi-appinfo.h
inet.o inet.lo: inet.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-inet.h ../include/pi-slp.h ../include/pi-syspkt.h \
 ../include/pi-padp.h ../include/pi-dlp.h
inetserial.o inetserial.lo: inetserial.c ../include/pi-source.h \
 ../include/pi-config.h ../include/pi-socket.h ../include/pi-args.h \
 ../include/pi-macros.h ../include/pi-serial.h \
 ../include/pi-inetserial.h ../include/pi-slp.h ../include/pi-syspkt.h \
 ../include/pi-padp.h
mail.o mail.lo: mail.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-mail.h ../include/pi-appinfo.h
memo.o memo.lo: memo.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-memo.h ../include/pi-appinfo.h
os2serial.o os2serial.lo: os2serial.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-serial.h ../include/pi-slp.h ../include/pi-syspkt.h \
 ../include/pi-padp.h
padp.o padp.lo: padp.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-padp.h ../include/pi-slp.h ../include/pi-serial.h
pi-file.o pi-file.lo: pi-file.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-file.h ../include/pi-dlp.h
serial.o serial.lo: serial.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-serial.h ../include/pi-inetserial.h \
 ../include/pi-padp.h ../include/pi-cmp.h ../include/pi-dlp.h \
 ../include/pi-syspkt.h
slp.o slp.lo: slp.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-slp.h
socket.o socket.lo: socket.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-serial.h ../include/pi-inetserial.h \
 ../include/pi-inet.h ../include/pi-padp.h ../include/pi-cmp.h \
 ../include/pi-dlp.h ../include/pi-syspkt.h
sync.o sync.lo: sync.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-sync.h
syspkt.o syspkt.lo: syspkt.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-syspkt.h ../include/pi-slp.h ../include/pi-serial.h
todo.o todo.lo: todo.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h \
 ../include/pi-dlp.h ../include/pi-todo.h ../include/pi-appinfo.h
unixserial.o unixserial.lo: unixserial.c ../include/pi-source.h \
 ../include/pi-config.h ../include/pi-socket.h ../include/pi-args.h \
 ../include/pi-macros.h ../include/pi-serial.h ../include/pi-slp.h \
 ../include/pi-syspkt.h ../include/pi-padp.h
utils.o utils.lo: utils.c ../include/pi-source.h ../include/pi-config.h \
 ../include/pi-socket.h ../include/pi-args.h ../include/pi-macros.h
