--- makefile.orig	2005-07-27 17:22:01.000000000 -0700
+++ makefile	2017-09-16 17:11:24.000000000 -0700
@@ -18,7 +18,7 @@
 
 # CC should be set to the name of your favorite C compiler.
 
-CC = cc
+CC = __MACPORTS_CC__
 
 # CSWITCHES is a list of all switches passed to the C compiler.  I strongly
 #   recommend using the best level of optimization.  I also strongly
@@ -73,7 +73,7 @@
 #
 #   CSWITCHES = -O -DNO_TIMER -DLINUX -I/usr/X11R6/include -L/usr/X11R6/lib
 
-CSWITCHES = -O -DLINUX -I/usr/X11R6/include -L/usr/X11R6/lib
+CSWITCHES = __MACPORTS_CPPFLAGS__ __MACPORTS_CFLAGS__ __MACPORTS_LDFLAGS__
 
 # TRILIBDEFS is a list of definitions used to compile an object code version
 #   of Triangle (triangle.o) to be called by another program.  The file
@@ -97,6 +97,8 @@
 all: $(BIN)triangle $(BIN)showme
 
 trilibrary: $(BIN)triangle.o $(BIN)tricall
+	$(CC) -dynamiclib -install_name __MACPORTS_PREFIX__/lib/libtriangle.dylib $(CSWITCHES) -o libtriangle.dylib $(BIN)triangle.o
+	/usr/bin/ar rcs libtriangle.a $(BIN)triangle.o

 
 $(BIN)triangle: $(SRC)triangle.c
 	$(CC) $(CSWITCHES) -o $(BIN)triangle $(SRC)triangle.c -lm
