Makefile
author Markus Bröker <mbroeker@largo.dyndns.tv>
Fri, 27 Dec 2013 16:00:09 +0100
changeset 167 7c6b221900bf
parent 164 e1f4bba1097a
child 169 df7c720bcaa6
permissions -rw-r--r--
Proper Datatypes to leave the 80's

     CC = gcc -g -ggdb $(PROF)
    CPP = g++ -g -ggdb $(PROF)
 CFLAGS = -Wall -O2 -Iinclude $(EXTRA)
  EXTRA = -I/usr/local/include
LDFLAGS = -L/usr/lib -L/usr/local/lib
     RM = rm -f
   FIND = find
   MAKE = make
 INDENT = indent
 ERASER = eraser

ifeq ("$(PROFILER)", "linux")
   PROF = -fprofile-arcs -ftest-coverage -pg
endif

TARGET  = numerierung
TARGET += signals
TARGET += tree
TARGET += utf8
TARGET += file_demo
TARGET += testcase
TARGET += atoi_print
TARGET += data_types
TARGET += dnsresolve
TARGET += nomalloc
TARGET += urandom
TARGET += threads
TARGET += crypt
TARGET += tokenpasting
TARGET += hex2chars
TARGET += floating
TARGET += max
TARGET += endian
TARGET += fak
TARGET += blackhole
TARGET += folge
TARGET += counter
TARGET += sudoku
TARGET += myprintf
TARGET += concatenation
TARGET += alpha_beta
TARGET += life
TARGET += bad_alloc
TARGET += lotto
TARGET += gauss
TARGET += mem2swap
TARGET += prog_limit
TARGET += connection
TARGET += copy
TARGET += function_pointers
TARGET += sort
TARGET += min2time
TARGET += recursive_compiler
TARGET += getpwnam_error
TARGET += vector
TARGET += base10
TARGET += files
TARGET += fork
TARGET += duff
TARGET += unicode
TARGET += fts
TARGET += clplaner
TARGET += daemon
TARGET += numbers
TARGET += nearest
TARGET += cppdatabase
TARGET += pipe
TARGET += compliteral
TARGET += getbits
TARGET += fun
TARGET += sts
TARGET += berkdb

# needs ncursesw
TARGET  += ncurses

#needs xpat
TARGET += xmlparser

# needs CUnit, ncurses
TARGET += cunit

# needs postgresql
TARGET += database

# needs ssl
TARGET += md5

# needs x11
TARGET += xdemo

# needs linux
TARGET += recording

.SUFFIXES: .c .cc .asm

.c.o:
	@echo Compiling $< ...
	@$(CC) -c $(CFLAGS) -o $@ $<

.cc.o:
	@echo Compiling $< ...
	@$(CPP) -c $(CFLAGS) -o $@ $<

.asm.o:
	@echo Assembling $< ...
	@$(NASM) $< -o $@

all: $(TARGET)

ncurses: ncurses.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lncursesw

numerierung: numerierung.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

xdemo: xdemo.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lX11

signals: signals.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

tree: tree.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

utf8: utf8.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

file_demo: file_demo.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

testcase: testcase.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

atoi_print: atoi_print.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

data_types: data_types.c
	@echo Compiling $< ...
	@$(CC) $(LDFLAGS) -std=c99 -o $@ $<

dnsresolve: dnsresolve.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

nomalloc: nomalloc.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

urandom: urandom.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

threads: threads.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lpthread

crypt: crypt.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lcrypt

tokenpasting: tokenpasting.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

hex2chars: hex2chars.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lm

floating: floating.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lm

max: max.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

recording: recording.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

endian: endian.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

fak: fak.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

blackhole: blackhole.c
	@echo Compiling AND Linking $< WITH -O0 ...
	@$(CC) $(LDFLAGS) -O0 -o $@ $<

folge: folge.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lm

counter: counter.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

sudoku: sudoku.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

cunit: cunit.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lcunit -lncurses

md5: md5.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lssl -lcrypto

myprintf: myprintf.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

concatenation: concatenation.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

alpha_beta: alpha_beta.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

life: life.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

bad_alloc: bad_alloc.o
	@echo Linking $< ...
	@$(CPP) $(LDFLAGS) -o $@ $<

lotto: lotto.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

mem2swap: mem2swap.o set_limit.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ mem2swap.o set_limit.o

prog_limit: prog_limit.o set_limit.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $?

database: database.c
	@echo Compiling $< ...
	@$(CC) -c -I$(shell pg_config --includedir) $<
	@echo Linking $< ...
	@$(CC) $(LDLAGS) -o $@ $@.o -lpq

gauss: gauss.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

connection: connection.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

copy: copy.o
	@echo Linking $< ...
	@$(CPP) $(LDFLAGS) -o $@ $<

function_pointers: function_pointers.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

sort: sort.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

min2time: min2time.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

recursive_compiler: recursive_compiler.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

getpwnam_error: getpwnam_error.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

xmlparser: xmlparser.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lexpat

vector: vector.o
	@echo Linking $< ...
	@$(CPP) $(LDFLAGS) -o $@ $<

base10: base10.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $< -lm

files: files.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

fork: fork.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

duff: duff.o
	@echo Linking $< ...
	@$(CC) $(LDFLAGS) -o $@ $<

unicode: unicode.c
	@echo Linking $<...
	@$(CC) $(LDFLAGS) -std=c99 -o $@ $<

fts: fts.c
	@echo Linking $< ...
	@$(CC) -Wall -O2 $(LDFLAGS) $< -o $@

clplaner: clplaner.o
	@echo Linking $<...
	@$(CC) $(LDFLAGS) -o $@ $<

daemon: daemon.c
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

numbers: numbers.o
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

nearest: nearest.o
	@echo Linking $<...
	@$(CPP) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

cppdatabase: cppdatabase.o
	@echo Linking $<...
	@$(CPP) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

pipe: pipe.o
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

compliteral: compliteral.o
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

getbits: getbits.o
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

fun: fun.o
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

sts: sts.o
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@

berkdb: berkdb.o
	@echo Linking $<...
	@$(CC) -Wall -O2 -g -ggdb $(LDFLAGS) $< -o $@ -ldb

.PHONY: beauty clean uninstall

clean:
ifdef FIND
	$(FIND) . -name '*~' -exec $(RM) {} \;
	$(FIND) . -name '*.[oa]' -exec $(RM) {} \;
	$(FIND) . -name '*.gcov' -exec $(RM) {} \;
	$(FIND) . -name '*.gcda' -exec $(RM) {} \;
	$(FIND) . -name '*.gcno' -exec $(RM) {} \;
	$(FIND) . -name 'gmon.out' -exec $(RM) {} \;
endif
	$(RM) $(TARGET)

beauty:
ifdef FIND
	$(FIND) . -name '*.[ch]' -exec $(INDENT) {} \;
	$(FIND) . -name '*.[ch]' -exec $(ERASER) {} \;
	$(FIND) . -name '*.java' -exec $(ERASER) {} \;
	$(FIND) . -name 'Makefile*' -exec $(ERASER) {} \;
endif
	@$(MAKE) clean