Skip to content

Commit

Permalink
refactor makefile, add mingw makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
szymor committed May 20, 2023
1 parent 1ce656f commit 0913c46
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
LOGFILE.TXT
stderr.txt
soulfu
soulfu.exe
source/soulfu.o
*.sdf
*.RUN
SAVELOG.TXT
SAVE*.DAT
CONFIG.DAT
*.dll
44 changes: 10 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,19 @@
.PHONY: all clean pack
.PHONY: all clean

SDP = sdp/sdp
SLC = slc/slc
SSC = ssc/ssc
PKG ?= pkg-config

TARGET = soulfu
DATAFILE = datafile.sdf
DATADIR = datadir
SRC = source/soulfu.c
OBJ = $(SRC:.c=.o)
LIB = -lm -lSDL -lSDL_net -lGL -logg -ljpeg -lvorbis
FLAGS = -m32 -g
DEP = $(wildcard source/*.c source/*.h)
LDLIBS = -lm $(shell $(PKG) --libs sdl SDL_net ogg libjpeg vorbis gl)
FLAGS = -m32 -DDEVTOOL

ifdef DEVTOOL
FLAGS += -DDEVTOOL
endif

all: $(TARGET) $(DATAFILE)
all: $(TARGET) data

clean:
rm -rf $(TARGET) $(OBJ) $(DATAFILE)

pack: $(DATAFILE)

$(DATAFILE): | $(DATADIR) $(SDP)
$(SSC) -c -i $(DATADIR)
$(SDP) -p -n -i $(DATADIR) -o $(DATAFILE)

$(SDP): | sdp
make -C sdp

$(SLC): | slc
make -C slc

$(SSC): | ssc
make -C ssc
rm -rf $(TARGET) $(DATAFILE)

$(TARGET): $(OBJ)
gcc $(FLAGS) -o $@ -Isource $(LIB) $(OBJ)
$(TARGET): $(DEP)
$(CC) $(FLAGS) -o $@ -Isource $(SRC) $(LDLIBS)

%.o: %.c
gcc $(FLAGS) -c -o $@ -Isource $(LIB) $<
include common.mk
20 changes: 20 additions & 0 deletions Makefile.mingw
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: all clean

PKG = i686-w64-mingw32-pkg-config
CC = i686-w64-mingw32-gcc

TARGET = soulfu
SRC = source/soulfu.c
DEP = $(wildcard source/*.c source/*.h)
LDLIBS = $(shell $(PKG) --libs sdl SDL_net ogg libjpeg vorbis) -lopengl32
FLAGS = -DDEVTOOL

all: $(TARGET) data

clean:
rm -rf $(TARGET) $(DATAFILE)

$(TARGET): $(DEP)
$(CC) $(FLAGS) -o $@ -Isource $(SRC) $(LDLIBS)

include common.mk
27 changes: 27 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.PHONY: data

SDP = sdp/sdp
SLC = slc/slc
SSC = ssc/ssc

DATAFILE = datafile.sdf
DATADIR = datadir
# do not pack RUN files
DATAEXT = DAT DDD JPG LAN MUS OGG PCX SRC SRF TXT
DATADEP = $(foreach ext,$(DATAEXT),$(wildcard $(DATADIR)/*.$(ext)))

data: $(DATAFILE)

# TBD: ssc should compile only things that changed since last build
$(DATAFILE): $(DATADEP) | $(DATADIR) $(SSC) $(SDP)
$(SSC) -c -i $(DATADIR)
$(SDP) -p -n -i $(DATADIR) -o $(DATAFILE)

$(SDP): | sdp
make -C sdp

$(SLC): | slc
make -C slc

$(SSC): | ssc
make -C ssc

0 comments on commit 0913c46

Please sign in to comment.