srcdir = @srcdir@
VPATH = @srcdir@

rootdir = $(srcdir)/..
@MCFG@@MCF@

CFLAGS = $(XCFLAGS)
CPPFLAGS = $(XCPPFLAGS) -DREGEX_MALLOC
LDFLAGS = $(XLDFLAGS)
DEFS = $(XDEFS)
LIBS = $(XLIBS) @TERMNET@ $(XLIB) @TERMNET@
OURLIBS = @LVFS@ @LSLANG@ @LEDIT@ @LINTL@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

SRCS =	dir.c util.c main.c screen.c dialog.c key.c keyxdef.c menu.c\
	file.c win.c color.c help.c find.c profile.c user.c view.c \
	ext.c mouse.c setup.c dlg.c option.c info.c \
	tree.c widget.c chmod.c mad.c xcurses.c xslint.c \
	wtools.c cons.handler.c chown.c subshell.c terms.c boxes.c \
	hotlist.c achown.c layout.c fsusage.c mountlist.c regex.c \
	complete.c slint.c command.c cmd.c panelize.c learn.c \
	listmode.c utilunix.c background.c rxvt.c popt.c \
	text.c

HDRS =	color.h file.h mouse.h user.h dialog.h find.h main.h \
	util.h dir.h global.h menu.h panel.h win.h mem.h \
	help.h profile.h dlg.h option.h tree.h info.h \
	widget.h chmod.h cons.saver.h mad.h wtools.h chown.h  \
	subshell.h view.h setup.h key.h ext.h boxes.h \
	hotlist.h layout.h fsusage.h mountlist.h regex.h complete.h \
	myslang.h command.h cmd.h tty.h fs.h panelize.h achown.h \
	learn.h listmode.h features.inc background.h \
	x.h popt.h textconf.h i18n.h

OBJS =	dir.o util.o screen.o dialog.o key.o keyxdef.o menu.o\
	file.o win.o color.o help.o find.o profile.o user.o view.o \
	ext.o mouse.o setup.o dlg.o option.o \
	tree.o widget.o chmod.o mad.o wtools.o info.o \
	cons.handler.o chown.o subshell.o terms.o boxes.o \
	hotlist.o achown.o layout.o fsusage.o mountlist.o \
        @XCURSES@ @REGEX_O@ complete.o slint.o command.o \
	cmd.o main.o panelize.o learn.o listmode.o utilunix.o \
	background.o rxvt.o popt.o text.o

#
# Distribution variables
#

DISTFILES = \
	$(HDRS) $(SRCS) Makefile.in TODO ChangeLog OChangeLog man2hlp.c \
	gindex.pl xmkdir cons.saver.c ncurses.patch mc.hlp depend.awk \
	fixhlp.c mfmt.c

# Should be: mc $(srcdir)/mc.hlp but it's remaking it always

all: mc mcmfmt @saver_target@

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

cons.saver: cons.saver.o
	$(CC) -s cons.saver.o -o cons.saver

check:
	@echo no tests are supplied.

mc: $(OBJS) @LIBVFS@ @LIBSLANG@ @LIBEDIT_A@
	$(CC) $(LDFLAGS) -o $@ $(OBJS) -L../vfs -L../slang -L../edit $(OURLIBS) $(LIBS) 

mfmt: mfmt.o
	$(CC) $(LDFLAGS) mfmt.o -o mfmt 

mcmfmt: mfmt
	cp mfmt mcmfmt

libvfs.a:
	cd ../vfs; $(MAKE) libvfs.a
@PCENTRULE@	-$(RMF) libvfs.a
@PCENTRULE@	$(LN_S) ../vfs/libvfs.a .

libmcslang.a:
	cd ../slang; $(MAKE) libmcslang.a
@PCENTRULE@	-$(RMF) libmcslang.a
@PCENTRULE@	$(LN_S) ../slang/libmcslang.a .

libedit.a:
	cd ../edit; $(MAKE) libedit.a
@PCENTRULE@	-$(RMF) libedit.a
@PCENTRULE@	$(LN_S) ../edit/libedit.a .

cross:
	$(MAKE) CC=gcc-linux CPP="gcc-linux -E" \
	CPPFLAGS="$(CPPFLAGS) -I/usr/local/lib/gcc-lib/i386-linux-linux/include/ncurses "

$(srcdir)/mc.hlp: $(docdir)/mc.1.in $(mclibdir)/xnc.hlp $(srcdir)/gindex.pl
	$(MAKE) man2hlp
	./man2hlp 58 $(docdir)/mc.1.in | cat - $(mclibdir)/xnc.hlp | \
	perl $(srcdir)/gindex.pl > $(srcdir)/mc.hlp

mc.html: $(docdir)/mc.1.in man2hlp
	./man2hlp 0 $(docdir)/mc.1.in > body.html
	cat index.html body.html > mc.html
	$(RM) index.html body.html

TAGS: $(SRCS)
	etags $(SRCS)

clean:
	$(RMF) mc cons.saver man2hlp fixhlp *.o core a.out mc.html mcmfmt
	$(RMF) libvfs.a libedit.a libmcslang.a mfmt

realclean: clean
	$(RMF) .depend
	$(RMF) TAGS
	$(RMF) *~

distclean:
	-$(RMF) $(srcdir)/*~ $(srcdir)/mc $(srcdir)/cons.saver
	-$(RMF) $(srcdir)/mfmt
	-$(RMF) $(srcdir)/man2hlp $(srcdir)/fixhlp $(srcdir)/*.o $(srcdir)/core
	-$(RMF) $(srcdir)/a.out $(srcdir)/mc.html
	-$(RMF) $(srcdir)/libvfs.a $(srcdir)/libmcslang.a $(srcdir)/libedit.a
	-if test $(srcdir) = .; then $(MAKE) realclean; fi
	-$(RMF) $(srcdir)/Makefile

install: mc mfmt @saver@
	$(INSTALL_PROGRAM) mc     $(DESTDIR)$(bindir)/$(binprefix)mc
	$(INSTALL_PROGRAM) mcmfmt $(DESTDIR)$(bindir)/$(binprefix)mcmfmt
	$(SEDCMD2) < $(srcdir)/mc.hlp > $(DESTDIR)$(libdir)/$(libprefix)mc.hlp 

install.saver: cons.saver
	$(INSTALL_PROGRAM) -m 4755 cons.saver $(DESTDIR)$(suppbindir)/cons.saver

uninstall:
	cd $(bindir); $(RMF) $(binprefix)mc
	cd $(bindir); $(RMF) $(binprefix)mcmfmt
	cd $(bindir); $(RMF) $(binprefix)cons.saver
	cd $(libdir); $(RMF) $(libprefix)mc.hlp

distcopy: $(srcdir)/mc.hlp
	$(CP) $(DISTFILES) ../../mc-$(VERSION)/src

depend dep: mcdep

fastdeploc: @fastdepslang@ @fastdepvfs@

# ***Dependencies***Do not edit***
@DOTDEPEND@
# ***End of dependencies***
