#
# Makefile	Makefile for Minicom on various systems.
#		You have to pick your system here. Just
#		uncomment it and let it compile.
#
# Version	@(#) Makefile 1.75 (28-Apr-1996) MvS
#
# Bugs		The Linux, Coherent 4.2, Sun and BSD versions
#		have been tested and are known to work.
#		For others, your mileage may vary...
#
#		Some old version of xgettext seems to give error messages
#		about illegal options in the po directory Makefile.
#		If you have this problem or you don't have gettext
#		installed, you can disable the localization stuff by 
#		 removing the -D_I18N_ option from OPFLAGS
#		  and -lintl from LIBS below,
#		  and commenting out the "PO = po" line.
#
# fmg 8/22/97: added History buffer search and organized FLAGS a bit
# jl April 98: added some comments
# enochw@scn.org Oct 99: flags for UWIN 2.0 (Unix for Windows)

# Where to install things for Linux sites (FSSTND)
BINDIR	= /usr/bin
LIBDIR	= /etc
DOCDIR	= /usr/doc/minicom
MANDIR	= /usr/man/man1

# fmg 8/22/97: seems a more logical place for this :-)
# Select Compile Options you want:
#
# -D_HISTORY		- Support for History buffer
# -D_HAVE_MACROS	- Support F-key macros
#                         For documentation, see file "../doc/Macros"
# -D_RH_FIX		- ReadHat Linux 4.1 F-key fix
#                         For documentation, see file "../doc/RedHat"
# -D_SEARCH_HISTORY	- Support searching of History buffer
#                         For documentation, see file "../doc/HistSearch"
# -D_I18N_		- Internationalization and localized text strings
#			  see file "../doc/Locales"
#
OPFLAGS	= -D_HISTORY -D_HAVE_MACROS -D_SEARCH_HISTORY -D_I18N_

# Remove if you don't have gettext and don't want to install it and use
# the localized strings
PO	= po

# Where to install things for FreeBSD sites.
# BINDIR = /usr/local/bin
# LIBDIR = /usr/local/etc/minicom
##DOCDIR = /usr/local/share/minicom
# DOCDIR = /usr/local/etc/minicom
# MANDIR = /usr/local/man/man1

# Where to install things for "normal" sites.
# BINDIR	= /usr/local/bin
# LIBDIR	= /usr/local/lib
# DOCDIR	= /usr/local/lib
# MANDIR	= /usr/local/man/man1

# Take these compilation flags for Linux with libncurses.
FLAGS	= -Wall -D_POSIX -D_SYSV -D_SELECT -pipe # -I/usr/include/ncurses
PROGS	= minicom runscript ascii-xfr
LFLAGS	= -s
LIBS	= -lncurses #-lintl
CC	= cc

# Take these compilation flags for FreeBSD.
#FLAGS	= -Wall -D_POSIX -D_BSD43 -D_SELECT -D_DCDFLOW
#PROGS	= minicom runscript ascii-xfr
#LFLAGS	= -s
#LIBS	= -ltermcap
#CC	= cc

# Take these flags for SCO unix.
#FLAGS	= -D_SYSV -D_SCO -D_POSIX -D_SELECT
#PROGS	= minicom runscript ascii-xfr
#LFLAGS	= -s
#LIBS	= -lcurses
#CC	= cc

# These flags are for BSD 4.3 alike systems. Tested on SunOs 4.1.3.
# Used to compile under other flavors of BSD4.3 too..
#LFLAGS	= # -s
#FLAGS	= -D_BSD43 -D_SELECT				# BSD style ioctls
#FLAGS	= -D_POSIX -D_BSD43 -D_SELECT -D_DCDFLOW	# BSD with Posix termios
#FLAGS	= -D_POSIX -D_BSD43 -D_SELECT -DSUN -D_DCDFLOW	# Sun include nightmare
#PROGS	= minicom runscript ascii-xfr
#LIBS	= -ltermcap
#CC	= cc

# Take these compilation flags for AIX 4.2.1 with libcurses
# and to compile with GNUs gcc
#FLAGS   = -Wall -D_POSIX -D_SELECT -D_HAVE_PARAM_H -D_AIX
#PROGS   = minicom runscript ascii-xfr
#LFLAGS  = -s
#LIBS    = -lcurses
#CC      = gcc

# These have been reported to work on Solaris 7 with GCC 2.95.1
#FLAGS   = -D_POSIX -D_BSD43 -D_SELECT -DSUN -D_DCDFLOW  # Sun include nightmare
#PROGS   = minicom runscript ascii-xfr
#LIBS    = -ltermcap
#CC      = gcc

# Take these compilation flags for UWIN 2.0 with libcurses.
#FLAGS	= -Wall -D_POSIX -D_SYSV -D_SELECT -pipe -D_UWIN2P0
#PROGS	= minicom runscript ascii-xfr
#LFLAGS	= -s
#LIBS	= -lcurses
#CC	= gcc

# ========== Everything below this line is not well-tested. ===========

# Take these flags for DG/UX (Data General/UX).
#FLAGS	= -O2 -Wall -D_POSIX -D_DGUX_SOURCE -D_SELECT
#PROGS	= minicom runscript ascii-xfr
#LFLAGS	= -s
#LIBS	= -ltermcap
#CC	= gcc

# Take these flags for OSF/1
#FLAGS	= -O2 -D_POSIX -D_SYSV -D_SELECT
#PROGS	= minicom runscript ascii-xfr
#LFLAGS	= -s
#LIBS	= -ltermcap
#CC	= cc

# These flags work for Coherent 4.2.
#FLAGS	= -D_POSIX -D_SYSV -D_SELECT -D_COH42 -D_COHERENT -D_NO_TERMIOS
#LFLAGS	= -s
#PROGS	= minicom runscript ascii-xfr
#LIBS	= -ltermcap -lmisc
#CC	= cc

