Makefile

%toc

Example Makefile for C

http://stackoverflow.com/a/1484873

TARGET = yourprogrammtitlehere
LIBS = -lm
CC = gcc
CFLAGS = -g -Wall

.PHONY: default all clean

default: $(TARGET)
	all: default

OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
HEADERS = $(wildcard *.h)

%.o: %.c $(HEADERS)
	    $(CC) $(CFLAGS) -c $< -o $@

.PRECIOUS: $(TARGET) $(OBJECTS)

$(TARGET): $(OBJECTS)
	    $(CC) $(OBJECTS) -Wall $(LIBS) -o $@

clean:
	    -rm -f *.o
	        -rm -f $(TARGET)

Makefile fuer LaTex

TEX = $(wildcard *.tex)
PDF = $(TEX:.tex=.pdf)
TEMPFILES = *.fls *.aux *.log *.fdb_latexmk

LATEXMK = latexmk
LATEXMKFLAGS = -pdf -interaction=batchmode --shell-escape

all: $(PDF)
.PHONY: all

test:
	echo $(TEX)
	echo $(PDF)

%.pdf: %.tex
	$(LATEXMK) $(LATEXMKFLAGS) $<

show:
	zathura $(PDF) > /dev/null 2>&1 &

clean:
	rm -f $(TEMPFILES) $(PDF)