CC	= gcc
RM	= rm -f
TAR	= tar
INSTALL = install
INC	= 
CFLAGS	= -pipe -O3 -fomit-frame-pointer -Wall -m486 $(INC)

# Don't edit anything here!
SCANPRG	= proc.o charset.o scan.o
TOSSPRG	= proc.o regex.o charset.o toss.o
UTILPRG	= proc.o regex.o juldate.o inout.o nlfunct.o \
	  charset.o utility.o
NODEPRG	= proc.o regex.o nlfunct.o nlcomp.o
MBEDPRG	= proc.o regex.o functs.o mbnl.o charset.o \
	  colors.o mbhelp.o mbsearch.o textedit.o template.o \
	  request.o mbmenu.o mbutil.o inout.o mbedit.o
ALLPRG	= fscan ftoss futility fnlc fmbedit

MANUAL	= feddi.1 feddirc.1 fscan.1 ftoss.1 fmbedit.1 futility.1 fnlc.1

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

all: $(ALLPRG)

fscan: $(SCANPRG)
	$(CC) -dynamic $(SCANPRG) -o fscan

ftoss: $(TOSSPRG)
	$(CC) -dynamic $(TOSSPRG) -o ftoss

futility: $(UTILPRG)
	$(CC) -dynamic $(UTILPRG) -o futility

fnlc: $(NODEPRG)
	$(CC) -dynamic $(NODEPRG) -o fnlc -lm

fmbedit: $(MBEDPRG)
	$(CC) -dynamic $(MBEDPRG) -o fmbedit -lncurses

instln: all
	for I in $(ALLPRG); do \
		ln -sf $(SRCDIR)/$$I $(BINDIR)/$$I; \
	done
	for I in $(MANUAL); do \
		ln -sf $(SRCMANDIR)/$$I $(MANDIR)/$$I; \
	done

install: all
	for I in $(ALLPRG); do \
	  ($(RM) -f $(BINDIR)/$$I; \
	  $(INSTALL) -s -g root -o root -m 0755 $(SRCDIR)/$$I $(BINDIR);); \
	done
	for I in $(MANUAL); do \
	  ($(RM) -f $(MANDIR)/$$I; \
	  $(INSTALL) -g root -o root -m 0644 $(SRCMANDIR)/$$I $(MANDIR);); \
	done

uninstln: clean
	for I in $(ALLPRG); do \
		($(RM) $(BINDIR)/$$I -f; \
		 $(RM) $(SRCDIR)/$$I -f;); \
	done
	for I in $(MANUAL); do \
		$(RM) $(MANDIR)/$$I -f;\
	done

uninstall: clean
	for I in $(ALLPRG); do \
		($(RM) $(BINDIR)/$$I -f; \
		 $(RM) $(SRCDIR)/$$I -f;); \
	done
	for I in $(MANUAL); do \
		$(RM) $(MANDIR)/$$I -f;\
	done

rmbin:
	$(RM) fmbedit ftoss fscan fnlc futility feddi.tgz

clean:
	$(RM) *.o

kill: clean rmbin

config.in:
	./config/config.make
	@$(RM) output

config: config.in

user.in:
	./config/config.user

user: user.in
