diff --git a/1996/Makefile b/1996/Makefile index ba2c62aec..8a68666a8 100644 --- a/1996/Makefile +++ b/1996/Makefile @@ -46,12 +46,17 @@ # See: http://creativecommons.org/licenses/by-sa/3.0/ -################ -# tool locations -################ +############################# +# shell used by this Makefile +############################# # -SHELL= /bin/bash -MAKE= make +SHELL= bash + +####################### +# common tool locations +####################### +# +include ../var.mk ############### diff --git a/1996/august/.gitignore b/1996/august/.gitignore index 36c24223d..4ebc5174f 100644 --- a/1996/august/.gitignore +++ b/1996/august/.gitignore @@ -1 +1,2 @@ august +august.oc diff --git a/1996/august/Makefile b/1996/august/Makefile index d06ef33b5..79acb84e2 100644 --- a/1996/august/Makefile +++ b/1996/august/Makefile @@ -1,156 +1,347 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - august + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-invalid-source-encoding + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +#CDEFINE= +CDEFINE= -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ + -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ + -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ + -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' + +# Include files that are needed to compile +# +CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august +CSILENCE+= -Wno-conditional-uninitialized -Wno-missing-variable-declarations \ + -Wno-poison-system-directories +# +CWARN+= -Weverything +# +endif + +# Specific add-ons or replacements for gcc only +# +ifeq ($(CC),gcc) +# +#CSILENCE+= +# +#CWARN+= +# +endif + + +############################## +# Special flags for this entry +############################## +# +ENTRY= august +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= fac.oc parse.oc test.oc +TARGET= ${PROG} ${PROG}.oc +# +ALT_OBJ= +ALT_TARGET= + + +################# +# build the entry +################# +# +all: data ${TARGET} + @${TRUE} + +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} ${CHMOD} +r fac.oc parse.oc test.oc # This forms a byte code execution engine written in OC # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc +${PROG}.oc: ${PROG}.c + ${RM} -f $@ + ${CC} ${CFLAGS} -E $< -o $@ ${LIBS} > $@ + ${CHMOD} +r $@ -# NOTE: this is the original source that won +# alternative executable # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc - -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket -# -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: -# -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 - -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 - -clean: - ${RM} -f *.o a.out core ${WINNERS} - -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc - -nuke: clobber +alt: data ${ALT_TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/august/README.md b/1996/august/README.md index f53909f1e..9e8347049 100644 --- a/1996/august/README.md +++ b/1996/august/README.md @@ -1,4 +1,4 @@ -Best of Show: +# Best of Show: Lennart Augustsson CR&T @@ -6,17 +6,20 @@ Best of Show: S-411 21 Goteborg Sweden +## To build: -Judges' comments: + make all + +### To run - To use: - make august cat august.c test.oc | ./august > test.oo ./august < test.oo - NOTE: Some compilers will compile this code into infinite loops! - If the above cat line does not execute in a very short amount - of time, then you may need to fix your compiler or use gcc. + NOTE: Some compilers will compile this code into infinite loops! + If the above cat line does not execute in a very short amount + of time, then you may need to fix your compiler or use gcc. + +## Judges' comments Try: cat august.c fac.oc | ./august > fac.oo @@ -56,8 +59,7 @@ Judges' comments: entry as it surely will make the 'best of the IOCCC' list. It was very well received by those who attended the IOCCC BOF. - -Selected notes from the author: +## Author's comments This program is a bytecode interpreter. This fact is not particularly obfuscated; any experienced C programmer can see that diff --git a/1996/august/august.orig.c b/1996/august/august.orig.c deleted file mode 100644 index 93053bd65..000000000 --- a/1996/august/august.orig.c +++ /dev/null @@ -1,321 +0,0 @@ -/*T } ¶ ; -ˆ -; - -; - } - {  - -{ ;  ; -; 1 { -è { ! -} { - ; é ; - -; - { - - - { ]- } ; ; | -í ; Q -; -´ë ; ; ; "û } -} Ü; ; -ýl - -} - } t dÀ ; -; + - t2 { ì ; - -} 1; C - i -; = } ; ; - -; -ì ; { - - { ê -} { � { ï } } - -; . { - { é } } ;  -{ ; -; /nÈ; 5 -} ; Ú { ;  - ; { 1 ; } ; ¨ý } { - -;  { ; . { ;  } ;  ; -; T ; -{ -; ; Ä; ;  { -; - { { ; ; -ì; ‘ ; ; ï; n!t } -; ì!; G; t;  ø; ¤ }  ; - - ; - } ; "; è# } -;  -{ -; �$ { -; -; & - - ; d˜ -{ - - ¶;  { -; Sé' -{ d; ; è); �c -{ - ;  ; -; &ï*; ; -— { -; -$; ¢; ,; ; $ˆd } —; ˆ; ë/Î; Î -; a; Í ; { - } ; j; #è1; - } -; Ä ; { ê5a; û Ät { ï4a } - } - -; £ ; -Û2; - -; 8 - -} ; } -; è8; ;  Ú6Q ; aÌ { ;  { ˆ -ì } -†; v: -{ -? - } - -{ ? - -{ ; 4r -; -; v=b; Û -; - ; - } ;  -; ; ; Þ { ú> - } } - {  ; - { Õ` -} -; - ; -!; -; 1; ; >; Ì } 1; X -; } p ; -; - -; ; ;  -; ; 2 } ; vm -2; ;1íJ -; - ; ; Ï } -; ÉJc; ›; d } -} ÞG; i } -; ; §F -{ vl¶þV; z -n -¶éOc; s -; ; ÑÞ; - uh¶ëR } hRs; A cl,; -; ; Z;  { -x -lw¶êUch�{  } - } ; àîVc } -; Ž; >ÈD - ; G ; ; † -; -îX; ’ˆ -; - -; 2 }  { é[;  -{  } - ; Þj; å; ë_; y - ; D; T; ; ?j; .n; ; ã { - -; Ú]; !; Ë; 0a - } J ; -; ^; . -{ { { îc; X ; ; ´; -J { -; ; - } — { êf;  -; { - ; ; : } {  -{ - - ; (h} } -{  } - } ; ; {  -; ûD; Tì Cr; ; I; WèsÎWQ -; ; -×; W { û } -; ( ; ; } -} ;  { -; ÿn{ k; © ; ‚; ?; %Ùk;  ; - - { ïv; -3{ (; h { - -; ; z - -; ; ]{ ; ˜ïx; S; { * } ˜; z} ; î;  -{ ; ~ -; -U; ö -; { ‡ -; í~; -Ob } ; ò; UU; U{ -{ %Ú|1èƒ; -; Q - ; -µ{ w{ š;  ; - { í‡; ‚; ü� - -… -} Ù†; ?; u -{ - - -ƒ -} } ; » ; ´ ; ;  } -; è -{ - -; ;  } - ; p ; ; ; Q; Ü�{ ; ; K; $ì“ -p; 1} -4; $; -2Q ; }  { -; $î— } ; #; -T; 1 -; ; +; ± }  -; ; -. ; {  -{ ; š{ -  ; - { -; ;  } - - -; { [ { ; £{ ; �; 0{  - { ôr ; éŸ -; - } =; w - -?; ; -ä; B®lwx - ; h�h - -} ; pj - ; ; ; ö { û§; 'n -; ; { ) { -; ú¤; -; -Q -; f; 'r -{ -? { ë¬; %lÂf} -; ~©{ qÛ¨;  -{ - { ÿ­; ÂÛ¬{ œÚžl,u -; & ; - - { í; G }  -; k -;  } - ;  -{ - - -; hR; ; Wß´;  -} ; - -; ; —e; Z; ž{ N; = - } ; < - { ]- Bšretur; ¡if -else -whil; do; nt -char - { ; { pu{  } -{ ; = -} B -} { -; ø¿`ˆ; dÀ; ´ } � -} } ; ø`; waÌ { •ma; > - { ; oJ -} ÈD -{  ; ; ; · ; - -; Á ; ; ;  ; ;  -{  -; ; €Õ; @ë ; Á; L { - -; ØÈ ; - */int m[Z]; - -#define U(x)s--;T=x -#define C(l,s)I(o==l){s;}E -#define Q(l,o)C(l,r=P;T=T o r) -#define O(l,o)C(l,T=o T) -#define H(l,s)C(l,U(s)) -int -main(){int*q,s,f,r,o,l,p,c,b; -char*d; -d=" \t\n;{}\0AÊP€³²‰Š@ɵ�gEÏͱ°Œ0�Ž‹q"; -b=256; -q=m; -g; -o=g; -c=g; -c=c+g*b; -p=c; -I(o){W(p){o=g; -C(59,r=2)C('{',r=5)C('}',r=8)r=0; -I(r){r=r+g%4; -l=1-g-r; -W(r--){*q=q[l]; -q++; -p--; -}}E{I((o==32)+(o==9)+(o==10)){r=g; -o=o%4+(r+(r==123))%8*3; -I(8 test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-poison-system-directories # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= dalbec +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + @echo "NOTE: This entry uses non-standard args to main() that do not work with modern compilers." + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/dalbec/README.md b/1996/dalbec/README.md index 09629a22d..ba18ef66c 100644 --- a/1996/dalbec/README.md +++ b/1996/dalbec/README.md @@ -1,4 +1,4 @@ -Best Numerical Obfuscation: +# Best Numerical Obfuscation: John Dalbec 20 Squire's Ct. (home address) @@ -7,13 +7,18 @@ Best Numerical Obfuscation: http://www.math.yale.edu/pub/users/dalbec/ +## To build: -Judges' comments: + make all + + NOTE: This entry uses non-standard args to main() that do not work with modern compilers. + +### To run - To use: - make dalbec ./dalbec +## Judges' comments + The output is mis-leading ... why does it also print 2047? Also try: @@ -32,8 +37,7 @@ Judges' comments: how this program works. The source is small enough to make the effort reasonable, and complex enough to make it interesting. - -Selected notes from the author: +## Author's comments This program assumes that your terminal wraps lines automatically. If this is not the case, you may need to change the space in the diff --git a/1996/eldby/Makefile b/1996/eldby/Makefile index d06ef33b5..19248286c 100644 --- a/1996/eldby/Makefile +++ b/1996/eldby/Makefile @@ -1,156 +1,338 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - eldby + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-empty-body -Wno-error -Wno-implicit-function-declaration \ + -Wno-return-type -Wno-unsequenced + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +CDEFINE= +#CDEFINE= -DIOCCC + +# Include files that are needed to compile +# +CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-double-promotion -Wno-float-conversion -Wno-implicit-float-conversion \ + -Wno-missing-prototypes -Wno-missing-variable-declarations \ + -Wno-poison-system-directories -Wno-strict-prototypes # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= eldby +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/eldby/README.md b/1996/eldby/README.md index d68b100e0..da36d1072 100644 --- a/1996/eldby/README.md +++ b/1996/eldby/README.md @@ -1,4 +1,4 @@ -Best Output: +# Best Output: Thor AAge Eldby European Technology Partner @@ -6,18 +6,20 @@ Best Output: 0955 OSLO Norway +## To build: -Judges' comments: + make all + +### To run - To use: - make eldby ./eldby +## Judges' comments + We were impressed by the author's ability to render spheres in 3D in a very small chunk of code. - -Selected notes from the author: +## Author's comments This program shows flying spheres. The program eats CPU on lesser equipt systems. The program will run until termination. Terminal diff --git a/1996/gandalf/.gitignore b/1996/gandalf/.gitignore index 235474030..ea4789acc 100644 --- a/1996/gandalf/.gitignore +++ b/1996/gandalf/.gitignore @@ -1 +1,3 @@ +cathat gandalf +hatcat diff --git a/1996/gandalf/Makefile b/1996/gandalf/Makefile index d06ef33b5..1555c8cce 100644 --- a/1996/gandalf/Makefile +++ b/1996/gandalf/Makefile @@ -1,156 +1,346 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - gandalf + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-keyword-macro \ + -Wno-shift-op-parentheses -Wno-unused-parameter + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +CDEFINE= +#CDEFINE= -DIOCCC + +# Include files that are needed to compile +# +CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-missing-prototypes -Wno-missing-variable-declarations \ + -Wno-poison-system-directories -Wno-strict-prototypes # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= gandalf +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= +TARGET= ${PROG} hatcat cathat +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + @echo "NOTE: This entry may not compile when using modern compilers." + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +hatcat: ${PROG} + ${RM} -f $@ + ${CP} $< $@ + +cathat: ${PROG} + ${RM} -f $@ + ${CP} $< $@ + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/gandalf/README.md b/1996/gandalf/README.md index 5c512a40e..d202a0343 100644 --- a/1996/gandalf/README.md +++ b/1996/gandalf/README.md @@ -1,4 +1,4 @@ -Best Layout: +# Best Layout: Dean Swift Trinome Communications @@ -10,31 +10,28 @@ Best Layout: http://www.tc3.co.uk/~gandalf/G.HTML +## To build: -Judges' comments: + make all + + NOTE: This entry may not compile when using modern compilers. + +### To run - To use: - make gandalf ./gandalf +## Judges' comments + Also try: - For C-shell: - - setenv PATH ( . $PATH ) - hatcat - cathat - - For K-shell, /bin/sh, bash, etc: - - PATH=.:$PATH - hatcat - cathat + PATH=.:$PATH + ./hatcat + ./cathat And next try: ./cathat - `pwd`/cathat # <--- those are back quotes + `pwd`/cathat Care to guess why these execute differently? Only the compiler knows ... ok maybe other things like the author, @@ -44,7 +41,6 @@ Judges' comments: cc -E gandalf.c - -Selected notes from the author: +## Author's comments The program requires an ASCII system. diff --git a/1996/huffman/Makefile b/1996/huffman/Makefile index d06ef33b5..535242044 100644 --- a/1996/huffman/Makefile +++ b/1996/huffman/Makefile @@ -1,156 +1,335 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - huffman + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-parentheses + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +CDEFINE= +#CDEFINE= -DIOCCC + +# Include files that are needed to compile +# +CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-poison-system-directories # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= huffman +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/huffman/README.md b/1996/huffman/README.md index 19931c088..dc3ca427d 100644 --- a/1996/huffman/README.md +++ b/1996/huffman/README.md @@ -1,4 +1,4 @@ -Best Obfuscated Character Set Utility: +# Best Obfuscated Character Set Utility: Ken Huffman Applied Innovation Inc @@ -8,14 +8,18 @@ Best Obfuscated Character Set Utility: huffmancoding@gmail.com +## To build: -Judges' comments: + make all + +### To run - To use: - make huffman echo 'Huffman Decoding' | ./huffman +## Judges' comments + Try: + echo 'seeing or feeling is believing' | ./huffman echo 'CC OR NOT CC' | ./huffman | ./huffman @@ -30,8 +34,7 @@ Judges' comments: This entry was very well received at the IOCCC BOF. - -Selected notes from the author: +## Author's comments This filter program is really not obfuscated code. It compiles cleanly with an ANSI C compiler and comes with user documentation that even a diff --git a/1996/jonth/Makefile b/1996/jonth/Makefile index d06ef33b5..945ddac26 100644 --- a/1996/jonth/Makefile +++ b/1996/jonth/Makefile @@ -1,156 +1,341 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - jonth + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-char-subscripts -Wno-error -Wno-implicit-function-declaration \ + -Wno-infinite-recursion -Wno-return-type -Wno-string-plus-int \ + -Wno-unsequenced -Wno-unused-parameter + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +CWARN= -Wall -Wextra ${CSILENCE} +#CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +CDEFINE= +#CDEFINE= -DIOCCC + +# Include files that are needed to compile +# +#CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +#LIBS= +#LIBS= -lm +LIBS= -L ${X11_LIBDIR} -lX11 -lm +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-c99-extensions -Wno-double-promotion -Wno-float-conversion \ + -Wno-implicit-float-conversion -Wno-implicit-int-conversion \ + -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-pedantic \ + -Wno-poison-system-directories -Wno-shadow -Wno-sign-conversion \ + -Wno-strict-prototypes # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= jonth +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/jonth/README.md b/1996/jonth/README.md index 833662fee..be10d62d1 100644 --- a/1996/jonth/README.md +++ b/1996/jonth/README.md @@ -1,4 +1,4 @@ -Best X11 Entry: +# Best X11 Entry: Jon Thingvold University of Oslo @@ -8,27 +8,24 @@ Best X11 Entry: http://www.uio.no/~jonth/ +## To build: -Judges' comments: + make all - To use: - make jonth +### To run ./jonth +## Judges' comments + Also try: ./jonth host1:0 host2:0 - NOTE: You may need to change the Makefile depending on where X11 - include files are found and what libs are required. For - example Solaris and Slowlaris need -lsocket. :-) - For extra credit, figure out how you can cheat by taking over a square already occupied by an opponent. - -Selected notes from the author: +## Author's comments This is mulituser tictactoe for X Windows. You may give one or two X displays as arguments to this game. diff --git a/1996/rcm/Makefile b/1996/rcm/Makefile index d06ef33b5..a6ba7bfb5 100644 --- a/1996/rcm/Makefile +++ b/1996/rcm/Makefile @@ -1,156 +1,340 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - rcm + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-empty-body -Wno-shift-op-parentheses + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +#CDEFINE= +CDEFINE= -DJ='if(' -Ds='else J O==' -DU='B(' \ + -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ + -DT='' -DY='' -DR='malloc(sizeof(n))' \ + -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar + +# Include files that are needed to compile +# +CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-comma -Wno-implicit-int-conversion -Wno-missing-prototypes \ + -Wno-missing-variable-declarations -Wno-padded \ + -Wno-poison-system-directories -Wno-sign-conversion # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= rcm +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= rfc1951.gz rfc1952.gz +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/rcm/README.md b/1996/rcm/README.md index dde333d4b..8af5dd6ff 100644 --- a/1996/rcm/README.md +++ b/1996/rcm/README.md @@ -1,32 +1,29 @@ -Best RFC Obfuscation: +# Best RFC Obfuscation: Ron McFarland 7941 Fawncreek Drive Cincinnati, Ohio 45249 USA +## To build: -Judges' comments: + make all + +### To run - To use: - make rcm ./rcm < rfc1951.gz - Also try: - - ./rcm < rfc1952.gz +## Judges' comments And for more information try: - ./rcm < rfc1951.gz ./rcm < rfc1952.gz For a good noop try: gzip -c < rcm.c | ./rcm - -Selected notes from the author: +## Author's comments Except for some silly requirements regarding input validation, CRC checking, and similar unimportant fluff, this program is a fully diff --git a/1996/schweikh1/Makefile b/1996/schweikh1/Makefile index d06ef33b5..0efb80eb0 100644 --- a/1996/schweikh1/Makefile +++ b/1996/schweikh1/Makefile @@ -1,156 +1,337 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - schweikh1 + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +CSILENCE= +#CSILENCE= -Wno-implicit-int + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +CDEFINE= +#CDEFINE= -DIOCCC + +# Include files that are needed to compile +# +#CINCLUDE= +CINCLUDE= -I. +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-conditional-uninitialized -Wno-disabled-macro-expansion \ + -Wno-missing-variable-declarations -Wno-poison-system-directories # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= schweikh1 +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= errno.h +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/schweikh1/README.md b/1996/schweikh1/README.md index dec510b08..8e1dc15f0 100644 --- a/1996/schweikh1/README.md +++ b/1996/schweikh1/README.md @@ -1,4 +1,4 @@ -Worst Abuse of the C Preprocessor: +# Worst Abuse of the C Preprocessor: Jens Schweikhardt DFN Network Operation Center @@ -8,13 +8,16 @@ Worst Abuse of the C Preprocessor: http://www.uni-stuttgart.de/People/schweikhardt/home.html +## To build: -Judges' comments: + make all + +### To run - To use: - make schweikh1 ./schweikh1 +## Judges' comments + Look at the source. There is something very odd going on here. Where does the real code come from if everything is a C pre-processor statement? @@ -22,8 +25,7 @@ Judges' comments: Clearly this is either the Best Use or the Worst Abuse of the C Preprocessor that the judges have seen this year! - -Selected notes from the author: +## Author's comments What this program does ---------------------- diff --git a/1996/schweikh2/Makefile b/1996/schweikh2/Makefile index d06ef33b5..78692f19b 100644 --- a/1996/schweikh2/Makefile +++ b/1996/schweikh2/Makefile @@ -1,156 +1,335 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - schweikh2 + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +CSILENCE= +#CSILENCE= -Wno-implicit-int + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +CDEFINE= +#CDEFINE= -DIOCCC + +# Include files that are needed to compile +# +CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-comma -Wno-poison-system-directories -Wno-sign-conversion # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= schweikh2 +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= hunni.pl hunni.c +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/schweikh2/README.md b/1996/schweikh2/README.md index 9d08f5c76..a318bfc6c 100644 --- a/1996/schweikh2/README.md +++ b/1996/schweikh2/README.md @@ -1,4 +1,4 @@ -Best Algorithm: +# Best Algorithm: Jens Schweikhardt DFN Network Operation Center @@ -8,14 +8,16 @@ Best Algorithm: http://www.uni-stuttgart.de/People/schweikhardt/home.html +## To build: -Judges' comments: + make all + +### To run - To use: - make schweikh2 - ./schweikh2 +## Judges' comments + Also try: ./schweikh2 15 1 0 0/0 @@ -37,8 +39,7 @@ Judges' comments: This entry was another crowd pleaser at the IOCCC BOF. - -Selected notes from the author: +## Author's comments Note: the source must be viewed with tabstop 8. To appreciate the beauty have your eyes half closed. diff --git a/1996/schweikh2/hunni.pl b/1996/schweikh2/hunni.pl old mode 100644 new mode 100755 index fbbecdd68..99bce43f5 --- a/1996/schweikh2/hunni.pl +++ b/1996/schweikh2/hunni.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # print "#define C \" \"\n"; print "#define O( _ ) # _\n"; diff --git a/1996/schweikh3/Makefile b/1996/schweikh3/Makefile index d06ef33b5..6a15aa562 100644 --- a/1996/schweikh3/Makefile +++ b/1996/schweikh3/Makefile @@ -1,156 +1,337 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - schweikh3 + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-language-extension-token -Wno-switch-bool + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +#CWARN= -Wall -Wextra ${CSILENCE} +CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +CSTD= -ansi +#CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +#CDEFINE= +CDEFINE= -D_POSIX_SOURCE + +# Include files that are needed to compile +# +#CINCLUDE= +CINCLUDE= -I. +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-comma -Wno-date-time -Wno-double-promotion \ + -Wno-poison-system-directories -Wno-unreachable-code # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= schweikh3 +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/schweikh3/README.md b/1996/schweikh3/README.md index 74633da62..401b01be1 100644 --- a/1996/schweikh3/README.md +++ b/1996/schweikh3/README.md @@ -1,4 +1,4 @@ -Best Utility: +# Best Utility: Jens Schweikhardt DFN Network Operation Center @@ -8,18 +8,20 @@ Best Utility: http://www.uni-stuttgart.de/People/schweikhardt/home.html +## To build: -Judges' comments: + make all - To use: - make schweikh3 +### To run - WARNING! + WARNING: Do not run this program without reading this text down to the end. + It may render your system unusable for a limited amount of time + or force you to reboot using the Big Red Button! This is not a joke. + You have been warned. - Do not run this program without reading this text down to the end. - It may render your system unusable for a limited amount of time - or force you to reboot using the Big Red Button! This is not a joke. - You have been warned. + ./schweikh3 + +## Judges' comments The source fails to compile on compilers that recognize the inline keyword by default. For gcc, you may need to use -ansi. @@ -38,8 +40,7 @@ Judges' comments: -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ schweikh3.c -o schweikh3 - -Selected notes from the author: +## Author's comments Why I think my entry is obfuscated ---------------------------------- diff --git a/1996/westley/Makefile b/1996/westley/Makefile index d06ef33b5..059ad252e 100644 --- a/1996/westley/Makefile +++ b/1996/westley/Makefile @@ -1,156 +1,336 @@ -# %W% %G% %U% +#!/usr/bin/env make # -# 1996 makefile +# IOCCC 1996 winning entry - westley + +################################################################################ # -# Copyright (c) 1997, Landon Curt Noll & Sriram Srinivasan -# All Rights Reserved. Permission for personal, educational or non-profit -# use is granted provided this this copyright and notice are included in its -# entirety and remains unaltered. All other uses must receive prior permission -# from Landon Curt Noll and Sriram Srinivasan. +# An Historical Makefile NOTE: +# +# The orig.Makefile, if it exits, is the original Makefile before this IOCCC +# year directory was reworked so that entries are in separate directories. +# This also applies to any orig.ansi.mk and orig.common.mk files. +# +# Several Makefiles were modified / formed in 2022, and as such it may have +# elements that are not historically compatible with way entries were built. +# The orig.Makefile, if it exits, is a copy of the pre-modified Makefile. +# +# Regarding individual entries: +# +# IOCCC winning entry code may not work on your system. Even with standards, +# conditions and build environments change, especially when it comes to more +# extreme code such you might find in an IOCCC winner. Moreover, what was +# allowed and liked in one IOCCC contest may no longer be liked/allowed in +# later IOCCC years. +# +# Corrections on winning author and fixing typos in remarks are VERY WELCOME. +# +# GitHub pull requests are welcome: +# +# If you have a patch that might make running an entry work in modern Unix-like +# environments, please create a GitHub pull request for the IOCCC judges to +# consider. +# +# Suggestions and corrections regarding Makefiles, winning author information, +# fixing typos in remarks, and code patches are welcome via opening a GitHub +# issue or better yet, by creating a GitHub pull request for the IOCCC judges +# to consider. To form a GitHub issue or GitHub pull, please visit: +# +# https://github.com/ioccc-src/winner +# +################################################################################ + +# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ -SHELL=/bin/sh -CAT=cat -CHMOD=chmod -CP=cp -GUNZIP=gunzip -UUDECODE=uudecode -LN=ln -RM=rm -SED=sed -TRUE=true +############################# +# shell used by this Makefile +############################# +# +SHELL= bash -# flags for ANSI compiles +####################### +# common tool locations +####################### # -# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode, -# others such as gcc may want -ansi, others may want nothing -# at all. Adjust the CFLAGS line as needed. -# -# NOTE: Some compilers cannot optimize, or optimize some entries -# incorrectly. You might want to turn on -O to see if your -# compiler can handle them. -# -#CFLAGS=-O -Xa -#CFLAGS=-Xa -#CFLAGS= -ansi -CFLAGS= -ansi -O -#CFLAGS= +include ../../var.mk -# ANSI compiler +# Set X11_LIBDIR to the directory where the X11 library resides # -# Set CC to the name of your ANSI compiler. -CC=cc +#X11_LIBDIR= /usr/X11R6/lib +#X11_LIBDIR= /usr/X11/lib +X11_LIBDIR= /opt/X11/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +#X11_INCDIR= /usr/X11R6/include +#X11_INCDIR= /usr/X11/include +X11_INCDIR= /opt/X11/include + +# Common C compiler warnings to silence +# +#CSILENCE= +CSILENCE= -Wno-char-subscripts -Wno-error -Wno-implicit-function-declaration \ + -Wno-int-to-pointer-cast + +# Common C compiler warning flags +# +#CWARN= ${CSILENCE} +#CWARN= -Wall ${CSILENCE} +CWARN= -Wall -Wextra ${CSILENCE} +#CWARN= -Wall -Wextra -pedantic ${CSILENCE} + +# Compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=gnu90 + +# Compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitness: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# Defines that are needed to compile +# +CDEFINE= +#CDEFINE= -DIOCCC + +# Include files that are needed to compile +# +CINCLUDE= +#CINCLUDE= -include stdlib.h +#CINCLUDE= -include stdio.h +#CINCLUDE= -include stdlib.h -include stdio.h +#CINCLUDE= -I ${X11_INCDIR} +#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 + +# Optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# Reasonable compilers will allow for -O3. +# +#OPT= +#OPT= -O +#OPT= -O1 +#OPT= -O2 +OPT= -O3 + +# Default flags for ANSI C compilation +# +CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} + +# Libraries needed to build +# +LIBS= +#LIBS= -lm +#LIBS= -L ${X11_LIBDIR} -lX11 +#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL + +# C compiler to use +# +CC= cc +#CC=clang #CC=gcc -# winners that compile under ANSI C +# Compiler add-ons or replacements for clang only # -WINNERS= august dalbec eldby gandalf huffman jonth rcm schweikh1 \ - schweikh2 schweikh3 westley -ALT_NAMES= august.orig - -LEVEL=5 - -all: $(WINNERS) - -# NOTE: Some compilers will compile this code into infinite loop -# progs. We have found gcc to work on a number of platforms. -# If the following example does not execute in a very -# short time, try a better compiler: +ifeq ($(CC),clang) # -# cat august.c test.oc | ./august > test.oo -# -august: august.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c -o august - ${CHMOD} +r fac.oc parse.oc test.oc - -# This forms a byte code execution engine written in OC +CSILENCE+= -Wno-bad-function-cast -Wno-pedantic -Wno-poison-system-directories # -august.oc: august.c - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.c > august.oc - ${CHMOD} +r august.oc - -# NOTE: this is the original source that won +CWARN+= -Weverything # -august.orig: august.orig.c fac.oc parse.oc test.oc - ${CC} ${CFLAGS} -DZ=60000 -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c -o august.orig - ${RM} -f august.oc - ${CC} ${CFLAGS} -E -DZ=40000 -D'T=m[s]' -D'P=m[s++]' \ - -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ - -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ - -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' \ - august.orig.c > august.oc - ${CHMOD} +r fac.oc parse.oc test.oc august.oc +endif -dalbec: dalbec.c - ${CC} ${CFLAGS} dalbec.c -o dalbec - -eldby: eldby.c - ${CC} ${CFLAGS} eldby.c -o eldby - -gandalf: gandalf.c - ${CC} ${CFLAGS} gandalf.c -o gandalf - ${RM} -f hatcat cathat - ${CP} gandalf hatcat - ${CP} gandalf cathat - -huffman: huffman.c - ${CC} ${CFLAGS} huffman.c -o huffman - -# Add -I${X}/include and -L${X}/lib if this doesn't build -# (X is the root of the X Window distribution) -# Solaris users add -lsocket +# Specific add-ons or replacements for gcc only # -jonth: jonth.c - ${CC} ${CFLAGS} jonth.c -o jonth -lX11 -lm - -rcm: rcm.c - ${CC} ${CFLAGS} -DJ='if(' -Ds='else J O==' -DU='B(' \ - -DX='for(' -DH='unsigned' -Dn='struct x' -DA='0,0,0,0,' \ - -DT='' -DY='' -DR='malloc(sizeof(n))' \ - -DM='%=K' -DK=32768 -DD='getchar()' -DN=putchar rcm.c -o rcm - -schweikh1: schweikh1.c errno.h - ${CC} ${CFLAGS} -I. schweikh1.c -o schweikh1 - -schweikh2: schweikh2.c hunni.c hunni.pl - ${CC} ${CFLAGS} -D_POSIX_SOURCE schweikh2.c -o schweikh2 - -# NOTE: On some systems such as SunOS, one may need to compile with: +ifeq ($(CC),gcc) # -# ${CC} ${CFLAGS} \ -# -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \ -# schweikh3.c -o schweikh3 -# -schweikh3: schweikh3.c iso646.h - ${CC} ${CFLAGS} -I. -D_POSIX_SOURCE schweikh3.c -o schweikh3 +#CSILENCE+= +# +#CWARN+= +# +endif -westley: westley.c clock1 clock2 clock3 - ${CC} ${CFLAGS} westley.c -o westley - ${CHMOD} +x clock1 clock2 clock3 -clean: - ${RM} -f *.o a.out core ${WINNERS} +############################## +# Special flags for this entry +############################## +# +ENTRY= westley +PROG= ${ENTRY} +# +OBJ= ${PROG}.o +DATA= clock1 clock2 clock3 +TARGET= ${PROG} +# +ALT_OBJ= +ALT_TARGET= -clobber: clean - ${RM} -f $(WINNERS) - ${RM} -f $(ALT_NAMES) - ${RM} -f fac.oo parse.oo test.oo hatcat cathat august.oc -nuke: clobber +################# +# build the entry +################# +# +all: data ${TARGET} @${TRUE} -install: all - ${CAT} $(WINNERS) $(ALT_NAMES) > /dev/null +.PHONY: all alt data everything clean clobber install \ + love haste waste maker easter_egg sandwich \ + supernova deep_magic magic charon pluto + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + +# alternative executable +# +alt: data ${ALT_TARGET} + @${TRUE} + +# data files +# +data: ${DATA} + @${TRUE} + +# both all and alt +# +everything: all alt + + +############### +# utility rules +############### +# +clean: + ${RM} -f ${OBJ} ${ALT_OBJ} + @-if [ -f indent.c ]; then \ + echo ${RM} -f indent.c; \ + ${RM} -f indent.c; \ + fi + +clobber: clean + ${RM} -f ${TARGET} ${ALT_TARGET} + @-if [ -e sandwich ]; then \ + ${RM} -f sandwich; \ + echo 'ate sandwich'; \ + fi + +install: + @echo "Dr. Spock says that is not logical!" + @${TRUE} + +# you may be able to misunderstand the source by reading indent.c +# +indent.c: ${PROG}.c + @if which "${GINDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${GINDENT} < $< > $@"; \ + ${GINDENT} < $< > $@; \ + elif which "${INDENT}" >/dev/null 2>&1; then \ + echo ${RM} -f $@; \ + ${RM} -f $@; \ + echo "${INDENT} < $< > $@"; \ + ${INDENT} < $< > $@; \ + else \ + echo "no intent tool found, ident $< yourself, sorry"; \ + echo "exit 1"; \ + exit 1; \ + fi + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'haste' + @${TRUE} + +maker: + @echo 'Participate in a maker faire' + @${TRUE} + +easter_egg: + @echo "you expected to often misunderstand this $${RANDOM} magic" + @echo "chongo '' /\\oo/\\" + @echo "Eggy" + +sandwich: easter_egg + @if [ `id -u` -eq 0 ]; then \ + echo 'Okay.'; \ + echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \ + else \ + echo 'What? Make it yourself.'; \ + exit 1; \ + fi + +# Understand the history of the Homebrew Computer Club +# as well as the West Coast Computer Faire and +# you might be confused different. :-) +# +supernova: sandwich + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v6; \ + else \ + echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \ + fi + @echo "A $@ helps ${MAKE} the elements that help form planets" + @${TRUE} + +deep_magic: supernova + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \ + --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + sleep 2; \ + echo "Wrong! Do it again!"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \ + else \ + echo "If you don't eat yer meat, you can't have any pudding!"; \ + echo "How can you have any pudding if you don't eat yer meat?!"; \ + fi + @${TRUE} + +# The IOCCC resident astronomer states +# +charon: magic + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore IAU, $@ is a planet" + +pluto: charon + ${MAKE} charon + @echo "$@ is a dwarf planet" + @echo "dwarf is a type of planet" + @echo "therefore, $@ is a planet" + @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" diff --git a/1996/westley/README.md b/1996/westley/README.md index 9e4d8618c..a7762ebd5 100644 --- a/1996/westley/README.md +++ b/1996/westley/README.md @@ -1,4 +1,4 @@ -Best One Liner: +# Best One Liner: Brian Westley (Merlyn LeRoy on Usenet) 1906 James Ave. @@ -7,13 +7,16 @@ Best One Liner: http://www.visi.com/~westley/index.html +## To build: -Judges' comments: + make all + +### To run - To use: - make westley sh ./clock1 +## Judges' comments + Also try: sh ./clock2 @@ -27,8 +30,7 @@ Judges' comments: short line. We think you will as well if you take the time to understand it. - -Selected notes from the author: +## Author's comments This 1-line program allows various analog ASCII clocks to print out the time; the ASCII clock is built from diff --git a/1996/westley/clock1 b/1996/westley/clock1 old mode 100644 new mode 100755 index 5ace33e6e..c79d1fbb4 --- a/1996/westley/clock1 +++ b/1996/westley/clock1 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh ./westley \ "%%%&&&'''666EEESSSaaannn{{{zzzyyyxxxwwwhhhYYYKKK===000###\$\$\$" \ "34CQ_lkj[M?234CQ_lkj[M?2" \ diff --git a/1996/westley/clock2 b/1996/westley/clock2 old mode 100644 new mode 100755 index 183d15cf2..b2d779f9e --- a/1996/westley/clock2 +++ b/1996/westley/clock2 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh ./westley \ "%%%\$\$\$###000===KKKYYYhhhwwwxxxyyyzzz{{{nnnaaaSSSEEE666'''&&&" \ "32?M[jkl_QC432?M[jkl_QC4" \ diff --git a/1996/westley/clock3 b/1996/westley/clock3 old mode 100644 new mode 100755 index 3689bb928..5c4119ebd --- a/1996/westley/clock3 +++ b/1996/westley/clock3 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh ./westley \ "123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijkl" \ "/\$%&'()*+,-./\$%&'()*+,-." \