# Generic Makefile for PARI programs -- evbarm running netbsd (portable C/GMP-6.3.0 kernel) 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
#  extgcd-dyn (linked dynamically with libpari)
#  extgcd-sta (linked statically)
#  libextgcd.so (to be used by "install" under GP)
#
# Under GP: install("extgcd", "GG&&", "gcdex", "./libextgcd.so") enables
# you to subsequently use gcdex to call extgcd (see the reference manual).
#

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

DBGFLAGS   = -g -Wall -O3 -Wall -fomit-frame-pointer  -O2 -I/usr/pkg/include -I/usr/pkg/include/ncurses -I/usr/include -I/usr/pkg/include -I/usr/pkg/include/ncurses -I/usr/include
CFLAGS     = -O3 -Wall -fomit-frame-pointer -O3 -Wall -fomit-frame-pointer  -O2 -I/usr/pkg/include -I/usr/pkg/include/ncurses -I/usr/include -I/usr/pkg/include -I/usr/pkg/include/ncurses -I/usr/include
#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         = gcc
CPPFLAGS   = -I. -I/usr/pkg/include
LD         = gcc
LDFLAGS    = -O3 -Wall -fomit-frame-pointer  -O2 -I/usr/pkg/include -I/usr/pkg/include/ncurses -I/usr/include -I/usr/pkg/include -I/usr/pkg/include/ncurses -I/usr/include -Wl,--export-dynamic -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib
MODLD       = gcc
MODLDFLAGS  = -shared  $(CFLAGS) $(DLCFLAGS) -Wl,-shared
EXTRAMODLDFLAGS = 
EXTRALIBS  =

RUNPTH     = -Wl,-rpath,/usr/pkg/lib
DLCFLAGS   = 
LIBS       = -lm -L/usr/pkg/lib -lgmp -L/usr/pkg/lib -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)
	$(MODLD) -o $@ $(MODLDFLAGS) $(OBJS) $(EXTRAMODLDFLAGS)

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

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

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