#
# Makefile
#
# Makefile for compiling xdialdctl
#
# $Id: Makefile,v 1.9 1996/12/05 22:06:58 joe Exp $
# Copyright 1996 Joe B. Edmonds (joe@elem.com)
#

# Define this to be yes to compile a debugging version:
DEBUG = no

# Define this to be yes to debug compilation:
COMPILE_DEBUG = no

EXECUTABLE = xdialdctl
SRCS = xdialdctl.c
LIBS = -L/usr/X11R6/lib -lXaw -lXt

# g++ for C++ style linking.  gcc for C style linking.
CC = gcc

####################### End of per-application settings #######################

#v1.0
# Define the following in your per-project Makefile:
#   (template in ~/pro/TEMPLATES)
#
#  DEBUG         = { yes, no }
#  COMPILE_DEBUG = { yes, no }
#  PROFILE       = { yes, no }
#  EXECUTABLE    = { executable_name }
#  SRCS          = { main.cc Record.cc ... } SOURCE FILES MUST END IN '.cc'!!!
#  LIBS          = { -Liostream ... }
#  CC            = { g++, gcc }
#
# Then be sure to include this file.
#

ifeq ($(CC),gcc)
# Exactly one object file per source file.
OBJS = $(SRCS:.c=.o)
else
# Exactly one object file per source file.
OBJS = $(SRCS:.cc=.o)
endif

ifeq ($(COMPILE_DEBUG),yes)
	DEBUG_FLAGS += -v
else
	DEBUG_FLAGS +=
endif

ifeq ($(DEBUG),yes)
# Adds debugging symbols, DEBUG macro, and all warnings
	DEBUG_FLAGS += -g -DDEBUG -Wall
	OPT_FLAGS = -O
	LDFLAGS += -g
else
	DEBUG_FLAGS +=
	OPT_FLAGS = -O2
	LDFLAGS +=
endif

ifeq ($(PROFILE),yes)
	DEBUG_FLAGS += -pg
	LDFLAGS += -pg
endif

CPPFLAGS = $(OPT_FLAGS) $(DEBUG_FLAGS)

all: $(EXECUTABLE)

tags: $(SRCS)
	etags $(SRCS)

$(EXECUTABLE): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

clobber: clean

clean: depend
	rm -f $(OBJS) $(EXECUTABLE) xdialdctl.tgz

install: $(EXECUTABLE) $(EXECUTABLE).man
	install -m 755 $(EXECUTABLE) /usr/X11R6/bin/
	install -m 644 $(EXECUTABLE).man /usr/man/man1/$(EXECUTABLE).1

dist:
	export GZIP="--best" ; cd .. ; tar zcvf xdialdctl/xdialdctl.tgz xdialdctl/{README,Makefile,xdialdctl.c,xdialdctl.man}

# As per the <('make' Info Page about Automatic Dependencies)>:
# Note there are two copies, one for gcc (C) and one for g++ (C++)
# since the filenames end in .c and .cc, respectively.
ifeq ($(CC),gcc)

depend:
	rm -f $(SRCS:.c=.d)

%.d: %.c
	$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< | sed '\''s/$*.o/& $@/g'\'' > $@'

include $(SRCS:.c=.d)

else

depend:
	rm -f $(SRCS:.cc=.d)

%.d: %.cc
	$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< | sed '\''s/$*.o/& $@/g'\'' > $@'

include $(SRCS:.cc=.d)
endif

