
# make install:
#	installs lde
# make install_terminfo:
#	installs terminfo files in /usr/lib/terminfo

INSTALL_DIR=/etc
OWNER=root
GROUP=system
PROG_NAME=lde

INSTALL_MAN=/usr/man/man8/lde.8
MAN_OWNER=root
MAN_GROUP=man

# To remove the curses support, comment out all the lines in this
# section.
# Where is your ncurses stuff?
# Define NC_HEADER if your include file is called <ncurses.h>,
# otherwise undefine it and set INCLUDE_DIR to point to the directory
# which contains curses.h for ncurses.
LIBCURSES=-lncurses
# LIBCURSES=-ldcurses
# CURSES_HEADER=-DNC_HEADER
INCLUDE_DIR=/usr/local/include
CURSES_SRC=nc_lde.c
CURSES_OBJ=nc_lde.o
CURSES_FLAGS=-DLDE_CURSES ${CURSES_HEADER}

# Other defines which might be useful
#
# -DEMERGENCY        -- compile in search code
# -DREAD_FULL_TABLES -- for ext2fs currently, can read in the full
#                       disk tables if defined, or just one group at
#                       a time (memory savings should really be on the
#                       order of kb, maybe 10's of kb)
# -DPARANOID         -- open device read only at all times
# -DALPHA_CODE       -- compile in alpha code, stuff which really
#                       doesn't have to be in lde-2.1 so we can get out of beta
#
CFLAGS=-Wall -O6 -DREAD_FULL_TABLES -DEMERGENCY -DALPHA_CODE ${CURSES_FLAGS}
LDFLAGS=-s
# CFLAGS=-Wall -g -DREAD_FULL_TABLES -DEMERGENCY -DALPHA_CODE ${CURSES_FLAGS}
# LDFLAGS=-g
CC=gcc

SRCS = filemode.c minix.c xiafs.c ext2fs.c no_fs.c recover.c main_lde.c ${CURSES_SRC} tty_lde.c

OBJS = filemode.o minix.o xiafs.o ext2fs.o no_fs.o recover.o main_lde.o ${CURSES_OBJ} tty_lde.o

$(PROG_NAME):	.depend $(OBJS)
	$(CC) $(LDFLAGS) -o $(PROG_NAME) $(OBJS) $(LIBCURSES)

install:	$(PROG_NAME)
	install -o $(OWNER) -g $(GROUP) -m0300 $(PROG_NAME) $(INSTALL_DIR)/$(PROG_NAME)

install.man:
	install -o $(MAN_OWNER) -g $(MAN_GROUP) -m 666 lde.8 $(INSTALL_MAN)

install_terminfo:
	install -d /usr/lib/terminfo/c
	install -d /usr/lib/terminfo/v
	install -d /usr/lib/terminfo/x
	install terminfo/x/xterm /usr/lib/terminfo/x
	install terminfo/v/vt100 /usr/lib/terminfo/v
	install terminfo/c/console /usr/lib/terminfo/c
	install terminfo/c/con132x43 /usr/lib/terminfo/c

clean:
	rm -f *.o

clear:	clean
	rm -f .depend $(PROG_NAME)

.depend:
	@echo Doing \"make depend\"
	@rm -f .depend
	@for i in *.c;do $(CPP) -M $$i;done >> .depend

depend:	.depend

tar:
	tar cvfz lde.tar.gz $(SRCS) $(PROG_NAME) terminfo COPYING \
            README INSTALL TODO UNERASE grep-inode doc Makefile lde.h \
            ChangeLog *.lsm lde.8

ifeq (.depend,$(wildcard .depend))
include .depend
endif

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


