VPATH = ../../objc
#  GNU Objective C Runtime Makefile
#  Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
#
#  This file is part of GNU CC.
#
#  GNU CC 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, or (at your option) any later version.
#
#  GNU CC 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 CC; see the file COPYING.  If not, write to the Free Software
#  Foundation, 59 Temple Place - Suite 330,
#  Boston, MA 02111-1307, USA.

#  This makefile is run by the parent dir's makefile.
#  thisdir1=`pwd`; \
#  srcdir1=`cd $(srcdir); pwd`; \
#  cd objc; \
#  $(MAKE) $(MAKEFLAGS) -f $$srcdir1/objc/Makefile libobjc.a \
#    srcdir=$$srcdir1 tooldir=$(tooldir) AR="$(AR)" AR_FLAGS="$(AR_FLAGS)" \
#    GCC_FOR_TARGET="$$thisdir1/xgcc -B$$thisdir1/" \
#    GCC_CFLAGS="$(GCC_CFLAGS)" incinstalldir=$$thisdir1/include
#    OBJC_THREAD_FILE="$(OBJC_THREAD_FILE)"
#  Two targets are used by ../Makefile: `all' and `mostlyclean'.

SHELL=/bin/sh

.SUFFIXES: .m

OPTIMIZE= -O

srcdir = ../../objc
VPATH = $(srcdir)

AR = ar
AR_FLAGS = rc

# Define this as & to perform parallel make on a Sequent.
# Note that this has some bugs, and it seems currently necessary 
# to compile all the gen* files first by hand to avoid erroneous results.
P =

# Definition of `all' is here so that new rules inserted by sed
# do not specify the default target.
all: all.indirect

# sed inserts variable overrides after the following line.
####target overrides
# translate the version string, so it can be used on DJGPP, where only
# one dot in filename is allowed

# to avoid recursion when redefining $(version)
_version:=$(version)
__version=$(word 1,$(subst ., ,$(_version))).
version=2.8.1

SYSTEM_HEADER_DIR=$(DJDIR)/include
X_CPPFLAGS=-DSTANDARD_INCLUDE_DIR=\"\$$DJDIR/include\" \
	   -DSTANDARD_INCLUDE_COMPONENT=\"\"
FIXINCLUDES=fixinc.djgpp

# when building a native compiler for DJGPP, make the target_alias
# a shorter name, since otherwise it will produce some problems, when
# using the same gcc once with long filenames and once with short (8+3)
# filenames
ifeq ($(findstring -pc-msdosdjgpp,$(target_alias)),-pc-msdosdjgpp)
target=i386-pc-msdosdjgpp
endif

# on DJGPP the 'ln -s' does not work correctly
LN = cp -p

EXTRA_PARTS = crtf.o djgpp.djl

INSTALL_TARGET += install_extra_djgpp_files

EXTRA_GCC_OBJS += djgcc-mktemp.o
####host overrides
LIBGCC1 = libgcc1.null
CROSS_LIBGCC1 = libgcc1.null

crtf.o:	$(srcdir)/config/i386/crtfgo32.c $(GCC_PASSES) $(CONFIG_H)
	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(CRT0STUFF_T_CFLAGS) \
	  -o crtf.o -c $(srcdir)/config/i386/crtfgo32.c 

#   Replacement for DJGPP libc.a function mktemp() that excludes 
#   possibility of filename conflicts between 2 or more copies of
#   gcc running simultanously. I added -I$(DJDIR)/include before
#   $(INCLUDES) to get DJGPP specific headers included before gcc
#   specific ones (the problem is with go32.h)
#
djgcc-mktemp.o: $(srcdir)/config/i386/djgcc-mktemp.c $(CONFIG_H) 
	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
  -I$(DJDIR)/include \
  $(INCLUDES) \
  $(DRIVER_DEFINES) \
  -o djgcc-mktemp.o -c $(srcdir)/config/i386/djgcc-mktemp.c


djgpp.djl: $(srcdir)/config/i386/djgpp.djl
	cp -p $(srcdir)/config/i386/djgpp.djl djgpp.djl

#  Fixes for some installation problems under DJGPP. 
#    - strips at least some executables and enlarges stack size of some of them
#    - removes some unneeded files that are being installed
#    - copies distribution versions of specs and djgpp.djl to installation
#      directory
install_extra_djgpp_files: crtf.o
	cp -p crtf.o $(prefix)/lib/gcc-lib/djgpp/$(version)/crtf.o
	cp -p $(srcdir)/config/i386/djgpp.specs $(prefix)/lib/gcc-lib/djgpp/$(version)/specs 	
	-cp -p $(srcdir)/config/i386/crtfgo32.c $(prefix)/lib/gcc-lib/djgpp/$(version)/crtf.c
	-rm -f $(prefix)/bin/c++.exe
	-rm -f $(prefix)/bin/djgpp-gcc.exe
	-ln -s $(prefix)/bin/gxx.exe $(prefix)/bin/g++.exe
	-for file in cc1.exe cc1plus.exe cc1obj.exe f771.exe; \
	 do \
	   if [ -f $(prefix)/lib/gcc-lib/djgpp/$(version)/$$file ]; then \
		strip $(prefix)/lib/gcc-lib/djgpp/$(version)/$$file; \
		stubedit $(prefix)/lib/gcc-lib/djgpp/$(version)/$$file minstack=1536k; \
	   else true; \
	   fi; \
	 done		
	-strip $(prefix)/lib/gcc-lib/djgpp/$(version)/cpp.exe
	-for file in gcc.exe gxx.exe g77.exe; \
	 do \
	   if [ -f $(prefix)/bin/$$file ]; then \
		strip $(prefix)/bin/$$file; \
	   else true; \
	   fi; \
	done
                                               ####cross overrides
####build overrides
#

OBJC_H = hash.h objc-list.h sarray.h objc.h objc-api.h \
  NXConstStr.h Object.h Protocol.h encoding.h typedstream.h thr.h

# Now figure out from those variables how to compile and link.
all.indirect: Makefile compiler objc-runtime

compiler:
	cd ..; $(MAKE) cc1obj

objc-runtime:
	cd ..; $(MAKE) libobjc.a

# copy objc headers to installation include directory
copy-headers: 
	-rm -fr $(incinstalldir)/objc
	-mkdir $(incinstalldir)/objc
	for file in $(OBJC_H); do \
	  realfile=$(srcdir)/$${file}; \
	  cp $${realfile} $(incinstalldir)/objc; \
	  chmod a+r $(incinstalldir)/objc/$${file}; \
	done

Makefile: $(srcdir)/Makefile.in $(srcdir)/../configure
	cd ..; $(SHELL) config.status

mostlyclean:
	-rm -f *.o libobjc.a xforward fflags
clean: mostlyclean
distclean: mostlyclean
extraclean: mostlyclean

# For Sun VPATH.

