Commit 2d6b6f04 by HiPhish

De-hardcode makefile.

parent 7faab7f0
# OS generated
# ---[ OS generated ]-----------------------------------------------------------
.DS_Store
.DS_Store?
._*
......@@ -9,25 +8,17 @@ Icon?
ehthumbs.db
Thumbs.db
#-------------------------------------------------------------------------------
# Compiler generated
*.o
*.out
*.a
*.plist
roll
#-------------------------------------------------------------------------------
# Editor generated
# ---[ Compiler generted ]------------------------------------------------------
build/
objects/
libraries/
include/
binaries/
documentation/
# ---[ Editor generated ]-------------------------------------------------------
*~
*.swapfile
*.swp
tags
#-------------------------------------------------------------------------------
# Project-related
build/
# ---[ Make variables ]---------------------------------------------------------
# ---[ Make variables - pass these to make ]------------------------------------
CC = cc
CFLAGS = -std=c99 -g -Werror -Wall
PREFIX = ./build
# ---[ Directories ]------------------------------------------------------------
SRCDIR = ./source
OBJDIR = ./objects
LIBDIR = ./libraries
INCDIR = ./include
BINDIR = ./binaries
DOCDIR = ./documentation
# ---[ Phony targets list ]-----------------------------------------------------
.PHONY = clean man
# ---[ Main targets ]-----------------------------------------------------------
# Optimised release build
......@@ -15,49 +29,66 @@ debug: release bin header lib man
# Run static analyser.
analyze: CFLAGS += --analyze -O0
analyze: ./source/roll
analyze: $(BINDIR)/roll
# ---[ Product targets ]--------------------------------------------------------
bin: ./source/roll
bin: $(BINDIR)/roll
@mkdir -p $(PREFIX)/bin
@cp ./source/roll $(PREFIX)/bin/roll
@cp $(BINDIR)/roll $(PREFIX)/bin/roll
header: ./source/roll.c
header: $(INCDIR)/roll.h
@mkdir -p $(PREFIX)/include
@cp ./source/libroll.h $(PREFIX)/include/roll.h
@cp $(INCDIR)/roll.h $(PREFIX)/include/roll.h
lib: ./source/libroll.a
lib: $(LIBDIR)/libroll.a
@mkdir -p $(PREFIX)/lib
@cp ./source/libroll.a $(PREFIX)/lib/libroll.a
@cp $(LIBDIR)/libroll.a $(PREFIX)/lib/libroll.a
man: ./man/man1/roll.1
man: $(DOCDIR)/man/man1/roll.1
@mkdir -p $(PREFIX)/share/man/man1
@cp ./man/man1/roll.1 $(PREFIX)/share/man/man1/roll.1
@cp $(DOCDIR)/man/man1/roll.1 $(PREFIX)/share/man/man1/roll.1
doxygen: ./contrib/doxygen/Doxyfile source/roll.c ./source/libroll.c ./source/libroll.h
doxygen: ./contrib/doxygen/Doxyfile $(SRCDIR)/*.c $(SRCDIR)/*.h
@mkdir -p $(PREFIX)
@( cat ./contrib/doxygen/Doxyfile ; echo "OUTPUT_DIRECTORY=\"$(PREFIX)/doxygen/\"" ) | doxygen -
ctags: ./tags
./tags: ./source/*.c ./source/*.h
@ctags -R --languages=c
# ---[ Source targets ]---------------------------------------------------------
./source/roll: ./source/roll.o ./source/libroll.a
@$(CC) $(CFLAGS) -o $@ $^
./source/roll.o: ./source/roll.c
$(OBJDIR)/roll.o: $(SRCDIR)/roll.c
@mkdir -p $(OBJDIR)
@$(CC) $(CFLAGS) -c -o $@ $^
./source/libroll.a: ./source/libroll.o
@ar -rsc $@ $^
./source/libroll.o: ./source/libroll.c ./source/libroll.h
$(OBJDIR)/libroll.o: $(SRCDIR)/libroll.c $(SRCDIR)/libroll.h
@mkdir -p $(OBJDIR)
@$(CC) $(CFLAGS) -c -o $@ $<
$(LIBDIR)/libroll.a: $(OBJDIR)/libroll.o
@mkdir -p $(LIBDIR)
@ar -rsc $@ $^
$(INCDIR)/roll.h: $(SRCDIR)/libroll.h
@mkdir -p $(INCDIR)
@cp $^ $@
$(BINDIR)/roll: $(OBJDIR)/roll.o $(OBJDIR)/libroll.o
@mkdir -p $(BINDIR)
@$(CC) $(CFLAGS) -o $@ $^
# ---[ Miscellaneous targets ]--------------------------------------------------
./tags: $(SRCDIR)/*.c $(SRCDIR)/*.h
@ctags -R --languages=c
$(DOCDIR)/man/man1/roll.1: ./man/man1/roll.1
@mkdir -p $(DOCDIR)/man/man1
@cp ./man/man1/roll.1 $(DOCDIR)/man/man1/roll.1
# ---[ Phony targets ]----------------------------------------------------------
clean:
@rm -rf $(PREFIX)/
@rm -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(DOCDIR) $(INCDIR)
@rm -f ./tags
@rm -f ./source/roll ./source/*.o ./source/*.a
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment