# One to rule all of them - vc version agnostic
# Not using the OGDF build approach for two reasons
#  - need a simple wrapper to use in Dia with different C++ runtime
#  - make it buildable with vc2005 and above

!IFNDEF PACKAGE

SUBS = augmentation basic cluster decomposition energybased external fileformats graphalg \
	incremental labeling layered lpsolver misclayout orthogonal packing planarity \
	planarlayout simultaneous tree upward


# The main target
all : sub-all

sub-all: 
	for %d in ($(SUBS)) do @nmake -nologo -f makefile.msc sub-one THIS=%d
	@cd energybased\multilevelmixer
	@nmake -nologo -f ..\..\makefile.msc multilevelmixer.lib PACKAGE=multilevelmixer OBJ_multilevelmixer=1
	@cd ..\..
	@nmake -nologo -f makefile.msc PACKAGE=ogdf ogdf.dll

sub-one:
	@cd $(THIS)
	@nmake -nologo -f ..\makefile.msc $(THIS).lib PACKAGE=$(THIS) OBJ_$(THIS)=1
	@cd ..

clean:
	for %d in ($(SUBS)) do @nmake -nologo -f makefile.msc sub-clean THIS=%d
	@nmake -nologo -f makefile.msc PACKAGE=ogdf clean	

sub-clean:
	@cd $(THIS)
	@nmake -nologo -f ..\makefile.msc PACKAGE=$(THIS) clean
	@cd ..

!ELSE

# random crashes due to threaded memory access? YES.
DEFINES = -DOGDF_MEMORY_MALLOC_TS # -DOGDF_DEBUG
#DEFINES = -DOGDF_DLL -DOGDF_INSTALL

INCLUDES = \
	-I ..\..\.. \
	-I ..\.. \
	-I .. \
#	-I D:\Devel\wdk7\inc\api\crt\stl60

PKG_CFLAGS = $(DEFINES) $(INCLUDES) /EHsc /nologo

PKG_LINK = \
	augmentation/augmentation.lib \
	basic/basic.lib \
	cluster/cluster.lib \
	decomposition/decomposition.lib \
	energybased/energybased.lib \
	external/external.lib \
	fileformats/fileformats.lib \
	graphalg/graphalg.lib \
	incremental/incremental.lib \
	labeling/labeling.lib \
	layered/layered.lib \
	lpsolver/lpsolver.lib \
	misclayout/misclayout.lib \
	orthogonal/orthogonal.lib \
	packing/packing.lib \
	planarity/planarity.lib \
	planarlayout/planarlayout.lib \
	simultaneous/simultaneous.lib \
	tree/tree.lib \
	upward/upward.lib \
	energybased\multilevelmixer\multilevelmixer.lib

!IFDEF OBJ_augmentation
OBJECTS = \
        DfsMakeBiconnected.obj \
        PlanarAugmentation.obj \
        PlanarAugmentationFix.obj \
	
!ENDIF

!IFDEF OBJ_basic
OBJECTS = \
        basic.obj \
        CliqueFinder.obj \
        CombinatorialEmbedding.obj \
        DualGraph.obj \
        EdgeComparer.obj \
        EdgeComparerSimple.obj \
        extended_graph_alg.obj \
        geometry.obj \
        Graph.obj \
        GraphAttributes.obj \
        GraphCopy.obj \
        graph_generators.obj \
        GridLayout.obj \
        GridLayoutModule.obj \
        Hashing.obj \
        Logger.obj \
        modules.obj \
        NearestRectangleFinder.obj \
        PoolMemoryAllocator.obj \
        PreprocessorLayout.obj \
        random_hierarchy.obj \
        simple_graph_alg.obj \
        stNumber.obj \
        String.obj \
        System.obj \
        UMLGraph.obj \

!ENDIF

!IFDEF OBJ_cluster
OBJECTS = \
        CconnectClusterPlanar.obj \
        CconnectClusterPlanarEmbed.obj \
        Clusterer.obj \
        ClusterGraph.obj \
        ClusterGraphAttributes.obj \
        ClusterPlanarizationLayout.obj \
        Cluster_ChunkConnection.obj \
        Cluster_CutConstraint.obj \
        Cluster_EdgeVar.obj \
        Cluster_MaxPlanarEdges.obj \
        CPlanarEdgeInserter.obj \
        CPlanarSubClusteredGraph.obj \
        CPlanarSubCLusteredST.obj \
        KuratowskiConstraint.obj \
        MaxCPlanar_Master.obj \
        MaxCPlanar_MinimalClusterConnection.obj \
        MaxCPlanar_Sub.obj \
        MaximumCPlanarSubgraph.obj \

!ENDIF

!IFDEF OBJ_decomposition 
OBJECTS = \
        BCTree.obj \
        DynamicBCTree.obj \
        DynamicSPQRForest.obj \
        DynamicSPQRTree.obj \
        NonPlanarCore.obj \
        PlanarSPQRTree.obj \
        StaticSPQRTree.obj \
        TricComp.obj \

!ENDIF

!IFDEF OBJ_external 
OBJECTS = \
	coin.obj
!ENDIF

!IFDEF OBJ_energybased 
OBJECTS = \
        AdjacencyOracle.obj \
        ArrayGraph.obj \
        Attraction.obj \
        CoinTutteLayout.obj \
        DavidsonHarel.obj \
        DavidsonHarelLayout.obj \
        EdgeAttributes.obj \
        EnergyFunction.obj \
        FastMultipoleEmbedder.obj \
        FastUtils.obj \
        FMEKernel.obj \
        FMEMultipoleKernel.obj \
        FMEThread.obj \
        FMMMLayout.obj \
        FruchtermanReingold.obj \
        GalaxyMultilevel.obj \
        GEMLayout.obj \
        IntersectionRectangle.obj \
        LinearQuadtree.obj \
        LinearQuadtreeBuilder.obj \
        LinearQuadtreeExpansion.obj \
        MAARPacking.obj \
        Multilevel.obj \
        MultilevelGraph.obj \
        NMM.obj \
        NodeAttributes.obj \
        NodePairEnergy.obj \
        numexcept.obj \
        Overlap.obj \
        Planarity.obj \
        PlanarityGrid.obj \
        QuadTreeNM.obj \
        QuadTreeNodeNM.obj \
        Repulsion.obj \
        Set.obj \
        SpringEmbedderFR.obj \
        SpringEmbedderFRExact.obj \
        SpringEmbedderKK.obj \
        StressMajorizationSimple.obj \
        UniformGrid.obj \
        WSPD.obj \

!ENDIF

!IFDEF OBJ_fileformats
OBJECTS = \
        DinoLineBuffer.obj \
        DinoTools.obj \
        DinoUmlDiagramGraph.obj \
        DinoUmlModelGraph.obj \
        DinoUmlToGraphConverter.obj \
        DinoXmlParser.obj \
        DinoXmlScanner.obj \
        GmlParser.obj \
        OgmlParser.obj \
        simple_graph_load.obj \
        XmlParser.obj \

!ENDIF

!IFDEF OBJ_graphalg
OBJECTS = \
        ConvexHull.obj \
        mcf_front_reinelt.obj \
        MinCostFlowModule.obj \
        MinCostFlowReinelt.obj \
        MinimumCut.obj \
        ShortestPathsWithBFM.obj \

!ENDIF

!IFDEF OBJ_incremental 
OBJECTS = \
        SimpleIncNodeInserter.obj \

!ENDIF

!IFDEF OBJ_labeling 
OBJECTS = \
        ELabelPosSimple.obj \

!ENDIF

!IFDEF OBJ_layered 
OBJECTS = \
        acyclic_subgraph.obj \
        CrossingsMatrix.obj \
        FastHierarchyLayout.obj \
        heuristics.obj \
        HierarchyLayoutModule.obj \
        OptimalHierarchyClusterLayout.obj \
        OptimalHierarchyLayout.obj \
        OptimalRanking.obj \
        ranking.obj \
        SplitHeuristic.obj \
        sugiyama-cluster.obj \
        sugiyama.obj \

!ENDIF

!IFDEF OBJ_lpsolver 
OBJECTS = \
        LPSolver_coin.obj \

!ENDIF

!IFDEF OBJ_misclayout 
OBJECTS = \
        BalloonLayout.obj \
        CircularLayout.obj \

!ENDIF

!IFDEF OBJ_orthogonal 
OBJECTS = \
        ClusterOrthoLayout.obj \
        ClusterOrthoShaper.obj \
        CompactionConstraintGraph.obj \
        EdgeRouter.obj \
        FlowCompaction.obj \
        LongestPathCompaction.obj \
        NodeInfo.obj \
        OrthoLayout.obj \
        OrthoRep.obj \
        OrthoShaper.obj \

!ENDIF

!IFDEF OBJ_packing 
OBJECTS = \
        CCLayoutPackModule.obj \
        ComponentSplitterLayout.obj \
        TileToRowsCCPacker.obj \

!ENDIF

