Artistic Style - Install Information

# Artistic Style Install Information

### Contents

Artistic Style Versions

Linux Version

GCC Compiler

Other Makefile Options

Clang Compiler

Intel Compiler

Mac OS X Version

Windows Version

Precompiled Executable

Visual C++ Compiler

Other Compilers

Compiler Options

### Artistic Style Versions

astyle_x.x_linux.tar.gz is the Linux version of Artistic Style. It contains the source code, documentation, and makefiles. The Linux Version compile instructions below give information for compiling the source code.

astyle_x.x_macosx.tar.gz is the Mac OS X version of Artistic Style. It contains the source code, documentation, and a makefile. The Mac OS X Version compile instructions below give information for compiling the source code.

astyle_x.x_windows.zip is the Windows version of Artistic Style. It contains the source code, documentation, Visual C project files, and an executable. The Windows Version compile instructions below give information for compiling the source code.

Only one platform is supported in each distribution package. If you use Artistic Style on more than one platform you will need to download packages for each platform. The main difference in platforms is the build directories and the line endings. Most compilers and development packages will accept any type of line ending. The source code and documentation are the same for all distributions.

### Linux Version

#### GCC Compiler

To compile using the GCC compiler you must have GCC (3.1 or better) installed.

The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the astyle/build/gcc directory. The executables will be in the astyle/build/gcc/bin directory. To build the command line configuration enter the following:

    cd astyle/build/gcc
    make

To build the other astyle configurations you can enter the file name or a symbolic name. Entering "make astyle" or "make release" will build the command line configuration. Following are the symbolic names and file names (in parens) of the various configurations:

- release builds the Artistic Style command line program (astyle). This is the default option.
- shared builds the Artistic Style program as a shared library (libastyle.so).
- static builds the Artistic Style program as a static library (libastyle.a).
- debug builds the Artistic Style command line program with debugging information (astyled).
- shareddebug builds the Artistic Style program as a shared library with debugging information (libastyled.so).
- staticdebug builds the Artistic Style program as a static library with debugging information (libastyled.a).
- all builds all of the above configurations.

  The following Java shared library builds are separate from the above. They include a Java Native Interface (JNI) and require that the Java Development Kit (JDK) be installed. The environment variable JAVA_HOME should be defined. It defines the install directory for the JDK. The makefile also has default install directories for Java 5 and 6. If the compile cannot find the file jni.h, either set the variable or change the value in the makefile.

- java builds the Artistic Style program as a shared library which includes the JNI (libastylej.so).
- javadebug builds the Artistic Style program as a shared library which includes the JNI and debugging information (libastylejd.so).
- javaall builds all of the above java configurations.

More than one configuration can be built at the same time. For example, to build all of the release configurations enter:

    cd astyle/build/gcc
    make release shared static

#### Other Makefile Options

The following makefile options are available for GCC, Clang, Intel, and Mac.

##### clean

Removes the object and executable files for all configurations.

To remove the files for all configurations:

    make clean

##### cleanobj

Removes the object files for all configurations. The executables will not be removed.

To remove only the object files for all configurations:

    make cleanobj

##### install

Installs the executable and documentation files. The default is /usr/bin for the executable and /usr/share/astyle for the documentation. You must have the appropriate permissions to use install.

To install the astyle to the default directories:

    make install

To install astyle to a different bin directory set a value for the macro $(prefix). For example to install the executable to a user's home directory (/home/user/bin):

    make prefix=$HOME install

##### uninstall

Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall.

To uninstall astyle from the default directories:

    make uninstall

To uninstall the files from a different directory set a value for the macro $(prefix). For example to uninstall the files from a user's home directory (/home/user):

     make prefix=$HOME uninstall

NOTE: The uninstall option will NOT remove the .astylerc files from the users home directories. The files must be removed individually for each user.

#### Clang Compiler

The Clang Compiler release 2.9.11 has a problem finding object files on some distributions (Ubuntu based). There is a script file, copyfiles.sh, that will copy three object files to the clang build directory so they can be linked. The directory may need to be modified for your distribution. Or, you may not need it at all. This problem has been fixed in version 3.0.

Clang has a static analyzer that finds potential bugs in C/C++ and Objective-C programs. It can be run as a standalone tool from the command-line, and runs in tandem with a build. There is a script file, analyze.sh, that will run the analysis on Artistic Style.

The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the astyle/build/clang directory. The executables will be in the astyle/build/clang/bin directory. To build the command line configuration enter the following:

    cd astyle/build/clang
    make

To build the other astyle configurations you can enter the file name or a symbolic name. The configurations for Clang are the same as for the GCC compiler. More than one configuration can be built at the same time. For example, to build all of the release configurations enter:

    cd astyle/build/clang
    make release shared static

