-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile.example
197 lines (165 loc) · 4.03 KB
/
Makefile.example
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/usr/bin/env make
#
# XXX - Please remove these 3 XXX-ed comment lines - XXX
# XXX - Hint: Lines with XXX's in them should be removed once you read them and consider their suggestions - XXX
# XXX - Change "an example Makefile" in the line below to a suitable and short 1-line title for your submission - XXX
# prog - an example Makefile
#
# XXX - Please remove these 4 XXX-ed comment lines - XXX
# XXX - Please copy this file into your submission directory under the name: Makefile - XXX
# XXX - Modify the resulting Makefile as needed - especially lines with XXX's in them - XXX
# XXX - Please add a space after '=' in variables unless it's empty - XXX
#############################
# shell used by this Makefile
#############################
#
SHELL= bash
#######################
# common tool locations
#######################
#
CLANG= clang
GCC= gcc
RM= rm
# Common C compiler warnings to silence
#
# Example: CSILENCE= -Wno-some-thing -Wno-another-thing
#
# NOTE: If you add -Wno-stuff to CSILENCE, please update
# CUNKNOWN in the next comment block.
#
# NOTE: Please don't add -Wno-unknown-warning-option to CSILENCE.
#
CSILENCE=
# Attempt to silence unknown warning option
#
# If you add -Wno-stuff to CSILENCE, then please change CUNKNOWN to read:
#
# CUNKNOWN= -Wno-unknown-warning-option
#
CUNKNOWN=
# Common C compiler warning flags
#
CWARN= -Wall -Wextra -pedantic ${CSILENCE} ${CUNKNOWN}
# The standard to compile against
#
# Your IOCCC submission is free to require older C standards, or
# even not specify a C standard at all. We suggest trying
# for -std=gnu17, but that is not a requirement and you won't
# be penalized if you name CSTD empty or use another
# well known and reasonably widely implemented C standard.
#
CSTD= -std=gnu17
# Compiler bit architecture
#
# Example for 32-bitness: ARCH= -m32
# Example for 64-bitness: ARCH= -m64
#
# NOTE: Normally one should not specify a specific architecture.
#
ARCH=
# Defines that are needed to compile
#
# Example: -Dfoo -Dbar=baz
#
CDEFINE=
# Include files that are needed to compile
#
# Example: CINCLUDE= -include stdio.h
#
CINCLUDE=
# Other flags to pass to the C compiler
#
# Example: COTHER= -fno-math-errno
#
COTHER=
# Optimization
#
OPT= -O3
# Default flags for ANSI C compilation
#
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${COTHER} ${OPT}
# Libraries needed to build
#
LDFLAGS=
# C compiler to use
#
CC= cc
# Compiler add-ons or replacements for clang only
#
ifeq "$(findstring $(CLANG),${CC})" "$(CLANG)"
#
CSILENCE+=
#
CWARN+= -Weverything
#
endif
# Specific add-ons or replacements for gcc only
#
ifeq "$(findstring $(GCC),${CC})" "$(GCC)"
#
CSILENCE+=
#
CWARN+=
#
endif
###########################################
# Special Makefile variables for this entry
###########################################
# what to build
#
PROG= prog
OBJ= ${PROG}.o
TARGET= ${PROG}
#
# XXX - uncomment the below lines if you have alt targets - XXX
# XXX - make sure to add all alt objects and targets that - XXX
# XXX - you wish to have compiled by make alt - XXX
#
#ALT_OBJ= ${PROG}.alt.o
#ALT_TARGET= ${PROG}.alt
#
# list any data files supplied with the submission
#
DATA=
#################
# build the entry
#################
#
all: data ${TARGET}
@:
.PHONY: all data try clean clobber
# how to compile
#
${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
# alternative executable
#
alt: data ${ALT_TARGET}
@${TRUE}
#
# XXX - if you have alt targets, add them here, like this - XXX
#
#${PROG}.alt: ${PROG}.alt.c
# ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
#
# data files
#
data: ${DATA}
@:
# one suggested way to run the program
#
try: ${PROG} ${DATA}
# XXX - Please remove these 4 XXX-ed comment lines - XXX
# XXX - Notice how we do not assume that . is a component in our PATH - XXX
# XXX - If no args are necessary, you do not have to specify any - XXX
# XXX - Change the next line as needed - XXX
./${PROG} some arguments
###############
# utility rules
###############
#
clean:
${RM} -f ${OBJ} ${ALT_OBJ}
clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}