DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: M T

⟦a0a7cbd25⟧ TextFile

    Length: 12860 (0x323c)
    Types: TextFile
    Names: »Makefile«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦cc8755de2⟧ »./libg++-1.36.1.tar.Z« 
        └─⟦23757c458⟧ 
            └─⟦this⟧ »libg++/proto-kit/Makefile« 

TextFile

# Makefile for libg++ prototype files
#   Copyright (C) 1989 Free Software Foundation, Inc.
#   written by Carl Staelin

#This file is part of GNU libg++.

#GNU libg++ is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 1, or (at your option)
#any later version.

#GNU libg++ is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with GNU libg++; see the file COPYING.  If not, write to
#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

#******************************************************************************
#  This GNUmakefile is useful for large and complex projects which involve
# both G++ library prototypes, and prototypes added by the user(s).  It 
# is assumed that certain conventions are followed.
#
# 1) each object has its own source and header files.  For example class W 
#    would have W.h and W.cc
#
# 2) each prototype object has its own source and header files (W.hP and W.ccP)
#
# 3) object header files are contained in directory $(IDIR) (for Include
#    DIRectory)
#
# 4) object source files are contained in the current directory
#
# 5) prototype instantiations are contained in $(PC) (for Prototype C++
#    directory)
#
# 6) user prototype files (both header and source) are contained in $(IPP)
#
# 7) non-class code is contained in .h and .cc files, which live in $(IDIR)
#    and the current directory respectively
#
# 8) for each class W, W_p is defined as a type which is the pointer to W
#
# *) as an extra, I have added the convention that whenever a W.cc file
#    is being compiled, the macro _W_cc is defined.  This is useful
#    particularly for conditional parts of header files (for example,
#    W.h could have ifdef _W_cc ...
#
# The makefile works in the following manner: the source dependencies are
# contained in .Makefile.S_DEP, while the (machine generated) object 
# dependencies are contained in .Makefile.O_DEP.  The types needed by
# the program are defined by several variables, and the makefile generates
# the necessary dependencies (both source and object) from those variables.
#
#  -- Carl Staelin
#     staelin@princeton.edu
#******************************************************************************

#******************************************************************************
# standard Makefile definitions

comma := ,
space := $(empty) $(empty)
tab := $(empty)	$(empty)

#******************************************************************************
# Basic definitions

# GNU directories
GNULIBDIR=/usr/local/lib
GNUIDIR = $(GNULIBDIR)/g++-include

# the g++ prototypes...
LPP = $(GNUIDIR)
PC = ../libg++

# the user's prototypes...
IPP = ../proto

# the include directory
IDIR = ../include

# the G++ include directories (for use in C++-FLAGS)
IDIRS = -I$(IDIR) -I$(PC) -I$(GNUIDIR) 

# the directories where the libraries live (for use in C++-FLAGS)
LDIRS = -L$(PC) 

#******************************************************************************
# standard function (and associated variables) definitions

C++ = g++
C++FLAGS = -pipe $(IDIRS) 

GENCLASS = genclass.extnsn
PREPEND  = prepend-header
CONVERT_DEPENDENCIES = convert-dependencies 

#******************************************************************************
# implicit rules

%.o : %.cc
	$(C++)	$(C++FLAGS) \
		-D$(strip $(subst .,_, _$(basename $(@F))_cc)) \
		-c -o $@ $(@D)$(basename $(@F)).cc

#******************************************************************************
# ipcress (object code) library definitions

PROTOLIBDESIGNATOR = p

PROTOLIB = $(PC)/lib$(PROTOLIBDESIGNATOR).a

LIBS = -l$(PROTOLIBDESIGNATOR)

#******************************************************************************
# types which do not have a class associated with them.  For example
# int, and l_u_int (long unsigned int)

BASIC_TYPES = \
	int \
	l_u_int 


#******************************************************************************
# User types -- these are the user's classes

TYPES =  \
	User_class_1 \
	User_class_2 \
	User_class_3

#******************************************************************************
# User files 

HEADER_FILES = \
	include \
	utils 

SOURCE_FILES = \
	utils

#******************************************************************************
# source files...

HEADERS = $(addprefix $(IDIR)/, $(addsuffix .h, $(TYPES) $(HEADER_FILES))) 

SOURCES = $(addsuffix .cc, $(TYPES) $(SOURCE_FILES))

OBJECTS = $(addsuffix .o, $(TYPES) $(SOURCE_FILES))

#******************************************************************************
# libg++ prototype instantiations

LIB_PROTO_FILES = \
	User_class_3_p.Set \
	User_class_3_p.AVLSet \
	User_class_1_p.SLList \
	User_class_1User_proto_1_p.Set \
	l_u_int.DLList \
	l_u_int.User_class_2User_proto_1_p.Map \
	l_u_int.User_class_2User_proto_1_p.AVLMap 

