diff --git a/Makefile b/Makefile index 33fc95f1..72c5355e 100644 --- a/Makefile +++ b/Makefile @@ -13,40 +13,56 @@ BIN_TARGETS=$(patsubst imag-%,,$(BINS)) LIB_TARGETS=$(LIBS) LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),test-$(x)) TARGETS=$(BIN_TARGETS) $(LIB_TARGETS) +RELEASE_TARGETS=$(foreach x,$(TARGETS),$(x)-release) +INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install) UPDATE_TARGETS=$(foreach x,$(TARGETS),$(x)-update) CLEAN_TARGETS=$(foreach x,$(TARGETS),$(x)-clean) all: $(TARGETS) - @$(ECHO) "\t[ALL ]" + @$(ECHO) "\t[ALL ]" + +release: $(RELEASE_TARGETS) + @$(ECHO) "\t[RELEASE]" bin: $(BIN_TARGETS) - @$(ECHO) "\t[ALLBIN]" + @$(ECHO) "\t[ALLBIN ]" lib: $(LIB_TARGETS) - @$(ECHO) "\t[ALLLIB]" + @$(ECHO) "\t[ALLLIB ]" lib-test: $(LIB_TARGETS_TEST) +install: $(INSTALL_TARGETS) + @$(ECHO) "\t[INSTALL]" + update: $(UPDATE_TARGETS) - @$(ECHO) "\t[UPDATE]" + @$(ECHO) "\t[UPDATE ]" clean: $(CLEAN_TARGETS) - @$(ECHO) "\t[CLEAN ]" + @$(ECHO) "\t[CLEAN ]" $(TARGETS): %: .FORCE - @$(ECHO) "\t[CARGO ]:\t$@" + @$(ECHO) "\t[CARGO ]:\t$@" @$(CARGO) build --manifest-path ./$@/Cargo.toml +$(RELEASE_TARGETS): %: .FORCE + @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)" + @$(CARGO) build --release --manifest-path ./$(subst -release,,$@)/Cargo.toml + $(LIB_TARGETS_TEST): %: .FORCE - @$(ECHO) "\t[TEST ]:\t$@" + @$(ECHO) "\t[TEST ]:\t$@" @$(CARGO) test --manifest-path ./$(subst test-,,$@)/Cargo.toml +$(INSTALL_TARGETS): %: .FORCE + @$(ECHO) "\t[INSTALL]:\t$(subst -install,,$@)" + @$(CARGO) install --force --path ./$(subst -install,,$@) + $(UPDATE_TARGETS): %: .FORCE - @$(ECHO) "\t[UPDATE]:\t$(subst -update,,$@)" + @$(ECHO) "\t[UPDATE ]:\t$(subst -update,,$@)" @$(CARGO) update --manifest-path ./$(subst -update,,$@)/Cargo.toml $(CLEAN_TARGETS): %: .FORCE - @$(ECHO) "\t[CLEAN]:\t$(subst -clean,,$@)" + @$(ECHO) "\t[CLEAN ]:\t$(subst -clean,,$@)" @$(CARGO) clean --manifest-path ./$(subst -clean,,$@)/Cargo.toml .FORCE: diff --git a/README.md b/README.md index 4c55a90f..08067e72 100644 --- a/README.md +++ b/README.md @@ -106,43 +106,61 @@ Here goes how to try imag out. ### Building -One can build all the modules simply by running `make` which defaults to -building all the modules and placing them in the `out/` directory of the project -root. +By now, there are several targets in the Makefile, fulfilling following roles: +* `all` Is the default and builds every crate in debug mode. This is the same as + traversing every directory yourself and calling `cargo build` in it. + To build a single crate, call `make `, for example + `make imag-store` +* `release`, as the name implies, builds every crate in release mode. Following + the example above, to build `imag-store` in release mode, call + `make imag-store-release`. +* `install` will install all binary crates to the default installation root (see + `man cargo-install`). To install a single module, run `make -install`, + again, for example: `make imag-store-install` +* `bin`/`lib` are separate targets for either building all binaries or + libraries. +* `lib-test` runs `cargo test` for all libraries. For testing a single library, + run `make test-libimagstore` for example. +* `clean` will run `cargo clean` in every crate. Again, for cleaning a single + crate, use `make imag-store-clean` for example. -``` -$> make - ... -$> ls out/ -imag-counter imag-link imag-notes imag-store imag-tag imag-view -``` - -Building all the modules may take some time, so alternatively one can build only -a specific module -by runing `$> make $module` where `$module` is one of the `imag-*` names, such -as `imag-counter`, `imag-link`, etc. +**There is currently no target for the `imag` binary itself. Please +build/install it yourself using `cargo build --manifest-path ./bin/Cargo.toml`** ### Running -To run imag, simply call `./out/imag`. -If you include the `out` directory in your `$PATH`, imag is able to find the -other imag executables. Try it out by running: +To test out a single module, simply using `cargo run -- ` in the +respective directory will do the trick. For using it "normally", install the +binaries as described above, as well as the imag-binary: +``` +$> make install +$> cargo install --path ./bin +``` +The installation root of the binaries (a.k.a. where they are installed to), may +not yet be in your $PATH. To see, where this installation root is, check out +`man cargo-install`. To change the $PATH in bash: ```bash -$> PATH=$PATH:$(pwd)/out imag --help +$> PATH=$PATH:~/.cargo/bin +$> imag --help ``` To test, simply add `--help` to one of the above commands: ```bash -$> PATH=$PATH:$(pwd)/out imag counter --help +$> imag counter --help ``` +Please note that $PATH will be reset in a new shell. To make these changes +permanent, see the User Guide of your shell. + ## Documentation For detailed information, please read [the documentation](./doc/) (You can either read the Markdown files or compile it to HTML/PDF using [pandoc](http://pandoc.org)). +Developer documentation is also available +[online on github.io](https://matthiasbeyer.github.io/imag/imag_documentation/index.html). Please note that the documentation is work in progress as well and may be outdated.