Postscript Warning

I do not use prototype anymore; it is therefore not anymore maintained. If something breaks (ie, due to compiler changes) then feel free to tell me and I'll fix it. For my own projects I now use a project generator, which generates a full-blown cwautomacros/cdeh/automake/autoconf/libtool/doxygen/etc project; this is still work IN PROGRESS, but you can see a preview here. The generator itself is not online yet, mail me if you're interested.

Introduction

Prototype Makefiles allows very fast project start ups: often no editing of Makefiles is needed at ALL.

Prototype Makefiles is a collection of shared Makefiles which are installed globally, and Makefile templates that can be copied into project directories using a simple script.  The shared Makefiles contain the rules for building a project, cleaning it and making dependencies etc.  The Makefile templates contain the data that is specific for each project.  This separation avoids duplication of code in Makefiles and is therefore extremely easy to maintain and extend.

Quick start

Installation

  1. Download the tar ball below.

  2. Unpack it with:

        tar xzf prototype-1.10.tar.gz
    

    This creates a subdirectory called prototype-1.10 in the current directory.

  3. cd into prototype-1.10:

        cd prototype-1.10
    
  4. Pick a directory where you want to install the shared stuff:

        ./configure --prefix=/usr --datadir=/usr/share
    

    See the INSTALL file for the meaning of the options.

    New (as of version 1.8)

    If you are upgrading prototype and you have already installed an older version, then you can just type:

        ./configure
      

    and it will determine the prefix and datadir that you used before.


  5. Install the package:

        make install
    

    (Or  gmake install  if you are using FreeBSD)

  6. The environment variable PROTODIR should point to the prototype installation directory ($(datadir)/prototype, where $(datadir) is set with --datadir while running ./configure, see the INSTALL file).

    As an example, if you use bash as your shell, you could add to your ~/.profile the following line,

        export PROTODIR=/usr/share/prototype
    
  7. Edit $PROTODIR/Makedefs.h to set your own prefered default values for CFLAGS and CXXFLAGS.  Please note that this file is overwritten the next time you upgrade (I'll fix that some day).

  8. To test the successful installation (all of the above), run the command:

        make test
    

Usage

Now you are ready to use the prototype Makefiles.

  1. Create a new project directory and change directory into it:

        mkdir myProject
        cd myProject
    
  2. Generate the base (project) Makefile:

        makeproto
    

    Note that you can not put sources in this directory, it wouldn't belong to anything.
    Instead create a `main', `lib' or `sub' directory. For instance:

  3. Create a directory and Makefile for the (or a) main executable:

        mkdir aProgram
        cd aProgram
        makeproto main
    

  4. Write code and just type make when you want to compile it!

Please, also read the README file that comes with the package.

Example

Below is given a Real Life (tm) project Makefile for a large and complex shared library which is divided up over several sub directories (the Makefiles in each of these subdirectories are not given, but look similar - with only data specific for that directory). This file is everything that needs maintenance for this sub directory. Everything that was added manually is made bold, the rest was generated by typing `makeproto lib':

  # Directory where the base Makefile resides:
  BASEDIR=../..

  # Library name, for example: "LIB=foo" -> libfoo.so and libfoo.a
  # The version of the library is read from .$(LIB).version (which is
  # automatically incremented 1 Minor Version every time you (re)install.
  LIB=cw

  # List of subdirectories:
  SUBDIRS:=$(shell list=`/bin/ls -1 -t | egrep -v '^(CVS|include)$$'`; for i in $$list; do if test -d $$i; then echo $$i; fi; done)

  # List of source files:
  CXXSRC:=$(shell /bin/ls -1 -t -F *$(CPPEXT) 2>/dev/null | grep '\$(CPPEXT)$$')

  # Library specific include flags, for example: -I$(BASEDIR)/include or -I.
  INCLUDEFLAGS=

  # Extra static libraries to link with:
  STATICLIBS=

  # Extra shared libraries to link with:
  SHAREDLIBS=-lcwd

  # Put here extra -L... flags
  LIBFLAGS=

  #-----------------------------------------------------------------------------

  include $(PROTODIR)/lib/PTMakefile

  #clean::
  #depend::
  #build::

  version.cc: Makefile .cw.version
	  echo "char const* libcw_version = \"$(VERSION)\";" > version.cc

  real-clean::
	  $(RM) -f version.cc

  include .cw.version

  CW_MAJOR:=$(VERSION_MAJOR)
  CW_MINOR:=$(VERSION_MINOR)
  CW_PATCH:=$(VERSION_PATCH)
  CW_VERSION:=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)

  install:
	  @( if [ -f $(BASEDIR)/lib/libcw.so.$(CW_VERSION) ]; then \
	    make .cw.install.timestamp; \
	  else \
	    echo "libcw.so.$(CW_VERSION) wasn't compiled yet"; \
	  fi )

  .cw.install.timestamp: $(BASEDIR)/lib/libcw.so.$(CW_VERSION)
	  $(INSTALL) -g $(INSTALL_GROUP) -m 755 -o $(INSTALL_OWNER) $(BASEDIR)/lib/libcw.so.$(CW_VERSION) $(LIB_DIR)
	  touch .cw.install.timestamp
	  /sbin/ldconfig
	  ln -sf $(LIB_DIR)/libcw.so.$(CW_MAJOR) $(LIB_DIR)/libcw.so
	  $(INSTALL) -d $(PREFIX)/include/libcw
	  $(INSTALL) -g $(INSTALL_GROUP) -m 644 -o $(INSTALL_OWNER) include/libcw/*.h $(PREFIX)/include/libcw
	  @echo "VERSION_MAJOR=$(CW_MAJOR)" > .cw.version
	  @echo "VERSION_MINOR=$(CW_MINOR)" >> .cw.version
	@echo "$(CW_PATCH)" | awk -- '{ printf ("VERSION_PATCH=%d\n", $$0 + 1) }' >> .cw.version

Changes in version 1.10

Changes in version 1.9

Changes in version 1.8

Changes in version 1.7

Changes in version 1.6

Changes in version 1.5

Changes in version 1.4

Changes in version 1.3

Changes in version 1.2

Changes in version 1.1

Warning: Upgrading prototype will overwrite $PROTODIR/Makedefs.h. If you made changes to that file (most likely setting a different default CFLAGS), then you'll have to redo that by hand after installing. You might want to backup $PROTODIR/Makedefs.h before installing.

Downloading

  • prototype-1.10.tar.gz