#!/usr/bin/env make
#
# YYYY/XXX	<<=== The IOCCC Judges will replace this line

# XXX - remove text below, including this line - XXX
# XXX -
# XXX - Please use this Makefile, renamed as Makefile of course, as the Makefile in
# XXX - your submission. Modify it as needed, including removing this comment and
# XXX - other comments we ask you to remove.
# XXX -
# XXX - remove text above, including this line - XXX

#############################
# shell used by this Makefile
#############################

SHELL= bash


#######################
# common tool locations
#######################
#
# XXX - remove text below, including this line - XXX
# XXX -
# XXX - The IOCCC judges will remove this line and uncomment the next line later
# -include ../var.mk ../../var.mk ../../../var.mk
# XXX -
# XXX - for now, set some common tool locations
# XXX - once var.mk is in use, the IOCCC judges will remove the section below
# XXX -
# XXX - remove text above, including this line - XXX
CC= cc
CHMOD= chmod
CLANG= clang
CLANG_FORMAT= clang-format
CPP= cpp
GCC= gcc
MV= mv
RM= rm
RMDIR= rmdir
TRUE= true


#####################
# C compiler settings
#####################

# Common C compiler warnings to silence
#
# Example: CSILENCE= -Wno-int-conversion -Wno-missing-variable-declarations -Wno-missing-prototypes
#
CSILENCE=

# Attempt to silence unknown warning options
#
CUNKNOWN= -Wno-unknown-warning-option

# Common C compiler warning flags
#
# XXX - remove text below, including this line - XXX
# XXX -
# XXX - NOTE: The addition of -pedantic to CWARN is a challenge that
# XXX -       You may wish to avoid if it proves too problematic.
# XXX -       There is NO penalty for removing -pedantic from CWARN.
# XXX -
# XXX - remove text above, including this line - XXX
#
CWARN= -Wall -Wextra -pedantic ${CSILENCE} ${CUNKNOWN}

# Compiler 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 -include stdlib.h -include unistd.h
#
CINCLUDE=

# Other flags to pass to the C compiler
#
# Example: COTHER= -fno-math-errno
#
COTHER=

# Optimization
#
# XXX - remove text below, including this line - XXX
# XXX -
# XXX - NOTE: Feel free to change the level of compiler optimization.
# XXX -       The "-O3" is just a friendly default you might wish to try.
# XXX -
# XXX - remove text above, including this line - XXX
#
# Example: OPT= -O0 -ggdb3
#
OPT= -O3

# Default flags for ANSI C compilation
#
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${COTHER} ${OPT}

# Libraries needed to build
#
# Example: LDFLAGS= -lncurses -lm
#
LDFLAGS=

# C compiler to use
# XXX - remove text below, including this line - XXX
# XXX -
# XXX - NOTE: The IOCCC Judges recommend you leave CC as just "cc"
# XXX -       and NOT set it to clang, or gcc, or something else
# XXX -       unless you have a STRONG reason to do so.
# XXX -
# XXX -       Setting CC to something other than "cc" makes your
# XXX -       code less portable to those who do not have your
# XXX -       particular C compiler.  **hint**
# XXX -
# XXX -       If you want to test your code with a particular C compiler,
# XXX -       use the make command line.  For example:
# XXX -
# XXX -           make all CC=clang
# XXX -           make all CC=gcc
# XXX -
# XXX - remove text above, including this line - XXX
#
CC= cc

# Compiler add-ons or replacements for clang only
#
ifeq "$(findstring $(CLANG),${CC})" "$(CLANG)"
#
# This code is only invoked when CC is "clang"
# such as when you use the make command line:
#
#    make all CC=clang
#    make all CC=clang-mp-12
#
CSILENCE+=
#
CWARN+= -Weverything
#
endif

# Specific add-ons or replacements for gcc only
#
ifeq "$(findstring $(GCC),${CC})" "$(GCC)"
#
# This code is only invoked when CC is "gcc"
# such as when you use the make command line:
#
#    make all CC=gcc
#    make all CC=gcc-15
#
CSILENCE+=
#
CWARN+=
#
endif


###########################################
# Special Makefile variables for this entry
###########################################

ENTRY= prog
PROG= ${ENTRY}
#
OBJ= ${PROG}.o
TARGET= ${PROG}
#
# XXX - remove text below, including this line - XXX
# XXX -
# XXX - If there is a prog.alt.c:
# XXX -
# XXX - remove text above, including this line - XXX
#
# ALT_OBJ= ${PROG}.alt.o
# ALT_TARGET= ${PROG}.alt
#
ALT_OBJ=
ALT_TARGET=

# list any data files supplied with your submission
#
# Example: DATA= curds whey
#
DATA=

# XXX - remove text below, including this line - XXX
# XXX -
# Other Makefile variables require by the code
#
# Example: WIDTH= 120
# XXX -
# XXX - Add any new Makefile variables your code might need below.
# XXX -
# XXX - remove text above, including this line - XXX


#################
# build the entry
#################

all: data ${TARGET}
	@${TRUE}

.PHONY: all alt data everything clean clobber

# how to compile
#
${PROG}: ${PROG}.c
	${CC} ${CFLAGS} ${PROG}.c -o $@ ${LDFLAGS}

# alternative executable
# XXX - remove text below, including this line - XXX
# XXX -
# XXX - remove this entire rule if you do NOT have a alt.prog.c
# XXX -
# XXX - remove text above, including this line - XXX
#
alt: data ${ALT_TARGET}
	@${TRUE}

# XXX - remove text below, including this line - XXX
# XXX -
# XXX - remove this entire rule if you do NOT have a alt.prog.c
# XXX -
# XXX - remove text above, including this line - XXX
${PROG}.alt: ${PROG}.alt.c
	${CC} ${CFLAGS} ${PROG}.alt.c -o $@ ${LDFLAGS}

# data files
#
data: ${DATA}
	@${TRUE}

# both all and alt
#
everything: all alt
	@${TRUE}


###############
# utility rules
###############
#
clean:
	${RM} -f ${OBJ} ${ALT_OBJ}

clobber: clean
	${RM} -f ${TARGET} ${ALT_TARGET}
	${RM} -rf *.dSYM


######################################
# optional include of 1337 hacker rulz
######################################

-include 1337.mk ../1337.mk ../../1337.mk
