-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
105 lines (85 loc) · 1.96 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Reset implicit rules as if using -r
.SUFFIXES:
# Reset implicit variables as if using -R
$(foreach var,$(filter-out .% MAKE% SUFFIXES,$(.VARIABLES)),\
$(if $(findstring $(origin $(var)),default),\
$(if $(filter undefine,$(.FEATURES)),\
$(eval undefine $(var)),\
$(eval $(var)=))))
# Build options
BUILTINS=1
PRAGMA_FP_CONTRACT=0
SIMD=1
OPENMP=1
DEBUG=0
PROFILE=0
SAVE_ASM=0
WINDOWS=0
# VARIABLES
CFLAGS+=-std=c11 -pedantic
CFLAGS+=-msse2 -mfpmath=sse
CFLAGS+=-g
WARN_FLAGS+=-Wall -Wextra -Winline -Wshadow
NO_WARN_FLAGS+=-w
ifeq ($(CC),)
CC=$(HOST)gcc
endif
ifeq ($(WINDRES),)
WINDRES=$(HOST)windres
endif
LIBS+=-ljpeg -lpng -lm -lz
OBJS+=jpeg2png.o utils.o jpeg.o png.o box.o compute.o logger.o progressbar.o fp_exceptions.o gopt/gopt.o ooura/dct.o
HOST=
EXE=
ifeq ($(BUILTINS),1)
CFLAGS+=-DBUILTIN_UNREACHABLE -DBUILTIN_ASSUME_ALIGNED -DATTRIBUTE_UNUSED
endif
ifeq ($(PRAGMA_FP_CONTRACT),1)
CFLAGS+=-DPRAGMA_FP_CONTRACT
else # not supported by gcc
CFLAGS+=-ffp-contract=off
endif
ifeq ($(SIMD),1)
CFLAGS+=-DUSE_SIMD
endif
ifeq ($(OPENMP),1)
BFLAGS+=-fopenmp
endif
ifeq ($(DEBUG),1)
CFLAGS+=-Og -DDEBUG
else
CFLAGS+=-O3 -DNDEBUG
endif
ifeq ($(PROFILE),1)
BFLAGS+=-pg
endif
ifeq ($(WINDOWS),1)
HOST=i686-w64-mingw32-
EXE=.exe
LDFLAGS+=-static -s
CFLAGS+=-mstackrealign # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659
RES+=icon.rc.o
endif
ifeq ($(SAVE_ASM),1)
CFLAGS+=-save-temps -masm=intel -fverbose-asm
endif
CFLAGS+=$(BFLAGS)
LDFLAGS+=$(BFLAGS)
# RULES
.PHONY: clean all install uninstall
all: jpeg2png$(EXE)
jpeg2png$(EXE): $(OBJS) $(RES) Makefile
$(CC) $(OBJS) $(RES) -o $@ $(LDFLAGS) $(LIBS)
-include $(OBJS:.o=.d)
gopt/gopt.o: gopt/gopt.c gopt/gopt.h Makefile
$(CC) $< -c -o $@ $(CFLAGS) $(NO_WARN_FLAGS)
%.o: %.c Makefile
$(CC) -MP -MMD $< -c -o $@ $(CFLAGS) $(WARN_FLAGS)
%.rc.o: %.rc Makefile
$(WINDRES) $< $@
clean:
git clean -Xf
install: all
install -Dm755 jpeg2png "$(DESTDIR)"/usr/bin/jpeg2png
uninstall:
rm "$(DESTDIR)"/usr/bin/jpeg2png