package org.apache.maven.plugin.nar;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import java.io.File;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Runs make on the GNU style generated Makefile
 * 
 * @goal nar-gnu-make
 * @phase compile
 * @requiresProject
 * @author Mark Donszelmann
 */
public class NarGnuMakeMojo
    extends AbstractGnuMojo
{
    public final void narExecute()
        throws MojoExecutionException, MojoFailureException
    {
        if ( !useGnu() )
        {
            return;
        }

        File srcDir = getGnuAOLSourceDirectory();
        if ( srcDir.exists() )
        {
            getLog().info( "Running GNU make" );
            int result = NarUtil.runCommand( "make", null, srcDir, null, getLog() );
            if ( result != 0 )
            {
                throw new MojoExecutionException( "'make' errorcode: " + result );
            }

            result = NarUtil.runCommand( "make", new String[] { "install" }, srcDir, null, getLog() );
            if ( result != 0 )
            {
                throw new MojoExecutionException( "'make install' errorcode: " + result );
            }
        }
    }
}

@@ -1185,261 +1185,1055 @@
     
-public final void narExecute()%0A        throws MojoExecutionException, MojoFailureException%0A    %7B%0A        if ( !useGnu() )%0A        %7B%0A            return;%0A        %7D%0A%0A        File srcDir = getGnuAOLSourceDirectory();%0A        if ( srcDir.exists() )%0A        %7B
+/**%0A     * Space delimited list of arguments to pass to make%0A     *%0A     * @parameter expression=%22%22%0A     */%0A    private String gnuMakeArgs;%0A%0A    /**%0A     * Comma delimited list of environment variables to setup before running make%0A     *%0A     * @parameter expression=%22%22%0A     */%0A    private String gnuMakeEnv;%0A%0A    /**%0A     * Boolean to control if we should run make instal after the make%0A     *%0A     * @parameter expression=%22%22 default-value=%22false%22%0A     */%0A    private boolean gnuMakeInstallSkip;%0A%0A    public final void narExecute()%0A        throws MojoExecutionException, MojoFailureException%0A    %7B%0A        if ( !useGnu() )%0A        %7B%0A            return;%0A        %7D%0A%0A        File srcDir = getGnuAOLSourceDirectory();%0A        if ( srcDir.exists() )%0A        %7B%0A            String%5B%5D args= null;%0A            String%5B%5D env= null;%0A%0A            if ( gnuMakeArgs != null )%0A            %7B%0A               args= gnuMakeArgs.split( %22 %22 );%0A            %7D%0A            if ( gnuMakeEnv != null )%0A            %7B%0A               env= gnuMakeEnv.split( %22,%22 );%0A            %7D%0A
 %0A   
@@ -2331,20 +2331,20 @@
 %22make%22, 
-null
+args
 , srcDir
@@ -2337,36 +2337,35 @@
 , args, srcDir, 
-null
+env
 , getLog() );%0A  
@@ -2521,71 +2521,443 @@
     
-result = NarUtil.runCommand( %22make%22, new String%5B%5D %7B %22install%22 %7D
+if ( !gnuMakeInstallSkip )%0A            %7B%0A               getLog().info( %22Running make install%22 );%0A               if ( args != null )%0A               %7B%0A                  gnuMakeArgs= gnuMakeArgs + %22 install%22;%0A                  args= gnuMakeArgs.split( %22 %22 );%0A               %7D%0A               else%0A               %7B%0A                  args= new String%5B%5D %7B %22install%22 %7D;%0A               %7D%0A               result = NarUtil.runCommand( %22make%22, args
 , sr
@@ -2972,32 +2972,35 @@
 ll, getLog() );%0A
+   
             if (
@@ -3018,32 +3018,35 @@
 0 )%0A            
+   
 %7B%0A              
@@ -3039,32 +3039,35 @@
                 
+ 
+  
 throw new MojoEx
@@ -3117,32 +3117,49 @@
 : %22 + result );%0A
+               %7D%0A
             %7D%0A  

Add the ability to controll arguments and environment variable when make runs; also option to skip make install step.