#
# Makefile for lkcd_config -- based on lcrash Makefile
#
# Copyright 1999 Silicon Graphics, Inc. All rights reserved.
# Copyright 2001 Matt D. Robinson (yakker@aparity.com). All rights reserved.
#
DEPTH  = .
include $(DEPTH)/commondefs

TARGET    = lkcd_config
CFILES    = lkcd_config.c
LIBS      = -lz
LFLAGS    = -L$(TOPDIR) -L$(TOPDIR)/include -L$(LKCDDIR)/libklib
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) 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 $(TARGET) $(ROOT)/sbin
	install -m 644 man/$(TARGET).1 $(ROOT)/usr/man/man1
