Makefile
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:51:15 +0200
changeset 85 9568a180fc43
parent 76 c46968bddef5
child 86 86b83a979d9e
permissions -rw-r--r--
[getopt]: support for long options Long options are quite useful, too committer: Markus Bröker <mbroeker@largo.homelinux.org>

     CC = gcc -g -ggdb $(PROF)
    CPP = g++ -g -ggdb $(PROF)
 CFLAGS = -Wall -O2 -Iinclude -ansi
     RM = rm -f
   FIND = find

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

TARGET  = ncurses
TARGET += numerierung
TARGET += xdemo
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 += recording
TARGET += endian
TARGET += fak
TARGET += blackhole
TARGET += folge
TARGET += counter
TARGET += sudoku
TARGET += cunit
TARGET += md5
TARGET += md5rec
TARGET += myprintf
TARGET += concatenation
TARGET += alpha_beta
TARGET += life
TARGET += bad_alloc
TARGET += lotto
TARGET += database
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 += xmlparser
TARGET += vector
TARGET += base10
TARGET += files
TARGET += fork
TARGET += duff
TARGET += unicode
TARGET += fts
TARGET += clplaner
TARGET += daemon

.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) $(CFLAGS) -lncursesw -o $@ $<

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

md5rec: md5rec.o
	@echo Linking $< ...
	@$(CC) -o $@ $< -llsf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.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 'Makefile*' -exec eraser {} \;
endif
	@make clean