Skip to content

Commit 0f94130

Browse files
committed
Better makefiles
1 parent 84659a9 commit 0f94130

File tree

7 files changed

+100
-144
lines changed

7 files changed

+100
-144
lines changed

.github/workflows/on-main-push-ci-nightly.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/checkout@v6
2020

2121
- name: make (Windows)
22-
run: make -f windows.makefile compile test
22+
run: make -f windows.makefile all
2323

2424
- name: Upload nightly build
2525
uses: actions/upload-artifact@v6
@@ -36,7 +36,7 @@ jobs:
3636
uses: actions/checkout@v6
3737

3838
- name: make (Linux)
39-
run: make -f linux.makefile compile test
39+
run: make -f linux.makefile all
4040

4141
- name: Upload nightly build
4242
uses: actions/upload-artifact@v6
@@ -53,7 +53,7 @@ jobs:
5353
uses: actions/checkout@v6
5454

5555
- name: make (MacOS)
56-
run: make -f macos.makefile compile test
56+
run: make -f macos.makefile all
5757

5858
- name: Upload nightly build
5959
uses: actions/upload-artifact@v6

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
*.exe
1+
*.o
2+
bin
3+
!bin/placeholder.txt
24

35
*.chr
46
*.clr

linux.makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#
2-
# commands
2+
# targets
33
#
4-
54
PCX2MSX=bin/pcx2msx
65
PCX2SPR=bin/pcx2spr
76
PCX2MSXPLUS=bin/pcx2msx+
@@ -11,15 +10,20 @@ PNG2SPR=bin/png2spr
1110
PNG2SPRPLUS=bin/png2spr+
1211
TMX2BIN=bin/tmx2bin
1312

14-
CCOMPILER=gcc
13+
#
14+
# options
1515
# (see https://interrupt.memfault.com/blog/best-and-worst-gcc-clang-compiler-flags)
16-
CCOMPILER_OPTIONS=-Wall -Wextra -Wshadow -Wdouble-promotion -Wundef -O3
17-
CCOMPILER_LINKER_OPTIONS=-lm
16+
#
17+
CC=gcc
18+
CFLAGS=-O3 -Wall -Wextra -Wshadow -Wdouble-promotion -Wundef
19+
LDFLAGS=-lm
1820

21+
#
22+
# commands
23+
#
1924
REMOVE=rm
2025

2126
#
2227
# main makefile
2328
#
24-
2529
include shared.makefile

macos.makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#
2-
# commands
2+
# targets
33
#
4-
54
PCX2MSX=bin/pcx2msx
65
PCX2SPR=bin/pcx2spr
76
PCX2MSXPLUS=bin/pcx2msx+
@@ -11,15 +10,20 @@ PNG2SPR=bin/png2spr
1110
PNG2SPRPLUS=bin/png2spr+
1211
TMX2BIN=bin/tmx2bin
1312

14-
CCOMPILER=gcc
13+
#
14+
# options
1515
# (see https://interrupt.memfault.com/blog/best-and-worst-gcc-clang-compiler-flags)
16-
CCOMPILER_OPTIONS=-Wall -Wextra -Wshadow -Wdouble-promotion -Wundef -O3
17-
CCOMPILER_LINKER_OPTIONS=
16+
#
17+
CC=gcc
18+
CFLAGS=-O3 -Wall -Wextra -Wshadow -Wdouble-promotion -Wundef
19+
LDFLAGS=
1820

21+
#
22+
# commands
23+
#
1924
REMOVE=rm
2025

2126
#
2227
# main makefile
2328
#
24-
2529
include shared.makefile

shared.makefile

Lines changed: 63 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -3,164 +3,108 @@
33
# file lists
44
#
55

6-
PCX_TOOLS=\
6+
TARGETS=\
77
$(PCX2MSX) \
88
$(PCX2SPR) \
99
$(PCX2MSXPLUS) \
10-
$(PCX2SPRPLUS)
11-
12-
PNG_TOOLS=\
10+
$(PCX2SPRPLUS) \
1311
$(PNG2MSX) \
1412
$(PNG2SPR) \
15-
$(PNG2SPRPLUS)
16-
17-
TMX_TOOLS= \
13+
$(PNG2SPRPLUS) \
1814
$(TMX2BIN)
1915

20-
PCX_TESTS=\
21-
test/charset.pcx.chr \
22-
test/charset.pcx.clr \
23-
test/bigsprites.pcx.spat.asm \
24-
test/bigsprites.pcx.spr.asm
16+
OBJS_PCX=\
17+
src/args.o \
18+
src/bitmap.o \
19+
src/readpcx.o
2520

26-
PNG_TESTS=\
27-
test/charset.png.chr \
28-
test/charset.png.clr \
29-
test/bigsprites.png.spat.asm \
30-
test/bigsprites.png.spr.asm
21+
OBJS_PNG=\
22+
src/args.o \
23+
src/bitmap.o \
24+
src/readpng.o \
25+
src/lodepng/lodepng.o
3126

