Added JavaScript port of the NuHash algorithm.
[nuhash.git] / Makefile
blobb673fee3467d57ddc3ec029142dc6337a0a97754
1 STATIC ?= 0
2 FLTO ?= 0
3 DEBUG ?= 0
4 STRIP ?= 0
6 # ----------------------------------------------------------------------------
7 # Flags
8 # ----------------------------------------------------------------------------
10 OS_TYPE := $(shell $(CC) -dumpmachine)
12 ifneq ($(TARGET),)
13 CFLAGS += -target $(TARGET)
14 endif
16 ifneq ($(SYSROOT),)
17 CFLAGS += --sysroot=$(SYSROOT)
18 endif
20 ifneq ($(CPU),)
21 CFLAGS += -m$(CPU)
22 endif
24 CFLAGS += -std=gnu99 -Wall -pedantic -Wno-deprecated-declarations -Ilibnuhash/c99/include -D_FILE_OFFSET_BITS=64
26 ifneq ($(DEBUG),1)
27 CFLAGS += -Ofast -DNDEBUG
28 else
29 CFLAGS += -Og -g
30 endif
32 ifeq ($(FLTO),1)
33 CFLAGS += -flto
34 endif
36 ifneq ($(MARCH),)
37 CFLAGS += -march=$(MARCH)
38 endif
40 ifneq ($(MTUNE),)
41 CFLAGS += -mtune=$(MTUNE)
42 endif
44 ifeq ($(STATIC),1)
45 LDFLAGS += -static
46 endif
48 ifeq ($(STRIP),1)
49 LDFLAGS += -Wl,-s
50 endif
52 ifneq ($(filter %w64-mingw32 %w64-windows-gnu,$(OS_TYPE)),)
53 LDFLAGS += -municode
54 endif
56 RCFLAGS += -Ilibnuhash/c99/src
58 # ----------------------------------------------------------------------------
59 # Files
60 # ----------------------------------------------------------------------------
62 INFILES = $(patsubst %.c,%.o,$(wildcard libnuhash/c99/src/*.c)) $(patsubst %.c,%.o,$(wildcard tool/src/*.c))
63 OUTFILE = bin/nuhash
64 OUTPATH = $(patsubst %/,%,$(dir $(OUTFILE)))
66 ifneq ($(filter %mingw32 %windows-gnu %cygwin %cygnus,$(OS_TYPE)),)
67 OUTFILE := $(OUTFILE).exe
68 endif
70 ifneq ($(filter %mingw32 %windows-gnu %cygwin %cygnus,$(OS_TYPE)),)
71 INFILES += $(patsubst %.rc,%.o,$(wildcard tool/res/*.rc))
72 endif
74 # ----------------------------------------------------------------------------
75 # Rules
76 # ----------------------------------------------------------------------------
78 .PHONY: all clean
80 all: $(OUTFILE)
82 $(OUTFILE): $(INFILES) | $(OUTPATH)
83 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
85 $(OUTPATH):
86 mkdir -p $@
88 %.o: %.c
89 $(CC) $(CFLAGS) -c -o $@ $<
91 %.o: %.rc
92 windres $(RCFLAGS) -o $@ $<
94 clean:
95 rm -vrf $(OUTPATH)
96 find . \! -path '*/.*' -type f -name '*.o' -exec rm -vf {} \;