diff --git a/src/metis-1-fixes.patch b/src/metis-1-fixes.patch new file mode 100644 index 00000000..98642f32 --- /dev/null +++ b/src/metis-1-fixes.patch @@ -0,0 +1,125 @@ +This file is part of MXE. See LICENSE.md for licensing information. + +Contains ad hoc patches for cross building. + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Mon, 20 Nov 2017 22:54:25 +1100 +Subject: [PATCH 1/5] mingw-w64-does-not-have-sys-resource-h + +taken from: +https://github.com/Alexpux/MINGW-packages/blob/484b873e8a1967b7809127682635888b7329417f/mingw-w64-metis/0001-mingw-w64-does-not-have-sys-resource-h.patch + +diff --git a/GKlib/gk_arch.h b/GKlib/gk_arch.h +index 1111111..2222222 100644 +--- a/GKlib/gk_arch.h ++++ b/GKlib/gk_arch.h +@@ -41,7 +41,9 @@ + #endif + #include + #include +- #include ++ #ifndef __MINGW32__ ++ #include ++ #endif + #include + #endif + + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Mon, 20 Nov 2017 22:55:34 +1100 +Subject: [PATCH 2/5] mingw-w64-do-not-use-reserved-double-underscored-names + +taken from: +https://github.com/Alexpux/MINGW-packages/blob/484b873e8a1967b7809127682635888b7329417f/mingw-w64-metis/0002-mingw-w64-do-not-use-reserved-double-underscored-names.patch + +diff --git a/GKlib/gk_getopt.h b/GKlib/gk_getopt.h +index 1111111..2222222 100644 +--- a/GKlib/gk_getopt.h ++++ b/GKlib/gk_getopt.h +@@ -52,10 +52,10 @@ struct gk_option { + + + /* Function prototypes */ +-extern int gk_getopt(int __argc, char **__argv, char *__shortopts); +-extern int gk_getopt_long(int __argc, char **__argv, char *__shortopts, ++extern int gk_getopt(int gk_argc, char **gk_argv, char *__shortopts); ++extern int gk_getopt_long(int gk_argc, char **gk_argv, char *__shortopts, + struct gk_option *__longopts, int *__longind); +-extern int gk_getopt_long_only (int __argc, char **__argv, ++extern int gk_getopt_long_only (int gk_argc, char **gk_argv, + char *__shortopts, struct gk_option *__longopts, int *__longind); + + + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Mon, 20 Nov 2017 22:58:20 +1100 +Subject: [PATCH 3/5] WIN32-Install-RUNTIME-to-bin + +taken from: +https://github.com/Alexpux/MINGW-packages/blob/484b873e8a1967b7809127682635888b7329417f/mingw-w64-metis/0003-WIN32-Install-RUNTIME-to-bin.patch + +diff --git a/libmetis/CMakeLists.txt b/libmetis/CMakeLists.txt +index 1111111..2222222 100644 +--- a/libmetis/CMakeLists.txt ++++ b/libmetis/CMakeLists.txt +@@ -8,9 +8,15 @@ if(UNIX) + target_link_libraries(metis m) + endif() + ++if(WIN32) ++ set(RT_DEST bin) ++else() ++ set(RT_DEST lib) ++endif() ++ + if(METIS_INSTALL) + install(TARGETS metis + LIBRARY DESTINATION lib +- RUNTIME DESTINATION lib ++ RUNTIME DESTINATION ${RT_DEST} + ARCHIVE DESTINATION lib) + endif() + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Mon, 20 Nov 2017 22:59:10 +1100 +Subject: [PATCH 4/5] Fix-GKLIB_PATH-default-for-out-of-tree-builds + +taken from: +https://github.com/Alexpux/MINGW-packages/blob/484b873e8a1967b7809127682635888b7329417f/mingw-w64-metis/0004-Fix-GKLIB_PATH-default-for-out-of-tree-builds.patch + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1111111..2222222 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,7 +1,7 @@ + cmake_minimum_required(VERSION 2.8) + project(METIS) + +-set(GKLIB_PATH "GKlib" CACHE PATH "path to GKlib") ++set(GKLIB_PATH "${CMAKE_SOURCE_DIR}/GKlib" CACHE PATH "path to GKlib") + set(SHARED FALSE CACHE BOOL "build a shared library") + + if(MSVC) + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Mon, 20 Nov 2017 23:05:12 +1100 +Subject: [PATCH 5/5] disable programs + + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1111111..2222222 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -24,4 +24,6 @@ include_directories(include) + # Recursively look for CMakeLists.txt in subdirs. + add_subdirectory("include") + add_subdirectory("libmetis") +-add_subdirectory("programs") ++if(BUILD_PROGRAMS) ++ add_subdirectory("programs") ++endif() diff --git a/src/metis-test.cpp b/src/metis-test.cpp new file mode 100644 index 00000000..c48d8ff1 --- /dev/null +++ b/src/metis-test.cpp @@ -0,0 +1,57 @@ +/* + * This file is part of MXE. See LICENSE.md for licensing information. + * + * taken from: https://gist.github.com/erikzenker/c4dc42c8d5a8c1cd3e5a + */ + + +#include /* NULL */ +#include +#include + + +// Install metis from: +// http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz + +// Build with +// g++ metis.cc -lmetis + +int main(){ + + idx_t nVertices = 6; + idx_t nEdges = 7; + idx_t nWeights = 1; + idx_t nParts = 2; + + idx_t objval; + idx_t part[nVertices]; + + + // Indexes of starting points in adjacent array + idx_t xadj[nVertices+1] = {0,2,5,7,9,12,14}; + + // Adjacent vertices in consecutive index order + idx_t adjncy[2 * nEdges] = {1,3,0,4,2,1,5,0,4,3,1,5,4,2}; + + // Weights of vertices + // if all weights are equal then can be set to NULL + idx_t vwgt[nVertices * nWeights]; + + + // int ret = METIS_PartGraphRecursive(&nVertices,& nWeights, xadj, adjncy, + // NULL, NULL, NULL, &nParts, NULL, + // NULL, NULL, &objval, part); + + int ret = METIS_PartGraphKway(&nVertices,& nWeights, xadj, adjncy, + NULL, NULL, NULL, &nParts, NULL, + NULL, NULL, &objval, part); + + std::cout << ret << std::endl; + + for(unsigned part_i = 0; part_i < nVertices; part_i++){ + std::cout << part_i << " " << part[part_i] << std::endl; + } + + + return 0; +} diff --git a/src/metis.mk b/src/metis.mk new file mode 100644 index 00000000..b6da6e94 --- /dev/null +++ b/src/metis.mk @@ -0,0 +1,38 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := metis +$(PKG)_WEBSITE := glaros.dtc.umn.edu +$(PKG)_DESCR := metis +$(PKG)_IGNORE := +$(PKG)_VERSION := 5.1.0 +$(PKG)_CHECKSUM := 76faebe03f6c963127dbb73c13eab58c9a3faeae48779f049066a21c087c5db2 +$(PKG)_SUBDIR := metis-$($(PKG)_VERSION) +$(PKG)_FILE := metis-$($(PKG)_VERSION).tar.gz +$(PKG)_URL := http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-$($(PKG)_VERSION).tar.gz +$(PKG)_DEPS := gcc + +define $(PKG)_UPDATE + $(call GET_LATEST_VERSION, http://glaros.dtc.umn.edu/gkhome/metis/metis/download, metis-) +endef + +define $(PKG)_BUILD + # build and install the library + cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)' \ + -DSHARED=$(CMAKE_SHARED_BOOL) + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' + $(MAKE) -C '$(BUILD_DIR)' -j 1 install + + # create pkg-config file + $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig' + (echo 'Name: $(PKG)'; \ + echo 'Version: $($(PKG)_VERSION)'; \ + echo 'Description: $($(PKG)_DESCR)'; \ + echo 'Libs: -lmetis'; \ + ) > '$(PREFIX)/$(TARGET)/lib/pkgconfig/$(PKG).pc' + + # compile test + '$(TARGET)-g++' \ + -W -Wall \ + '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \ + `'$(TARGET)-pkg-config' $(PKG) --cflags --libs` +endef