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

PROGS = ellipt-klein-bottle ellipt-torus ellipt-sphere

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 type is "-shared", if the 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 = 4

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

########################################################################
# and now the user's files
########################################################################

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

# unorientable 2d surface embedded into 4d
ELLIPT_KLEIN_BOTTLE_OFILES = ellipt-klein-bottle.o libdemo.a

ellipt-klein-bottle: \
 $(ELLIPT_KLEIN_BOTTLE_OFILES) $(ALBERTA_INCLUDE_PATH)/alberta.h
	$(LINK) $(ELLIPT_KLEIN_BOTTLE_OFILES) $(LIBS)

# embedded S^3 \subset \R^4
ELLIPT_SPHERE_OFILES = ellipt-sphere.o libdemo.a

ellipt-sphere: $(ELLIPT_SPHERE_OFILES) $(ALBERTA_INCLUDE_PATH)/alberta.h
	$(LINK) $(ELLIPT_SPHERE_OFILES) $(LIBS)

# embedded T^3 \subset \R^4
ELLIPT_TORUS_OFILES = ellipt-torus.o libdemo.a

ellipt-torus: $(ELLIPT_TORUS_OFILES)
	$(LINK) $(ELLIPT_TORUS_OFILES) $(LIBS)

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

.PHONY: clean realclean new

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

realclean: clean albertarealclean

new: albertanew
