adventskalender-2009/Makefile
Florian Eitel b5c6cd5168 Replaced Makefile with better one
* added special output directory for executable and object files
* improved configuration section
* supported multi source files
* fixed ugly warning in clean (... with ugly hack ^^)
* added SILENT and PHONY to tasks
* added dependency for run target
* split default task in compile (and optional other tasks)
* split compile in build of each object file and executable
2009-12-07 06:12:11 +08:00

41 lines
728 B
Makefile

####### Compile Flags
CC= gcc
CFLAGS= -Wall -Os -std=c99
CLIBS=
CINCL=
####### Commands
RM= rm -r
MKDIR= mkdir -p
####### Directories
SRCDIR= src
OUTDIR= bin
OBJDIR= $(OUTDIR)/objects
####### Project
OBJEND= o
SRCEND= c
NAME= game
EXE = $(OUTDIR)/$(NAME)
SRCS = $(shell ls -1 $(SRCDIR)/*.$(SRCEND))
BINS = $(SRCS:$(SRCDIR)%.$(SRCEND)=$(OBJDIR)%.$(OBJEND))
all: compile
compile: $(BINS) $(EXE)
$(EXE): $(BINS)
$(CC) $(CINCL) -o $(OUTDIR)/$(NAME) -export-dynamic $(BINS) $(CLIBS) $(CFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.$(SRCEND)
$(MKDIR) $(OBJDIR)
$(CC) $(CINCL) -c $< -o $@ $(CFLAGS)
clean:
$(RM) $(OUTDIR) || true
run: $(OUTDIR)/$(NAME)
./$(OUTDIR)/$(NAME)
.PHONY: clean
.SILENT: run