32-
TMX_TESTS=\
33-
test/screen.tmx.bin \
34-
test/metatiles.tmx.bin
27+
OBJS_TMX=\
28+
src/args.o \
29+
src/tiled.o \
30+
src/readtmx.o
3531

36-
COMMON_DEPS_C=\
37-
src/args.c
38-
39-
COMMON_DEPS_PCX_C=\
40-
src/bitmap.c \
41-
src/readpcx.c \
42-
$(COMMON_DEPS_C)
43-
44-
COMMON_DEPS_PNG_C=\
45-
src/bitmap.c \
46-
src/readpng.c \
47-
src/lodepng/lodepng.c \
48-
$(COMMON_DEPS_C)
49-
50-
COMMON_DEPS_TMX_C=\
51-
src/tiled.c \
52-
src/readtmx.c \
53-
$(COMMON_DEPS_C)
54-
55-
COMMON_DEPS_H=\
56-
src/args.h
57-
58-
COMMON_DEPS_PCX_H=\
32+
DEPS_PCX=\
33+
src/args.h \
5934
src/bitmap.h \
60-
src/readpcx.h \
61-
$(COMMON_DEPS_H)
35+
src/readpcx.h
6236

63-
COMMON_DEPS_PNG_H=\
37+
DEPS_PNG=\
38+
src/args.h \
6439
src/bitmap.h \
6540
src/readpng.h \
66-
src/lodepng/lodepng.h \
67-
$(COMMON_DEPS_H)
41+
src/lodepng/lodepng.h
6842

69-
COMMON_DEPS_TMX_H=\
43+
DEPS_TMX=\
44+
src/args.h \
7045
src/tiled.h \
71-
src/readtmx.h \
72-
$(COMMON_DEPS_H)
46+
src/readtmx.h
47+
48+
TESTS=\
49+
test/charset.pcx.chr \
50+
test/charset.pcx.clr \
51+
test/bigsprites.pcx.spat.asm \
52+
test/bigsprites.pcx.spr.asm \
53+
test/charset.png.chr \
54+
test/charset.png.clr \
55+
test/bigsprites.png.spat.asm \
56+
test/bigsprites.png.spr.asm \
57+
test/screen.tmx.bin \
58+
test/metatiles.tmx.bin
7359

7460
#
7561
# default target
7662
#
7763

78-
default: compile_png
79-
80-
clean: clean_pcx clean_png clean_tmx
81-
82-
clean_pcx:
83-
$(REMOVE) $(PCX_TOOLS)
84-
85-
clean_png:
86-
$(REMOVE) $(PNG_TOOLS)
87-
88-
clean_tmx:
89-
$(REMOVE) $(TMX_TOOLS)
64+
default: all
9065

91-
compile: $(PCX_TOOLS) $(PNG_TOOLS) $(TMX_TOOLS)
66+
clean:
67+
$(REMOVE) $(TARGETS)
9268

93-
compile_pcx: $(PCX_TOOLS)
69+
all: $(TARGETS)
9470

95-
compile_png: $(PNG_TOOLS)
96-
97-
compile_tmx: $(TMX_TOOLS)
98-
99-
test: test_pcx test_png test_tmx
100-
101-
test_pcx: $(PCX_TOOLS) $(PCX_TESTS)
102-
103-
test_png: $(PNG_TOOLS) $(PNG_TOOLS)
104-
105-
test_tmx: $(TMX_TOOLS) $(TMX_TOOLS)
71+
test: $(TOOLS) $(TESTS)
10672

10773
demo: demo_sprplus_pcx demo_sprplus_png
10874

75+
.PHONY: default clean all test demo
76+
10977
#
11078
# main targets
11179
#
11280

113-
$(PCX2MSX): \
114-
src/pcx2msx.c \
115-
$(COMMON_DEPS_PCX_C) src/charset.c \
116-
$(COMMON_DEPS_PCX_H) src/charset.h
117-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_PCX_C) src/charset.c -o $@
118-
119-
$(PCX2MSXPLUS): \
120-
src/pcx2msx+.c \
121-
$(COMMON_DEPS_PCX_C) src/charset.c src/nametable.c \
122-
$(COMMON_DEPS_PCX_H) src/charset.h src/nametable.h
123-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_PCX_C) src/charset.c src/nametable.c -o $@
124-
125-
$(PCX2SPR): \
126-
src/pcx2spr.c \
127-
$(COMMON_DEPS_PCX_C) src/sprite.c \
128-
$(COMMON_DEPS_PCX_H) src/sprite.h
129-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_PCX_C) src/sprite.c -o $@
130-
131-
$(PCX2SPRPLUS): \
132-
src/pcx2spr+.c \
133-
$(COMMON_DEPS_PCX_C) src/sprite+.c src/output.c \
134-
$(COMMON_DEPS_PCX_H) src/sprite.h src/sprite+.h src/output.h
135-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_PCX_C) src/sprite+.c src/output.c -o $@
81+
$(PCX2MSX): src/pcx2msx.c $(OBJS_PCX) src/charset.o $(DEPS_PCX) src/charset.h
82+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_PCX) src/charset.o
83+
84+
$(PCX2MSXPLUS): src/pcx2msx+.c $(OBJS_PCX) src/charset.c src/nametable.c $(DEPS_PCX) src/charset.h src/nametable.h
85+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_PCX) src/charset.c src/nametable.c
86+
87+
$(PCX2SPR): src/pcx2spr.c $(OBJS_PCX) src/sprite.c $(DEPS_PCX) src/sprite.h
88+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_PCX) src/sprite.c
89+
90+
$(PCX2SPRPLUS): src/pcx2spr+.c $(OBJS_PCX) src/sprite+.c src/output.c $(DEPS_PCX) src/sprite.h src/sprite+.h src/output.h
91+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_PCX) src/sprite+.c src/output.c
13692

