# $Id: Makefile,v 1.1 2004/12/21 23:26:19 tjm Exp $
#
# This file is part of liballoc.
# A library which provides memory allocation facilities.
#
# Created by Silicon Graphics, Inc.
#
# Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
#
# This code is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or     
# (at your option) any later version. See the file COPYING for more        
# information.                                              
#
DEPTH        = ..
-include $(DEPTH)/../.config

EXTRA_CFLAGS = $(GFLAGS) -DALLOC_DEBUG
ifeq ($(ARCH),s390x)
EXTRA_CFLAGS +=  -DPTRSZ64
endif
ifeq ($(ARCH),ia64)
EXTRA_CFLAGS += -DPTRSZ64
endif
ifeq ($(ARCH),x86_64)
EXTRA_CFLAGS += -DPTRSZ64
endif
ifeq ($(ARCH),ppc64)
ifeq ($(PPC64_GCC),1)
EXTRA_CFLAGS += -DPTRSZ64
endif
endif
EXTRA_CFLAGS += -I.  -I../libutil -I$(TOPDIR)/include -I../libklib/include

LIBDIR = /usr/lib

.c.o:
	$(CC) $(EXTRA_CFLAGS) -c -o $*.o $<

TARGETS   = liblkcd_alloc.a
CFILES    = alloc.c
HFILES    = alloc.h
OFILES    = $(CFILES:.c=.o)

all: default

clean:
	/bin/rm -f *.o 
	/usr/bin/find . -name ".[a-Z]*.flags" -print | xargs /bin/rm -f
	/usr/bin/find . -name ".depend" -print | xargs /bin/rm -f

mrproper clobber: clean
	/bin/rm -f $(TARGETS)

headers:
	mkdir -p $(ROOT)/usr/include/lkcd
	install -m 644 $(HFILES) $(ROOT)/usr/include/lkcd

exports: $(TARGETS)
	mkdir -p $(ROOT)$(LIBDIR)/lkcd
	install -m 644 $(TARGETS) $(ROOT)$(LIBDIR)/lkcd

install: headers exports

default: $(TARGETS)

$(TARGETS): $(OFILES)
	$(AR) ccurl $(TARGETS) $(OFILES)

include $(DEPTH)/../Rules.make
