# This file is part of BOINC.
# https://boinc.berkeley.edu
# Copyright (C) 2025 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# BOINC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
#
# NOTE: this requires the libzip library which can be installed by the
# scipt mac_build/buildlibzip.sh, which uses CMake via the command line.
#

# 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
# Updated 9/28/25 to replace boinc_zip with the libzip library dependency

# 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
LIBZIP_DIR = $(BOINC_DIR)/../libzip
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$(LIBZIP_DIR)/lib \
    -L$(BOINC_BUILD_DIR) \
    -L$(PREFIX)/lib \
    -L.

PROGS = wrapper

all: $(PROGS)

clean: distclean

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

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