Skip to content

Commit a846575

Browse files
committed
compile objects more explicitly and make targets less phony
1 parent aef4932 commit a846575

File tree

1 file changed

+46
-29
lines changed

1 file changed

+46
-29
lines changed

Windows/makefile

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
APPNAME = Kiwi8
21
ARCH = x64
32

43
# SDL dependency files
@@ -23,9 +22,29 @@ LIBS = user32.lib \
2322
Comdlg32.lib \
2423
Shell32.lib
2524

25+
# Source files
26+
CORE_SRCS = ..\Core\Audio.cc ..\Core\Chip8.cc ..\Core\Display.cc ..\Core\Gui.cc \
27+
..\Core\imgui_impl_sdl.cc ..\Core\Input.cc ..\Core\main.cc \
28+
..\Core\opcodes.cc ..\Core\open_file_dialog.cc
29+
IMGUI_SRCS = ..\frameworks\imgui\imgui.cpp ..\frameworks\imgui\imgui_demo.cpp \
30+
..\frameworks\imgui\imgui_draw.cpp
31+
WINDOWS_SRCS = src\file_dialog.cc
32+
33+
# Object files (all built in current directory)
34+
OBJS = Audio.obj Chip8.obj Display.obj Gui.obj imgui_impl_sdl.obj Input.obj \
35+
main.obj opcodes.obj open_file_dialog.obj imgui.obj imgui_demo.obj \
36+
imgui_draw.obj file_dialog.obj
37+
38+
RESOURCE = Kiwi8.res
39+
40+
APP_NAME = Kiwi8
41+
APP_EXE = Kiwi8.exe
42+
43+
APP_DEBUG = debug\$(APP_NAME).exe
44+
APP_RELEASE = release\$(APP_NAME).exe
45+
2646
# Default target
27-
all: clean build_debug build_release
28-
DEL *.exe *.obj *.res *.pdb
47+
all: $(APP_DEBUG) $(APP_RELEASE)
2948

3049
# Build SDL if lib doesn't exist (DLL and headers come together)
3150
$(SDL_LIB):
@@ -34,45 +53,43 @@ $(SDL_LIB):
3453
$(SDL_DLL): $(SDL_LIB)
3554
@REM DLL is created by same script that creates LIB
3655

37-
build_debug: $(SDL_LIB) $(SDL_DLL) objects resource
38-
$(CC) $(CFLAGS) /Zi /Fe$(APPNAME) $(INCS) *.obj *.res $(LIBS) $(LFLAGS) $(DEBUG)
56+
$(OBJS): $(CORE_SRCS) $(IMGUI_SRCS) $(WINDOWS_SRCS)
57+
$(CC) $(CFLAGS) /c $(INCS) $(CORE_SRCS) $(IMGUI_SRCS) $(WINDOWS_SRCS)
58+
59+
$(RESOURCE): src\Kiwi8.rc resources\Kiwi8.ico
60+
RC src\Kiwi8.rc
61+
MOVE src\Kiwi8.res $@
62+
63+
$(APP_DEBUG): $(SDL_LIB) $(SDL_DLL) $(OBJS) $(RESOURCE)
64+
$(CC) $(CFLAGS) /Zi /Fe$(APP_NAME) $(INCS) *.obj *.res $(LIBS) $(LFLAGS) $(DEBUG)
3965
IF NOT EXIST debug MKDIR debug
40-
MOVE $(APPNAME).exe debug\$(APPNAME).exe
41-
COPY frameworks\sdl\bin\SDL2.dll debug\SDL2.dll
66+
COPY $(SDL_DLL) debug\SDL2.dll
67+
MOVE $(APP_NAME).exe $@
4268

43-
build_release: $(SDL_LIB) $(SDL_DLL) objects resource
44-
$(CC) $(CFLAGS) /Fe$(APPNAME) $(INCS) *.obj *.res $(LIBS) $(LFLAGS) $(RELEASE)
69+
$(APP_RELEASE): $(SDL_LIB) $(SDL_DLL) $(OBJS) $(RESOURCE)
70+
$(CC) $(CFLAGS) /Fe$(APP_NAME) $(INCS) *.obj *.res $(LIBS) $(LFLAGS) $(RELEASE)
4571
IF NOT EXIST release MKDIR release
46-
MOVE $(APPNAME).exe release\$(APPNAME).exe
47-
COPY frameworks\sdl\bin\SDL2.dll release\SDL2.dll
72+
COPY $(SDL_DLL) release\SDL2.dll
73+
MOVE $(APP_NAME).exe $@
4874

4975
test_debug:
50-
debug\$(APPNAME).exe
76+
debug\$(APP_NAME).exe
5177

5278
test_release:
53-
release\$(APPNAME).exe
54-
55-
# Build object files
56-
objects: src\*.c* ..\Core\*.c* ..\frameworks\imgui\imgui*.cpp
57-
$(CC) $(CFLAGS) /c $(INCS) $(CFLAGS) $?
58-
59-
# Build resource file
60-
resource: src\$(APPNAME).rc resources\$(APPNAME).ico
61-
RC src\$(APPNAME).rc
62-
MOVE src\$(APPNAME).res $(APPNAME).res
79+
release\$(APP_NAME).exe
6380

6481
# Clean any leftover build files (keeps SDL)
6582
clean:
66-
DEL *.exe *.obj *.res *.pdb
67-
cd debug & DEL *.exe *.dll
68-
cd release & DEL *.exe *.dll
83+
-DEL /Q $(APP_DEBUG) $(APP_RELEASE) *.obj *.res *.pdb 2>nul
84+
-IF EXIST debug RD /S /Q debug
85+
-IF EXIST release RD /S /Q release
6986

7087
# Remove just SDL (for forcing recompile)
7188
clean-sdl:
72-
RD /S /Q frameworks\sdl\lib
73-
RD /S /Q frameworks\sdl\include
89+
-RD /S /Q frameworks\sdl\lib
90+
-RD /S /Q frameworks\sdl\include
7491

7592
# Remove everything including SDL (full reset)
7693
distclean: clean clean-sdl
77-
RD /S /Q frameworks\sdl\backups
78-
RD /S /Q ..\Windows\third_party
94+
-RD /S /Q frameworks\sdl\backups
95+
-RD /S /Q ..\Windows\third_party

0 commit comments

Comments
 (0)