#
# Copyright (C) 1997, Ericsson Telecommunications
# Author: Bjorn Gustavsson
#
# Running this Makefile without arguments to automatically create
# the Makefiles for your specific operating system.  The results will
# be saved in a platform dependent sub-directory, so you can safely
# configure for several platforms in the same clearcase view.
#
# Run 'clearmake makefiles' if you just want to rebuild the Makefiles,
# without determining the configuration parameters.  This is useful if
# you've changed a Makefile.in file.
#

TARGET := $(shell './config.guess')

ifeq ($(findstring vxworks,$(TARGET)),vxworks)
do_vxworks:
	HOST_TYPE=$(HOST_TYPE) WIND_BASE=$(WIND_BASE) ./configure.vxworks $(TARGET)
else

ifneq (,$(findstring linux,$(TARGET)))
CONFIG_FLAGS = --enable-elib-malloc
endif

ifneq (,$(findstring univel-sysv4,$(TARGET)))
CONFIG_FLAGS = --enable-elib-malloc --x-libraries=/usr/lib/X11
endif

ifeq ($(TARGET),free_source)
CONFIG_FLAGS += --host=$(TARGET)
endif

do_configure: configure
	@if test ! -d $(TARGET); then mkdir $(TARGET); fi
	CONFIG_STATUS=$(TARGET)/config.status CFLAGS="" \
	    ./configure --cache-file $(TARGET)/config.cache $(CONFIG_FLAGS)

clean:
	rm -f config.log
	rm -rf $(TARGET)
	rm -f configure

makefiles:
	$(TARGET)/config.status

configure: configure.in
	@if autoconf configure.in > /dev/null; \
	then \
		rm -f configure; \
		autoconf configure.in > configure; \
		chmod +x configure; \
	fi

win32: do_configure
	./configure.win32 $(TARGET)

endif