# Take these flags for Dynix/ptx (Sequent)
#FLAGS	= -D_POSIX -D_SYSV -D_SELECT -D_SEQUENT -D_NO_TERMIOS
#LFLAGS	= -s
#PROGS	= minicom runscript ascii-xfr
#LIBS	= -ltermcap -lsocket
#CC	= cc

# Take these flags for a SysV system (sysv/HPUX/ISC)
#FLAGS	= -D_SYSV		 			   # Generic Sysv
#FLAGS	= -D_SYSV -D_POSIX				   # Posix SysV
#FLAGS	= -D_HPUX_SOURCE -D_POSIX -D_SYSV -D_SELECT	   # HPUX
#FLAGS	= -D_SYSV -D_SVR2 -D_POSIX -D_NO_TERMIOS	   # Sysv R2, eg UnixPC
#FLAGS	= -Wall -D_SYSV -DISC -D_SYSV3 -D_POSIX -D_SELECT  # ISC unix
#### Only include the "keyserv" program if you don't have select()
#PROGS	= minicom runscript ascii-xfr #keyserv
#LFLAGS	= -s
#LIBS	= -ltermcap
#LIBS	= -ltermcap -linet -lnsl_c -lcposix # ISC unix.
#CC	= cc

# Take these flags for Mark Williams' Coherent version 3.2 (286 version)
#FLAGS	= -D_COHERENT -D_COH3
#LFLAGS	= -s
#PROGS	= minicom runscript ascii-xfr keyserv
#LIBS	= -lterm
#CC	= cc

# Take these flags for the PC Minix ACK compiler
#FLAGS	= -D_MINIX -D_POSIX
#LFLAGS	= -i
#PROGS	= minicom runscript ascii-xfr keyserv
#LIBS	=
#CC	= cc

# Take these flags for a 68000 Minix
#FLAGS	= -D_MINIX -D_POSIX
#LFLAGS	= -s
#PROGS	= minicom runscript ascii-xfr keyserv
#LIBS	=

# Nothing should have to change beneath this line

SRCS	= minicom.c vt100.c config.c help.c updown.c \
	  util.c dial.c window.c wkeys.c ipc.c main.c \
	  keyserv.c windiv.c script.c sysdep1.c sysdep2.c \
	  rwconf.c file.c getsdir.c wildmat.c common.c

HDRS	= minicom.h window.h keyboard.h charmap.h config.h \
	  configsym.h patchlevel.h vt100.h port.h sysdep.h \
	  getsdir.h

OTHERS	= History Install Makefile Porting Readme Readme.rzsz Todo \
	  install.sh minicom.1 minicom.users runscript.1 saralogin \
	  scriptdemo unixlogin

MOBJS	= minicom.o vt100.o config.o help.o updown.o \
	  util.o dial.o window.o wkeys.o ipc.o \
	  windiv.o sysdep1.o sysdep2.o rwconf.o main.o \
	  file.o getsdir.o wildmat.o common.o

KOBJS	= keyserv.o wkeys.o sysdep2.o

SOBJS	= script.o sysdep1.o common.o

# fmg 8/22/97: merge in new OPFLAGS...
CFLAGS	= $(FLAGS) $(OPFLAGS) -DLIBDIR=\"$(LIBDIR)\"

R	= $(ROOTDIR)

all:		$(PROGS) $(PO)

minicom:	$(MOBJS)
		$(CC) $(LFLAGS) -o minicom $(MOBJS) $(LIBS)

po: dummy
		$(MAKE) -C po

keyserv:	$(KOBJS)
		$(CC) -o keyserv $(LFLAGS) $(KOBJS) $(LIBS)

runscript:	$(SOBJS)
		$(CC) -o runscript $(LFLAGS) $(SOBJS) $(LIBS)

ascii-xfr:	ascii-xfr.o
		$(CC) -s -o ascii-xfr $(LFLAGS) ascii-xfr.o

script.o:	script.c

ascii-xfr.o:	ascii-xfr.c

keyserv.o:	keyserv.c $(HDRS)

minicom.o:	minicom.c $(HDRS)

main.o:		main.c $(HDRS)

windiv.o:	windiv.c $(HDRS)

vt100.o:	vt100.c $(HDRS)
		$(CC) -c $(CFLAGS) -DMINICOM vt100.c

config.o:	config.c $(HDRS)

fastsystem.o:	fastsystem.c $(HDRS)

dial.o:		dial.c $(HDRS)

help.o:		help.c $(HDRS)

updown.o:	updown.c $(HDRS)

window.o:	window.c $(HDRS)

wkeys.o:	wkeys.c $(HDRS)

ipc.o:		ipc.c $(HDRS)

common.o:	common.c $(HDRS)

sysdep1.o:	sysdep1.c $(HDRS)

sysdep2.o:	sysdep2.c $(HDRS)

rwconf.o:	rwconf.c $(HDRS)

dummy:

install:	$(PROGS)
		$(MAKE) -C po install R=$(R)
		sh install.sh $(R)$(LIBDIR) $(R)$(BINDIR) $(R)$(MANDIR) $(R)$(DOCDIR)

install2:	$(PROGS)
		sh install.sh $(R)$(LIBDIR) $(R)$(BINDIR) $(R)$(MANDIR) $(R)$(DOCDIR)

clobber:
		rm -f *.o *~ minicom keyserv runscript ascii-xfr
		$(MAKE) -C po clean

clean:		
		rm -f *.o
		@echo "Type \"make clobber\" to really clean up."

realclean:		
		rm -f *.o minicom keyserv runscript ascii-xfr *.orig *~
