Append (instead of assigning) to CFLAGS, and declare (by appending) and use LDFLAGS, so that user- (or MacPorts-)specified flags aren't ignored. Change _POSIX_SOURCE to _POSIX_C_SOURCE=2L to fix: main.c:65:17: error: implicit declaration of function 'getopt' is invalid in C99 [-Werror,-Wimplicit-function-declaration] Add tokens.h to dependencies of tokdump.o. Remove duplicate declaration of dependencies of interpret.o. Declare dependencies of main.o to fix (when building in parallel): main.c:24:10: fatal error: 'tokens.h' file not found Remove tokens.h from dependencies of monitor.o. Preface the comment "# Hmmm...this is probably Bison-specific" with "@" to prevent it from appearing in the terminal during the build. Add cupl.h to dependencies of lextest. --- Makefile.orig 2019-06-12 10:39:17.000000000 -0500 +++ Makefile 2023-01-12 20:54:04.000000000 -0600 @@ -5,11 +5,12 @@ CDEBUG = -g # use -O for production, -g for debugging YFLAGS = -vt # use -l for production, -vt for debugging -CFLAGS = $(CDEBUG) -D_POSIX_SOURCE -DPARSEDEBUG -DYYDEBUG=1 +CFLAGS += $(CDEBUG) -D_POSIX_C_SOURCE=2L -DPARSEDEBUG -DYYDEBUG=1 +LDFLAGS += -lm MODULES = main.o grammar.o lexer.o interpret.o tokdump.o execute.o monitor.o cupl: $(MODULES) - $(CC) $(MODULES) -lm -o cupl + $(CC) $(MODULES) $(LDFLAGS) -o cupl # You can use either lex or flex #LEX = lex @@ -30,18 +31,18 @@ mv y.tab.h tokens.h grammar.o: grammar.c cupl.h -tokdump.o: tokdump.c toktab.h +tokdump.o: tokdump.c tokens.h toktab.h lexer.o: lexer.c tokens.h cupl.h interpret.o: interpret.c tokens.h cupl.h -interpret.o: interpret.c tokens.h cupl.h +main.o: main.c tokens.h cupl.h execute.o: execute.c tokens.h cupl.h -monitor.o: monitor.c tokens.h cupl.h +monitor.o: monitor.c cupl.h toktab.h: tokens.h - # Hmmm...this is probably Bison-specific + @# Hmmm...this is probably Bison-specific awk toktab.h '/^# define / {print $$3 ", \"" $$3 "\","}' -lextest: lexer.c tokens.h tokdump.o +lextest: lexer.c tokens.h cupl.h tokdump.o $(CC) $(CFLAGS) -DMAIN lexer.c tokdump.o -o lextest cupl.1: cupl.xml