# Glue comes in two flavors, one for flat address spaces and one for base
# relative.  When gen_glue is compiled, which form of glue is generated
# when it is run depends upon whether "__no_baserel" or "__baserel" was defined
# when it was compiled.

#### Start of system configuration section. ####

srcdir =	@srcdir@
VPATH =		@srcdir@

# Common prefix for machine-independent installed files.
prefix =	@prefix@

# Common prefix for machine-dependent installed files.
exec_prefix =	@exec_prefix@

bindir =	$(exec_prefix)/bin
libdir =	$(exec_prefix)/Sys/libs

INSTALL =	@INSTALL@
INSTALL_DATA =	@INSTALL_DATA@

CC =		@CC@

CFLAGS =	@CFLAGS@
LDFLAGS =	@LDFLAGS@

RANLIB =	@RANLIB@
AR =		ar
RM =		rm -f

#### End system configuration section ####

# BASE is defined to be either "no-baserel" or "baserel" by an upper level
# makefile.  The default is "no-baserel".

BASE =		no-baserel

FLAVOR_CFLAGS =
OTHER_CFLAGS =	-fomit-frame-pointer
ALL_CFLAGS =	$(CFLAGS) $(FLAVOR_CFLAGS) $(OTHER_CFLAGS) $(INCS) $(DEFS)

DEFS =
INCS =		-I$(srcdir) -I$(srcdir)/../library -I$(srcdir)/../include
LIB =		libglue.a
SHELL =		/bin/sh

.c.o:
		$(CC) $(ALL_CFLAGS) -c $< -o $@

.s.o:
		cp $*.s x.c
		$(CC) $(CFLAGS) $(OTHER_CFLAGS) -traditional -E x.c -o x.s
		$(CC) $(CFLAGS) $(OTHER_CFLAGS) $(INCS) -c x.s -o $*.o
		$(RM) x.c x.s


all:		gen_glue $(LIB)

# Don't use $(ALL_CFLAGS) here until -fbaserel is fully working again...

gen_glue.o:	gen_glue.c $(srcdir)/../include/sys/syscall.def
		$(CC) $(CFLAGS) $(INCS) $(DEFS) -D__`echo $(BASE) | sed "s/-/_/"` -c $< -o $@

gen_glue:	gen_glue.o
		$(CC) gen_glue.o -o gen_glue

$(LIB):		gen_glue
		./gen_glue
		$(RM) __must_recompile*
		for asm in *.s; do echo $$asm ; $(CC) -c $$asm; done
		$(AR) rv $(LIB) *.o
