#
# Program:    R   A   C
#
# RAC - Rows and Columns, the text extraction tool 
# http://aurelio.net/rac
#
# Copyright 2003  Aurelio Marinho Jargas
#                 Thobias Salazar Trevisan
#
# Please address all bugs and comments to:
#     verde@aurelio.net
#     thobias@thobias.org
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, version 2.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You have received a copy of the GNU General Public License along
#   with this program, on the COPYING file.
#

PROGRAM_NAME   = rac
TARGET         = /usr/bin
MANPAGE_TARGET = /usr/share/man/pt_BR/man1
CC             = gcc

CFLAGS = -Wall -O3 -Werror -funroll-loops -fomit-frame-pointer \
			-pipe -D_GNU_SOURCE -pedantic

NOOPT = -Wall -O0 -D_GNU_SOURCE 

# Uncomment this for FreeBSD and friends.                                 
#CC = cc                                                                  
#CFLAGS = -Wall -O2 -Werror -I/usr/local/include -L/usr/local/lib -lgnugetopt

# STRIP	Option. 
STRIP_OPTION = --strip-all
# uncomment the next option if you have Solaris, MacOS or your
# 'strip' command does not support the '--strip-all' option
#STRIP_OPTION = -x

# DEBUG flags. 
# usage: 'make debug'
#MYDEBUG = -DDEBUG1 
MYDEBUG = -DDEBUG1 -DDEBUG2
#MYDEBUG = -DDEBUG1 -DDEBUG2 -DDEBUG3
DFLAGS = -Wall -g -pipe -fPIC -D_GNU_SOURCE $(MYDEBUG)

SOURCE = exec.c  input.c  lib_rac.c
OBJ = exec.o  input.o  lib_rac.o

all: $(PROGRAM_NAME)

$(PROGRAM_NAME):  $(PROGRAM_NAME).c $(OBJ) 
	$(CC) $(CFLAGS) -o $(PROGRAM_NAME) $(PROGRAM_NAME).c $(OBJ) 
	strip $(STRIP_OPTION) $(PROGRAM_NAME)
# if you are using a cygwin system, add a '.exe' at the end of previous
# line, ie, change that line to:
#	strip $(STRIP_OPTION) $(PROGRAM_NAME).exe
# windows, so we have to 'strip' the rac.exe file :/

debug: $(PROGRAM_NAME).c $(SOURCE)
	$(CC) $(DFLAGS) -o $(PROGRAM_NAME) $(PROGRAM_NAME).c $(SOURCE)

profile: $(PROGRAM_NAME).c $(OBJ)
	$(CC) -Wall -O3 -Werror -funroll-loops -pipe -fPIC -D_GNU_SOURCE \
	-pedantic -o $(PROGRAM_NAME) $(PROGRAM_NAME).c $(OBJ) -pg

noopt:  $(PROGRAM_NAME).c $(SOURCE)
	$(CC) $(NOOPT) -o $(PROGRAM_NAME) $(PROGRAM_NAME).c $(SOURCE) 

clean:
	rm -f $(OBJ) $(PROGRAM_NAME) $(PROGRAM_NAME).tgz

install: $(PROGRAM_NAME)
	cp $(PROGRAM_NAME) $(TARGET)
	cp ../doc/$(PROGRAM_NAME).1 $(MANPAGE_TARGET)

uninstall:
	rm -f $(TARGET)/$(PROGRAM_NAME)
	rm -f $(MANPAGE_TARGET)/$(PROGRAM_NAME).1

tar:
	tar -zcvf $(PROGRAM_NAME).tgz Makefile *.[ch] Changelog

ctags:
	rm -rf tags
	ctags *.[ch]

.PHONY: clean all debug install uninstall

