2009-12-06 14:49:38 +01:00
|
|
|
####### Compile Flags
|
2009-12-06 21:11:29 +01:00
|
|
|
# Compiler
|
2009-12-06 14:49:38 +01:00
|
|
|
CC= gcc
|
2009-12-06 21:11:29 +01:00
|
|
|
# Compiler flags
|
2009-12-10 23:23:02 +01:00
|
|
|
CFLAGS= -Wall -std=c99 -ggdb
|
2009-12-06 21:11:29 +01:00
|
|
|
# Libraries
|
2009-12-16 15:37:24 +01:00
|
|
|
CLIBS= `sdl-config --cflags` -lSDL -lSDL_ttf -lGL
|
2009-12-06 14:49:38 +01:00
|
|
|
####### Commands
|
|
|
|
RM= rm -r
|
|
|
|
MKDIR= mkdir -p
|
|
|
|
####### Directories
|
|
|
|
SRCDIR= src
|
2009-12-19 21:57:22 +01:00
|
|
|
DOCDIR= doc
|
2009-12-06 14:49:38 +01:00
|
|
|
OUTDIR= bin
|
|
|
|
OBJDIR= $(OUTDIR)/objects
|
|
|
|
####### Project
|
2009-12-06 21:11:29 +01:00
|
|
|
# file extension for object and source files
|
2009-12-06 14:49:38 +01:00
|
|
|
OBJEND= o
|
|
|
|
SRCEND= c
|
2009-12-06 21:11:29 +01:00
|
|
|
# name of programm (and executable)
|
2009-12-19 21:57:22 +01:00
|
|
|
NAME= adventgame
|
2009-12-06 14:49:38 +01:00
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# path to executable
|
2009-12-06 14:49:38 +01:00
|
|
|
EXE = $(OUTDIR)/$(NAME)
|
2009-12-06 21:11:29 +01:00
|
|
|
# execute shell command "ls -1 src/*.c" for a listing of all source files
|
2009-12-06 14:49:38 +01:00
|
|
|
SRCS = $(shell ls -1 $(SRCDIR)/*.$(SRCEND))
|
2009-12-06 21:11:29 +01:00
|
|
|
# substitude /$(SRCDIR)(.*)$(SRCEND)/$(OBJDIR)\1$(OBJEND)/
|
2009-12-06 14:49:38 +01:00
|
|
|
BINS = $(SRCS:$(SRCDIR)%.$(SRCEND)=$(OBJDIR)%.$(OBJEND))
|
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# default task depends on compile
|
2009-12-07 16:57:30 +01:00
|
|
|
all: init compile
|
|
|
|
|
|
|
|
# create object-folder
|
|
|
|
init:
|
|
|
|
$(MKDIR) $(OBJDIR)
|
2009-12-06 14:49:38 +01:00
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# compile depends on object files and executable
|
2009-12-06 14:49:38 +01:00
|
|
|
compile: $(BINS) $(EXE)
|
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# executable depends on all object files
|
2009-12-06 14:49:38 +01:00
|
|
|
$(EXE): $(BINS)
|
2009-12-07 16:57:30 +01:00
|
|
|
$(CC) -o $(OUTDIR)/$(NAME) -export-dynamic $(BINS) $(CLIBS) $(CFLAGS)
|
2009-12-06 14:49:38 +01:00
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# each file in OBJDIR/*.o depends on corresponding source file in SRCDIR
|
2009-12-07 16:57:30 +01:00
|
|
|
# $@ = name of target (*.o)
|
|
|
|
# $< = first dependency (*.c)
|
2009-12-06 21:11:29 +01:00
|
|
|
$(OBJDIR)/%.o: $(SRCDIR)/%.$(SRCEND)
|
2009-12-07 16:57:30 +01:00
|
|
|
$(CC) -c $< -o $@ $(CLIBS) $(CFLAGS)
|
2009-12-06 14:49:38 +01:00
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# delete OUTDIR
|
2009-12-07 16:57:30 +01:00
|
|
|
# don't raise an error if directory not exists
|
2009-12-06 14:49:38 +01:00
|
|
|
clean:
|
|
|
|
$(RM) $(OUTDIR) || true
|
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# start programm
|
2009-12-06 14:49:38 +01:00
|
|
|
run: $(OUTDIR)/$(NAME)
|
2009-12-19 21:57:22 +01:00
|
|
|
./$(OUTDIR)/$(NAME) -v
|
|
|
|
|
|
|
|
man: $(DOCDIR)/$(NAME).6
|
|
|
|
gzip $(DOCDIR)/$(NAME).6 > $(OUTDIR)/$(NAME).6.gz
|
|
|
|
|
|
|
|
man-test: $(DOCDIR)/$(NAME).6
|
|
|
|
groff -man -Tascii $(DOCDIR)/$(NAME).6
|
2009-12-06 14:49:38 +01:00
|
|
|
|
2009-12-06 21:11:29 +01:00
|
|
|
# execute clean every time
|
2009-12-06 14:49:38 +01:00
|
|
|
.PHONY: clean
|
2009-12-06 21:11:29 +01:00
|
|
|
# don't show command in run target
|
2009-12-06 14:49:38 +01:00
|
|
|
.SILENT: run
|
2009-12-06 21:11:29 +01:00
|
|
|
|