You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1008 B
44 lines
1008 B
# A Generic Makefile For Quick and Dirty Projects |
|
# |
|
# This Makefile has been tested using GNU make and bash. Your mileage may vary |
|
# with other make implementations and/or shells. |
|
|
|
CFLAGS = $(shell sdl2-config --cflags) |
|
LDFLAGS = $(shell sdl2-config --libs) |
|
|
|
CC = cc |
|
MKDIR = mkdir -p |
|
|
|
OBJDIR = ./obj |
|
BINDIR = ./bin |
|
ASSETDIR = ./assets |
|
|
|
# System-specific Makefile overrides. |
|
-include Makefile.override |
|
|
|
# The rest of these settings should are automatically configured. Tweak at your |
|
# own peril! :P |
|
OUTFILE = $(shell basename $(shell pwd)) |
|
ALL_C := $(shell find . -type f -name '*.c') |
|
OBJFILES := $(addprefix $(OBJDIR)/,$(ALL_C:%.c=%.o)) |
|
|
|
all: $(OUTFILE) |
|
|
|
$(OBJDIR)/%.o: %.c |
|
$(MKDIR) $(@D) |
|
$(CC) $(CFLAGS) -o $@ -c $< |
|
|
|
$(OUTFILE): $(OBJFILES) |
|
$(MKDIR) $(BINDIR) |
|
$(CC) $(LDFLAGS) -o $(BINDIR)/$(OUTFILE) $^ |
|
|
|
if [ -d $(ASSETDIR) ]; then \ |
|
cp $(ASSETDIR)/* $(BINDIR); \ |
|
fi |
|
|
|
test: $(OUTFILE) |
|
cd $(BINDIR);./$(OUTFILE) |
|
|
|
clean: |
|
$(RM) -r $(OBJFILES) |
|
$(RM) $(BINDIR)/$(OUTFILE)
|
|
|