forked from michal-tomlein/sha256crack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (39 loc) · 1.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
CC=gcc
UNAME_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
ifeq ($(UNAME_S),Darwin)
CFLAGS=-std=gnu99 -fopenmp
LIBS=-framework OpenCL
else
CUDA_INCLUDE=/usr/local/cuda/include
CFLAGS=-std=gnu99 -fopenmp -I$(CUDA_INCLUDE)
LIBS=-lm -lOpenCL
endif
EXECUTABLE=sha256crack
OUTPUT_DIR=build
INSTALL_PREFIX=/usr/local
SOURCES=sha256.c
HEADERS=$(SOURCES:.c=.h)
OBJECTS=$(addprefix $(OUTPUT_DIR)/,$(SOURCES:.c=.o))
OTHER_OBJECTS=$(addprefix $(OUTPUT_DIR)/,main.o)
all: $(OUTPUT_DIR)/$(EXECUTABLE)
$(OUTPUT_DIR)/$(EXECUTABLE): $(OBJECTS) $(OTHER_OBJECTS)
$(CC) $(CFLAGS) $(LIBS) -o $(OUTPUT_DIR)/$(EXECUTABLE) $(OBJECTS) $(OTHER_OBJECTS)
$(OUTPUT_DIR)/main.o: main.c sha256.cl.h sha256.h
$(CC) $(CFLAGS) -o $@ -c $<
$(OUTPUT_DIR)/%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -o $@ -c $<
sha256.cl.h: sha256.cl
echo "const char * program_source =" > sha256.cl.h
sed 's/"/\\\\"/g' sha256.cl | while read line; do \
echo '"'"$$line\\\n"'"' >> sha256.cl.h; \
done
echo ';' >> sha256.cl.h;
install: all
cp -f $(OUTPUT_DIR)/$(EXECUTABLE) $(INSTALL_PREFIX)/bin/$(EXECUTABLE)
cp -f sha256crack.1 $(INSTALL_PREFIX)/share/man/man1/sha256crack.1
uninstall:
rm -f $(INSTALL_PREFIX)/bin/$(EXECUTABLE)
rm -f $(INSTALL_PREFIX)/share/man/man1/sha256crack.1
clean:
rm -f $(OBJECTS) $(OTHER_OBJECTS)
rm -f sha256.cl.h