Files
Tony Finch 9a2f8dc168 Make 1998/fanf more like the original
I've added some notes to `thanks-for-help` explaining the changes, and
removed the caveat from the README since the code is now much closer
to the original.

Fun fact: T for Tony is once again the only letter not used in fanf.c
2024-12-30 16:06:04 +00:00

173 lines
3.4 KiB
Makefile

#!/usr/bin/env make
#
# IOCCC 1998 winning entry - fanf
################################################################################
#
# 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-pointer-bool-conversion -Wno-unused-parameter -Wno-main \
-Wno-implicit-function-declaration -Wno-address \
-Wno-builtin-declaration-mismatch -Wno-int-conversion \
-Wno-gnu-line-marker -Wno-strict-prototypes
# 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=gnu90
# 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-comma -Wno-disabled-macro-expansion -Wno-missing-prototypes \
-Wno-missing-variable-declarations -Wno-padded \
-Wno-poison-system-directories -Wno-unused-macros
#
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= fanf
PROG= ${ENTRY}
#
OBJ= ${PROG}.o
DATA= fanf.lambda
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
#################
# build the entry
#################
#
all: data ${TARGET}
@${TRUE}
.PHONY: all alt data everything clean clobber
${PROG}: ${PROG}.c
@echo "This may take some time to complete:"
${CC} ${CSTD} ${PROG}.c -E > ${PROG}tmp1.c
${CC} ${CSTD} ${PROG}tmp1.c -E > ${PROG}tmp2.c
${CC} ${CFLAGS} ${PROG}tmp2.c ${LDFLAGS} -o $@
# alternative executable
#
alt: data ${ALT_TARGET}
@${TRUE}
# 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
${RM} -f ${PROG}tmp1.c ${PROG}tmp2.c
######################################
# optional include of 1337 hacker rulz
######################################
-include 1337.mk ../1337.mk ../../1337.mk