#LINK=$(CC)
# If we're cross-compiling, a hints file will override this
-# to a uniq target directory, but otherwise it just goes in
+# to a unique target directory, but otherwise it just goes in
# ../src
TARGETPFX=
#SYSOBJ = $(TARGETPFX)bemain.o $(TARGETPFX)unixtty.o $(TARGETPFX)ioctl.o
+# NetHack 3.7 began introducing C99 code.
+#
+# If your compiler needs an appropriate switch to accept C99 code.
+# CSTD = -std=c99
+
# if you are using gcc as your compiler:
# uncomment the CC definition below if it's not in your environment
# if you get setcgtty() warnings during execution, you are feeding gcc
# CC = arm-linux-gcc
#
#
+# The gcc compiler switch for accepting C99 code. Because gcc had extensions in
+# earlier versions, a number of C99 features were already compiling cleanly, but
+# not all (e.g., 'for' loop initial declarations).
+# CSTD = -std=c99
+
# if you're debugging and want gcc to check as much as possible, use:
# CC = gcc -W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings
# If we're cross-compiling these will get overridden elsewhere, likely via
# a hints file. TARGETPFX was set above earlier.
TARGET_CC = $(CC)
-TARGET_CFLAGS = $(CFLAGS)
+TARGET_CFLAGS = $(CFLAGS) $(CSTD)
TARGET_LINK = $(LINK)
TARGET_LFLAGS = $(LFLAGS)
TARGET_CXX = $(CXX)
# special rules, to force update of makedefs, real dependencies should be
# below in the 'make depend' output.
monst.o:
- $(CC) $(CFLAGS) -c -o $@ monst.c
+ $(CC) $(CFLAGS) $(CSTD) -c -o $@ monst.c
@rm -f $(MAKEDEFS)
objects.o:
- $(CC) $(CFLAGS) -c -o $@ objects.c
+ $(CC) $(CFLAGS) $(CSTD) -c -o $@ objects.c
@rm -f $(MAKEDEFS)
# outdated Qt 3 windowport meta-object-compiler output
# execute things like 'foo.o')
# MAKE = make
+# NetHack 3.7 began introducing C99 code.
+#
+# If your compiler needs an appropriate switch to accept C99 code.
+# CSTD = -std=c99
+
# if you are using gcc as your compiler,
# uncomment the CC definition below if it's not in your environment
# CC = gcc
TARGETPFX=
TARGET_CC = $(CC)
-TARGET_CFLAGS = $(CFLAGS)
+TARGET_CFLAGS = $(CFLAGS) $(CSTD)
TARGET_CLINK = $(CLINK)
TARGET_LFLAGS = $(LFLAGS)
TARGET_CXX = $(CXX)
../include/monst.h ../include/monsters.h ../include/objects.h \
../include/you.h ../include/context.h ../include/flag.h \
../include/dlb.h ../include/patchlevel.h mdgrep.h
- $(CC) $(CFLAGS) -c makedefs.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c makedefs.c -o $@
# Don't require perl to build; that is why mdgrep.h is spelled wrong below.
mdgreph: mdgrep.pl
# support code used by several of the utility programs (but not makedefs)
panic.o: panic.c $(CONFIG_H)
- $(CC) $(CFLAGS) -c panic.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c panic.c -o $@
# with all of extern.h's functions to complain about, we drown in
$(CLINK) $(LFLAGS) -o dlb $(DLBOBJS) $(LIBS)
dlb_main.o: dlb_main.c $(CONFIG_H) ../include/dlb.h
- $(CC) $(CFLAGS) -c dlb_main.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c dlb_main.c -o $@
# dependencies for tile utilities
./tilemap
tiletext.o: ../win/share/tiletext.c $(CONFIG_H) ../win/share/tile.h
- $(CC) $(CFLAGS) -I../win/share -c ../win/share/tiletext.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -I../win/share -c ../win/share/tiletext.c -o $@
tiletxt.o: ../win/share/tiletxt.c ../win/share/tilemap.c $(HACK_H)
- $(CC) $(CFLAGS) -I../win/share -c ../win/share/tiletxt.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -I../win/share -c ../win/share/tiletxt.c -o $@
tilemap.o: ../win/share/tilemap.c $(HACK_H)
- $(CC) $(CFLAGS) -c ../win/share/tilemap.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../win/share/tilemap.c -o $@
gifread.o: ../win/share/gifread.c $(CONFIG_H) ../win/share/tile.h
- $(CC) $(CFLAGS) -I../win/share -c ../win/share/gifread.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -I../win/share -c ../win/share/gifread.c -o $@
ppmwrite.o: ../win/share/ppmwrite.c $(CONFIG_H) ../win/share/tile.h
- $(CC) $(CFLAGS) -I../win/share -c ../win/share/ppmwrite.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -I../win/share -c ../win/share/ppmwrite.c -o $@
tile2bmp.o: ../win/share/tile2bmp.c $(HACK_H) ../win/share/tile.h
- $(CC) $(CFLAGS) -I../win/share -c ../win/share/tile2bmp.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -I../win/share -c ../win/share/tile2bmp.c -o $@
tile2x11.o: ../win/X11/tile2x11.c $(HACK_H) ../win/share/tile.h \
../include/tile2x11.h
- $(CC) $(CFLAGS) -I../win/share -c ../win/X11/tile2x11.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -I../win/share -c ../win/X11/tile2x11.c -o $@
tile2img.o: ../win/gem/tile2img.c $(HACK_H) ../win/share/tile.h \
../include/bitmfile.h
- $(CC) $(CFLAGS) -I../win/share -c ../win/gem/tile2img.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -I../win/share -c ../win/gem/tile2img.c -o $@
xpm2img.o: ../win/gem/xpm2img.c $(HACK_H) ../include/bitmfile.h
- $(CC) $(CFLAGS) -c ../win/gem/xpm2img.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../win/gem/xpm2img.c -o $@
bitmfile.o: ../win/gem/bitmfile.c ../include/bitmfile.h
- $(CC) $(CFLAGS) -c ../win/gem/bitmfile.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../win/gem/bitmfile.c -o $@
tile2beos.o: ../win/BeOS/tile2beos.cpp $(HACK_H) ../win/share/tile.h
- $(CXX) $(CFLAGS) -I../win/share -c ../win/BeOS/tile2beos.cpp -o $@
+ $(CXX) $(CFLAGS) $(CSTD) -I../win/share -c ../win/BeOS/tile2beos.cpp -o $@
# note: tileedit.cpp was developed for Qt2 and will not compile using Qt5
tileedit.o: ../win/Qt/tileedit.cpp
uudecode: uudecode.o
$(CLINK) $(LFLAGS) -o uudecode uudecode.o $(LIBS)
uudecode.o: ../sys/share/uudecode.c
- $(CC) $(CFLAGS) -c -o uudecode.o ../sys/share/uudecode.c
+ $(CC) $(CFLAGS) $(CSTD) -c -o uudecode.o ../sys/share/uudecode.c
# using dependencies like
# ../src/foo::
# (note: these dependencies have been copied from Makefile.src so only come
# indirectly from 'make depend', hence are subject to bit rot as src changes)
$(OBJDIR)/alloc.o: ../src/alloc.c $(CONFIG_H)
- $(CC) $(CFLAGS) -c ../src/alloc.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../src/alloc.c -o $@
$(OBJDIR)/drawing.o: ../src/drawing.c $(CONFIG_H) ../include/color.h \
../include/rm.h ../include/objclass.h ../include/defsym.h \
../include/objects.h ../include/sym.h
- $(CC) $(CFLAGS) -c ../src/drawing.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../src/drawing.c -o $@
$(OBJDIR)/decl.o: ../src/decl.c $(HACK_H)
- $(CC) $(CFLAGS) -c ../src/decl.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../src/decl.c -o $@
$(OBJDIR)/monst.o: ../src/monst.c $(CONFIG_H) ../include/permonst.h \
../include/align.h ../include/monattk.h ../include/monflag.h \
../include/monsters.h ../include/sym.h ../include/defsym.h \
../include/color.h
- $(CC) $(CFLAGS) -c ../src/monst.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../src/monst.c -o $@
$(OBJDIR)/objects.o: ../src/objects.c $(CONFIG_H) ../include/obj.h \
../include/prop.h ../include/skills.h ../include/color.h \
../include/objclass.h ../include/defsym.h ../include/objects.h
- $(CC) $(CFLAGS) -c ../src/objects.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../src/objects.c -o $@
$(OBJDIR)/dlb.o: ../src/dlb.c $(CONFIG_H) ../include/dlb.h
- $(CC) $(CFLAGS) -c ../src/dlb.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../src/dlb.c -o $@
# this differs substantially from what Makefile.src specifies
$(OBJDIR)/date.o: ../src/date.c $(CONFIG_H)
- $(CC) $(CFLAGS) -c ../src/date.c -o $@
+ $(CC) $(CFLAGS) $(CSTD) -c ../src/date.c -o $@
# make sure hack.h dependencies get transitive information
$(HACK_H): $(CONFIG_H)