#############################################################################
# Primesense template makefile.
# This file should not be made, but only included from other makefiles.
# By default, this makefile compiles in release. To compile a debug version:
#    make CFG=Debug
#
# Project makefile should define the following BEFORE including this file:
# SRC_FILES - a list of all source files
# Output name under one of the following:
#     NETLIB_NAME (.net module) or
#     NETEXE_NAME (.net executable)
# BIN_DIR - Bin directory (output dir)
# INC_DIRS - a list of additional include directories
# USED_LIBS - a list of libraries to link with
# CSFLAGS - [Optional] additional flags for mono compiler
# NET_WIN_FORMS - [Optional] when 1, application uses WinForms
#############################################################################

# take this file's dir
COMMON_CS_MAKE_FILE_DIR = $(dir $(lastword $(MAKEFILE_LIST)))

include $(COMMON_CS_MAKE_FILE_DIR)CommonDefs.mak

# create -r option to mcs
USED_NETLIBS_OPTION = $(foreach lib,$(USED_LIBS),-r:$(lib).dll)

ifeq "$(NET_WIN_FORMS)" "1"
	USED_NETLIBS_OPTION += -r:System.Windows.Forms.dll -r:System.Drawing.dll
endif

# add the output dir as a place to search for assemblies
USED_NETLIBS_OPTION += -lib:$(OUT_DIR)

ifeq "$(CFG)" "Release"
	CSFLAGS += -o+
endif

# some lib / exe specifics
ifneq "$(NETLIB_NAME)" ""
	OUTPUT_NAME = $(NETLIB_NAME).dll
	TARGET = library
endif
ifneq "$(NETEXE_NAME)" ""
	OUTPUT_NAME = $(NETEXE_NAME).exe
	TARGET = winexe
endif

OUTPUT_COMMAND = gmcs -out:$(OUTPUT_FILE) -target:$(TARGET) $(CSFLAGS) $(USED_NETLIBS_OPTION) $(SRC_FILES)

#############################################################################
# Targets
#############################################################################
include $(COMMON_CS_MAKE_FILE_DIR)CommonTargets.mak

# Final output file
$(OUTPUT_FILE): 
	$(OUTPUT_COMMAND)

