adventskalender-2009/Makefile

85 lines
2.1 KiB
Makefile
Raw Permalink Normal View History

####### Compile Flags
2009-12-06 21:11:29 +01:00
# Compiler
CC= gcc
2009-12-06 21:11:29 +01:00
# Compiler flags
CFLAGS= -Wall -std=c99 -ggdb
2009-12-06 21:11:29 +01:00
# Libraries
CLIBS= `sdl-config --cflags` -lSDL -lSDL_ttf -lGL
####### Commands
RM= rm -r
MKDIR= mkdir -p
####### Directories
SRCDIR= src
2009-12-19 21:57:22 +01:00
DOCDIR= doc
OUTDIR= bin
OBJDIR= $(OUTDIR)/objects
####### Project
2009-12-06 21:11:29 +01:00
# file extension for object and source files
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
VERSION= 0.1
2009-12-06 21:11:29 +01:00
# path to executable
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
SRCS = $(shell ls -1 $(SRCDIR)/*.$(SRCEND))
2009-12-06 21:11:29 +01:00
# substitude /$(SRCDIR)(.*)$(SRCEND)/$(OBJDIR)\1$(OBJEND)/
BINS = $(SRCS:$(SRCDIR)%.$(SRCEND)=$(OBJDIR)%.$(OBJEND))
2009-12-06 21:11:29 +01:00
# default task depends on compile
all: init compile
# create object-folder
init:
$(MKDIR) $(OBJDIR)
2009-12-06 21:11:29 +01:00
# compile depends on object files and executable
compile: $(BINS) $(EXE)
2009-12-06 21:11:29 +01:00
# executable depends on all object files
$(EXE): $(BINS)
$(CC) -o $(OUTDIR)/$(NAME) -export-dynamic $(BINS) $(CLIBS) $(CFLAGS)
2009-12-06 21:11:29 +01:00
# each file in OBJDIR/*.o depends on corresponding source file in SRCDIR
# $@ = name of target (*.o)
# $< = first dependency (*.c)
2009-12-06 21:11:29 +01:00
$(OBJDIR)/%.o: $(SRCDIR)/%.$(SRCEND)
$(CC) -c $< -o $@ $(CLIBS) $(CFLAGS)
2009-12-06 21:11:29 +01:00
# delete OUTDIR
# don't raise an error if directory not exists
clean:
$(RM) $(OUTDIR) || true
2009-12-06 21:11:29 +01:00
# start programm
run: $(OUTDIR)/$(NAME)
2009-12-19 21:57:22 +01:00
./$(OUTDIR)/$(NAME) -v
man: $(DOCDIR)/$(NAME).6
cat $(DOCDIR)/$(NAME).6 | gzip - > $(OUTDIR)/$(NAME).6.gz
2009-12-19 21:57:22 +01:00
man-test: $(DOCDIR)/$(NAME).6
groff -man -Tascii $(DOCDIR)/$(NAME).6
install: compile man
cp $(OUTDIR)/$(NAME) /usr/local/bin/
cp $(OUTDIR)/$(NAME).6.gz /usr/local/man/
uninstall:
rm /usr/local/bin/adventgame || true
rm /usr/local/man/adventgame.6.gz || true
export: clean
mkdir -p $(OUTDIR)/adventgame-$(VERSION)/
cp -r src/ doc/ dist/ Makefile $(OUTDIR)/adventgame-$(VERSION)/
cp README.rdoc $(OUTDIR)/adventgame-$(VERSION)/README
tar cjf $(OUTDIR)/adventgame-$(VERSION).tar.bz2 -C $(OUTDIR)/ adventgame-$(VERSION)
2009-12-06 21:11:29 +01:00
# execute clean every time
.PHONY: clean
2009-12-06 21:11:29 +01:00
# don't show command in run target
.SILENT: run
2009-12-06 21:11:29 +01:00