shithub: rgbds

Download patch

ref: 4be81d9ffd1751508345227ae1fefcde256e64a2
parent: ccc666c1e4b38fa2d1608b81d49b0dac253cefca
parent: 1288737c0d195243b63fcbdd4c3b9a8ba3ce21ce
author: Eldred Habert <[email protected]>
date: Sat Sep 21 21:55:51 EDT 2019

Merge pull request #416 from ISSOtm/makefile

Improve Makefile

--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,8 @@
 sudo: required
 install:
   - ./.travis-deps.sh
-  - make
-  - sudo make install
+  - make Q=
+  - sudo make install Q=
 os:
   - linux
   - osx
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,9 @@
 # SPDX-License-Identifier: MIT
 #
 
+.SUFFIXES:
+.SUFFIXES: .h .l .y .c .o
+
 # User-defined variables
 
 Q		:= @
@@ -33,6 +36,10 @@
 # Non-overridable CFLAGS
 REALCFLAGS	:= ${CFLAGS} ${WARNFLAGS} -std=c99 -D_POSIX_C_SOURCE=200809L \
 		   -Iinclude -DBUILD_VERSION_STRING=\"${VERSION_STRING}\"
+# Overridable LDFLAGS
+LDFLAGS		:=
+# Non-overridable LDFLAGS
+REALLDFLAGS	:= ${LDFLAGS} ${WARNFLAGS}
 
 YFLAGS		:=
 LFLAGS		:= --nounistd
@@ -62,8 +69,7 @@
 	src/extern/utf8decoder.o \
 	src/version.o
 
-src/asm/asmy.h: src/asm/asmy.c
-src/asm/locallex.o src/asm/globlex.o src/asm/lexer.o src/asm/constexpr.o: src/asm/asmy.h
+src/asm/globlex.o src/asm/lexer.o src/asm/constexpr.o: src/asm/asmy.h
 
 rgblink_obj := \
 	src/link/assign.o \
@@ -80,7 +86,6 @@
 	src/extern/err.o \
 	src/version.o
 
-src/link/parser.h: src/link/parser.c
 src/link/lexer.o: src/link/parser.h
 
 rgbfix_obj := \
@@ -96,27 +101,32 @@
 	src/version.o
 
 rgbasm: ${rgbasm_obj}
-	$Q${CC} ${REALCFLAGS} -o $@ ${rgbasm_obj} -lm
+	$Q${CC} ${REALLDFLAGS} -o $@ ${rgbasm_obj} -lm
 
 rgblink: ${rgblink_obj}
-	$Q${CC} ${REALCFLAGS} -o $@ ${rgblink_obj}
+	$Q${CC} ${REALLDFLAGS} -o $@ ${rgblink_obj}
 
 rgbfix: ${rgbfix_obj}
-	$Q${CC} ${REALCFLAGS} -o $@ ${rgbfix_obj}
+	$Q${CC} ${REALLDFLAGS} -o $@ ${rgbfix_obj}
 
 rgbgfx: ${rgbgfx_obj}
-	$Q${CC} ${REALCFLAGS} ${PNGLDFLAGS} -o $@ ${rgbgfx_obj} ${PNGLDLIBS}
+	$Q${CC} ${REALLDFLAGS} ${PNGLDFLAGS} -o $@ ${rgbgfx_obj} ${PNGLDLIBS}
 
 # Rules to process files
 
+# We want the yacc and lex invocations to pass through our rules
+.y.o:
+.l.o:
+
+# yacc- and lex-generated C files have an accompanying header
+.c.h:
+	$Qtouch $@
+
 .y.c:
 	$Q${YACC} -d ${YFLAGS} -o $@ $<
 
-.l.o:
-	$Q${RM} $*.c
-	$Q${LEX} ${LFLAGS} -o $*.c $<
-	$Q${CC} ${REALCFLAGS} -c -o $@ $*.c
-	$Q${RM} $*.c
+.l.c:
+	$Q${LEX} ${LFLAGS} -o $@ $<
 
 .c.o:
 	$Q${CC} ${REALCFLAGS} ${PNGCFLAGS} -c -o $@ $<
@@ -125,12 +135,13 @@
 # for the html documentation.
 
 clean:
-	$Q${RM} rgbasm rgbasm.exe ${rgbasm_obj}
-	$Q${RM} rgblink rgblink.exe ${rgblink_obj}
-	$Q${RM} rgbfix rgbfix.exe ${rgbfix_obj}
-	$Q${RM} rgbgfx rgbgfx.exe ${rgbgfx_obj}
+	$Q${RM} rgbasm rgbasm.exe src/asm/*.o
+	$Q${RM} rgblink rgblink.exe src/link/*.o
+	$Q${RM} rgbfix rgbfix.exe src/fix/*.o
+	$Q${RM} rgbgfx rgbgfx.exe src/gfx/*.o
 	$Q${RM} src/asm/asmy.c src/asm/asmy.h
 	$Q${RM} src/link/lexer.c src/link/parser.c src/link/parser.h
+	$Q${RM} src/extern/*.o
 
 # Target used to remove all html files generated by the wwwman target
 
--- a/src/link/.gitignore
+++ b/src/link/.gitignore
@@ -1,2 +1,4 @@
 parser.c
 parser.h
+lexer.c
+lexer.h