# Location of the gcc source tree and version:
GCC_SRC = /home/alex/40meg/gcc-2.7.2
GCC_VERSION = 2.7.2

CFLAGS=-O2
LDFLAGS=-s

# Special values for building a DOS version under Linux
ifdef XDOS
CC = gcc-go32
LD = gcc-go32
CXX = gcc-go32
LDXX = gcc-go32
LDFLAGS += -lgpp
CFLAGS += -DEXECUTABLE_SUFFIX='\".exe\"'
EXE = .exe
GCC_MAKE_ARGS = CC=gcc-go32 HOST_CC=cc HOST_PREFIX=loser-
MTAG = win95
else
MTAG = `uname`
endif

GCC_MAKE_ARGS += CFLAGS="$(CFLAGS)" LDFLAGS=$(LDFLAGS)
CLASS_OPTS = $(CFLAGS)

.EXPORT_ALL_VARIABLES:

### begin common section ###

INSTALL = install
VERSION_TAG := $(shell date +%y%m%d)-$(MTAG)
ROOT = /tmp
CLASS_SRC = ./class
MKDIRHIER = mkdir -p

INSTLIB = $(ROOT)/lib/gcc-lib/saturn-local-hp48/$(GCC_VERSION)
INSTBIN = $(ROOT)/bin
INSTPUB = $(ROOT)/saturn-local-hp48

PUBDIRS  := $(shell find $(shell cat make.pubfiles) -prune -type d)
PUBFILES := $(shell find $(shell cat make.pubfiles) -prune -type f)

default: usr-tree

build-lib: usr-tree1 FORCE
	$(MAKE) -C lib-source install \
	LIBDIR=$(INSTLIB) HPDIR=$(INSTPUB)/download \
	CC="$(INSTBIN)/xgcc -B$(INSTLIB)/ -I../../include" \
	CFLAGS="" CP="$(INSTALL_DATA)"

zip: hp48xgcc-$(VERSION_TAG).zip

USR_TREE = 'foreach $$t("cccp", "xgcc", "cc1") { \
	if(-e $$t && !-e "$$t$(EXE)") { unlink $$t; } \
	elsif(!-e $$t && -e "$$t$(EXE)") { unlink "$$t$(EXE)"; } }'

usr-tree: FORCE
	cd $(GCC_SRC); perl -e $(USR_TREE)
	$(MAKE) -C $(GCC_SRC) $(GCC_MAKE_ARGS) xgcc cc1 cccp
	$(MAKE) -e -C $(CLASS_SRC)
	$(MAKE) -e -C objdump

usr-tree1: $(INSTLIB) $(INSTBIN) public-files \
	  $(INSTBIN)/xgcc$(EXE) $(INSTLIB)/cc1$(EXE) $(INSTLIB)/specs \
	  $(INSTLIB)/ld$(EXE) $(INSTLIB)/as$(EXE) $(INSTLIB)/cpp$(EXE) \
	  $(INSTBIN)/objdump

$(addprefix $(INSTPUB)/,$(PUBDIRS)):
	$(INSTALL) -d $@

$(addprefix $(INSTPUB)/,$(PUBFILES)): $(INSTPUB)/%: %
	$(INSTALL_DATA) $? $@

public-files: $(addprefix $(INSTPUB)/,$(PUBDIRS)) \
	      $(addprefix $(INSTPUB)/,$(PUBFILES))

hp48xgcc-$(VERSION_TAG).zip: usr-tree
	cd $(ROOT) && zip -uyr $@ usr

$(INSTBIN)/xgcc$(EXE): $(GCC_SRC)/xgcc$(EXE)
	$(INSTALL_PROG) $? $@

$(INSTLIB)/cc1$(EXE): $(GCC_SRC)/cc1$(EXE)
	$(INSTALL_PROG) $? $@

$(INSTLIB)/cpp$(EXE): $(GCC_SRC)/cccp$(EXE)
	$(INSTALL_PROG) $? $@

$(INSTLIB)/ld$(EXE): $(CLASS_SRC)/clld$(EXE)
	$(INSTALL_PROG) $? $@

$(INSTLIB)/as$(EXE): $(CLASS_SRC)/class$(EXE)
	$(INSTALL_PROG) $? $@

$(INSTLIB)/specs: gcc-target/specs
	$(INSTALL_DATA) gcc-target/specs $@

$(INSTBIN)/objdump: objdump/objdump
	$(INSTALL_PROG) $? $@

$(INSTLIB) $(INSTBIN):
	$(INSTALL) -d $@	

clean: FORCE
	$(MAKE) -C class clean

.PHONY:	FORCE



syntax highlighted by Code2HTML, v. 0.9.1