1- APPNAME = Kiwi8
21ARCH = 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\K iwi8.rc
61+ MOVE src\K iwi8.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 \s dl \b in \S DL2.dll debug \S DL2.dll
66+ COPY $(SDL_DLL ) debug\S DL2.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 \s dl \b in \S DL2.dll release \S DL2.dll
72+ COPY $(SDL_DLL ) release\S DL2.dll
73+ MOVE $( APP_NAME ) .exe $@
4874
4975test_debug :
50- debug\$ (APPNAME ).exe
76+ debug\$ (APP_NAME ).exe
5177
5278test_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)
6582clean :
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)
7188clean-sdl :
72- RD /S /Q frameworks\s dl\l ib
73- RD /S /Q frameworks\s dl\i nclude
89+ - RD /S /Q frameworks\s dl\l ib
90+ - RD /S /Q frameworks\s dl\i nclude
7491
7592# Remove everything including SDL (full reset)
7693distclean : clean clean-sdl
77- RD /S /Q frameworks\s dl\b ackups
78- RD /S /Q ..\W indows\t hird_party
94+ - RD /S /Q frameworks\s dl\b ackups
95+ - RD /S /Q ..\W indows\t hird_party
0 commit comments