CC=gcc
CXX=g++
# The arch parameter specifies the target CPU type. Possible values for this version of
# DynaPDF are -arch i386 and -arch x86_64 or both.
ARCH=-arch x86_64

CC_FLAGS=-fPIC -fno-strict-aliasing -O3 $(ARCH)

# These flags are normally only required if you build a Universal Binary.
CC_FLAGS2=-mmacosx-version-min=10.9
LD_LIBS=-weak_framework Carbon -weak_framework System -weak_framework Foundation -lc -lm -lc++ $(ARCH) -mmacosx-version-min=10.9
LIB_NAME=../dynapdf/libdynapdf.a

SRC=acroform.cpp font_test.c hello_world.cpp metafiles.cpp personalize.cpp text_formatting.cpp
OBJ=${SRC:.cpp=.o} ${SRC:.c=.o}

install: $(OBJ)
	$(CXX) -o acroform.exe acroform.o $(LIB_NAME) $(CC_FLAGS) $(CC_FLAGS2) $(LD_LIBS)
	$(CC) -o font_test.exe font_test.o $(LIB_NAME) $(CC_FLAGS) $(CC_FLAGS2) $(LD_LIBS)
	$(CXX) -o hello_world.exe hello_world.o $(LIB_NAME) $(CC_FLAGS) $(CC_FLAGS2) $(LD_LIBS)
	$(CXX) -o metafiles.exe metafiles.o $(LIB_NAME) $(CC_FLAGS) $(CC_FLAGS2) $(LD_LIBS)
	$(CXX) -o personalize.exe personalize.o $(LIB_NAME) $(CC_FLAGS) $(CC_FLAGS2) $(LD_LIBS)
	$(CXX) -o text_formatting.exe text_formatting.o $(LIB_NAME) $(CC_FLAGS2) $(CC_FLAGS) $(LD_LIBS)
	chmod 777 runtests
	./runtests

clean:
	rm -f *.o
	rm -f acroform.exe font_test.exe hello_world.exe metafiles.exe personalize.exe text_formatting.exe

%.o: %.c
	$(CC) $(CC_FLAGS) $(CC_FLAGS2) -o $@ -c $<

%.o: %.cpp
	$(CXX) $(CC_FLAGS) $(CC_FLAGS2) -o $@ -c $<
