Difference between revisions of "Artistic Style"
(Created page with "'''Artistic Style''' (command: <code>astyle</code>) is a source formatter for C-like programming languages. ==Installation== Because new and desirable features are added way...") |
|||
Line 11: | Line 11: | ||
* The Makefile will have to be patched so that <code>DESTDIR</code> is supported. | * The Makefile will have to be patched so that <code>DESTDIR</code> is supported. | ||
* The prefix /usr/local will be passed directly to make as a variable. | * The prefix /usr/local will be passed directly to make as a variable. | ||
+ | |||
+ | ===Unpack=== | ||
Start by unpacking and going to the build dir for gcc. | Start by unpacking and going to the build dir for gcc. | ||
Line 19: | Line 21: | ||
$ cd astyle/build/gcc</nowiki> | $ cd astyle/build/gcc</nowiki> | ||
− | In the Makefile, any destination directories ''under '''only''' the <code>install</code> and <code>uninstall</code> targets'' need to be prefixed with <code>$(DESTDIR)</code> and quoted as necessary. | + | ===Add DESTDIR support in Makefile=== |
+ | |||
+ | In the Makefile, any destination directories ''under '''only''' the <code>install</code> and <code>uninstall</code> targets'' need to be prefixed with <code>$(DESTDIR)</code> and quoted as necessary. As of astyle 3.0.1, this is done with the following changes: | ||
* Replace any <code>$(ipath)</code> with <code>"$(DESTDIR)$(ipath)"</code>. | * Replace any <code>$(ipath)</code> with <code>"$(DESTDIR)$(ipath)"</code>. | ||
* Replace any <code>$(SYSCONF_PATH)</code> with <code>"$(DESTDIR)$(SYSCONF_PATH)"</code>. | * Replace any <code>$(SYSCONF_PATH)</code> with <code>"$(DESTDIR)$(SYSCONF_PATH)"</code>. | ||
+ | |||
+ | My diff for astyle 3.0.1 looked like this: | ||
+ | |||
+ | <syntaxhighlight lang=diff> | ||
+ | --- Makefile.original 2017-10-20 11:04:21.741319875 -0400 | ||
+ | +++ Makefile 2017-10-20 11:05:29.609323159 -0400 | ||
+ | @@ -193,20 +193,20 @@ | ||
+ | rm -f $(objdir)/*.o | ||
+ | |||
+ | install: | ||
+ | - $(INSTALL) -m 755 -d $(ipath) | ||
+ | - @$(INSTALL) -m 755 $(bindir)/astyle $(ipath) | ||
+ | + $(INSTALL) -m 755 -d "$(DESTDIR)$(ipath)" | ||
+ | + @$(INSTALL) -m 755 $(bindir)/astyle "$(DESTDIR)$(ipath)" | ||
+ | |||
+ | - @if [ -d $(SYSCONF_PATH)/html ]; then \ | ||
+ | - rm -rf $(SYSCONF_PATH)/html; \ | ||
+ | + @if [ -d "$(DESTDIR)$(SYSCONF_PATH)"/html ]; then \ | ||
+ | + rm -rf "$(DESTDIR)$(SYSCONF_PATH)"/html; \ | ||
+ | fi | ||
+ | |||
+ | - $(INSTALL) -m 755 -d $(SYSCONF_PATH) | ||
+ | - @mkdir -p $(SYSCONF_PATH)/html; | ||
+ | + $(INSTALL) -m 755 -d "$(DESTDIR)$(SYSCONF_PATH)" | ||
+ | + @mkdir -p "$(DESTDIR)$(SYSCONF_PATH)"/html; | ||
+ | @for files in ../../doc/*.html ../../doc/*.css; \ | ||
+ | do \ | ||
+ | - $(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \ | ||
+ | + $(INSTALL) -m 644 $$files "$(DESTDIR)$(SYSCONF_PATH)"/html; \ | ||
+ | done | ||
+ | |||
+ | uninstall: | ||
+ | - rm -f $(ipath)/astyle | ||
+ | - rm -rf $(SYSCONF_PATH) | ||
+ | + rm -f "$(DESTDIR)$(ipath)"/astyle | ||
+ | + rm -rf "$(DESTDIR)$(SYSCONF_PATH)" | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===Create fake install dir with mkake=== | ||
Use [[mkfake]] to set up a fake destination directory. mkfake arranges for the install prefix under the fake dir to link to a directory with the name of the package (in this case <code>astyle-3.0.1</code>); this directory will be [[stow]]ed later. | Use [[mkfake]] to set up a fake destination directory. mkfake arranges for the install prefix under the fake dir to link to a directory with the name of the package (in this case <code>astyle-3.0.1</code>); this directory will be [[stow]]ed later. | ||
Line 29: | Line 72: | ||
$ eval "`PACKAGE=astyle-3.0.1 mkfake`" | $ eval "`PACKAGE=astyle-3.0.1 mkfake`" | ||
# Agree to prompts - refer to </nowiki>[[mkfake]]<nowiki> for more information</nowiki> | # Agree to prompts - refer to </nowiki>[[mkfake]]<nowiki> for more information</nowiki> | ||
+ | |||
+ | ===Build and install to fake=== | ||
Use make to build and install the program. Note that <code>make install</code> won't work on its own; one of the astyle build targets (such as <code>release</code>) must be built first. | Use make to build and install the program. Note that <code>make install</code> won't work on its own; one of the astyle build targets (such as <code>release</code>) must be built first. | ||
Line 37: | Line 82: | ||
# Build the release version and install it to the fake dir | # Build the release version and install it to the fake dir | ||
$ make prefix="$REAL" DESTDIR="$FAKE" release install</nowiki> | $ make prefix="$REAL" DESTDIR="$FAKE" release install</nowiki> | ||
+ | |||
+ | ===Move the fake install dir into /usr/local/stow and stow it=== | ||
Once that's done, [[stow]] the result as with any mkfake'd build. | Once that's done, [[stow]] the result as with any mkfake'd build. |
Revision as of 08:14, 20 October 2017
Artistic Style (command: astyle
) is a source formatter for C-like programming languages.
Contents
Installation
Because new and desirable features are added way before your distro picks them up in the standard package, this is a program you'll want to compile and install manually.
The program unfortunately has a static Makefile and doesn't use a configure
script, so using stow is a bit more difficult than normal.
We use almost the normal mkfake process here, with these subtleties:
- The Makefile will have to be patched so that
DESTDIR
is supported. - The prefix /usr/local will be passed directly to make as a variable.
Unpack
Start by unpacking and going to the build dir for gcc.
# In /tmp (substitute another dir as appropriate) $ tar xvf ~/src/astyle_3.0.1_linux.tar.gz $ cd astyle/build/gcc
Add DESTDIR support in Makefile
In the Makefile, any destination directories under only the install
and uninstall
targets need to be prefixed with $(DESTDIR)
and quoted as necessary. As of astyle 3.0.1, this is done with the following changes:
- Replace any
$(ipath)
with"$(DESTDIR)$(ipath)"
. - Replace any
$(SYSCONF_PATH)
with"$(DESTDIR)$(SYSCONF_PATH)"
.
My diff for astyle 3.0.1 looked like this:
--- Makefile.original 2017-10-20 11:04:21.741319875 -0400
+++ Makefile 2017-10-20 11:05:29.609323159 -0400
@@ -193,20 +193,20 @@
rm -f $(objdir)/*.o
install:
- $(INSTALL) -m 755 -d $(ipath)
- @$(INSTALL) -m 755 $(bindir)/astyle $(ipath)
+ $(INSTALL) -m 755 -d "$(DESTDIR)$(ipath)"
+ @$(INSTALL) -m 755 $(bindir)/astyle "$(DESTDIR)$(ipath)"
- @if [ -d $(SYSCONF_PATH)/html ]; then \
- rm -rf $(SYSCONF_PATH)/html; \
+ @if [ -d "$(DESTDIR)$(SYSCONF_PATH)"/html ]; then \
+ rm -rf "$(DESTDIR)$(SYSCONF_PATH)"/html; \
fi
- $(INSTALL) -m 755 -d $(SYSCONF_PATH)
- @mkdir -p $(SYSCONF_PATH)/html;
+ $(INSTALL) -m 755 -d "$(DESTDIR)$(SYSCONF_PATH)"
+ @mkdir -p "$(DESTDIR)$(SYSCONF_PATH)"/html;
@for files in ../../doc/*.html ../../doc/*.css; \
do \
- $(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \
+ $(INSTALL) -m 644 $$files "$(DESTDIR)$(SYSCONF_PATH)"/html; \
done
uninstall:
- rm -f $(ipath)/astyle
- rm -rf $(SYSCONF_PATH)
+ rm -f "$(DESTDIR)$(ipath)"/astyle
+ rm -rf "$(DESTDIR)$(SYSCONF_PATH)"
Create fake install dir with mkake
Use mkfake to set up a fake destination directory. mkfake arranges for the install prefix under the fake dir to link to a directory with the name of the package (in this case astyle-3.0.1
); this directory will be stowed later.
$ eval "`PACKAGE=astyle-3.0.1 mkfake`" # Agree to prompts - refer to mkfake for more information
Build and install to fake
Use make to build and install the program. Note that make install
won't work on its own; one of the astyle build targets (such as release
) must be built first.
This invocation of make is also where prefix
and DESTDIR
must be set. mkfake has added the correct values in the environment as REAL
and FAKE
, respectively.
# Build the release version and install it to the fake dir $ make prefix="$REAL" DESTDIR="$FAKE" release install
Move the fake install dir into /usr/local/stow and stow it
Once that's done, stow the result as with any mkfake'd build.
# Install the build to the stow dir and stow it cd /usr/local/stow sudo mv "$FAKE/$PACKAGE" ./ sudo stow "$PACKAGE"