aligrudi / neatroff_make

Neatroff top-level makefile
50 stars 15 forks source link

Can't set PREFIX to different directory #6

Closed averms closed 3 years ago

averms commented 3 years ago

I want to install to /usr/local/src/neatroff so that I can use GNU Stow to symlink binaries to /usr/local. Here is what I tried:

sudo make init CC='gcc -march=native' PREFIX=/usr/local/src/neatroff
sudo make neat CC='gcc -march=native' PREFIX=/usr/local/src/neatroff

The second command fails with

./gen.sh: Font </usr/local/src/neatroff/fonts/NimbusRoman-Regular.afm> not found!

Also, curious about one thing: do I have to run both commands as sudo if I want to install into a root-owned directory? Usually programs will allow you to run make as unprivileged and only require root for make install. I don't think there is an easy way to install, the 'neat' target simply builds but doesn't install.

aligrudi commented 3 years ago

a-vrma notifications@github.com wrote:

I want to install to /usr/local/src/neatroff so that I can use GNU Stow to symlink binaries to /usr/local. Here is what I tried:

sudo make init CC='gcc -march=native' PREFIX=/usr/local/src/neatroff
sudo make neat CC='gcc -march=native' PREFIX=/usr/local/src/neatroff

The second command fails with

./gen.sh: Font </usr/local/src/neatroff/fonts/NimbusRoman-Regular.afm> not found!

Also, curious about one thing: do I have to run both commands as sudo if I want to install into a root-owned directory? Usually programs will allow you to run make as unprivileged and only require root for make install. I don't think there is an easy way to install, the 'neat' target simply builds but doesn't install.

The install branch was not updated for more than two years and the recommended way for using neatroff_make is what the master branch does.

I think a clean alternative to the install target is simply assuming that the neatroff_make directory is not removed (placed inside /usr/local/share/ for instance).

This would probably make using Neatroff easier. See demo/Makefile (I suggest copying this Makefile when using Neatroff; even the fonts directory is passed to Ghostscript); only BASE should be modified to point to the installation prefix.

What is your opinion?

In any case, neatroff_make/demo/neatstart.ms needs to be updated.

Ali
averms commented 3 years ago

I think a clean alternative to the install target is simply assuming that the neatroff_make directory is not removed (placed inside /usr/local/share/ for instance).

The issue with that is that one would have to build the program in the same place they run it from, which is not conducive to packaging. In addition, one would have to keep all the source files and build artifacts around. I think the best setting would be to have a more conventional Makefile. The neat and init targets would build everything in the current directory. The PREFIX variable would be used by the neat target to pass constants (FDIR and MDIR) to neatroff and neatpost. Generating the fonts would be done in the current directory without regards for PREFIX. This way it will work both for people who want to install, and people who just want to try it out. Then make install could look something like

install:
    @cd neatroff && install -Dm755 roff $(PREFIX)/bin/neatroff
    @cp -R devutf $(PREFIX)/share/neatroff/devutf
    # etc.

After installation, PREFIX will be a well organized directory with executables in 'bin' and fonts + macros in 'share/neatroff'.

You could have an uninstall target too but that is not vital.

This would probably make using Neatroff easier. See demo/Makefile (I suggest copying this Makefile when using Neatroff; even the fonts directory is passed to Ghostscript); only BASE should be modified to point to the installation prefix.

Yes, the Makefile is very helpful. Maybe you could recommend copying it in neatstart.ms?

aligrudi commented 3 years ago

a-vrma notifications@github.com wrote:

I think a clean alternative to the install target is simply assuming that the neatroff_make directory is not removed (placed inside /usr/local/share/ for instance).

The issue with that is that one would have to build the program in the same place they run it from, which is not conducive to packaging. In addition, one would have to keep all the source files and build artifacts around. I think the best setting would be to have a more conventional Makefile. The neat and init targets would build everything in the current directory. The PREFIX variable would be used by the neat target to pass constants (FDIR and MDIR) to neatroff and neatpost. Generating the fonts would be done in the current directory without regards for PREFIX. This way it will work both for people who want to install, and people who just want to try it out. Then make install could look something like

