views:

57

answers:

1

Compiling a CUDA enabled version of aircrack-ng that hasn't been bug-fixed in a while so needed a bit of patching to get most of the way there.

Basically, the make cannot find the relevant compiler (nvcc) for this one section of code;

Relevent Makefile section

ifeq ($(CUDA), true)
CFLAGS += -DCUDA_ENABLED

NVCC := $(CUDA_BIN)/nvcc
INCLUDES += -I. -I$(CUDA_INSTALL_PATH)/include
COMMONFLAGS += $(INCLUDES) -DUNIX

NVCCFLAGS += --compiler-options -fno-strict-aliasing --host-compilation=C $(COMMONFLAGS)

# Change this only if you have COMPUTE > 1.0
NVCCFLAGS += -maxrregcount 12

# Enable this for extra compiler and as output
#NVCCFLAGS += --ptxas-options "-v" --verbose

LIBSSL += -L$(CUDA_INSTALL_PATH)/lib -L$(CUDA_INSTALL_PATH)/lib64 -lcuda -lcudart

%.o : %.cu   
    $(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $<
endif

Relevant Make output

/nvcc --compiler-options -fno-strict-aliasing --host-compilation=C -I. -I/include -DUNIX -maxrregcount 12  -o cudacrypto.o -c cudacrypto.cu
make[1]: /nvcc: Command not found
make[1]: *** [cudacrypto.o] Error 127
make[1]: Leaving directory `/home/bolster/src/aircrack-ng-cuda/src'
make: *** [install] Error 2

As you can see it looks like make is dropping the environment variables 'CUDA_BIN'.

Output of echo $CUDA_BIN

/usr/local/cuda/bin

Output of which nvcc

/usr/local/cuda/bin/nvcc

I am not a make-guru by any stretch, so if I'm doing something patently obviously wrong, forgive me.

After trying hard coding the nvcc flag with the full path, that section compiles, but when it comes to a crypto section (involving libssl) it cannot find the necessary libraries, and in a similar fashion as above isn't replacing 'CUDA_INSTALL_PATH', even though it is in the environment, which indicates to be that something weird is going on.

+1  A: 

It's usually not a good idea to rely on environmental variables in a makefile. Making the value explicit in the makefile, or specifying it in the call (e.g. make CUDA=...) is actually the correct way to go.

If you still want to use the value from the environment, I don't know why your makefile isn't working, but you can try this:

 CUDA_BIN := $(shell echo $$CUDA_BIN)
Beta
That way worked but if explicit declaration is the right way to go then that answers my question.
Andrew Bolster