The Other Makefile Options are the same as for the GCC compiler.

#### Intel Compiler

The compiler release should be 2011.1.107 or higher. These procedures and the makefile will not work for earlier versions.

To compile the source there are environment variables that must be set. If this has not been done already enter: "source <install-dir>/bin/iccvars.sh <arg>", where <install-dir> is the directory where the compiler is installed and <arg> is ia32 or intel64 . On an Intel x64 platform installed in the default directory the instruction would be

    source /opt/intel/bin/iccvars.sh intel64

If this is not done the make will display an error message "*** No rule to make target `obj/astyle_main.o', needed by `astyle'." Instructions for the options are in the compiler documentation file "getting_started_c.pdf" in the section "Starting the Compiler from the Command Line".

The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the astyle/build/intel directory. The executables will be in the astyle/build/intel/bin directory. To build the command line configuration enter the following:

    cd astyle/build/intel
    make

To build the other astyle configurations you can enter the file name or a symbolic name. The configuration names for Intel are the same as for the GCC compiler. More than one configuration can be built at the same time. For example, to build all of the debug configurations enter:

    cd astyle/build/intel
    make debug shareddebug staticdebug

The Other Makefile Options are the same as for the GCC compiler.

### Mac OS X Version

The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the astyle/build/mac directory. The executables will be in the astyle/build/mac/bin directory. To build the command line configuration enter the following:

    cd astyle/build/mac
    make

To build the other astyle configurations you can enter the file name or a symbolic name. The configurations for Mac are the same as for the Linux GCC compiler. More than one configuration can be built at the same time. For example, to build all of the release configurations enter:

    cd astyle/build/mac
    make release shared static

The Other Makefile Options are the same as for the Linux GCC compiler.

### Windows Version

#### Precompiled Executable

In addition to the source files, the Windows distribution package contains an Artistic Style Win32 executable (AStyle.exe). If you prefer to compile the executable yourself follow the following instructions.

#### Visual C++ Compiler

There are configuration and project files for 3 versions of the Visual C compiler; build/vs2005 (Visual Studio 2005), build/vs2008 (Visual Studio 2008) and build/vs2010 (Visual Studio 2010). Open the AStyle configuration file in the appropriate "build" directory. All project files have Debug, Release and Static configurations. Debug file output will be in the "debug" directory. Release file output will be in the "bin" directory. Static file output will be in the "binstatic" directory. The following solution files are available.

- All AStyle builds the release and the debug configurations for all of the following.
- AStyle builds the Artistic Style command line program (AStyle.exe). This project has an extra "Static" option. It is the same as the "Release" build except that it is linked with a static runtime library. This is needed if the executable is to be run on a system without Visual Studio installed. The builds for this configuration are placed in a separate "binstatic" directory.
- AStyleDll builds the Artistic Style program as a Dynamic Link Library (AStyle.dll). This will also build an exports library and a static library for linking the dll.
- AStyleJava builds the Artistic Style program as a Dynamic Link Library (AStylej.dll) that can be called from a Java program. The Java Development (JDK) is required for the project to compile. This builds the Artistic Style as a Dynamic Link Library (AStylej.dll) that can be called from a Java program. The Project Properties must have an include path to the JDK include and include/win32 directories. This is set in "Project > Properties > C/C++ > General > Additional Include Directories". The default setting is for the JDK to be installed in the default directory, but it may not be the most current release. The output DLL can also be called from a C++ or C# program.
- AStyleLib builds the Artistic Style program as a Static Library (libAStyle.lib). This can be statically linked to a calling program.

#### Other Compilers

To use other compilers a project file must be built using a development environment.

- Create a project using the compiler's development environment
- Add to the project all the .cpp and .h files in the "src" directory.
- The Compiler Options section discusses the compiler options to use.
- Compile.

### Compiler Options

No macro definitions are required to compile the executable. To compile as a static or shared (dynamic) library define the macro ASTYLE_LIB. To compile a Java shared (dynamic) library define the macro ASTYLE_JNI. Then use the appropriate compiler and linker options to compile the static or shared library. Add debug options to compile the debug versions.

Artistic Style is a small program and it is best to optimize for speed. The debug configurations are not usually optimized. To optimize for speed in the release configurations use the macro NDEBUG to remove asserts. If necessary, use an option to activate the C++11 standards (--std=c++0x on GCC and MinGW). Use an option that allows inline function expansion. Runtime Type Information (RTTI) is NOT needed. Exceptions are not used. Use whole program optimization if your compiler supports it. There may be other options you can use depending on the compiler.