summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 49035a0b9ed8fdf41df67bf5d68c9a359d755001 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#########################
# Configure build      
#########################
CPP_COMPILER=gcc
ASM_COMPILER=yasm

#
#  optimize  
#  level 3    
#         \    
CC_FLAGS=-O3 -s -fomit-frame-pointer -DUNIX #-ffast-math 
LD_FLAGS=-lm 
#	  /    
#      math   
#
# NOTE on -ffast-math
#
# First, breaks strict IEEE compliance, e.g. allows re-ordering of 
# instructions to a mathematical equivalent, which may not be IEEE
# floating-point equivalent. 
#
# Second, disables setting errno after single-instruction math functions, 
# avoiding a write to a thread-local variable (can produce 100% speedup on
# certain architectures). 
#
# Third, assumes finite math only, meaning no checks for NaN (or 0) are 
# made where they would normally be. It is assumed these values will never 
# appear. 
#
# Fourth, enables reciprocal approximations for division and reciprocal 
# square root.
#
# Fifth, disables signed zero (even if the compile target supports it) 
# and rounding math, which enables optimizations e.g. constant folding.
#
# Sixth, generates code assuming no hardware interrupts occur in math
# due to signal()/trap(). If these cannot be disabled on the compile
# target and consequently occur, they will not be handled.
#

#########################
# Configure files 
#########################

HUG_SOURCES=main.c \
	    util.c \
	    coder.c \
	    mixer.c \
	    predictor.c \
	    context.c \
	    model.c \

	
HUG_OBJECTS=$(HUG_SOURCES:.c=.o)
ASM_SOURCES=asm/paq7asm-x86_64.asm
ASM_OBJECTS=$(ASM_SOURCES:.asm=.o)

#########################
# Configure rules 
#########################

all: hug 

test: hug 
	./hug dat/csf.txt
	./hug -d csf.txt.hug csf.out
	diff csf.out dat/csf.txt 
	rm csf.out csf.txt.hug

hug: $(HUG_SOURCES) asm
	$(CPP_COMPILER) $(CC_FLAGS) $(HUG_SOURCES) $(ASM_OBJECTS) -o hug 

asm: $(ASM_SOURCES)
	$(ASM_COMPILER) $(ASM_SOURCES) -f elf -m amd64

install:
	cp hug /usr/local/bin

clean:
	rm -f $(HUG_OBJECTS) $(ASM_OBJECTS) hug gmon.out