-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathMakefile
More file actions
196 lines (162 loc) · 4.23 KB
/
Makefile
File metadata and controls
196 lines (162 loc) · 4.23 KB
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
#!/usr/bin/env make
#
# IOCCC 2004 winning entry - vik2
################################################################################
#
# IOCCC winning entry code may not work on your system. What was liked/allowed
# and worked in the past may no longer be liked/allowed or compile/run today.
#
# Bug fixes, corrections and typo fixes are VERY WELCOME. If you see a problem,
# first check this URL for a list of known bugs and (mis)features of IOCCC entries:
#
# https://www.ioccc.org/bugs.html
#
# GitHub pull requests are welcome! Please see the above URL for details.
#
################################################################################
#
# This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
# You are free to share and adapt this file under the terms of this license:
#
# Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
#
# For more information, see: https://creativecommons.org/licenses/by-sa/4.0/
#############################
# shell used by this Makefile
#############################
#
SHELL= bash
#######################
# common tool locations
#######################
#
include ../../var.mk
# Common C compiler warnings to silence
#
CSILENCE= -Wno-strict-prototypes -Wno-implicit-function-declaration \
-Wno-builtin-declaration-mismatch
# Attempt to silence unknown warning option
#
CUNKNOWN= -Wno-unknown-warning-option
# Common C compiler warning flags
#
CWARN= -Wall -Wextra ${CSILENCE} ${CUNKNOWN}
# Compiler standard
#
CSTD= -std=gnu99
# Compiler bit architecture
#
ARCH=
# Defines that are needed to compile
#
CDEFINE=
# Include files that are needed to compile
#
CINCLUDE=
# Optimization
#
OPT= -O3
# Default flags for ANSI C compilation
#
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${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+= -Wno-poison-system-directories -Wno-unused-macros \
-Wno-reserved-macro-identifier
#
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
##############################
#
ENTRY= vik2
PROG= ${ENTRY}
#
OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
#################
# build the entry
#################
#
all: data ${TARGET}
@${TRUE}
.PHONY: all alt data everything clean clobber
${PROG}: ${PROG}.c
${CC} ${CFLAGS} -DFNAME='"${PROG}.c"' '-DSTOP=_5' ${PROG}.c -o ${PROG}
# alternative executable
#
alt: data ${ALT_TARGET}
@${TRUE}
# data files
#
data: ${DATA}
@${TRUE}
# both all and alt
#
everything: all alt
@${TRUE}
# The original vik2 source
#
# On some systems such as Linux, this source either fails
# to finish compiling or takes a super-long time generating
# a huge number of compiler errors. As such, we do not
# recommend compiling this code. However for ailurophiles the
# curiosity factor, even though it may have the effect of:
#
# kill -9 cat
#
# may be too strong to not try and compile the original
# vik2 source code. Therefore we offer this special
# Makefile rule for those who do not wish to curtail (or cattail :-) )
# their curiosity.
#
cat-killing-curiosity: vik2.possible.cat.death.c
@echo 'Curiosity killed the cat ...'
${RM} -f ${PROG}.possible.cat.death_1.c
${CC} -E '-DSTOP=_5' '-DFNAME="${PROG}.possible.cat.death_1.c"' \
${PROG}.possible.cat.death.c > ${PROG}.possible.cat.death_1.c
${RM} -f ${PROG}.possible.cat.death_2.c
${CC} -E ${PROG}.possible.cat.death_1.c > ${PROG}.possible.cat.death_2.c
${CC} ${CFLAGS} ${PROG}.possible.cat.death_2.c -o $@ 2>/dev/null
@echo '... but satisfaction brought it back. :-)'
###############
# utility rules
###############
#
clean:
${RM} -f ${OBJ} ${ALT_OBJ}
vik2_clean:
${RM} -f vik2.o
vik2_clobber: vik2_clean
${RM} -f vik2
clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}
${RM} -rf *.dSYM
${RM} -f ${PROG}.possible.cat.death_1.c ${PROG}.possible.cat.death_2.c cat-killing-curiosity
######################################
# optional include of 1337 hacker rulz
######################################
-include 1337.mk ../1337.mk ../../1337.mk