########## fre:ac commands makefile ##########

include $(dir $(firstword $(MAKEFILE_LIST)))/$(FREAC_PATH)/Makefile-options

CCOPTS = -fvisibility=hidden -DBOCA_COMPONENT_BUILD $(DEFINE)
LDOPTS = $(LIBS)

ifneq ("$(CDK_INSTALL_PATH)","")
	CCOPTS += -I"$(CDK_INSTALL_PATH)"/include
	LDOPTS += -L"$(CDK_INSTALL_PATH)"/$(LIBDIR)
endif

ifeq ($(BUILD_WIN32),True)
	LDOPTS += -lsmooth -lboca -Wl,--dynamicbase,--nxcompat,--enable-auto-import
else
	CCOPTS += -fPIC

	ifneq ($(BUILD_SOLARIS),True)
	ifneq ($(BUILD_HAIKU),True)
		CCOPTS += -pthread

		ifneq ($(BUILD_OSX),True)
			ifeq ($(BUILD_NETBSD),True)
				CCOPTS += -I/usr/pkg/include
			else
				CCOPTS += -I/usr/local/include
			endif
		endif
	endif
	endif

	LDOPTS += -L$(prefix)/lib -lsmooth-$(SMOOTHVER) -lboca-$(BOCAVER)

	ifeq ($(BUILD_OSX),True)
		LDOPTS += -Wl,-headerpad,80
	else ifeq ($(BUILD_NETBSD),True)
		LDOPTS += -Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib
	else
		ifneq ($(BUILD_LINUX),True)
		ifneq ($(BUILD_SOLARIS),True)
			LDOPTS += -L/usr/local/lib
		endif
		endif
	endif
endif

all: allcmds $(FREAC_PATH)/$(BINDIR)/boca/freac_$(TYPE)_$(TARGET).$(BOCAVER)$(SHARED)

allcmds:
	+ $(ALLCMD1)
	+ $(ALLCMD2)

$(FREAC_PATH)/$(BINDIR)/boca/freac_$(TYPE)_$(TARGET).$(BOCAVER)$(SHARED) : $(OBJECTS)
	mkdir -p $(FREAC_PATH)/$(BINDIR)/boca
ifneq ($(BUILD_OSX),True)
	$(LD) --shared -o $@ $(OBJECTS) $(LDOPTS) $(LDFLAGS)
else
	$(LD) -dynamiclib -o $@ $(OBJECTS) $(LDOPTS) $(LDFLAGS)
endif

clean:
	rm -f $(FREAC_PATH)/$(BINDIR)/boca/freac_$(TYPE)_$(TARGET).$(BOCAVER)$(SHARED) $(OBJECTS)
	$(CLEANCMD1)
	$(CLEANCMD2)

install: all
ifneq ($(BUILD_WIN32),True)
	$(INSTALL) -d "$(DESTDIR)"$(libdir)/freac
	$(INSTALL_DATA) $(FREAC_PATH)/$(BINDIR)/boca/freac_$(TYPE)_$(TARGET).$(BOCAVER)$(SHARED) "$(DESTDIR)"$(libdir)/freac
endif
	$(INSTCMD1)
	$(INSTCMD2)

uninstall:
ifneq ($(BUILD_WIN32),True)
	rm -f "$(DESTDIR)"$(libdir)/freac/freac_$(TYPE)_$(TARGET).$(BOCAVER)$(SHARED)
endif
	$(UINSTCMD1)
	$(UINSTCMD2)

.c.o:
	$(CC) $(CCOPTS) $(CFLAGS) -c $< -o $@

.cpp.o:
	$(CXX) $(CCOPTS) $(CXXFLAGS) -c $< -o $@

.m.o:
	$(OBJC) $(CCOPTS) $(OBJCFLAGS) -c $< -o $@

.mm.o:
	$(OBJCXX) $(CCOPTS) $(OBJCXXFLAGS) -c $< -o $@
