From d63ff7700d95e56db61479c008dfb5a72c328144 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 1 Apr 2016 16:49:49 -0700 Subject: [PATCH] fix #H4287 - inconsistent handling of CPPFLAGS [Subject should mention Unix, but would exceed 50 characters.] Explicit build rules ignore $(CPPFLAGS), but the implicit C rule (at least in GNU make) specifies it. If user has a value for this in the environment, that value would apply to building some source files but not others. This patch gives it an explicit empty value, so building via implicit rule should expand it to nothing and match the fact that it's omitted from explicit rules. There was one C++ file which relied on the implicit C++ rule. I've added it to the files processed by 'make depend' and re-run that. It now will get built via an explicit rule. Also, a small amount of reformatting for HACKCSRC. --- doc/fixes36.1 | 3 +++ sys/unix/Makefile.src | 32 +++++++++++++++++++++----------- sys/unix/Makefile.utl | 5 +++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 029de8685..4074f3056 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -221,6 +221,9 @@ unix: options file with CR+LF line ends and an invalid option line resulted in unix: race condition with parallel make: src/Makefile might start building makedefs before finishing monst.o and objects.o; if so, util/Makefile can build them too, and they might be clobbered by simultaneous write +unix: Makefile.{src,utl} ignored CPPFLAGS which is expanded by the default .c + rule by GNU make so if user had a value for that in the environment, + it would apply to some files but not others; explicitly override it win32gui: getversionstring() was overflowing the provided Help About buffer win32gui: guard against buffer overflow in in mswin_getlin() win32gui: handle menu_color attribute diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 7b477940f..5488e6106 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -167,6 +167,11 @@ CXX=g++ #CXX=arm-linux-g++ #LINK=arm-linux-gcc +# we specify C preprocessor flags via CFLAGS; files built with default rules +# might include $(CPPFLAGS) which could get a value from user's environment; +# we avoid that by forcing it empty rather than by overriding default rules +CPPFLAGS = + # file for regular expression matching REGEXOBJ = posixregex.o #REGEXOBJ = pmatchregex.o @@ -333,11 +338,11 @@ HACKCSRC = allmain.c alloc.c apply.c artifact.c attrib.c ball.c bones.c \ mkmaze.c mkobj.c mkroom.c mon.c mondata.c monmove.c monst.c \ mplayer.c mthrowu.c muse.c music.c o_init.c objects.c objnam.c \ options.c pager.c pickup.c pline.c polyself.c potion.c pray.c \ - priest.c quest.c questpgr.c read.c rect.c region.c restore.c rip.c \ - rnd.c role.c rumors.c save.c shk.c shknam.c sit.c sounds.c sp_lev.c \ - spell.c steal.c steed.c sys.c teleport.c timeout.c topten.c track.c \ - trap.c \ - u_init.c uhitm.c vault.c version.c vision.c weapon.c were.c wield.c \ + priest.c quest.c questpgr.c read.c rect.c region.c restore.c \ + rip.c rnd.c role.c rumors.c save.c shk.c shknam.c sit.c sounds.c \ + sp_lev.c spell.c steal.c steed.c sys.c teleport.c timeout.c \ + topten.c track.c trap.c u_init.c \ + uhitm.c vault.c version.c vision.c weapon.c were.c wield.c \ windows.c wizard.c worm.c worn.c write.c zap.c # all operating-system-dependent .c (for dependencies and such) @@ -347,6 +352,7 @@ SYSCSRC = ../sys/atari/tos.c ../sys/share/pcmain.c ../sys/share/pcsys.c \ ../sys/share/random.c \ ../sys/share/ioctl.c ../sys/share/unixtty.c ../sys/unix/unixmain.c \ ../sys/unix/unixunix.c ../sys/unix/unixres.c ../sys/be/bemain.c +SYSCXXSRC = ../sys/share/cppregex.cpp # generated source files (tile.c is handled separately via WINxxxSRC) GENCSRC = monstr.c vis_tab.c #tile.c @@ -501,8 +507,10 @@ $(MAKEDEFS): $(FIRSTOBJ) \ # Source files created by 'makedefs' at build time. # Each is given an artificial dependency upon the one before -# so that parallel makes will have to build them sequentially and -# not clobber makedefs by attempting simultaneous builds of it. +# so that parallel makes will have to build them sequentially. +# (More for documentation than effect; 'make' should know not +# to try to build $(MAKEDEFS) for bar.h while it is in the +# process of building it for foo.h.) ../include/onames.h: $(MAKEDEFS) @( cd ../util ; $(MAKE) ../include/onames.h ) ../include/pm.h: $(MAKEDEFS) ../include/onames.h @@ -559,11 +567,11 @@ spotless: clean depend: ../sys/unix/depend.awk \ - $(SYSCSRC) $(WINCSRC) $(WINCXXSRC) $(CHAINSRC) $(GENCSRC) \ - $(HACKCSRC) + $(SYSCSRC) $(WINCSRC) $(SYSCXXSRC) $(WINCXXSRC) \ + $(CHAINSRC) $(GENCSRC) $(HACKCSRC) $(AWK) -f ../sys/unix/depend.awk ../include/*.h \ - $(SYSCSRC) $(WINCSRC) $(WINCXXSRC) $(CHAINSRC) $(GENCSRC) \ - $(HACKCSRC) >makedep + $(SYSCSRC) $(WINCSRC) $(SYSCXXSRC) $(WINCXXSRC) \ + $(CHAINSRC) $(GENCSRC) $(HACKCSRC) >makedep @echo '/^# DO NOT DELETE THIS LINE OR CHANGE ANYTHING BEYOND IT/+2,$$d' >eddep @echo '$$r makedep' >>eddep @echo 'w' >>eddep @@ -718,6 +726,8 @@ load_img.o: ../win/gem/load_img.c ../include/load_img.h gr_rect.o: ../win/gem/gr_rect.c ../include/gr_rect.h $(CC) $(CFLAGS) -c ../win/gem/gr_rect.c tile.o: tile.c $(HACK_H) +cppregex.o: ../sys/share/cppregex.cpp + $(CXX) $(CXXFLAGS) -c ../sys/share/cppregex.cpp qt_win.o: ../win/Qt/qt_win.cpp $(HACK_H) ../include/func_tab.h \ ../include/dlb.h ../include/patchlevel.h ../include/tile2x11.h \ ../include/qt_win.h ../include/qt_clust.h ../include/qt_kde0.h \ diff --git a/sys/unix/Makefile.utl b/sys/unix/Makefile.utl index 5f092ecfa..3cd34906e 100644 --- a/sys/unix/Makefile.utl +++ b/sys/unix/Makefile.utl @@ -95,6 +95,11 @@ NHSROOT=.. #CFLAGS = -O -I../include #LFLAGS = +# we specify C preprocessor flags via CFLAGS; files built with default rules +# might include $(CPPFLAGS) which could get a value from user's environment; +# we avoid that by forcing it empty rather than by overriding default rules +CPPFLAGS = + LIBS = # If you are cross-compiling, you must use this: -- 2.50.1