13793
#
13894

139-
$(PNG2MSX): \
140-
src/png2msx.c \
141-
$(COMMON_DEPS_PNG_C) src/charset.c src/nametable.c \
142-
$(COMMON_DEPS_PNG_H) src/charset.h src/nametable.h
143-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_PNG_C) src/charset.c src/nametable.c -o $@ $(CCOMPILER_LINKER_OPTIONS)
95+
$(PNG2MSX): src/png2msx.c $(OBJS_PNG) src/charset.o src/nametable.o $(DEPS_PNG) src/charset.h src/nametable.h
96+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_PNG) src/charset.o src/nametable.o $(LDFLAGS)
14497

145-
$(PNG2SPR): \
146-
src/png2spr.c \
147-
$(COMMON_DEPS_PNG_C) src/sprite.c \
148-
$(COMMON_DEPS_PNG_H) src/sprite.h
149-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_PNG_C) src/sprite.c -o $@ $(CCOMPILER_LINKER_OPTIONS)
98+
$(PNG2SPR): src/png2spr.c $(OBJS_PNG) src/sprite.o $(DEPS_PNG) src/sprite.h
99+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_PNG) src/sprite.o $(LDFLAGS)
150100

151-
$(PNG2SPRPLUS): \
152-
src/png2spr+.c \
153-
$(COMMON_DEPS_PNG_C) src/sprite+.c src/output.c \
154-
$(COMMON_DEPS_PNG_H) src/sprite.h src/sprite+.h src/output.h
155-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_PNG_C) src/sprite+.c src/output.c -o $@ $(CCOMPILER_LINKER_OPTIONS)
101+
$(PNG2SPRPLUS): src/png2spr+.c $(OBJS_PNG) src/sprite+.o src/output.o $(DEPS_PNG) src/sprite.h src/sprite+.h src/output.h
102+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_PNG) src/sprite+.o src/output.o $(LDFLAGS)
156103

157104
#
158105

159-
$(TMX2BIN): \
160-
src/tmx2bin.c \
161-
$(COMMON_DEPS_TMX_C) \
162-
$(COMMON_DEPS_TMX_H)
163-
$(CCOMPILER) $(CCOMPILER_OPTIONS) $< $(COMMON_DEPS_TMX_C) -o $@
106+
$(TMX2BIN): src/tmx2bin.c $(OBJS_TMX) $(DEPS_TMX)
107+
$(CC) $(CFLAGS) -o $@ $< $(OBJS_TMX)
164108

165109
#
166110
# test targets

src/tiled.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <stdlib.h>
99
#include <string.h>
1010

11-
#include "tiled.h"
1211
#include "args.h"
12+
#include "tiled.h"
1313

1414
/* Constant values --------------------------------------------------------- */
1515

windows.makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#
2-
# commands
2+
# targets
33
#
4-
54
PCX2MSX=bin\pcx2msx.exe
65
PCX2SPR=bin\pcx2spr.exe
76
PCX2MSXPLUS=bin\pcx2msx+.exe
@@ -11,18 +10,21 @@ PNG2SPR=bin\png2spr.exe
1110
PNG2SPRPLUS=bin\png2spr+.exe
1211
TMX2BIN=bin\tmx2bin.exe
1312

14-
CCOMPILER=gcc
13+
#
14+
# options
1515
# (see https://interrupt.memfault.com/blog/best-and-worst-gcc-clang-compiler-flags)
16-
CCOMPILER_OPTIONS=-Wall -Wextra -Wshadow -Wdouble-promotion -Wundef -O3
17-
# CCOMPILER_OPTIONS=-Wall -Wextra -Wshadow -Wdouble-promotion -Wundef -ggdb
18-
CCOMPILER_LINKER_OPTIONS=
16+
#
17+
CC=gcc
18+
CFLAGS=-O3 -Wall -Wextra -Wshadow -Wdouble-promotion -Wundef
19+
LDFLAGS=
1920

21+
#
22+
# commands
23+
#
2024
REMOVE=cmd /c del
21-
2225
ASSEMBLER=asmsx
2326

2427
#
2528
# main makefile
2629
#
27-
2830
include shared.makefile

0 commit comments

Comments
 (0)