# makefile for BOINC wrapper application on Macintosh.
# This is invoked from BuildMacWrapper.sh shell script.
# It should not be used by itself without the script.
# Updated 8/28/20 for compatibility with Xcode 10
# Updated 2/6/23 to include additional search paths

# Change the following to match your installation
BOINC_DIR = ../..
BOINC_API_DIR = $(BOINC_DIR)/api
BOINC_LIB_DIR = $(BOINC_DIR)/lib
BOINC_ZIP_DIR = $(BOINC_DIR)/zip
BOINC_BUILD_DIR = $(BOINC_DIR)/mac_build/build/Deployment
BOINC_CONFIG_DIR =  $(BOINC_DIR)/clientgui/mac

CFLAGS = $(VARIANTFLAGS) \
	-g \
    -I$(BOINC_CONFIG_DIR) \
    -I$(BOINC_DIR) \
    -I$(BOINC_LIB_DIR) \
    -I$(BOINC_API_DIR) \
    -I$(BOINC_ZIP_DIR) \
    -I$(PREFIX)/include

CXXFLAGS = $(CFLAGS) -stdlib=libc++

LDFLAGS = \
    -L$(BOINC_API_DIR) \
    -L$(BOINC_LIB_DIR) \
    -L$(BOINC_ZIP_DIR) \
    -L$(BOINC_BUILD_DIR) \
    -L$(PREFIX)/lib \
    -L.

PROGS = wrapper

all: $(PROGS)

clean: distclean

distclean:
	/bin/rm -f $(PROGS) *.o

REGEXP_OBJS = \
	regexp.o \
	regsub.o \
	regerror.o \
	regexp_memory.o \
	regexp_report.o

regexp.o: regexp.c
	$(CC) $(CFLAGS) -c regexp.c

regsub.o: regsub.c
	$(CC) $(CFLAGS) -c regsub.c

regerror.o: regerror.c
	$(CC) $(CFLAGS) -c regerror.c

regexp_memory.o: regexp_memory.c
	$(CC) $(CFLAGS) -c regexp_memory.c

regexp_report.o: regexp_report.c
	$(CC) $(CFLAGS) -c regexp_report.c

wrapper: wrapper.o $(REGEXP_OBJS)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o wrapper wrapper.o $(REGEXP_OBJS) -pthread -lboinc_api -lboinc -lboinc_zip
