########################################################################
#   Sample ALBERTA Makefile for DIM_OF_WORLD = 1                       #
########################################################################
.PHONY: all

PROGS = ellipt nonlin heat ellipt-periodic

all: $(PROGS)

DEFAULT = ellipt

prefix = /usr/local
exec_prefix = ${prefix}

# delete line, if the paths are environment variables
ALBERTA_INCLUDE_PATH = ${prefix}/include/alberta
ALBERTA_LIB_PATH = ${exec_prefix}/lib
ALBERTA_LIBEXEC_PATH = ${exec_prefix}/libexec/alberta-3.0.3

# compile flags
#
# run make with "make DEBUG=1" to get debuggable code
#
ifeq ($(DEBUG),1)
CFLAGS = -pipe -O2 -isystem /usr/local/include -fno-strict-aliasing  -O0 -ggdb3 -fno-inline -fno-builtin 
ALBERTA_DEBUG = 1
else
CFLAGS = -pipe -O2 -isystem /usr/local/include -fno-strict-aliasing  
ALBERTA_DEBUG = 0
endif
FFLAGS = 

# link flags (use "-shared" or "-static" to specify ALBERTA library type).
# Default is "-shared" if configuration permits it.
# Use "-all-static" to create a standalone, truly static binary.

LDFLAGS =  -lXm -lXt -pthread -Wl,-rpath=/usr/local/lib/gcc11  -L/usr/local/lib/gcc11 -L/usr/local/lib 

# uncomment line for using the debug library
#DEBUG = 1

include $(ALBERTA_LIBEXEC_PATH)/Makefile.alberta

########################################################################
# DFLAGS: DIM_OF_WORLD
########################################################################

DIM_OF_WORLD = 1

########################################################################
# set virtual path
########################################################################
VPATH = ./:../Common

########################################################################
# and now the applications
########################################################################

# small support library for graphics and command-line parsing
libdemo.a: libdemo.a(cmdline.o graphics.o geomview-graphics.o)
	/usr/local/bin/ranlib $@
libdemo.a(cmdline.o graphics.o geomview-graphics.o): alberta-demo.h

# the classical Poisson demo-program
ELLIPT_OFILES = ellipt.o libdemo.a

ellipt: $(ELLIPT_OFILES) $(ALBERTA_INCLUDE_PATH)/alberta.h
	$(LINK) $(ELLIPT_OFILES) $(LIBS)

# the classical non-linear elliptic test problem
NONLIN_OFILES = nonlin.o nlprob.o nlsolve.o libdemo.a

nonlin: $(NONLIN_OFILES) nonlin.h $(ALBERTA_INCLUDE_PATH)/alberta.h
	$(LINK) $(NONLIN_OFILES) $(LIBS)

# the classical heat test-problem
HEAT_OFILES = heat.o libdemo.a

heat: $(HEAT_OFILES) $(ALBERTA_INCLUDE_PATH)/alberta.h
	$(LINK) $(HEAT_OFILES) $(LIBS)

# test program for periodic meshes (torus and Klein's bottle)
ELLIPT_PERIODIC_OFILES = ellipt-periodic.o libdemo.a

ellipt-periodic: $(ELLIPT_PERIODIC_OFILES) $(ALBERTA_INCLUDE_PATH)/alberta.h
	$(LINK) $(ELLIPT_PERIODIC_OFILES) $(LIBS)

################################################################################

.PHONY: clean realclean new

clean: albertaclean
	-rm -f $(PROGS) libdemo.a

realclean: clean albertarealclean

new: albertanew
