-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (99 loc) · 2.36 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
106
107
108
109
110
111
112
113
114
115
116
117
118
#### Options ####
## Memory dimensions
#
# For example, an 8x4 memory (default)
# gives you 32 single-byte memory blocks.
#
mem_x = 8
mem_y = 4
## Built-in protections
#
# Precautions against unexpected behaviour.
# You probably want this to be on.
#
use_safety = yes
## Random uses OpenSSL?
#
# The default generator doesn't give numbers
# random enough. This is why alternative
# backends are provided.
#
# Available backends: openssl system
#
rand_backend = openssl
## ANSI extension
#
# Not currently considered a part of the Duh
# standard (we do have one, duh! what do you
# mean?).
#
extension_ansi = yes
## Debug extension
#
# Useful debugging functions, also not part
# of the Duh standard.
#
extension_debug = yes
#################
# DO NOT EDIT #
# UNLESS SURE #
#################
SHELL=/bin/bash
src = main.c memory.c trace.c random.c
cc = gcc
cflags =
ldflags =
def = -DMEMX=$(mem_x) -DMEMY=$(mem_y)
ifeq ($(use_safety), yes)
def += -DSAFETY
endif
ifeq ($(rand_backend), openssl)
cflags += $(shell pkg-config --cflags openssl)
ldflags += $(shell pkg-config --libs openssl)
def += -DRAND_BACKEND=RAND_OPENSSL
else ifeq ($(rand_backend), system)
$(warning System random number backend produces suboptimal results.)
def += -DRAND_BACKEND=RAND_SYSTEM
else
$(error Invalid random number backend: $(rand_backend))
endif
# Extensions
ext_def =
ext_src =
ifeq ($(extension_ansi), yes)
ext_def += -DEXTENSION_ANSI
ext_src += ansi.c
endif
ifeq ($(extension_debug), yes)
ext_def += -DEXTENSION_DEBUG -ggdb
ext_src += debug.c
endif
duh: $(src) $(ext_src)
@echo
@echo "==[ Duh configuration ]======================"
@echo
@echo " C Compiler: $(cc)"
@echo " Compiler flags: $(cflags)"
@echo " Linker flags: $(ldflags)"
@echo
@echo " VM memory size: $(mem_x) x $(mem_y) = $$(( $(mem_x) * $(mem_y) )) bytes"
@echo " Random number subsystem: $(rand_backend)"
@echo
@echo
@echo "-- Features ---------------------------------"
@echo
@echo " Safety: $(use_safety)"
@echo
@echo
@echo "-- Extensions -------------------------------"
@echo
@echo " ANSI: $(extension_ansi)"
@echo " Debug: $(extension_debug)"
@echo
@echo
$(cc) $(src) $(ext_src) -o$@ -O2 -Wall \
$(def) \
$(ext_def) \
$(cflags) $(ldflags)
clean:
@-rm -f duh *~