# # Copyright (c) 1994, 1995, 1996 Gunther Schadow. All rights reserved. # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. include $(TOPDIR)/config.mk ifndef ROOTDIR ROOTDIR := $(TOPDIR) HAVE_ROOT = else HAVE_ROOT = YES endif PG_VERSION = 1.3 # # Variables # PATH := $(TOPDIR)/bin:$(PATH):/usr/local/bin COPT += -fno-implicit-templates override CFLAGS += -DPROTOGEN $(INCLUDE) $(DEFINES) LDFLAGS += $(LDOPT) $(LNCLUDE) $(LIBOPTS) INCLUDE += -I. -I$(ROOTDIR)/include -I$(TOPDIR)/include LNCLUDE += -L. -L$(ROOTDIR)/lib -L$(TOPDIR)/lib LOADLIBES := $(LOADLIBES) -lpg -lg++ -lstdc++ -lgdbm -lm $(EXTRALIBS) JUNK += GNUmakefile.bak $(OBJS) *~ a.out *.core core *.o *.a *.log \ *.so lib*.so* #DISTJUNK+= ifdef HAVE_ROOT include $(ROOTDIR)/GNUmakefile.inc endif # # Explicite rules # PHONIES = all lib clean distclean source depend sourceclean sourcesave progs .PHONY: $(PHONIES) %.all: @subdirs="$(SUBDIRS)" ;\ for i in $$subdirs ;\ do \ echo Making $@ in $$i ; \ ( $(CD) $$i; $(MAKE) $@ ) ; \ done ; \ $(MAKE) $* # # Default rules # clean: rm -f $(JUNK) distclean: undepend rm -f $(JUNK) $(DISTJUNK) depend: @echo depending in `pwd` @sed -n \ -e "1,/^### Do not change this line, make depend uses it! ###/p"\ GNUmakefile > /tmp/mkf$$$$ ; \ $(CC) $(CFLAGS) -M $(C_SRCS) $(CC_SRCS) >> /tmp/mkf$$$$ ; \ $(MV) GNUmakefile GNUmakefile.bak ; \ $(MV) /tmp/mkf$$$$ GNUmakefile undepend: @echo undepending in `pwd` @sed -n \ -e "1,/^### Do not change this line, make depend uses it! ###/p"\ GNUmakefile > GNUmakefile.bak ; \ $(MV) GNUmakefile.bak GNUmakefile progs: $(PROGS) install-bin: test -n "$(PROGS)" && $(INSTBIN) $(PROGS) $(PGBIN) || true clean-bin: $(RM) -f - $(PROGS) install: # # Library rules # LIBDIR = $(ROOTDIR)/lib INCLDIR = $(ROOTDIR)/include LIBFILE = $(LIBRARY:%=lib%.a) ifdef CSHARED SHLIB = $(LIBRARY:%=lib%.so.$(PG_VERSION)) endif ABSTOPDIR = $(shell cd $(TOPDIR) ; pwd) ABSROOTDIR= $(shell cd $(ROOTDIR) ; pwd) GENSRCDIR = $(ROOTDIR)/source$(patsubst $(ABSROOTDIR)%,%,$(shell pwd)) ifndef THISDIR THISDIR = $(patsubst $(ABSTOPDIR)/%,%,$(shell pwd)) THISDIRR= $(patsubst $(ABSROOTDIR)/%,%,$(shell pwd)) endif ifdef GENSRCS source: gensrcs-stamp $(GENSRCS) gensrcs-stamp: $(TOPDIR)/bin/pgpl $(MAKE) gensrcs touch $@ endif sourceclean: $(RM) -f $(GENSRCS) gensrcs-stamp sourcesave: if [ -n "$(GENSRCS)" ] ; \ then \ $(MKDIRHIER) $(GENSRCDIR) ; \ $(LN) $(GENSRCS) $(GENSRCDIR) ; \ fi OBJS += $(C_SRCS:.c=.o) $(CC_SRCS:.cc=.o) ifdef CSHARED SOBJS = $(OBJS:.o=.so) endif lib: $(OBJS) $(SOBJS) $(LIBFILE) $(SHLIB) $(LIBFILE):: $(OBJS) $(RM) -f $@ $(AR) -r$(ARFLAGS) $@ \ $$(lorder $(OBJS) $$(find $(SUBDIRS) -name "*.o" 2>/dev/null) \ |tsort) $(RANLIB) $@ $(SHLIB):: $(SOBJS) $(RM) -f $@ $(SHLD) -o $@ \ $$(lorder $(SOBJS) $$(find $(SUBDIRS) -name "*.so" 2>/dev/null) \ |tsort) ifdef ROOT includes: ./include $(CD) $(TOPDIR)/include ; \ $(RM) -f $(ROOT) ; \ $(LNS) $(TOPDIR)/$(THISDIR)/include $(ROOT) ; \ else includes: $(H_SRCS) if [ -n "$(H_SRCS)" ] ; then \ $(CD) $(ROOTDIR)/include ; \ $(RM) -f $(H_SRCS) ; \ $(LNS) $(H_SRCS:%=../$(THISDIRR)/%) . ; \ fi endif # # Implicite rules # # disallow direct executable make from source %: %.c %: %.cc %.o: %.cc $(CC) -c $(COPT) $(CFLAGS) -I$(GXXINCL) $< %.so: %.cc $(CC) -o $*.so -c $(COPT) $(CFLAGS) $(CSHARED) -I$(GXXINCL) $< %.o: %.c $(CC) -c $(COPT) $(CFLAGS) $< %.so: %.c $(CC) -o $*.so -c $(COPT) $(CFLAGS) $(CSHARED) $< %: %.o $(LD) $(LDFLAGS) -o $@ $^ $(LOADLIBES) rep%.cc: rep%.conf $(TOPDIR)/bin/repconf repconf $< ANY%-config.h: ANY%.conf $(TOPDIR)/bin/anyconf anyconf $<