!IFDEF OBJ_planarity
OBJECTS = \
        BoyerMyrvold.obj \
        BoyerMyrvoldInit.obj \
        BoyerMyrvoldPlanar.obj \
        ClusterPlanRep.obj \
        EdgeInsertionModule.obj \
        EmbedderMaxFace.obj \
        EmbedderMaxFaceLayers.obj \
        EmbedderMDMFLengthAttribute.obj \
        EmbedderMinDepth.obj \
        EmbedderMinDepthMaxFace.obj \
        EmbedderMinDepthMaxFaceLayers.obj \
        EmbedderMinDepthPiTa.obj \
        EmbedPQTree.obj \
        ExtractKuratowskis.obj \
        FastPlanarSubgraph.obj \
        FindKuratowskis.obj \
        FixedEmbeddingInserter.obj \
        GraphReduction.obj \
        Layout.obj \
        LayoutPlanRepModule.obj \
        MaximalPlanarSubgraphSimple.obj \
        MaximumPlanarSubgraph.obj \
        MMCrossingMinimizationModule.obj \
        MMFixedEmbeddingInserter.obj \
        MMSubgraphPlanarizer.obj \
        MMVariableEmbeddingInserter.obj \
        PlanarizationGridLayout.obj \
        PlanarizationLayout.obj \
        PlanarizationLayout_inc.obj \
        PlanarModule.obj \
        PlanarPQTree.obj \
        PlanarSubgraphModule.obj \
        PlanarSubgraphPQTree.obj \
        PlanRep.obj \
        PlanRepExpansion.obj \
        PlanRepInc.obj \
        PlanRepUML.obj \
        SimpleEmbedder.obj \
        SubgraphPlanarizer.obj \
        TopologyModule.obj \
        VariableEmbeddingInserter.obj \
        VariableEmbeddingInserter2.obj \

!ENDIF

!IFDEF OBJ_planarlayout 
OBJECTS = \
        BiconnectedShellingOrder.obj \
        IOPoints.obj \
        MixedModelBase.obj \
        MixedModelCrossingsBeautifierModule.obj \
        MixedModelLayout.obj \
        MMCBBase.obj \
        PlanarDrawLayout.obj \
        PlanarStraightLayout.obj \
        ShellingOrder.obj \
        ShellingOrderModule.obj \
        TriconnectedShellingOrder.obj \

!ENDIF

!IFDEF OBJ_simultaneous 
OBJECTS = \
        SimDraw.obj \
        SimDrawCaller.obj \
        SimDrawColorizer.obj \
        SimDrawCreator.obj \
        SimDrawCreatorSimple.obj \
        SimDrawManipulatorModule.obj \

!ENDIF

!IFDEF OBJ_tree 
OBJECTS = \
        RadialTreeLayout.obj \
        TreeLayout.obj \

!ENDIF

!IFDEF OBJ_upward
OBJECTS = \
        DominanceLayout.obj \
        ExpansionGraph.obj \
        FaceSinkGraph.obj \
        FeasibleUpwardPlanarSubgraph.obj \
        FixedEmbeddingUpwardEdgeInserter.obj \
        FUPSSimple.obj \
        LayerBasedUPRLayout.obj \
        SubgraphUpwardPlanarizer.obj \
        UpwardPlanarModule.obj \
        UpwardPlanarSubgraphModule.obj \
        UpwardPlanarSubgraphSimple.obj \
        UpwardPlanRep.obj \
        VisibilityLayout.obj \

!ENDIF

!IFDEF OBJ_multilevelmixer
OBJECTS = \
        BarycenterPlacer.obj \
        CirclePlacer.obj \
        EdgeCoverMerger.obj \
        IndependentSetMerger.obj \
        LocalBiconnectedMerger.obj \
        MatchingMerger.obj \
        MedianPlacer.obj \
        MixedForceLayout.obj \
        MMMExampleFastLayout.obj \
        MMMExampleNiceLayout.obj \
        MMMExampleNoTwistLayout.obj \
        ModularMultilevelMixerLayout.obj \
        RandomMerger.obj \
        RandomPlacer.obj \
        ScalingLayout.obj \
        SolarMerger.obj \
        SolarPlacer.obj \
        ZeroPlacer.obj \

!ENDIF

$(PACKAGE).lib : $(OBJECTS)
	lib /out:$(PACKAGE).lib $(OBJECTS)

# /link /MAP:ogdf.map /machine:ix86 /OPT:REF
$(PACKAGE).dll : ogdf-simple.obj $(PKG_LINK)
	$(CC) $(CFLAGS) -Zi -LD -Fe$(PACKAGE).dll ogdf-simple.obj \
	$(PKG_LINK) $(EXTRALIBS) user32.lib kernel32.lib psapi.lib $(LDFLAGS) /link /MAP:ogdf.map 

.cpp.obj :
	$(CC) -Zi -MT $(CFLAGS) -c $(PKG_CFLAGS) $<


clean:
	del *.obj *.pdb *.ilk *.lib *.dll *.map

!ENDIF
