
## makefile for s u l a (testing..)
## 
## this Makefile works on linux. See ../INSTALL for info on compiling.
##
##     info: http://www.geocities.com/SiliconValley/Peaks/8771
##
## take a look at mkconfig.h to make sure default directories are correct.
## =====================================================================
## Please if you correct any errors let me know.
##		fotang@techie.com, m.tano@wirtschaft.fh-wolfenbuettel.de
##	02/1998


CC=gcc
DEFS   = -DDEBUG
#Recompile with this if you dont want long options for commands which use them:
#DEFS = -DDEBUG -DDONT_HAVE_GETOPT
#for sulahp.1:
MAN_DIR=/usr/local/man

CCFLAG=-O2 -Wall $(DEFS) -I../xpm -I../include  -g
LDFLAGS = -s
## comment out the next 2 lines in order to later run program through a debugger. bugs.bugs.
CCFLAG=-O2 -Wall $(DEFS) -I../xpm -I../include
LDFLAGS =
#libefence (3)        - Electric Fence Malloc Debugger. Want to debug with it? 
SYSLIB=-L/usr/X11R6/lib -lX11 -lm -lefence
SYSLIB=-L/usr/X11R6/lib -lX11 -lm

#       building a pseudo-static version: 
LIBS = -static -lforms -dynamic -lXpm $(SYSLIB)
 
#       comment out the following line if you want to build a version that
#	will run without xforms. about 1MB in size.
LIBS= -lforms $(SYSLIB)

#
#	-- y o u   m a y  s t o p  h e r e --
#

include mkconfig.h
CFLAGS=$(CCFLAG) $(MK_CFLAGS)


OBJ=	util.o script.o script_gui.o idle_cb.o lag.o help.o setup.o set.o \
	cmd_def.o cmd.o ctcp.o etc.o checksum.o\
	etc_cb.o dcc_gui.o dcc.o ignore.o nicks.o\
	mode.o user.o numeric.o  msg.o parser.o \
	net.o global.o attribs.o chanwin.o chanwin_cb.o sula.o \
	sula_cb.o servers_cb.o servers.o main.o
AUX_OBJ= sulahp.o

SRC= ${OBJ:%.o=%.c}
BIN  = sula
AUXBIN  = sulahp

.SUFFIXES: .o .c

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

bins: sula sulahp
sula: $(OBJ)
	$(CC) $(LDFLAGS) -o $(BIN) $(OBJ) $(LIBS)
	-@printf "\nCompilation completed.\n\
	\rType \"make install\" to install program.\n\n"

sulahp: $(AUX_OBJ)
	$(CC) -o  $(AUXBIN) $(AUX_OBJ)

all:	config depend $(BIN) $(AUXBIN) install install_home


config:
	$(CC) -o Config Config.c && ./Config

depend:
	makedepend -- $(CFLAGS) -- $(SRC)

install:
	-@printf "\n\nStarting installation..\n\n"
	-@if test -f $(BIN_DIR)/$(BIN); then \
		cp -f $(BIN_DIR)/$(BIN) $(BIN_DIR)/$(BIN).old; \
	fi
	@cp -vf $(BIN) $(BIN_DIR) && chmod -v $(BINMODE) $(BIN_DIR)/$(BIN)
	@cp -vf $(AUXBIN) $(BIN_DIR) && chmod -v $(BINMODE) $(BIN_DIR)/$(AUXBIN)
	-cp -vf $(AUXBIN).1 $(MAN_DIR)/man1

	-@echo
	-@printf "\nCopying configuration and help files..\n"
	-@echo Use X resource files \(\~/.Xdefaults etc\) to customarize your client
	-@printf "See sula.app-defaults for entries.\n\n" 
	-@mkdir -p $(LIB_DIR) && cp -dpPRf ../sula/* $(LIB_DIR)
	-@cp -vdRf ../conf/* $(LIB_DIR)
	-@cp -vf ../sula.app-defaults $(RESOURCE_DIR)/Sula
	-@echo "======================================================="
	-@printf "\n\n\"%s\" installed.\nmake install_home to install %s\n\n" \
		$(BIN) ~/$(P_HOME)
	-@echo "======================================================="

install_home:
	-@printf "\nCopying files to \"%s\"\n" ~/$(P_HOME)
	-@test -d ~/$(P_HOME)  || mkdir -p ~/$(P_HOME)
	-@cp -dvR ../conf/* ~/$(P_HOME)
#	-@! test -d ~/$(P_HOME)  && mkdir -p ~/$(P_HOME)
#	@test -d ~/$(P_HOME) && for i in ../conf/sula_*;do \
#	if ! test -f ~/$(P_HOME)/$$i;then \
#		cp -bv $$i ~/$(P_HOME) \
#	fi


clean:
	-rm -f *.o core a.out
