blob: ef374261091427b6a318afc624f27325f56a164a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
.PHONY: server client shared install
# > configuration start
lib_name := som_net
CC = gcc
CFLAGS = -I. -g -Wall -Werror -Wextra
LD_FLAGS = -L.
# < configuration end
.SOURCES := $(wildcard $(MAKECMDGOALS)/*.c)
.OBJECTS := $(patsubst $(MAKECMDGOALS)/%.c,$(MAKECMDGOALS)/%.o,$(.SOURCES))
SHARED_LD = -shared -fPIC
CLIENT_LD = -l${lib_name}
SERVER_LD = -l${lib_name}
export LD_LIBRARY_PATH:=`pwd`
# help text
default:
@echo " make targets: shared, client, server, [install >WIP<]"
@echo " *shared is required for all targets!"
# target: client
client: .client_comp
.client_comp: $(.OBJECTS)
$(CC) ${LD_FLAGS} ${CFLAGS} -o client_example ${.OBJECTS} ${CLIENT_LD}
# target: server
server: .server_comp
.server_comp: $(.OBJECTS)
$(CC) ${LD_FLAGS} ${CFLAGS} -o server_example ${.OBJECTS} ${SERVER_LD}
# target: shared
shared: .shared_comp
.shared_comp: $(.OBJECTS)
$(CC) ${LD_FLAGS} ${SHARED_LD} ${CFLAGS} -o lib${lib_name}.so ${.OBJECTS}
clean:
rm -f $(wildcard ./**/*.o) client_example server_example lib${lib_name}.so
**/%.o: **/%.c
$(CC) -c -o $@ $<
|