-
Notifications
You must be signed in to change notification settings - Fork 118
Add support for Makefiles and generic build scripts #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
16daa62
778fb0e
91a649c
ac01e26
100d30c
5fae72c
a124c42
ec8855d
df531fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ for it to successfully build with the Fortran Package Manager (FPM). | |
| - [Multi-level library](#multi-level-library) | ||
| - [Be more explicit](#be-more-explicit) | ||
| - [Add some tests](#add-some-tests) | ||
| - [Adding dependencies](#adding-dependencies) | ||
| - [Custom build scripts](#custom-build-scripts) | ||
|
|
||
| ## What kind of package can FPM build? | ||
|
|
||
|
|
@@ -662,3 +664,32 @@ You can even specify the path to another folder, if for example you've got anoth | |
| fpm package in the same repository. Like this: `helloff = { path = "helloff" }`. | ||
| Note that you should *not* specify paths outside of your repository, or things | ||
| won't work for your users. | ||
|
|
||
| ### Custom Build Scripts | ||
|
|
||
| If there is something special about your library that makes fpm unable to build | ||
| it, you can provide your own build script. fpm will then simply call your | ||
| build script to build the library. | ||
|
|
||
| To specify a build script to be used, put it in the library section of your | ||
| `fpm.toml` file, like: | ||
|
|
||
| ```toml | ||
| [library] | ||
| source-dir="src" | ||
| build-script="my_build_script" | ||
| ``` | ||
|
|
||
| fpm will set the following environment variables to specify some parameters to | ||
| the build script. | ||
|
|
||
| * `FC` - The Fortran compiler to be used | ||
| * `FFLAGS` - The flags that should be passed to the Fortran compiler | ||
| * `BUILD_DIR` - Where the compiled files should be placed | ||
| * `INCLUDE_DIRS` - The folders where any dependencies can be found | ||
|
|
||
| Additionally, script will be called with the name of the archive (`*.a` file) | ||
| that should be produced as the command line argument. | ||
|
Comment on lines
+693
to
+694
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a full path to the archive file including
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is the full path. And it actually is also for Makefiles. This is the target specified, so your Makefile doesn't necessarily have to have the library as the default target.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, that makes a lot of sense. I would suggest also stating that explicitly in the following section about invoking |
||
|
|
||
| > Note: If the name of the build script is `Makefile` or ends with `.mk`, then | ||
| > the make program will be used to run it. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ dependencies: | |
| - directory | ||
| - extra | ||
| - filepath | ||
| - MissingH | ||
| - optparse-applicative | ||
| - process | ||
| - shake | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| build/* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| INCLUDE_FLAGS = $(addprefix -I,$(INCLUDE_DIRS)) | ||
|
|
||
| $(BUILD_DIR)/libmakefile_complex.a: $(BUILD_DIR)/wrapper_mod.o | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to prefix all the environment variables with
etc.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ones I used are actually the standard environment variables for Makefiles. You (almost) can use an empty Makefile and these would actually work. We can use prefixed variables, but it's one extra difference from what a lot of people will already have and be used to.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems fine to me - |
||
| ar rs $(@) $(^) | ||
|
|
||
| $(BUILD_DIR)/wrapper_mod.mod: src/wrapper_mod.f90 | ||
|
|
||
| $(BUILD_DIR)/wrapper_mod.o: src/wrapper_mod.f90 | ||
| $(FC) -c -J$(BUILD_DIR) $(INCLUDE_FLAGS) $(FFLAGS) -o $(@) $(<) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| program makefile_complex | ||
| use wrapper_mod, only: do_stuff | ||
|
|
||
| implicit none | ||
|
|
||
| call do_stuff | ||
| end program makefile_complex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trailing 'S' implies multiple folders can be specified - is this done in a system-dependent manner using colon/semicolon separators? If so, it's worth mentioning that here. (I had thought multiple include paths had to be specified with multiple
-Iflags.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are space separated. So yes, that should be mentioned here, and it is then necessary for your build script to turn this list into the appropriate flags for the compiler(s). I'll add this info.