# Makefile for cln/src

#### Start of system configuration section. ####

# Directories used by "make":
srcdir = @srcdir@
top_srcdir = @top_srcdir@

# Directories used by "make install":
prefix = @prefix@
local_prefix = /usr/local
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
libdir = @libdir@
includedir = @includedir@
mandir = @mandir@
DESTDIR =

# Programs used by "make":
# C compiler
CC = @CC@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
# C++ compiler
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
CXXCPP = @CXXCPP@
INCLUDES = -I../include -I${top_srcdir}/include
override CPPFLAGS += ${INCLUDES}
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_COMPILE = ${LIBTOOL} --mode=compile
LIBTOOL_LINK = ${LIBTOOL} --mode=link
LIBTOOL_INSTALL = ${LIBTOOL} --mode=install
LIBTOOL_UNINSTALL = ${LIBTOOL} --mode=uninstall
AR = ar
AR_FLAGS = rc
RANLIB = @RANLIB@
MV = mv
LN = ln
RM = rm -f
MKDIR = mkdir -p
@SET_MAKE@
# Libtool's library interface versions:
CL_CURRENT = @CL_CURRENT@
CL_REVISION = @CL_REVISION@
CL_AGE = @CL_AGE@

# Programs used by "make install":
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

#### End of system configuration section. ####

SHELL = /bin/sh

# Needed by ${LIBTOOL}.
top_builddir = ..

# When this Makefile is called with SUBDIR=some_subdirectory, it builds
# only the object files belonging to sources in that subdirectory. The
# final library is built only if SUBDIR=.
SUBDIR = .

# Define the search path for sources.
# The variable ${aux_srcdir} is needed because new versions of aufoconf tend to
# remove ${srcdir}, ${srcdir} and so on...
aux_srcdir = @srcdir@
VPATH = ${aux_srcdir}/${SUBDIR}

# Add subdirectory specific flags.
include ${srcdir}/${SUBDIR}/Makeflags
override CPPFLAGS += ${SUBDIR_INCLUDES}

# Need to know the system name.
SYSTEM := $(shell uname -s)

FILES_CC := $(notdir $(wildcard ${srcdir}/${SUBDIR}/*.cc))
FILES_CC := $(filter-out %.i.cc, ${FILES_CC})
ASMFILES_CC := $(patsubst cl_asm_@host_cpu@_%.cc,cl_asm_%.cc, $(filter cl_asm_@host_cpu@_%.cc, ${FILES_CC}))
FILES_CC := $(filter-out cl_asm_%.cc, ${FILES_CC})

FILES_I_CC := $(patsubst %.cc,%.i.cc,${FILES_CC})

FILES_S := $(patsubst %.cc,%.s,${FILES_CC})

FILES_LO := $(patsubst %.cc,%.lo,${FILES_CC})

ASMFILES_S := $(patsubst %.cc,%.s,${ASMFILES_CC})

ASMFILES_LO := $(patsubst %.cc,%.lo,${ASMFILES_CC})

OBJECTS_LO = ${FILES_LO} ${ASMFILES_LO}

SUBDIRS := $(patsubst ${srcdir}/%/.,%,$(wildcard ${srcdir}/${SUBDIR}/*/.))
# Avoid certain subdirectories:
#   private/ and old/ don't contain valid sources,
#   CVS/, RCS/ and SCCS/ are created when people put the sources under version control,
#   ii_files/ is created during "make" by SGI C++.
SUBDIRS := $(filter-out old ./old private ./private CVS %/CVS RCS %/RCS SCCS %/SCCS ii_files ./ii_files,${SUBDIRS})


# Rule 'all' must be the first in the file.
all : _all_


# Recurse into subdirectories

SUBDIRS_DIRDEP := $(patsubst %,%.dirdep,${SUBDIRS})

${SUBDIRS_DIRDEP} : %.dirdep :


# Target 'all' creates all necessary files for $(SUBDIR) and its subdirectories.

SUBDIRS_TARGET_ALL := $(patsubst %,%.target_all,${SUBDIRS})

${SUBDIRS_TARGET_ALL} : %.target_all : %.dirdep
	${MAKE} SUBDIR=$* all

ifeq (${SUBDIR},.)
ALLFILES_CC := $(notdir $(wildcard ${srcdir}/*.cc) $(foreach subdir,${SUBDIRS}, $(wildcard ${srcdir}/${subdir}/*.cc) $(wildcard ${srcdir}/${subdir}/*/*.cc) $(wildcard ${srcdir}/${subdir}/*/*/*.cc)))
ALLFILES_CC := $(filter-out %.i.cc, ${ALLFILES_CC})
ALLASMFILES_CC := $(patsubst cl_asm_@host_cpu@_%.cc,cl_asm_%.cc, $(filter cl_asm_@host_cpu@_%.cc, ${ALLFILES_CC}))
ALLFILES_CC := $(filter-out cl_asm_%.cc, ${ALLFILES_CC})
ALLFILES_LO := $(patsubst %.cc,%.lo,${ALLFILES_CC})
ALLASMFILES_LO := $(patsubst %.cc,%.lo,${ALLASMFILES_CC})
ALLOBJECTS_LO = ${ALLFILES_LO} ${ALLASMFILES_LO}

_all_ : allo-local ${SUBDIRS_TARGET_ALL} libcln.la
else
_all_ : allo-local ${SUBDIRS_TARGET_ALL}
endif


# Target 'alls' creates all .s files for $(SUBDIR) and its subdirectories.

