### This Makefile assumes that you have initialized your OOo SDK environment #############
# Windows:
# Uncomment the OS = WIN in the first line
# Adjust the MINGW path
#
# Wine:
# Source the config.wine
#
# Linux:
# Run /usr/lib/openoffice/basis3.2/sdk/setsdkenv_unix
# or <home>/openoffice.org3.2_sdk/<host-name>/setsdkenv_unix.csh or .sh
#
###########################################################################################
#OS = WIN
#MINGW = C:\MinGW\msys\1.0
VERSION = @VERSION@
SHELL = @SHELL@
install_sh = @install_sh@
mkinstalldirs = $(install_sh) -d
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
# The following is copied and adapted from the Makefile of the complextoolbarcontrol example of the SDK
ifeq "$(OS)" "WINE"
PRJ=$(BASE)/Program\ Files/OpenOffice.org\ 3/Basis/sdk
else
PRJ=$(OO_SDK_HOME)
endif
SETTINGS=$(PRJ)/settings
include $(SETTINGS)/settings.mk
include $(SETTINGS)/std.mk
include $(SETTINGS)/dk.mk
# Define non-platform/compiler specific settings
COMP_NAME=iMath-$(VERSION)-beta-$(OS)
COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
COMP_PACKAGE_DIR=iMathout
COMP_PACKAGE = $(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)
COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE)")
COMP_UNOPKG_MANIFEST = META-INF$(PS)manifest.xml
COMP_MAPFILE = $(COMP_PACKAGE_DIR)/$(COMP_NAME).uno.map
# override output directory settings
OUT_MISC = .
OUT_INC = ./inc
OUT = .
COMP_CONFIG=iMathMenu.xcu iMathProtocolHandler.xcu iMathJob.xcu iMathOptionsDialog.xcu iMathWriterWindowState.xcu iMathOptionData.xcs iMathOptionData.xcu iMathJob.xcu
REGISTERFLAG = cpp_$(COMP_NAME)_register_component.flag
COMP_TYPEFLAG = cpp_$(COMP_NAME)_types.flag
CXXFILES = smathparser.yxx smathlexer.lxx imathprint.cpp smathdriver.cxx imathutils.cxx \
iMath.cxx iMath-XDispatch.cxx iMath-XContainerWindowEventHandler.cxx iMath-XDialogEventHandler.cxx \
iMath-XAsyncJob.cxx iMath-XOther.cxx component.cxx
PREFIX=libiMath
SLOFILES1 = $(patsubst %.cxx,$(PREFIX)-%.$(OBJ_EXT),$(CXXFILES))
SLOFILES2 = $(patsubst %.yxx,$(PREFIX)-%.$(OBJ_EXT),$(SLOFILES1))
SLOFILES3 = $(patsubst %.lxx,$(PREFIX)-%.$(OBJ_EXT),$(SLOFILES2))
SLOFILES = $(patsubst %.cpp,$(PREFIX)-%.$(OBJ_EXT),$(SLOFILES3))
# Targets
.PHONY: all
all: iMath
include $(SETTINGS)/stdtarget.mk
ifeq "$(OS)" "WIN"
TOUCH = $(MINGW)/bin/touch.exe
BISON = $(MINGW)/bin/bison.exe
FLEX = $(MINGW)/bin/flex.exe
CC_INCLUDES_WIN = -I$(MINGW)/local/include
else
TOUCH = touch
BISON = bison
FLEX = flex
endif
###### Dependencies - any way of automating this? OOo doesn't seem to use automake
smathdriver.cxx: smathdriver.hxx imathutils.hxx imathprint.h
$(TOUCH) $@
iMath.cxx: iMath.hxx imathutils.hxx
$(TOUCH) $@
iMath-XDialogEventHandler.cxx : iMath.hxx imathutils.hxx imathprint.h
$(TOUCH) $@
iMath-XContainerWindowEventHandler.cxx : iMath.hxx imathutils.hxx
$(TOUCH) $@
iMath-XDispatch.cxx: iMath.hxx imathutils.hxx
$(TOUCH) $@
iMath-XOther.cxx: iMath.hxx imathutils.hxx imathprint.h
$(TOUCH) $@
iMath-XAsyncJob.cxx: iMath.hxx imathutils.hxx
$(TOUCH) $@
imathutils.cxx smathlexer.lxx smathparser.yxx: imathutils.hxx
$(TOUCH) $@
###### How do we make this generic for different platforms???
smathparser.cxx smathparser.hxx: smathparser.yxx
$(BISON) -y -d -osmathparser.cxx $<
smathlexer.cxx: smathlexer.lxx smathparser.hxx imathprint.h
$(FLEX) -o smathlexer.cxx $<
##### add $(STL_INCLUDES) here if necessary
$(PREFIX)-%.$(OBJ_EXT) : %.cxx smathparser.hxx $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(CC) $(CC_FLAGS) $(CC_INCLUDES) $(CC_INCLUDES_WIN) -I. $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
#### Remove this once imathprint is moved to libeqc
$(PREFIX)-%.$(OBJ_EXT) : %.cpp smathparser.hxx $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(CC) $(CC_FLAGS) $(CC_INCLUDES) $(CC_INCLUDES_WIN) -I. $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
$(COMP_MAPFILE) : $(SLOFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
ifeq "$(OS)" "MACOSX"
nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
endif
ifeq "$(OS)" "WINE"
$(COMP_IMPL_NAME) : $(SLOFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
/MAP:$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
/LIBPATH:$(CPP_WINDOWS_VC) msvcrt.lib msvcprt.lib \
/LIBPATH:$(CPP_WINDOWS_SDK) Kernel32.Lib \
/LIBPATH:$(BASE)/cl/lib/ libginac.lib libcln.lib libeqc.lib \
/LIBPATH:"$(OO_SDK_HOME)/lib" $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB)
$(LINK_MANIFEST)
else
ifeq "$(OS)" "WIN"
$(COMP_IMPL_NAME) : $(SLOFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
/MAP:$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
msvcrt.lib msvcprt.lib Kernel32.Lib $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) \
/LIBPATH:$(BASE)/local/lib/ libginac.lib libcln.lib libeqc.li
$(LINK_MANIFEST)
else
$(COMP_IMPL_NAME) : $(SLOFILES) $(COMP_MAPFILE)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
-L/usr/lib -leqc -lginac -lcln
ifeq "$(OS)" "MACOSX"
$(INSTALL_NAME_URELIBS) $@
endif
endif
endif
# rule for component package manifest
$(COMP_UNOPKG_MANIFEST) : Makefile
-$(MKDIR) $(subst /,$(PS),$(@D))
@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathMenu.xcu$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.basic-library$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathDialogs$(PS)$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathWriterWindowState.xcu$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathProtocolHandler.xcu$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathJob.xcu$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathOptionsDialog.xcu$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-schema$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathOptionData.xcs$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
@echo manifest:full-path="$(QM)iMathOptionData.xcu$(QM)"/$(CSEP) >> $@
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
@echo manifest:full-path="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"/$(CSEP) >> $@
#uncomment to include Windows build in Linux package
@echo $(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=native;platform=Windows$(QM)" >> $@
@echo manifest:full-path="$(QM)$(UNOPKG_PLATFORM)/$(COMP_NAME).uno.dll$(QM)"/$(CSEP) >> $@
@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
ifneq "$(OS)" "WIN"
# flip in is Debian package flip
flip -m $@
endif
# rule for component package file
$(COMP_PACKAGE) : $(COMP_IMPL_NAME) $(COMP_CONFIG) $(COMP_UNOPKG_MANIFEST)
-$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
-$(MKDIR) $(subst /,$(PS),$(UNOPKG_PLATFORM))
$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(UNOPKG_PLATFORM))
$(SDK_ZIP) $@ $(UNOPKG_PLATFORM)/*
$(SDK_ZIP) -u $@ $(COMP_CONFIG) logo_small.png logo_big.png
$(SDK_ZIP) -ur $@ description.xml registration/license*
$(SDK_ZIP) -ur $@ iMathDialogs/*.x??
$(SDK_ZIP) -u $@ $(COMP_UNOPKG_MANIFEST)
$(SDK_ZIP) -u $@ init.imath units.imath
$(REGISTERFLAG) : $(COMP_PACKAGE)
ifeq ($(SDK_AUTO_DEPLOYMENT),YES)
-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
ifeq "$(OS)" "WINE"
"$(OO_SDK_OFFICE_BIN_DIR)$(PS)"unopkg.exe add -f -v $(COMP_PACKAGE_URL)
else
ifeq "$(OS)" "WIN"
$(DEPLOYTOOL) -v $(COMP_PACKAGE_URL)
else
/usr/lib/openoffice/program/unopkg add -f -v $(COMP_PACKAGE_URL)
endif
endif
@echo flagged > $(subst /,$(PS),$@)
else
@echo --------------------------------------------------------------------------------
@echo If you want to install your component automatically, please set the environment
@echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
@echo possible if no office instance is running.
@echo --------------------------------------------------------------------------------
endif
iMath : $(REGISTERFLAG)
@echo --------------------------------------------------------------------------------
@echo The "$(QM)iMath$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
@echo You can use this component inside your office installation, see the example
@echo description.
@echo --------------------------------------------------------------------------------
deploy: $(COMP_PACKAGE)
-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
ifeq "$(OS)" "WINE"
"$(OO_SDK_OFFICE_BIN_DIR)$(PS)"unopkg.exe add -f -v $(COMP_PACKAGE_URL)
else
ifeq "$(OS)" "WIN"
$(DEPLOYTOOL) -v $(COMP_PACKAGE_URL)
else
/usr/lib/openoffice/program/unopkg add -f -v $(COMP_PACKAGE_URL)
endif
endif
@echo flagged > $(subst /,$(PS),$@)
editbin:
wine "/c-ro/Programme/Microsoft Visual Studio 9.0/VC/bin/editbin.exe" /subsystem:console $(BASE)/Program\ Files/OpenOffice.org\ 3/program/soffice.exe
run: $(REGISTERFLAG)
"$(OFFICE_PROGRAM_PATH)$(PS)soffice$(EXE_EXT)" -writer
runt: $(REGISTERFLAG)
"$(OFFICE_PROGRAM_PATH)$(PS)soffice$(EXE_EXT)" -writer ../doc/iMath-tour.odt
rund: $(REGISTERFLAG)
"$(OFFICE_PROGRAM_PATH)$(PS)soffice$(EXE_EXT)" -writer ../doc/Standard-Engineering-Calculations4.odt
rune: $(REGISTERFLAG)
"$(OFFICE_PROGRAM_PATH)$(PS)soffice$(EXE_EXT)" -writer ../doc/Evaluation.odt
.PHONY: clean
clean :
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
-$(DEL) $(SLOFILES) libiMath.la *.o *.lo
-$(DEL) $(COMP_IMPL_NAME)
-$(DEL) $(COMP_NAME)*
-$(DEL) smathparser.cxx smathparser.hxx smathlexer.cxx
-$(DELRECURSIVE) $(UNOPKG_PLATFORM)
-$(DELRECURSIVE) $(OUT_INC) META-INF $(COMP_PACKAGE_DIR)
-$(DEL) $(SDKTYPEFLAG)
distclean: clean
install: install-exec-local install-data-local
uninstall: uninstall-local
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install-exec-local: $(COMP_PACKAGE)
$(mkinstalldirs) $(DESTDIR)/usr/lib/openoffice/share/extension/install
$(INSTALL_DATA) $(COMP_PACKAGE) $(DESTDIR)/usr/lib/openoffice/share/extension/install/$(COMP_NAME).$(UNOOXT_EXT)
install-data-local: init.imath units.imath
$(mkinstalldirs) $(DESTDIR)/usr/lib/openoffice/share/extension/imath
$(INSTALL_DATA) init.imath $(DESTDIR)/usr/lib/openoffice/share/extension/imath
$(INSTALL_DATA) units.imath $(DESTDIR)/usr/lib/openoffice/share/extension/imath
uninstall-local:
-rm -f $(DESTDIR)/usr/lib/openoffice/share/extension/install/$(COMP_PACKAGE)
-rm -f $(DESTDIR)/usr/lib/openoffice/share/extension/imath/init.imath
-rm -f $(DESTDIR)/usr/lib/openoffice/share/extension/imath/units.imath