
export SRCDIR

DEFAULT_ARCHITECTURE := $(shell $(SRCDIR)/config.guess)
ifndef ARCHITECTURE
ARCHITECTURE = $(DEFAULT_ARCHITECTURE)
endif

## Linux
ifneq (,$(findstring linux,$(ARCHITECTURE)))
# Here CC must be gcc if you want to build shared libraries,
# and you cant uncomment the -fomit-frame-pointer in the definition
# of CSOFLAGS if you feel adventurous or you have gcc 2.7.0, for which
# this optimization seems to work even with -fpic.
prefix		= /usr

CC		=gcc
CMDFLAGS	=-MM		#make depend
COFLAGS		=-fomit-frame-pointer #non-pic c compile
CSOCCFLAGS      =-fomit-frame-pointer -fpic #pic c compile
CSOCMD          =gcc		#link shared lib command
CSOFLAGS        = -shared -Wl,-soname -Wl,$(SONAME) #link shared lib flags
CUSESHLIBFLAGS	=
CFLAGS		=-I. -O3 -D_BSD_SOURCE #flags for all compiles
INS		=install -m 644	#text install
INSS		=install -m 755	#install shared lib
INSX		=install -m 755	#install executable
INSL		=cp -p

SHLIB_EXT       = so
RANLIB		=ranlib
AR		=ar
ARFLAGS		=r

endif

## HPUX
ifneq (,$(findstring hpux,$(ARCHITECTURE)))
prefix          = /usr/local

CC              =gcc
CMDFLAGS        =-MM
COFLAGS         =
CSOCCFLAGS      =-fpic
CUSESHLIBFLAGS	=-Xlinker +s
CSOCMD          = gcc 
CSOFLAGS        = -shared -fpic
CFLAGS          = -I. -g -O3

# look for gnu install
ifneq (,$(shell install --version 2>/dev/null | grep GNU))
INSTALL = install
else
INSTALL = $(SRCDIR)/bsdinst
endif

INS             = $(INSTALL) -m 644
INSS		= $(INSTALL) -m 555
INSX            = $(INSTALL) -m 755
INSL            =cp -p

SHLIB_EXT       = sl
RANLIB          =ranlib
AR              =ar
ARFLAGS         =rc
endif

## Alpha
ifneq (,$(findstring alpha,$(ARCHITECTURE)))
prefix          = /usr/local

CC              =cc
CMDFLAGS        =-M
COFLAGS         =
CSOCCFLAGS      = 
CSOCMD          = ld
CSOFLAGS        = -shared -no_archive -expect_unresolved "*" -L$(LIB) -rpath $(LIB) -soname $(SONAME)
CFLAGS          =-I. -I$(INC) -O2 -Olimit 2900
INS             =install -m 644
INSS            =install -m 755
INSX            =install -m 755
INSL            =cp -p

SHLIB_EXT       = so
RANLIB          =ranlib
AR              =ar
ARFLAGS         =rc
endif


## Common defines
LIB		=$(prefix)/lib
INC		=$(prefix)/include
BIN		=$(prefix)/bin
MAN		=$(prefix)/man
MAN1		=$(MAN)/man1
MAN3		=$(MAN)/man3
MAN5		=$(MAN)/man5