SUBDIRS_TARGET_ALLS := $(patsubst %,%.target_alls,${SUBDIRS})

${SUBDIRS_TARGET_ALLS} : %.target_alls : %.dirdep
	${MAKE} SUBDIR=$* alls

alls : alls-local ${SUBDIRS_TARGET_ALLS}

alls-local : ${FILES_S} ${ASMFILES_S}


# Target 'allo' creates all .lo files for $(SUBDIR) and its subdirectories.
SUBDIRS_TARGET_ALLO := $(patsubst %,%.target_allo,${SUBDIRS})

${SUBDIRS_TARGET_ALLO} : %.target_allo : %.dirdep
	${MAKE} SUBDIR=$* allo

allo : allo-local ${SUBDIRS_TARGET_ALLO}

allo-local : ${FILES_LO} ${ASMFILES_LO}


ASMFLAGS := @ASMFLAGS@
ifeq (@AS_UNDERSCORE@,true)
ASMFLAGS += -DUNDERSCORE
endif

# Rules for normal compilation.

%.lo : %.c
	${LIBTOOL_COMPILE} ${CC} ${CFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -c $<

%.lo : %.cc
	${LIBTOOL_COMPILE} ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -c $<

# Rules for normal compilation, only needed for debugging.

%.s : %.c
	${CC} ${CFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -S $< -o $@

%.s : %.cc
	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -S $< -o $@

# Rules for preprocessing.

%.i : %.c
	${CPP} ${CFLAGS} ${CPPFLAGS} ${TARGET_ARCH} $< > $@

%.i.cc : %.cc
	${CXXCPP} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} $< > $@

# Rules for assembly language files,

ifneq (${ASMFILES_LO},)

ifneq ($(filter @host_cpu@,sparc sparc64),)
${ASMFILES_S} : %.s : %.cc
	${CXXCPP} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} ${ASMFLAGS} $< | grep -v '^#' | grep -v '^ *#line' | sed -e 's/\([.%]\) /\1/g' -e 's/ , /,/g' -e 's/ :/:/g' -e 's/\$$/#/g' > $@
else
ifeq (@host_cpu@,m68k)
${ASMFILES_S} : %.s : %.cc
ifeq (@AS_UNDERSCORE@,true)
	${CXXCPP} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -P ${ASMFLAGS} $< | sed -e 's/\\#/#/g' -e 's/\$$//g' > $@
else
	${CXXCPP} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -P ${ASMFLAGS} $< | sed -e 's/\\#/#/g' -e 's/\$$/%/g' > $@
endif
else
ifeq (@host_cpu@,hppa)
${ASMFILES_S} : %.s : %.cc
	-${CXXCPP} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -P ${ASMFLAGS} $< > $@
else
${ASMFILES_S} : %.s : %.cc
	${CXXCPP} ${CXXFLAGS} ${CPPFLAGS} ${TARGET_ARCH} -P ${ASMFLAGS} $< > $@
endif
endif
endif

ifeq (@host_cpu@,hppa)
# Only the native as groks the .SHORTDATA statements
${ASMFILES_LO} : %.lo : %.s
	${LIBTOOL_COMPILE} ${CC} ${CFLAGS} ${TARGET_ARCH} -c $< \
	|| COMPILER_PATH=/usr/ccs/bin ${LIBTOOL_COMPILE} ${CC} ${CFLAGS} ${TARGET_ARCH} -c $< \
	|| COMPILER_PATH=/bin ${LIBTOOL_COMPILE} ${CC} ${CFLAGS} ${TARGET_ARCH} -c $<
else
${ASMFILES_LO} : %.lo : %.s
	${LIBTOOL_COMPILE} ${CC} ${CFLAGS} ${ASMFLAGS} ${TARGET_ARCH} -c $<
endif

endif


ifeq (${SUBDIR},.)

${ALLOBJECTS_LO} : ${SUBDIRS_TARGET_ALL}

libcln.la : ${LIBTOOL} ${ALLOBJECTS_LO}
	echo ${ALLOBJECTS_LO} | tr ' ' '\n' > libcln.objectlist
	${LIBTOOL_LINK} ${CXX} -o libcln.la -rpath ${libdir} -version-info ${CL_CURRENT}:${CL_REVISION}:${CL_AGE} ${LDFLAGS} ${LIBS} -objectlist libcln.objectlist

install : all force
	${MKDIR} ${DESTDIR}${libdir}
	${LIBTOOL_INSTALL} ${INSTALL_PROGRAM} libcln.la ${DESTDIR}${libdir}/libcln.la
	${MKDIR} ${DESTDIR}${includedir}/cln
	${INSTALL_DATA} ${top_srcdir}/include/cln/*.h ${DESTDIR}${includedir}/cln
	${INSTALL_DATA} ../include/cln/*.h ${DESTDIR}${includedir}/cln

installdirs : force
	${MKDIR} ${DESTDIR}${libdir}
	${MKDIR} ${DESTDIR}${includedir}/cln

uninstall : force
	${LIBTOOL_UNINSTALL} ${RM} ${DESTDIR}${libdir}/libcln.la
	${RM} -r ${DESTDIR}${includedir}/cln

check : all

mostlyclean : clean

clean : force
	${RM} *.s *.o *.lo *.a *.la *.objectlist core
	${RM} -r .libs _libs

distclean : clean
	${RM} config.status config.log config.cache Makefile

maintainer-clean : distclean

endif

force :
