# Copyright (C) 2001-2003  Daniel Kelly
# Copyright (C) 2009, 2010  Peter Pentchev
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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 should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

CFLAGS_OPT?=	-O2
CFLAGS_DBG?=	-g
CFLAGS_WARN?=	-Wall -W -ansi -pedantic -Wbad-function-cast -Wcast-align \
		-Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes \
		-Wnested-externs -Wpointer-arith -Wshadow \
		-Wstrict-prototypes -Wwrite-strings \
		-Wsystem-headers -Wno-format-y2k -Winline -Wno-pointer-sign \
		-Wreturn-type -Wswitch -Wunused-parameter

CFLAGS?=	${CFLAGS_OPT} ${CFLAGS_DBG}
CFLAGS+=	${CFLAGS_WARN}

CC?=gcc
LIBS?=
RM?=rm -f
GZIP?=		gzip -c9
FALSE?=		false

# Keep this uncommented if you are building prips on a POSIX-compatible
# system.  If you are not sure, chances are that you most probably are.
CFLAGS+=	-DHAVE_POSIX
# Keep this uncommented if your header files provide a definition for
# the POSIX-compatible 32-bit unsigned integer type
CFLAGS+=	-DHAVE_UINT32_T
# If you do NOT have the POSIX-compatible uint32_t type, please specify
# which of the integer types on your platform is 32-bits wide
#CFLAGS+=	-DINT32_T=int

all: prips prips.1.gz

prips: main.o prips.o except.o
	$(CC) $(LDFLAGS) -o prips main.o prips.o except.o $(LIBS)

main.o: main.c prips.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c main.c

prips.o: prips.c prips.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -c prips.c 

except.o: except.c except.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -c except.c

prips.1.gz:	prips.1
	${GZIP} prips.1 > prips.1.gz || (${RM} prips.1.gz; ${FALSE})

clean:	
	$(RM) core *~ *.o prips prips.1.gz
