diff --git a/T/TopOpt_in_PETSc/build_tarballs.jl b/T/TopOpt_in_PETSc/build_tarballs.jl new file mode 100644 index 00000000000..40fb05caf84 --- /dev/null +++ b/T/TopOpt_in_PETSc/build_tarballs.jl @@ -0,0 +1,42 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder, Pkg + +name = "TopOpt_in_PETSc" +version = v"0.1" + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/topopt/TopOpt_in_PETSc", "26eecbf3b1d0135956e0364d77c30e43e9bc3db2"), + DirectorySource("./bundled"), +] + +# Bash recipe for building across all platforms +# New makefiles added, the patches fix some weird include issues mostly. +# There is likely a better way to fix them, or upstream the fixes. +script = raw""" +cd TopOpt_in_PETSc +make -f ../Makefile libtopopt.${dlext} topopt${exeext} +install -Dvm 755 "topopt${exeext}" "${bindir}/topopt${exeext}" +install -Dvm 755 "libtopopt.${dlext}" "${libdir}/libtopopt.${dlext}" +install_license lesser.txt +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = expand_cxxstring_abis(supported_platforms(exclude=[Platform("i686", "windows")])) + +# The products that we will ensure are always built +products = [ + LibraryProduct("libtopopt", :libtopopt), + ExecutableProduct("topopt", :topopt) +] + +# Dependencies that must be installed before this package can be built +dependencies = [ + Dependency("PETSc_jll"; compat="3.16.5"), + Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")) +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"9") diff --git a/T/TopOpt_in_PETSc/bundled/Makefile b/T/TopOpt_in_PETSc/bundled/Makefile new file mode 100644 index 00000000000..08ba2ca8bef --- /dev/null +++ b/T/TopOpt_in_PETSc/bundled/Makefile @@ -0,0 +1,18 @@ +CXXFLAGS = -fPIC +CPPFLAGS =-I. -I$(includedir) -I$(libdir)/petsc/double_real_Int32/include -I$(libdir)/petsc/double_real_Int32/ +LDFLAGS = -L$(libdir) -Wl,-rpath,$(libdir)/petsc/double_real_Int32/lib -L$(libdir)/petsc/double_real_Int32/lib +LDLIBS = -lpetsc_double_real_Int32 +ifneq (,$(findstring mingw,$(target))) + LDLIBS += -lmsmpi +else + LDLIBS += -lmpi +endif + +topopt$(exeext): main.o TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o + $(CXX) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) + +libtopopt.$(dlext): TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o + $(CXX) $(CPPFLAGS) -shared -o $@ $^ $(LDFLAGS) $(LDLIBS) + +clean: + rm -rf topopt$(exeext) libtopopt.$(dlext) *.o output* binary* log* makevtu.pyc Restart* diff --git a/T/TopOpt_in_PETSc/bundled/patches/petsc_name_mangle.patch b/T/TopOpt_in_PETSc/bundled/patches/petsc_name_mangle.patch new file mode 100644 index 00000000000..1693a10b05f --- /dev/null +++ b/T/TopOpt_in_PETSc/bundled/patches/petsc_name_mangle.patch @@ -0,0 +1,14 @@ +diff --git a/config/BuildSystem/config/packages/BlasLapack.py b/config/BuildSystem/config/packages/BlasLapack.py +index bbae50c096..9ad0a994eb 100644 +--- a/config/BuildSystem/config/packages/BlasLapack.py ++++ b/config/BuildSystem/config/packages/BlasLapack.py +@@ -121,7 +121,8 @@ class Configure(config.package.Package): + foundLapack = 0 + self.f2c = 0 + # allow a user-specified suffix to be appended to BLAS/LAPACK symbols +- self.suffix = self.argDB.get('with-blaslapack-suffix', '') ++ # argDB return a list when with-blaslapack-suffix is used ++ self.suffix = self.argDB.get('with-blaslapack-suffix', '')[0] + mangleFunc = self.compilers.fortranMangling + self.logPrint('Checking for Fortran name mangling '+mangleFunc+' on BLAS/LAPACK') + foundBlas = self.checkBlas(blasLibrary, self.getOtherLibs(foundBlas, blasLibrary), mangleFunc,'dot')