summaryrefslogtreecommitdiff
path: root/Makefile
blob: 904806c6ae87c63633331dc4d84f96279ef2574b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
CC=gcc
# Base Directories
SRCDIR=src
BINDIR=bin
INCDIR=include
RESDIR=res

# Common flags
CFLAGS=-I$(INCDIR) -O2 -march=native -flto #-ffast-math

# Resource compiler for Windows
WINDRES=windres

# Resource file definitions
RESOURCE_FILE=glamac.rc         # Your resource script file with icon definitions  
RESOURCE_OBJ=$(BINDIR)/glamac_res.o  # The compiled resource object file

# glautils
GLA_SRCS=$(wildcard $(SRCDIR)/glautils/*.c)
GLA_EXES=$(patsubst $(SRCDIR)/glautils/%.c, $(BINDIR)/%.exe, $(GLA_SRCS))

# glamac
GLAMAC_SRC=$(SRCDIR)/glamac/glamac.c \
           $(SRCDIR)/glamac/glamac_view.c \
           $(SRCDIR)/glamac/glamac_render.c \
           $(SRCDIR)/glamac/glamac_events.c \
           $(SRCDIR)/glamac/glass_data.c

# SDL2 Flags
SDL2_CFLAGS=-I$(USERPROFILE)/scoop/apps/sdl2/current/include/SDl2 -I$(USERPROFILE)/scoop/apps/sdl2-ttf/current/include/SDL2_ttf -O2 -march=native -flto -s #-ffast-math
SDL2_LDFLAGS=-L$(USERPROFILE)/scoop/apps/sdl2/current/lib -L$(USERPROFILE)/scoop/apps/sdl2-ttf/current/lib -lSDL2main -lSDL2 -lSDL2_ttf -mwindows -flto
SDL2_DLL_SRC=$(USERPROFILE)/scoop/apps/sdl2/current/lib/SDL2.dll
SDL2_tff_DLL_SRC=$(USERPROFILE)/scoop/apps/sdl2-ttf/current/lib/SDL2_ttf.dll
SDL2_DLL_DEST=$(BINDIR)

# Setup target
setup:
	mkdir -p $(BINDIR) 

all: glautils glamac sdl2 structure

glautils: $(GLA_EXES)
$(BINDIR)/%.exe: $(SRCDIR)/glautils/%.c
	$(CC) $< $(CFLAGS) -o $@

# Compile resource file
$(RESOURCE_OBJ): $(RESOURCE_FILE)
	$(WINDRES) -i $< -o $@

# Link glamac with resources
glamac: $(BINDIR)/glamac.exe
$(BINDIR)/glamac.exe: $(GLAMAC_SRC) $(RESOURCE_OBJ)
	$(CC) $^ $(CFLAGS) $(SDL2_CFLAGS) $(SDL2_LDFLAGS) -o $@

sdl2:
	cp $(SDL2_DLL_SRC) $(SDL2_DLL_DEST)
	cp $(SDL2_tff_DLL_SRC) $(SDL2_DLL_DEST)

clean:
	rm -f $(BINDIR)/*
	rm -f structure.txt

rebuild: clean all

# Generate project structure
structure:
	@powershell -Command "(Get-Item .).Name | Set-Content structure.txt; (tree /a /f | Select-Object -Skip 3) | Add-Content structure.txt"
Back to https://optics-design.com