# Unix-specific GNU make file. Holds all Unix-specific build
# information. For instance, using GCC.

# $Log: GNUmake,v $
# Revision 1.7  1996/11/07 15:28:13  jont
# [Bug #1740]
# [Bug #1740]
# Make reference to app-defaults relative to source tree rather than
# to ~sml
#

GCCOPTS         = -O -ansi \
                  -Wall \
		  -Wpointer-arith \
		  -Wwrite-strings \
                  -Winline \
		  -Waggregate-return \
		  -Wmissing-prototypes \
		  -Wnested-externs

# cannot use -Wcast-align, as we regularly do things which it will warn
# 	e.g. mlval foo = f();
#            mlval bar = *(mlval *)(foo - THE_TAG_WHICH_I_KNOW)
#
# cannot use -Wcast-qual, as the prototype for XtOpenDisplay()
# does not use (const char *) arguments.
#
# cannot use -Wshadow, as we don't have a naming scheme that enforces
# it (e.g. ml_string is a function, as is exn_name, ...).
#
# cannot use -Wstrict-prototypes, because it complains (for no good
# reason) about signal-handling code like:
#
#		sv.sv_handler = SIG_IGN;
#
# cannot use -Wredundant-decls, because the Gcc-installed include
# files break this rule all the time (e.g. sys/signal.h declares
# "void (*signal())()" twice!)
#
# cannot use -Wconversion, as we frequently do use prototypes to
# force argument types, e.g. arena.c:
# 
#	extern byte *block_alloc(byte type,size_t size);
#
#       arena_init(/* ... */)
#       { /* ... */
#	  block_alloc( (byte)0, foo);
#
# Here the first argument would be converted to int if it were not for
# the prototype. On SPARC and MIPS, GCC 2.5.8 does not complain because
# ints and chars (bytes) are passed the same way so the compiler does
# not warn (and we can use -Wconversion; see the platform-specific make
# file).  However, gcc-2.7.2 warns on SPARC, MIPS and i386 so -Wconversion
# cannot be used at all any more.

DEFINEOPTS = $(DEFINES:%=-D%)

DEFINEDEBUGOPTS = $(DEFINESDEBUG:%=-D%)

INCLUDEDIRS	:= $(INCLUDEDIRS) ../app-defaults
INCLUDES = $(INCLUDEDIRS:%=-I%)

GCCOPTSDEBUG     = $(GCCOPTS) -g

GCCFLAGS      = $(DEFINEOPTS) $(INCLUDES) $(GCCOPTS) $(TARGETOPTS)
GCCFLAGSDEBUG = $(DEFINEOPTS) $(DEFINEDEBUGOPTS) $(INCLUDES) $(GCCOPTSDEBUG) $(TARGETOPTSDEBUG)
GCC	    = gcc

# Use GCC for: compiling, assembling, linking, and generating dependencies.

COMPILE		= $(GCC)
COMPILEFLAGS	= $(GCCFLAGS) -c -o 
COMPILEFLAGSDEBUG = $(GCCFLAGSDEBUG) -c -o 

ASM	       = $(GCC)
ASMFLAGS       = $(GCCFLAGS) -c -o 
ASMFLAGSDEBUG  = $(GCCFLAGSDEBUG) -c -o 

LINK            = $(GCC)
LINKFLAGS       = $(GCCFLAGS) -B/bin/ -o 
LINKFLAGSDEBUG  = $(GCCFLAGSDEBUG) -B/bin/ -o 

LINKENDFLAGS       = 
LINKENDFLAGSDEBUG  = 

DEPENDGEN          = $(GCC)
DEPENDGENFLAGS     = $(GCCFLAGS) -MM


#
# ERRNO_HEADER is the name of the file that contains all the error
# number #defines.  On most machines it is in /usr/include/sys/errno.h
# and so that is the default that is used if ERRNO_HEADER is not overriden
# in the OS/ARCH specific GNUmake (see rts/src/OS/Linux/arch/I386/GNUmake
# for an example of this being overriden).
#
ifeq (,$(ERRNO_HEADER))
  ERRNO_HEADER = /usr/include/sys/errno.h
endif



# Since this file is included by ../../../GNUmakefile before the "all" 
# target is defined, any system specific rules will be hit instead of
# all if no specific target is requested.  The following ensures that
# the default "all" rule is hit instead.

unixall: all



gen/$(ARCH)/$(OS)/os_errors.c: awk/unix_os_errors_c.awk
	@echo 'MAKE: $< -> $@'
	@$(MKDIR) gen/$(ARCH)/$(OS) $(MKDIREND)
	@$(AWK) -f awk/unix_os_errors_c.awk < $(ERRNO_HEADER) > $@
