allow setting the standard
CSTD can be manually set near the top of src/Makefile, util/Makefile or by including c99=1 or C99=1 on the build make command line if using the linux.370 or macOS.370 hints files.
This commit is contained in:
+14
-4
@@ -44,7 +44,7 @@ SHELL=/bin/sh
|
|||||||
#LINK=$(CC)
|
#LINK=$(CC)
|
||||||
|
|
||||||
# If we're cross-compiling, a hints file will override this
|
# 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
|
# ../src
|
||||||
TARGETPFX=
|
TARGETPFX=
|
||||||
|
|
||||||
@@ -68,6 +68,11 @@ SYSOBJ = $(TARGETPFX)ioctl.o $(TARGETPFX)unixmain.o $(TARGETPFX)unixtty.o \
|
|||||||
#SYSOBJ = $(TARGETPFX)bemain.o $(TARGETPFX)unixtty.o $(TARGETPFX)ioctl.o
|
#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:
|
# if you are using gcc as your compiler:
|
||||||
# uncomment the CC definition below if it's not in your environment
|
# uncomment the CC definition below if it's not in your environment
|
||||||
# if you get setcgtty() warnings during execution, you are feeding gcc
|
# if you get setcgtty() warnings during execution, you are feeding gcc
|
||||||
@@ -90,6 +95,11 @@ SYSOBJ = $(TARGETPFX)ioctl.o $(TARGETPFX)unixmain.o $(TARGETPFX)unixtty.o \
|
|||||||
# CC = arm-linux-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:
|
# 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
|
# CC = gcc -W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings
|
||||||
|
|
||||||
@@ -189,7 +199,7 @@ MOCPATH ?= $(QTDIR)/bin/$(MOC)
|
|||||||
# If we're cross-compiling these will get overridden elsewhere, likely via
|
# If we're cross-compiling these will get overridden elsewhere, likely via
|
||||||
# a hints file. TARGETPFX was set above earlier.
|
# a hints file. TARGETPFX was set above earlier.
|
||||||
TARGET_CC = $(CC)
|
TARGET_CC = $(CC)
|
||||||
TARGET_CFLAGS = $(CFLAGS)
|
TARGET_CFLAGS = $(CFLAGS) $(CSTD)
|
||||||
TARGET_LINK = $(LINK)
|
TARGET_LINK = $(LINK)
|
||||||
TARGET_LFLAGS = $(LFLAGS)
|
TARGET_LFLAGS = $(LFLAGS)
|
||||||
TARGET_CXX = $(CXX)
|
TARGET_CXX = $(CXX)
|
||||||
@@ -674,11 +684,11 @@ $(LUALIB) ../include/nhlua.h:
|
|||||||
# special rules, to force update of makedefs, real dependencies should be
|
# special rules, to force update of makedefs, real dependencies should be
|
||||||
# below in the 'make depend' output.
|
# below in the 'make depend' output.
|
||||||
monst.o:
|
monst.o:
|
||||||
$(CC) $(CFLAGS) -c -o $@ monst.c
|
$(CC) $(CFLAGS) $(CSTD) -c -o $@ monst.c
|
||||||
@rm -f $(MAKEDEFS)
|
@rm -f $(MAKEDEFS)
|
||||||
|
|
||||||
objects.o:
|
objects.o:
|
||||||
$(CC) $(CFLAGS) -c -o $@ objects.c
|
$(CC) $(CFLAGS) $(CSTD) -c -o $@ objects.c
|
||||||
@rm -f $(MAKEDEFS)
|
@rm -f $(MAKEDEFS)
|
||||||
|
|
||||||
# outdated Qt 3 windowport meta-object-compiler output
|
# outdated Qt 3 windowport meta-object-compiler output
|
||||||
|
|||||||
+28
-23
@@ -23,6 +23,11 @@ NHSROOT=..
|
|||||||
# execute things like 'foo.o')
|
# execute things like 'foo.o')
|
||||||
# MAKE = make
|
# 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,
|
# if you are using gcc as your compiler,
|
||||||
# uncomment the CC definition below if it's not in your environment
|
# uncomment the CC definition below if it's not in your environment
|
||||||
# CC = gcc
|
# CC = gcc
|
||||||
@@ -203,7 +208,7 @@ DLBOBJS = dlb_main.o $(OBJDIR)/dlb.o $(OALLOC)
|
|||||||
|
|
||||||
TARGETPFX=
|
TARGETPFX=
|
||||||
TARGET_CC = $(CC)
|
TARGET_CC = $(CC)
|
||||||
TARGET_CFLAGS = $(CFLAGS)
|
TARGET_CFLAGS = $(CFLAGS) $(CSTD)
|
||||||
TARGET_CLINK = $(CLINK)
|
TARGET_CLINK = $(CLINK)
|
||||||
TARGET_LFLAGS = $(LFLAGS)
|
TARGET_LFLAGS = $(LFLAGS)
|
||||||
TARGET_CXX = $(CXX)
|
TARGET_CXX = $(CXX)
|
||||||
@@ -226,7 +231,7 @@ makedefs.o: makedefs.c ../src/mdlib.c $(CONFIG_H) \
|
|||||||
../include/monst.h ../include/monsters.h ../include/objects.h \
|
../include/monst.h ../include/monsters.h ../include/objects.h \
|
||||||
../include/you.h ../include/context.h ../include/flag.h \
|
../include/you.h ../include/context.h ../include/flag.h \
|
||||||
../include/dlb.h ../include/patchlevel.h mdgrep.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.
|
# Don't require perl to build; that is why mdgrep.h is spelled wrong below.
|
||||||
mdgreph: mdgrep.pl
|
mdgreph: mdgrep.pl
|
||||||
@@ -249,7 +254,7 @@ lintdefs:
|
|||||||
|
|
||||||
# support code used by several of the utility programs (but not makedefs)
|
# support code used by several of the utility programs (but not makedefs)
|
||||||
panic.o: panic.c $(CONFIG_H)
|
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
|
# with all of extern.h's functions to complain about, we drown in
|
||||||
@@ -274,7 +279,7 @@ dlb: $(DLBOBJS)
|
|||||||
$(CLINK) $(LFLAGS) -o dlb $(DLBOBJS) $(LIBS)
|
$(CLINK) $(LFLAGS) -o dlb $(DLBOBJS) $(LIBS)
|
||||||
|
|
||||||
dlb_main.o: dlb_main.c $(CONFIG_H) ../include/dlb.h
|
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
|
# dependencies for tile utilities
|
||||||
@@ -318,34 +323,34 @@ tilemap: tilemap.o $(OBJDIR)/objects.o $(OBJDIR)/monst.o $(OBJDIR)/drawing.o
|
|||||||
./tilemap
|
./tilemap
|
||||||
|
|
||||||
tiletext.o: ../win/share/tiletext.c $(CONFIG_H) ../win/share/tile.h
|
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)
|
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)
|
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
|
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
|
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
|
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 \
|
tile2x11.o: ../win/X11/tile2x11.c $(HACK_H) ../win/share/tile.h \
|
||||||
../include/tile2x11.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 \
|
tile2img.o: ../win/gem/tile2img.c $(HACK_H) ../win/share/tile.h \
|
||||||
../include/bitmfile.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
|
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
|
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
|
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
|
# note: tileedit.cpp was developed for Qt2 and will not compile using Qt5
|
||||||
tileedit.o: ../win/Qt/tileedit.cpp
|
tileedit.o: ../win/Qt/tileedit.cpp
|
||||||
@@ -357,7 +362,7 @@ tileedit: tileedit.o $(TEXT_IO)
|
|||||||
uudecode: uudecode.o
|
uudecode: uudecode.o
|
||||||
$(CLINK) $(LFLAGS) -o uudecode uudecode.o $(LIBS)
|
$(CLINK) $(LFLAGS) -o uudecode uudecode.o $(LIBS)
|
||||||
uudecode.o: ../sys/share/uudecode.c
|
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
|
# using dependencies like
|
||||||
# ../src/foo::
|
# ../src/foo::
|
||||||
@@ -374,27 +379,27 @@ uudecode.o: ../sys/share/uudecode.c
|
|||||||
# (note: these dependencies have been copied from Makefile.src so only come
|
# (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)
|
# indirectly from 'make depend', hence are subject to bit rot as src changes)
|
||||||
$(OBJDIR)/alloc.o: ../src/alloc.c $(CONFIG_H)
|
$(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 \
|
$(OBJDIR)/drawing.o: ../src/drawing.c $(CONFIG_H) ../include/color.h \
|
||||||
../include/rm.h ../include/objclass.h ../include/defsym.h \
|
../include/rm.h ../include/objclass.h ../include/defsym.h \
|
||||||
../include/objects.h ../include/sym.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)
|
$(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 \
|
$(OBJDIR)/monst.o: ../src/monst.c $(CONFIG_H) ../include/permonst.h \
|
||||||
../include/align.h ../include/monattk.h ../include/monflag.h \
|
../include/align.h ../include/monattk.h ../include/monflag.h \
|
||||||
../include/monsters.h ../include/sym.h ../include/defsym.h \
|
../include/monsters.h ../include/sym.h ../include/defsym.h \
|
||||||
../include/color.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 \
|
$(OBJDIR)/objects.o: ../src/objects.c $(CONFIG_H) ../include/obj.h \
|
||||||
../include/prop.h ../include/skills.h ../include/color.h \
|
../include/prop.h ../include/skills.h ../include/color.h \
|
||||||
../include/objclass.h ../include/defsym.h ../include/objects.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
|
$(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
|
# this differs substantially from what Makefile.src specifies
|
||||||
$(OBJDIR)/date.o: ../src/date.c $(CONFIG_H)
|
$(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
|
# make sure hack.h dependencies get transitive information
|
||||||
$(HACK_H): $(CONFIG_H)
|
$(HACK_H): $(CONFIG_H)
|
||||||
|
|||||||
@@ -149,8 +149,18 @@ endif # CPLUSPLUS_NEED17
|
|||||||
endif # end of clang++-specific section
|
endif # end of clang++-specific section
|
||||||
CXX=$(CCXX)
|
CXX=$(CCXX)
|
||||||
endif # CPLUSPLUS_NEEDED
|
endif # CPLUSPLUS_NEEDED
|
||||||
|
|
||||||
endif # MAKEFILE_SRC
|
endif # MAKEFILE_SRC
|
||||||
|
|
||||||
|
ifeq "$(c99)" "1"
|
||||||
|
WANT_C99=1
|
||||||
|
endif
|
||||||
|
ifeq "$(C99)" "1"
|
||||||
|
WANT_C99=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(WANT_C99)" "1"
|
||||||
|
CSTD = -std=c99
|
||||||
|
endif
|
||||||
|
|
||||||
#end of compiler.370
|
#end of compiler.370
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user