# Uncomment for LibC 5 Linux platform (e.g. SlackWare 3.x)
#PLATFORM = LINUX
#CFLAGS += -O2
#CC = gcc

# Uncomment for LibC 6-based Linux platform (e.g. RedHat 5)
PLATFORM = LINUX_LC6
CFLAGS += -O2
CC = gcc

# Uncomment for FreeBSD (< 5.0) platform
#PLATFORM = FREEBSD
#CFLAGS += -O2
#CC = gcc

# Uncomment for FreeBSD (>= 5.0) platform
#PLATFORM = FREEBSD5
#CFLAGS += -O2
#CC = gcc

# Uncomment for Win32 platform under Cygwin1.1.
#PLATFORM = WIN32
#CFLAGS += -O2
#CC = gcc

# Uncomment for HP-UX platform (HP-UX 10.20)
# then select your compiler...
#PLATFORM = HPUX
#---------------------For HP Ansi/C compiler
#CFLAGS += -Ae
#CC = cc
#------------------------------------For gcc
#CFLAGS += -O2
#CC = gcc

# Uncomment for Solaris platform
#PLATFORM = SOLARIS
#CFLAGS += -O
#CC = gcc
#LIBS = -lsocket -lnsl -lresolv

# Uncomment for debugging
#DEBUG = -DINCL_DEBUG_CODE

DEFINES = -D$(PLATFORM) $(DEBUG)
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man

#===========================================================
# You shouldn't need to change anything beyond this point
#===========================================================
PROGS = sendsms
MANPAGES = $(wildcard *.[0-9])
HTMLMAN = $(addsuffix .html, $(MANPAGES))


#=============================================================
all: $(PROGS)

doc: $(HTMLMAN)

sendsms: sendsms.o
	$(CC) -o sendsms sendsms.o $(LIBS)

sendsms.o: sendsms.c sendsms.h
	$(CC) $(CFLAGS) $(DEFINES) -c sendsms.c

stuff.o: stuff.c sms_serv.h
	$(CC) $(CFLAGS) $(DEFINES) -c stuff.c
	
listing:
	enscript -GE Makefile sendsms.c sendsms.h BUGS TODO INSTALL
	man -l ./sendsms.1 -t | lpr

install:
	cp sendsms $(BINDIR)
	strip $(BINDIR)/sendsms
	chmod 755 $(BINDIR)/sendsms
	chown root:bin $(BINDIR)/sendsms
	cp sendsms.1 $(MANDIR)/man1
	chmod 644 $(MANDIR)/man1/sendsms.1
	chown root:bin $(MANDIR)/man1/sendsms.1

%.1.html: %.1
	rman -f HTML -r '%s.%s.html' $< > $@

%.5.html: %.5
	rman -f HTML -r '%s.%s.html' $< > $@

clean:
	rm -f core sendsms *.exe *.o *~ *.html

