#
# Makefile for tde 5.0 for djgpp and unix
# June 5, 1994, Frank Davis
# July 24, 1997, Jason Hood
# May 25, 1998, Jason Hood - combined unix and djgpp makefiles; added install
#
# UNIX works with ncurses 1.8.5 (according to Frank).
#
# I've used make 3.75; it may work with previous versions.
#

# Define the system for which to compile.
OS = djgpp
#OS = unix

# Location to place the executable/binary file.
bindir	= d:/utils
#bindir	= /usr/local/bin

# Should the executable/binary be stripped?
STRIP = strip
#STRIP = rem

CFLAGS	= -Wall -g
CFLAGS += -O2 -finline-functions
CFLAGS += -DNDEBUG

ifeq ($(OS),djgpp)
CFLAGS += -m486 -fomit-frame-pointer
PROJ	= tde.exe
LIBS	=
# Should the executable be compressed?
DJP	= djp -q
#DJP	= rem
else
CFLAGS += -D__UNIX__
PROJ	= tde
LIBS	= -lncurses
DJP	= rem
endif

VPATH	 = $(OS)
CPPFLAGS = -I.

OBJS = bj_ctype.o  block.o    cfgfile.o   config.o   console.o	\
       criterr.o   default.o  diff.o	  dirlist.o  ed.o	\
       file.o	   filmatch.o findrep.o   global.o   help.o	\
       hwind.o	   macro.o    main.o	  menu.o     port.o	\
       prompts.o   pull.o     query.o	  regx.o     sort.o	\
       syntax.o    tab.o      tdeasm.o	  utils.o    window.o	wordwrap.o

INC  = tdestr.h common.h tdefunc.h define.h

%.o : %.c
	@echo Compiling $<
	@$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

$(PROJ): $(OBJS)
	@echo Creating	$(PROJ)
	@$(CC) -o $(PROJ) $(OBJS) $(LIBS)

bj_ctype.o:  bj_ctype.c bj_ctype.h tdestr.h common.h
block.o:     block.c	$(INC)
cfgfile.o:   cfgfile.c	tdestr.h syntax.h
config.o:    config.c	config.h $(INC)
console.o:   console.c	$(INC)
criterr.o:   criterr.c	criterr.h $(INC)
default.o:   default.c	tdestr.h define.h
diff.o:      diff.c	$(INC)
dirlist.o:   dirlist.c	$(INC)
ed.o:	     ed.c	$(INC)
file.o:      file.c	$(INC)
filmatch.o:  filmatch.c filmatch.h tdestr.h common.h
findrep.o:   findrep.c	$(INC)
global.o:    global.c	tdestr.h tdefunc.h
help.o:      help.c
hwind.o:     hwind.c	$(INC)
macro.o:     macro.c	$(INC)
main.o:      main.c	$(INC)
menu.o:      menu.c	tdestr.h define.h
port.o:      port.c	$(INC)
prompts.o:   prompts.c	bj_ctype.h
pull.o:      pull.c	$(INC)
query.o:     query.c	$(INC)
regx.o:      regx.c	$(INC)
sort.o:      sort.c	$(INC)
syntax.o:    syntax.c	syntax.h $(INC)
tab.o:	     tab.c	$(INC)
tdeasm.o:    tdeasm.c	$(INC)
utils.o:     utils.c	$(INC)
window.o:    window.c	$(INC)
wordwrap.o:  wordwrap.c $(INC)

install:
	cp $(PROJ) tdedbg.exe
	$(STRIP) $(PROJ)
	$(DJP) $(PROJ)
	cp $(PROJ) $(bindir)