LIB_PROTO_HEADER_FILES = \
	User_class_1.defs \
	User_class_1_p.defs \
	User_class_3.defs \
	User_class_3_p.defs \
	User_class_1User_proto_1.defs \
	User_class_1User_proto_1_p.defs \
	l_u_int.defs 
	
LIB_PROTO_HEADERS = $(addprefix $(PC)/, $(addsuffix .h, $(LIB_PROTO_FILES) $(LIB_PROTO_HEADER_FILES))) 

LIB_PROTO_SOURCES = $(addprefix $(PC)/, $(addsuffix .cc, $(LIB_PROTO_FILES))) 

LIB_PROTO_OBJECTS = $(addsuffix .o, $(basename $(LIB_PROTO_SOURCES))) 

#******************************************************************************
# User prototype instantiations

PROTO_FILES = \
	User_class_1.User_proto_1 \
	User_class_2.User_proto_1

# some user prototypes have just a header class definition file (.h)
PROTO_HEADER_FILES = 

PROTO_HEADERS = $(addprefix $(PC)/, $(addsuffix .h, \
		$(PROTO_FILES) $(PROTO_HEADER_FILES)))

PROTO_SOURCES = $(addprefix $(PC)/, $(addsuffix .cc, $(PROTO_FILES)))

PROTO_OBJECTS = $(addsuffix .o, $(basename $(PROTO_SOURCES)))

PROTO_TYPE_SOURCES = $(addsuffix P, $(PROTO_HEADERS) $(PROTO_SOURCES))

#*****************************************************************************
# program(s) to be made

program : $(OBJECTS) $(PROTOLIB) program.o
	$(C++) $(C++FLAGS) -o program program.o $(OBJECTS) $(LDIRS) $(LIBS)

#******************************************************************************
# various cleanup stuff...

.PHONY : rmback clean realclean

