#
# Makefile for lkcd_ksyms
#
# Copyright 1999 Silicon Graphics, Inc. All rights reserved.
# COPYRIGHT(C) FUJITSU LIMITED 2001
#
DEPTH  = .
include $(DEPTH)/commondefs

TARGET    = lkcd_ksyms
CFILES    = main.c
LIBS      = -llkcd_alloc -lklib -llkcd_util -lbfd -liberty -lsial -lz
LFLAGS    = -static -rdynamic -L../lcrash -L$(TOPDIR) -L$(LKCDDIR)/libklib \
	    -L$(GDB_DIR)/bfd -L$(GDB_DIR)/libiberty -L$(GDB_DIR)/opcodes \
            -L$(LKCDDIR)/liballoc -L$(LKCDDIR)/libsial -L$(LKCDDIR)/libutil
OFILES    = $(CFILES:.c=.o)
SUB_DIRS  = man

all: default

default: $(TARGET)

$(TARGET): subdirs_make
	$(CC) -o $@ $(LDFLAGS) $(LFLAGS) $(OFILES) $(LIBS)

subdirs_make: $(OFILES)
	for dir in $(SUB_DIRS) ; do \
		( cd $$dir ; make TOPDIR=$(TOPDIR); cd ..) \
	done

clean:
	/bin/rm -f *.o
	for dir in $(SUB_DIRS) ; do \
		( cd $$dir ; \
		make TOPDIR=$(TOPDIR) GFLAGS=$(GFLAGS) \
		ARCH=$(ARCH) clean; cd .. ); \
	done

clobber: clean
	/bin/rm -f $(TARGET)

$(OFILES): $(HEADERS)

#
# We avoid this for now -- you'll need to do a make clobber followed
# by a make if you want to fix this later.
#
$(HEADERS): symlinks

symlinks:
	/bin/rm -f $(HPATH)/arch
	(cd $(HPATH) ; /bin/ln -sf arch-$(ARCH) arch)
	(cd $(LKCDDIR)/libklib ; make ARCH=$(ARCH) symlinks)

headers:

exports install: $(TARGET)
	mkdir -p $(ROOT)/sbin
	mkdir -p $(ROOT)/usr/man/man1
	install -m 755 lkcd_ksyms $(ROOT)/sbin/lkcd_ksyms
	install -m 644 man/lkcd_ksyms.1 $(ROOT)/usr/man/man1
