# Generic Makefile for PARI programs -- ix86 running freebsd 32-bit version
#
#  This file was created by Configure. Any change made to it will be
#  lost when Configure is run.
#
# make all will create
#  matexp-dyn (linked dynamically with libpari)
#  matexp-sta (linked statically)
#  libmatexp.so (to be used by "install" under GP)
#
# Under GP: install(matexp, Gp, mexp, "./libmatexp.so") enables you to
# subsequently use mexp to call matexp (see the reference manual).
#

# change this TARGET to compile your own programs
TARGET = matexp
SHELL  = /bin/sh

DBGFLAGS   = -g -Wall -Wno-implicit -O -pipe 
CFLAGS     = -O -pipe  -DGCC_INLINE -Wall -Wno-implicit -fomit-frame-pointer -O -pipe 
#CFLAGS    = $(DBGFLAGS)

# Various linkers use different flags to force static compilation. Choose
# the one which is relevant for your installation.
#
# Solaris ld (global)
#STATIC    = -dn

# Solaris ld (toggle: no shared object accepted until -B dynamic is seen
#STATIC    = -B static

# gcc
#STATIC    = -static

CC         = cc
CPPFLAGS   = -I. -I/usr/local/include/pari
LD         = cc
LDFLAGS    = -O -pipe  -DGCC_INLINE -Wall -Wno-implicit -fomit-frame-pointer  
DLLD       = /usr/bin/ld
DLLDFLAGS  = -shared  -lc -lm
EXTRADLLDFLAGS  = 
EXTRALIBS  =

RUNPTH     = 
LIBDIR     = -L/usr/local/lib
DLCFLAGS   = 
LIBS       = -lm -lpari

RM = rm -f


OBJS = $(TARGET).o
DYN = lib$(TARGET).so
ALL = $(TARGET)-sta $(TARGET)-dyn $(DYN)

dft: $(TARGET)-dyn

all: $(ALL)

sta: $(TARGET)-sta

dyn: $(TARGET)-dyn

dynlib: $(DYN)

$(DYN): $(OBJS)
	$(DLLD) -o $@ $(DLLDFLAGS) $(OBJS) $(EXTRADLLDFLAGS)

$(TARGET)-sta: $(OBJS)
	$(LD) -o $@ $(LDFLAGS) $< $(LIBDIR) $(EXTRALIBS) $(STATIC) $(LIBS)

$(TARGET)-dyn: $(OBJS)
	$(LD) -o $@ $(LDFLAGS) $< $(RUNPTH) $(LIBDIR) $(LIBS)

%.o: %.c
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
clean:
	-$(RM) *.o $(ALL)
