Thank you very much! I'll try this and update. On Tue, Nov 7, 2017 at 11:55 AM, John Peterson <jwpeter...@gmail.com> wrote:
> > > On Tue, Nov 7, 2017 at 9:48 AM, Zack Vitoh <jandle...@gmail.com> wrote: > >> Hi, I am new to libmesh, and have installed it to >> $HOME/src/libmesh/build/ >> >> I am trying the simplest thing I can think of: copy the source for >> introduction_ex1.C into a 'myexamples' subdirectory of >> $HOME/src/libmesh/build and create a simple, comprehensible makefile to >> run >> the code. >> >> Do I simply copy and modify the makefile.in from the original example >> like >> so? >> >> example_name = introduction_ex1 >> >> install_dir = $HOME/src/libmesh/build/myexamples/introduction/ex1 >> data = introduction_ex1.C run.sh >> sources = $(data) run.sh >> >> check_SCRIPTS = run.sh >> CLEANFILES = output.xda output.xdr >> >> >> ############################################## >> # include common example environment >> include $(top_srcdir)/examples/Make.common >> >> PS: I do not understand automake, and so do not understand the 1200 lines >> of the makefile.am in the original example, but I sense that I should not >> try to modify this since it is generated by automake >> > > > > My advice is actually to not try and copy an example when getting started > since, as you have seen, the automake system is difficult to work with. > > After "make install" into $LIBMESH_DIR, I'd create your new application in > a different directory (not in the libmesh source tree or installation > directory) and use a human readable Makefile like the one below. > > Put your main program in a file called "foo.cc" and then simply run > "make". Let us know if you run into issues... > > -- > John > > > > # This Makefile assumes you have libmesh built and installed in > $LIBMESH_DIR. > > # If the user has no environment variable > # called METHOD, he gets optimized mode. > ifeq (x$(METHOD),x) > METHOD := opt > endif > > # installed libmesh location of libmesh-config script > libmesh_config := $(LIBMESH_DIR)/bin/libmesh-config > > # Use the libmesh-config script to determine the usual make variables. > # Note: passing $METHOD along to the libmesh-config script handles the > # case where METHOD is not set and the user does > # make METHOD=dbg foo > # since in this case, METHOD is never set in the environment and thus > # never passed to libmesh-config correctly. > libmesh_CXX := $(shell METHOD=$(METHOD) $(libmesh_config) --cxx) > libmesh_INCLUDE := $(shell METHOD=$(METHOD) $(libmesh_config) --include) > libmesh_CPPFLAGS := $(shell METHOD=$(METHOD) $(libmesh_config) --cppflags) > libmesh_CXXFLAGS := $(shell METHOD=$(METHOD) $(libmesh_config) --cxxflags) > libmesh_LIBS := $(shell METHOD=$(METHOD) $(libmesh_config) --libs) > > # File management variables. > headers := $(wildcard *.h) > srcs := $(wildcard *.C) > # Note: spaces are treated as literal characters in patsubst commands! > objs := $(patsubst %.C,%-$(METHOD).o,$(srcs)) > deps := $(patsubst %.C,%-$(METHOD).d,$(srcs)) > > mainfile := $(wildcard *.cc) > mainexe := $(patsubst %.cc,%-$(METHOD),$(mainfile)) > maindep := $(patsubst %.cc,%.d,$(mainfile)) > > .PHONY: clean > > # Disable make builtin rules for compiling .C files into objects > # https://stackoverflow.com/questions/4122831/disable- > make-builtin-rules-and-variables-from-inside-the-make-file > .SUFFIXES: > > # .SECONDARY with no prerequisites causes all targets to be treated as > # secondary (i.e., no target is removed because it is considered > # intermediate). > .SECONDARY: > > all: $(mainexe) > > # Generate object files. > %-$(METHOD).o: %.C > @echo "Compiling" $< > @$(libmesh_CXX) -MMD -MP -MT $@ $(libmesh_INCLUDE) $(libmesh_CPPFLAGS) > $(libmesh_CXXFLAGS) -c $< -o $@ > > # How to build executables. If you have a source file called foo.cc, > # type 'make foo' to build an executable from it. > %-$(METHOD): %.cc $(objs) > @echo "Compiling" $< > @$(libmesh_CXX) -MMD -MP -MT $@ -MF $(maindep) $(libmesh_INCLUDE) > $(libmesh_CPPFLAGS) $(libmesh_CXXFLAGS) $< -o $@ $(libmesh_LIBS) > $(libmesh_LDFLAGS) $(EXTERNAL_FLAGS) $(objs) > > echo: > @echo "$(srcs)" > @echo "$(objs)" > @echo "$(deps)" > @echo "$(maindeps)" > > # File management rules. > clean: > rm -f *~ $(mainexe) $(objs) $(deps) $(maindep) > > # Include all the .d files generated by the compiler, but don't error > # if the files don't exist yet. > -include $(deps) > -include $(maindep) > > > > > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users