This commit is contained in:
James 2024-03-26 11:23:54 +10:00
parent c2485979aa
commit 81a5404a55
4 changed files with 69 additions and 10 deletions

View File

@ -9,11 +9,16 @@ CAT=type # \
SEVENZ="C:\Program Files\7-Zip\7z.exe" -y # \
SDL2LIB=SDL2.lib # \
SDL2IMGLIB=SDL2_image.lib # \
CCOBJ=cl /c /Iinclude # \
CCOBJ=cl /nologo /c /Iinclude # \
OBJOUT=/Fo#\
EXEOUT=/Fe#\
CCEXE=cl /Iinclude # \
LDFLAGS=SDL2main.lib SDL2.lib shell32.lib /link /subsystem:windows # \
CCEXE=cl /nologo /Iinclude # \
#LDFLAGS=SDL2main.lib SDL2.lib shell32.lib /link /subsystem:windows # \
LDFLAGS= kernel32.lib user32.lib shell32.lib /link /subsystem:console # \
RUNPREFIX= # \
USE_TRAY=-DTRAY_WINAPI=1 # \
LINK_TRAY= # \
LINK_SDL= SDL2.lib #\
!else
# Make code here
MV=mv -f
@ -30,6 +35,10 @@ OBJOUT=-o
EXEOUT=-o
CCEXE=gcc -Iinclude
LDFLAGS=
RUNPREFIX=./
USE_TRAY=-DTRAY_APPINDICATOR=1 $(shell pkg-config --cflags appindicator3-0.1)
LINK_TRAY=$(shell pkg-config --libs appindicator3-0.1)
LINK_SDL= SDL2.lib
# \
!endif
@ -83,6 +92,10 @@ clean:
veryclean:reallyclean
reallyclean: clean
-@$(RM) purforce.exe
-@$(RM) tray.exe
-@$(RM) icon.ico
-@$(RM) pf.ico
-@$(RM) pf.png
-@$(RMDIR) build
distclean: reallyclean
-@$(RM) SDL2.a
@ -96,19 +109,29 @@ distclean: reallyclean
PUR_OBJS= \
build$(PS)main.obj \
build$(PS)error.obj
build$(PS)error.obj \
build$(PS)stats.obj \
build$(PS)systray.obj
build$(PS)main.obj: build Makefile main.c api.h include$(PS)SDL.h include$(PS)SDL_image.h
$(CCOBJ) main.c $(OBJOUT)$@
build$(PS)stats.obj: build Makefile stats.c api.h include$(PS)SDL.h include$(PS)SDL_image.h
$(CCOBJ) stats.c $(OBJOUT)$@
build$(PS)error.obj: build Makefile api.h error.c
$(CCOBJ) error.c $(OBJOUT)$@
build$(PS)systray.obj: build pf.ico pf.png api.h tray$(PS)tray.h
$(CCOBJ) systray.c $(OBJOUT)$@
build:
mkdir build
pf.ico: images$(PS)pf.ico
$(CP) images$(PS)pf.ico $@
pf.png: images$(PS)pf.png
$(CP) images$(PS)pf.png $@
purforce: purforce.exe
$(RUNPREFIX)purforce.exe
purforce.exe: $(PUR_OBJS) $(SDL2LIB) $(SDL2IMGLIB) Makefile
$(CCEXE) $(PUR_OBJS) $(SDL2IMGLIB) $(EXEOUT)$@ $(LDFLAGS)
$(CCEXE) $(PUR_OBJS) $(SDL2IMGLIB) $(EXEOUT)$@ $(LINK_SDL) $(LDFLAGS)
sdl2dev.zip:
$(CP) ..\..\assets\windows\SDL2-devel-2.30.0-VC.zip $@
@ -142,4 +165,13 @@ SDL2.lib: sdl2dev.zip
SDL2.a:
sudo apt-get install sdl2-dev
ln -s /user/local/lib/sdl2/sdl2.so ./SDL2.a
touch SDL2.a
touch SDL2.a
build$(PS)trayxmpl.obj: build tray$(PS)example.c tray$(PS)tray.h
$(CCOBJ) $(USE_TRAY) tray$(PS)example.c $(OBJOUT)$@
icon.ico: tray$(PS)icon.ico
$(CP) tray$(PS)icon.ico $@
tray.exe: build$(PS)trayxmpl.obj icon.ico
$(CCEXE) $(USE_TRAY) build$(PS)trayxmpl.obj $(EXEOUT)$@ $(LINK_TRAY) $(LDFLAGS)
tray: tray.exe
$(RUNPREFIX)tray.exe

3
api.h
View File

@ -3,5 +3,6 @@
#include <stdarg.h>
void reportError(const char *fmt,...);
enum ps { ps_startup,ps_shutdown};
void print_stats(enum ps ps);
#endif//api_h

28
main.c
View File

@ -1,13 +1,38 @@
#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <SDL_image.h>
#include "api.h"
SDL_Window * purrwin;
void purrer(void) {
SDL_Init(SDL_INIT_TIMER|SDL_INIT_EVENTS|SDL_INIT_VIDEO);
purrwin = SDL_CreateWindow("PurrForce :3",
100, 100, 320,
360, SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP|SDL_WINDOW_SHOWN);
if(purrwin == NULL) {
puts(SDL_GetError());
} else {
SDL_DestroyWindow(purrwin);
}
SDL_Quit();
}
int main(int argc,char**argv){
puts("hello world");
SDL_SetMainReady();
print_stats(ps_startup);
purrer();
print_stats(ps_shutdown);
return 0;
}
/*
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* mascot_tex;
int main(int argc, char* argv[]) {
int zmain(int argc, char* argv[]) {
SDL_Surface* mascot_sur=NULL;
reportError("startup purrforce?");
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
@ -54,3 +79,4 @@ int main(int argc, char* argv[]) {
return 0;
}
*/

View File

@ -1 +1 @@
nmake %*
nmake /NOLOGO %*