
# make install:
#	installs lde
# make install.terminfo:
#	installs terminfo files in /usr/lib/terminfo
# make install.man
#	install the man page

VERSION=\"2.2\"

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
# CURSES_INCLUDE_DIR=-I/usr/local/include
# CURSES_INCLUDE_DIR=-I/usr/include/ncurses
CURSES_SRC=nc_lde.c nc_block.c nc_inode.c nc_dir.c
CURSES_OBJ=nc_lde.o nc_block.o nc_inode.o nc_dir.o
CURSES_FLAGS=-DLDE_CURSES $(CURSES_HEADER) $(CURSES_INCLUDE_DIR)

# Other defines which might be useful
#
# -DREAD_PART_TABLES -- for ext2fs currently, can read in the full
#                       disk tables if undefined, or just one group at
#                       a time when defined (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 -O2 -DVERSION=$(VERSION) -DALPHA_CODE $(CURSES_FLAGS) -Wstrict-prototypes -Wmissing-prototypes
LDFLAGS=-s
# LDFLAGS=-s --static
# CFLAGS=-Wall -g -DVERSION=$(VERSION) -DALPHA_CODE $(CURSES_FLAGS) -Wstrict-prototypes -Wmissing-prototypes
# 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 bitops.c	

OBJS = filemode.o minix.o xiafs.o ext2fs.o no_fs.o recover.o \
       main_lde.o $(CURSES_OBJ) tty_lde.o bitops.o

HEADERS = lde.h nc_lde.h bitops.h nc_block_help.h nc_inode_help.h \
	nc_lde_help.h no_fs.h xiafs.h curses.h minix.h nc_dir.h \
	nc_lde.h recover.h ext2fs.h nc_block.h nc_inode.h tty_lde.h


$(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\"
	@for i in *.c;do $(CPP) -M $$i;done >> .depend

depend:
	@rm -f .depend
	@$(MAKE) .depend

dep:	depend

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

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

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


