libtest/Makefile
author Markus Bröker <mbroeker@largo.dyndns.tv>
Tue, 01 Jun 2010 23:40:56 +0200
changeset 130 f4b424b93e45
parent 66 2b4f786d9073
permissions -rw-r--r--
getbits added committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
     CC = gcc
66
2b4f786d9073 Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 7
diff changeset
     2
 CFLAGS = -Wall -O2 -fPIC
7
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     3
LDFLAGS = -Llib -ltest
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
OBJECTS = func1.o func2.o
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
.c.o:
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
	$(CC) -c $(CFLAGS) -shared $<
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     8
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
all: lib/libtest.so.1.0.1 prog
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    10
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    11
prog: main.c
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    12
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
lib/libtest.so.1.0.1: $(OBJECTS)
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
	$(CC) -shared -Wl,-soname,lib/libtest.so.1 $(OBJECTS) -o $@
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
	@echo "Look carefully at this :)"
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
	ln -s libtest.so.1.0.1 lib/libtest.so.1
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    18
	ln -s libtest.so.1.0.1 lib/libtest.so
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    20
.PHONY: clean
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    22
clean:
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    23
	rm -f lib/libtest.*
a1aa30f0f904 libtest demonstrates how to use shared libraries
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    24
	rm -f *.o prog