Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages
The standard reconfigurable interface makefile template.

# Universal Unix Makefile for reconfigurable interface libraries
# =============================================

# Short Instructions
# ------------------

# 1. Build and install the utils library
# 2. "make -f Makefile.in boot"
# 3. "make"
# You should now have a reconfigurable library

# Long Instructions
# -----------------

# Build *and install* the basic utils distribution.  See the
# utils README for instructions.  

# Create a file Setup.in for your extension.  
# For a simple interface class called "spam" on file "spam.cc", it can
# contain a single line:
#   spam spammodule.cc
# You can build as many interfaces as you want in the same directory --
# just have a separate line for each of them in the Setup.in file.

# Note that the build process copies Setup.in to Setup, and then works
# with Setup.  It doesn't overwrite Setup when Setup.in is changed, so
# while you're in the process of debugging your Setup.in file, you may
# want to edit Setup instead, and copy it back to Setup.in later.
# (All this is done so you can distribute your extension easily and
# someone else can select the modules they actually want to build by
# commenting out lines in the Setup file, without editing the
# original.  Editing Setup is also used to specify nonstandard
# locations for include or library files.)

# Run "make -f Makefile.in boot".  This creates Makefile and
# config.cc, incorporating the values for the root directory from $UTILS_DIR
# and the platform from $PLATFORM environment variables

# Note: "make boot" implies "make clobber" -- it assumes that when you
# bootstrap you may have changed platforms so it removes all previous
# output files.

# Note: Each time you edit Makefile.in or Setup, you must run
# "make Makefile" before running "make".

# Hint: if you want to use VPATH, you can start in an empty
# subdirectory and say (e.g.):
#   make -f ../Makefile.in boot srcdir=.. VPATH=..


# === Bootstrap variables (edited through "make boot") ===

platform=       $(PLATFORM)

# Source directory and VPATH in case you want to use VPATH.
# (You will have to edit these two lines yourself -- there is no
# automatic support as the Makefile is not generated by
# config.status.)
srcdir=		.
VPATH=		.

include $(UTILS_DIR)/include/$(PLATFORM)/UtilsFlags.mk
include $(UTILS_DIR)/include/maketools/ModUtils.mk

LIBS=		-L$(INSTALL_DIR)/lib -L$(UTILS_DIR)/lib \
		$(LIB_NAME) $(MODLIBS) $(EXTRA_LIBS) $(UTILS_LIBS)

# === Variables that you may want to customize (rarely) ===

# (Static) build target
TARGET=		$(LIB_NAME)

SUPPORT=

default: all

# These two variables can be set in Setup to merge interfaces.
BASELIB=	
BASESETUP=	

# === Variables set by makesetup ===

INTERFACE_NAME= _INTERFACE_NAME_
MODOBJS=	_MODOBJS_ 
MODLIBS=	_MODLIBS_
MODTESTS=       _MODTESTS_

# === Definitions added by makesetup ===

# === Variables from configure 

ifndef PLATFORM
  PLATFORM := $(shell $(UTILS_DIR)/bin/config.guess)
  $(warning PLATFORM not defined, please set to '$(PLATFORM)')
endif

INSTALL_PROGRAM=${INSTALL} -m $(EXEMODE)
INSTALL_DATA=	${INSTALL} -m $(FILEMODE)

# Install prefix for architecture-independent files
prefix=		$(INSTALL_DIR)

# Install prefix for architecture-dependent files
exec_prefix=	$(prefix)
exec_installdir = $(prefix)/bin

# === Fixed definitions ===

# Shell used by make (some versions default to the login shell, which is bad)
SHELL=		/bin/sh

# Expanded directories
BINDIR=		$(INSTALL_DIR)/bin
LIBDIR=		$(INSTALL_DIR)/lib
INCLUDEDIR=	$(UTILS_DIR)/include

# Detailed destination directories
TOOLUT=	$(INCLUDEDIR)/maketools
LIBP=		$(exec_installdir)/lib

CONFIG=		$(INCLUDEDIR)/$(PLATFORM)

UTILSLIBS=	$(LIBP)/$(INTF_TYPE).a

MAKESETUP=	$(TOOLUT)/makesetup
MAKEFILE=	$(CONFIG)/Makefile.utils
CONFIGCIN=	$(TOOLUT)/config.cc.in
LIB_NAME=       lib$(INTERFACE_NAME).a
INTERFACE_INC=  ..

SYSLIBS=	

ADDOBJS+=	config.o

CPPFLAGS = $(DEFS) $(USERFLAGS) -I$(INTERFACE_INC) \
		-I$(INSTALL_DIR)/include -I$(INCLUDEDIR) 
CXXFLAGS = $(OPT) 
CFLAGS = $(CXXFLAGS)
FILEMODE=	644
CXXDEPPAT = $(SHELL) -ec '$(CXX) -M % $(DEPFLAGS) $(CPPFLAGS) $< \
		| sed '\''s/\($*\.o\)[ :]*/\1 $@ : /g'\'' > $@ '