rmback : 
	cd .. ; rm -f proto/*~ include/*~ src/*~

clean : rmback
	rm -f $(OBJECTS) $(PROTOLIB) $(LIB_PROTO_OBJECTS) $(PROTO_OBJECTS)

realclean : clean
	rm -f $(LIB_PROTO_SOURCES) $(PROTO_SOURCES) $(LIB_PROTO_HEADERS) $(PROTO_HEADERS)

#******************************************************************************
# library dependencies

$(PROTOLIB) : $(LIB_PROTO_OBJECTS) $(PROTO_OBJECTS)
	rm -f $(PROTOLIB) ; \
	ar q $(PROTOLIB) $(LIB_PROTO_OBJECTS) $(PROTO_OBJECTS) ; \
	ranlib $(PROTOLIB)

#******************************************************************************
# "functions" for creating library source code from prototypes

components = $(subst .,$(space),$(notdir $(basename $@)))
ifdef_filename = $(subst .,_,$(notdir $(basename $@)))

first-parameter = $(word 1, $(components))
second-parameter = $(word 2, $(three-parts-q))
generic-type = $(word $(words $(components)), $(components))

debug.type.gen.h : 
	@ echo '$$(components) = $(components)' ;
	@ echo '$$(words $$(components)) = $(words $(components))' ;
	@ echo '$$(word $$(words $$(components)), $(components)) = $(word $(words $(components)), $(components))' ;

# are there three parts to the generic file name?
three-parts-q = $(subst 3,$(components),$(filter 3, $(words $(components))))

# is the first generic parameter a val parameter?
first-val-q = $(filter %_p, $(first-parameter)) $(filter-out %_p, $(foreach basic-type, $(BASIC_TYPES), $(filter $(basic-type), $(first-parameter))))

#
# is the second paramter a val parameter? (if there is a second parameter)
#     - if there is a second parameter then there are two copies of the second
#       parameter.  
#     - if the parameter is a "val" type, then there is one copy of the type
#     - if the parameter is a "ref" type, then do nothing.
#
# hence the cases are:
#    - there exists a second type
#      - it has type "val": there are three words on the output string
#      - it has type "ref": there are two words on the output string
#    - there isn't a second type: there are 0 or 1 words on the output string
#
second-val-q = $(foreach offset, 1 2, $(second-parameter)) \
  $(filter %_p, $(second-parameter)) $(filter-out %_p, $(foreach basic-type, $(BASIC_TYPES), $(filter $(basic-type), $(second-parameter))))

define make-defs-file
( \
  echo '#ifndef $(patsubst %, _%_h', $(ifdef_filename)) ; \
  echo '#define $(patsubst %, _%_h', $(ifdef_filename)) ; \
  echo $(patsubst %_p, '#include "%.defs.h"', $(first-parameter)) ; \
  echo '#define $(patsubst %_p, %_pEQ(a$(comma)b), $(first-parameter)) \
    $(patsubst %_p, %EQ(*(a)$(comma)*(b))', $(first-parameter)) ; \
  echo '#define $(patsubst %_p, %_pLE(a$(comma)b), $(first-parameter)) \
    $(patsubst %_p, %LE(*(a)$(comma)*(b))', $(first-parameter)) ; \
  echo '#define $(patsubst %_p, %_pCMP(a$(comma)b), $(first-parameter)) \
    $(patsubst %_p, %CMP(*(a)$(comma)*(b))', $(first-parameter)) ; \
  echo '#define $(patsubst %_p, %_pHASH(x), $(first-parameter)) \
    $(patsubst %_p, %HASH(*(x))', $(first-parameter)) ; \
  echo '#endif $(patsubst %, _%_h', $(ifdef_filename)) ; \
) > $@ 
endef

define make-proto-file
$(GENCLASS) \
  $(dir $<) \
  $(dir $@) \
  $(suffix $@) \
  $(patsubst %,-2, $(word 1, $(three-parts-q))) \
  $(first-parameter) \
  $(patsubst %,val, $(first-val-q)) \
  $(patsubst %,ref,$(filter 0, $(words $(first-val-q)))) \
  $(second-parameter) \
  $(patsubst %,val, $(filter 3, $(words $(second-val-q)))) \
  $(patsubst %,ref, $(filter 2, $(words $(second-val-q)))) \
  $(generic-type)
endef


define prepend-proto-includes
$(PREPEND) \
  $(addsuffix .h, $(basename $@)) \
  '#include "include.h"' \
  $(patsubst %, '#include "%.h"', $(foreach proto, $(TYPES) $(LIB_PROTO_FILES) $(LIB_PROTO_HEADER_FILES) $(PROTO_FILES) $(PROTO_HEADER_FILES), $(patsubst %, $(proto), $(filter $(subst .,,$(proto)), $(patsubst %_p, %, $(first-parameter) $(second-parameter))))))
endef

ifeq (TRUE,FALSE)

endif
#******************************************************************************
# libg++ prototype dependencies

$(addprefix $(PC)/, $(addsuffix .h, $(filter-out char_p.defs, \
  $(filter %_p.defs, $(LIB_PROTO_HEADER_FILES))))) : 
	echo creating $@ ; \
	$(make-defs-file) ;

lib_proto_intermediate_sources = \
$(filter-out %_p.defs.h, $(LIB_PROTO_HEADERS) $(LIB_PROTO_SOURCES)) \
$(addprefix $(PC)/, $(addsuffix .h, char_p.defs)) 

lib_type_and_suffix_list = $(sort $(join $(suffix $(basename $(lib_proto_intermediate_sources))), $(addprefix ., $(suffix $(lib_proto_intermediate_sources)))))

#******************************************************************************
# user prototype dependencies

proto_intermediate_sources = \
	$(PROTO_HEADERS) \
	$(PROTO_SOURCES) 

type_and_suffix_list = $(sort $(join $(suffix $(basename $(proto_intermediate_sources))), $(addprefix ., $(suffix $(proto_intermediate_sources)))))

#******************************************************************************
# generate machine generated dependencies 

H_FILES  = $(HEADERS) $(LIB_PROTO_HEADERS) $(PROTO_HEADERS)
CC_FILES = $(SOURCES) $(LIB_PROTO_SOURCES) $(PROTO_SOURCES)

DEPENDENCIES = $(addsuffix .d, $(basename $(CC_FILES)))

$(addsuffix .d, $(basename $(CC_FILES))) : %.d : %.cc
	$(C++) -M $(C++FLAGS) $< | \
		$(CONVERT_DEPENDENCIES) $(dir $@) | \
		sort -u | 
		sed 's?$(LPP)?$$(LPP)?g'  | \
		sed 's?$(PC)?$$(PC)?g' > $@ ; 

$(DEPENDENCIES) : $(H_FILES)

.PHONY : dependencies source-dependencies object-dependencies 

dependencies : source-dependencies object-dependencies 

object-dependencies : $(DEPENDENCIES) 
	@echo making object dependencies ; \
	cat $(sort $(DEPENDENCIES)) > .Makefile.O_DEP ;

source-dependencies : 
	@ echo making source dependencies... ; \
	( \
	  $(foreach type, $(lib_type_and_suffix_list), echo '%.$(type) : $$(LPP)/$(type)P'; echo '$(tab)$$(make-proto-file) ; $(patsubst %, $$(prepend-proto-includes);, $(filter h, $(suffix $(type))))'; echo ; ) \
	  $(foreach type, $(type_and_suffix_list), echo '%.$(type) : $$(IPP)/$(type)P'; echo '$(tab)$$(make-proto-file) ; $(patsubst %, $$(prepend-proto-includes);, $(filter h, $(suffix $(type))))'; echo;) \
	) > .Makefile.S_DEP ;


#******************************************************************************
# include machine generated dependencies 

include .Makefile.S_DEP
include .Makefile.O_DEP