install:
  @cd neatroff && install -Dm755 roff $(PREFIX)/bin/neatroff
  @cp -R devutf $(PREFIX)/share/neatroff/devutf
  # etc.

After installation, PREFIX will be a well organized directory with executables in 'bin' and fonts + macros in 'share/neatroff'.

How about using the same directory structure as in neatroff_make:

/usr/local/share/neatroff/ neatroff/ roff neatpost/ post pdf neatmkfn/ mkfn neateqn/ eqn neatrefer/ refer troff/ pic/ pic tbl/ tbl soin/ soin shape/ shape devutf/ DESC ... fonts/ ... tmac/ ... demo/ ... man/ ...

Do you think we have to copy the binaries to $PREFIX/bin? If so, maybe we can create symlinks in $PREFIX/bin.

You could have an uninstall target too but that is not vital.

This would probably make using Neatroff easier. See demo/Makefile (I suggest copying this Makefile when using Neatroff; even the fonts directory is passed to Ghostscript); only BASE should be modified to point to the installation prefix.

Yes, the Makefile is very helpful. Maybe you could recommend copying it in neatstart.ms?

Patches are welcome (we have to update installation section too).

Thanks Ali

aligrudi commented 3 years ago

Please try the following patch.

diff --git a/Makefile b/Makefile index ff18a38..6e83a49 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,11 @@

Neatroff top-level Makefile

Installation prefix

-PREFIX = $(PWD) -# Input fonts directory -FONTS = $(PREFIX)/fonts -# Output device directory -FDIR = $(PREFIX)/ -# Macro directory -MDIR = $(PREFIX)/tmac +PREFIX = /opt +BASE = $(PREFIX)/share/neatroff + +INSTALL = install +MKDIR = mkdir -p -m 755

all: help

@@ -18,6 +16,7 @@ help: @echo " init_fa Initialise for Farsi" @echo " neat Compile the programs and generate the fonts" @echo " pull Update git repositories (git pull)"

@@ -43,16 +42,46 @@ pull: git pull

neat:

averms commented 3 years ago

Worked great for me with the following changes, although the binaries are still in their own directories under share. If you prefer it that way then it's fine. Makes it harder to package or use from the command line (have to add all directories to PATH) but not impossible. Maybe it makes sense since there are many different programs, it's installing more of a "suite" than a single tool.

diff --git a/Makefile b/Makefile
index 32fdec7..117f061 100644
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,7 @@ neat:
        @cd soin && $(MAKE)
        @cd shape && $(MAKE)
        @echo "Generating font descriptions"
-   @cd neatmkfn && ./gen.sh $(PWD)/fonts $(FDIR)/devutf >/dev/null
+   @cd neatmkfn && ./gen.sh $(PWD)/fonts $(PWD)/devutf >/dev/null

 install:
        @echo "Copying binaries to $(BASE)"
@@ -103,4 +103,4 @@ clean:
        @cd troff/pic && $(MAKE) clean
        @cd soin && $(MAKE) clean
        @test ! -d shape || (cd shape && $(MAKE) clean)
-   @rm -r $(FDIR)/devutf
+   @rm -r $(PWD)/devutf

makefile.patch.txt

aligrudi commented 3 years ago

a-vrma notifications@github.com wrote:

Worked great for me with the following changes, although the binaries are still in their own directories under share. If you prefer it that way then it's fine. Makes it harder to package or use from the command line (have to add all directories to PATH) but not impossible. Maybe it makes sense since there are many different programs, it's installing more of a "suite" than a single tool.

The following patch creates symlinks to binaries in PREFIX/bin but I am not sure if this is good idea for the same reason you mentioned:

diff --git a/Makefile b/Makefile index 117f061..e6759c1 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,18 @@ install: @chmod 644 $(BASE)/fonts/ @echo "Updating fontpath in font descriptions" @for f in $(BASE)/devutf/; do sed "/^fontpath /s=$(PWD)/fonts=$(BASE)/devutf=" <$$f >.fd.tmp; mv .fd.tmp $$f; done

makefile.patch.txt

Thanks, Applied.

Ali
averms commented 3 years ago

Ok, issue solved.