CDEPPAT = $(SHELL) -ec '$(CC) -M % $(DEPFLAGS) $(CPPFLAGS) $< \
		| sed '\''s/\($*\.o\)[ :]*/\1 $@ : /g'\'' > $@ '

# === Fixed rules ===

FLAG_FILE = $(INTERFACE_NAME).mk
FLAG_SUPPORT_LIBS = $(USERLIBS) $(BASEMODLIBS) $(EXPORTLIBS) 
FLAG_LIBS = -l$(INTERFACE_NAME) $(FLAG_SUPPORT_LIBS)

# Build everything
all:		$(SUPPORT) $(TARGET) $(INSTALLS) $(BINTARGETS) $(FLAG_FILE)

.PHONY: $(FLAG_FILE)
$(FLAG_FILE):
	@echo "$(INTERFACE_NAME)_LIBS = $(FLAG_LIBS)" > $(FLAG_FILE)
	@echo "$(INTERFACE_NAME)_SUPPORT = $(FLAG_SUPPORT_LIBS)" >> \
		$(FLAG_FILE)
	@echo "INTF_LIBS := \$$(INTF_LIBS) $(FLAG_LIBS)" >> $(FLAG_FILE)

install:	all
		@if test ! -d $(INSTALL_DIR)/lib; then \
			mkdir $(INSTALL_DIR)/lib; \
		fi; 
		@if test ! -d $(INSTALL_DIR)/include; then \
			mkdir $(INSTALL_DIR)/include; \
		fi; 
		@if test ! -d $(INSTALL_DIR)/bin; then \
			mkdir $(INSTALL_DIR)/bin; \
		fi; 
		$(INSTALL_DATA) $(TARGET) $(INSTALL_DIR)/lib
		${RANLIB} -t $(INSTALL_DIR)/lib/$(LIB_NAME)
		@if test ! -d $(INSTALL_DIR)/include/$(INTERFACE_NAME); then \
			mkdir $(INSTALL_DIR)/include/$(INTERFACE_NAME); \
		fi; 
		$(INSTALL_DATA) $(INTERFACE_INC)/$(INTERFACE_NAME)/$(INTERFACE_NAME).h $(INSTALL_DIR)/include/$(INTERFACE_NAME)	
		$(INSTALL_DATA) Makefile $(INSTALL_DIR)/include/$(INTERFACE_NAME) 
		@if test ! -z "$(INSTALLS)"; then \
			for prog in "$(INSTALLS)"; do \
			  $(INSTALL_PROGRAM) $$prog $(INSTALL_DIR)/bin; \
			done ; \
			echo "Installing $(INSTALLS)"; \
		fi;
		$(INSTALL_DATA) $(FLAG_FILE) $(INSTALL_DIR)/include/$(INTERFACE_NAME)
#ADDINSTALLS

# Build the library containing our extension modules
$(LIB_NAME):		$(MODOBJS) $(ADDOBJS)
		-rm -f $(LIB_NAME)
		$(AR) cr $(LIB_NAME) $(MODOBJS) $(ADDOBJS)
		$(RANLIB) $(LIB_NAME) 

# This runs makesetup *twice* to use the BASESETUP definition from Setup
config.cc Makefile:	Setup $(BASESETUP) $(MAKESETUP) Makefile.in
		@echo "Generating files"
		@$(MAKESETUP) \
		 -m Makefile.in -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
		@$(MAKE) -f Makefile do-it-again

# Internal target to run makesetup for the second time
do-it-again:  	$(FLAG_FILE)
		@$(MAKESETUP) \
		 -m Makefile.in -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)

# Make config.o from the config.cc created by makesetup
config.o:	config.cc
		$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c config.cc

# Setup is copied from Setup.in *only* if it doesn't yet exist
Setup:
		cp $(srcdir)/Setup.in Setup

# Bootstrap target
boot:	clobber
	$(MAKE) -f $(srcdir)/Makefile.in VPATH=$(VPATH) srcdir=$(srcdir) \
		Makefile

# Handy target to remove intermediate files, backups, and tests
clean:
		-rm -f *.o *~ $(EXTRA_CLEANS)
		-rm -f $(MODTESTS)

# Handy target to remove everything that is easily regenerated
clobber:	clean
		-rm -f *.a tags TAGS config.cc $(TARGET) 



# Handy target to remove everything you don't want to distribute
distclean:	clobber
		-rm -f Makefile Setup *.d

%.d: %.cc 
	@echo Generating dependencies for $<
	@$(SHELL) -ec '$(CXX) -M $(1) $(DEPFLAGS) $(CPPFLAGS) $< \
		| sed '\''s/\($*\.o\)[ :]*/\1 $@ : /g'\'' > $@ '

%.d: %.c
	@echo Generating dependencies for $<
	@$(SHELL) -ec '$(CC) -M $(1) $(DEPFLAGS) $(CPPFLAGS) $< \
		| sed '\''s/\($*\.o\)[ :]*/\1 $@ : /g'\'' > $@ '

Generated on Tue Sep 7 20:37:59 2004 for ModUtils by doxygen 1.3.8