-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (40 loc) · 1.28 KB
/
Makefile
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
46
47
48
49
50
51
52
53
CC = gcc
INC_PATH ?= -Iinc/ -Iinc/linux
CFLAGS = -fPIC $(INC_PATH)
OSTYPE = $(shell uname)
ifneq (${OSTYPE}, Linux)
CFLAGS += -DHOLYBSD
else
CFLAGS += -DOS_LINUX -DFN_DEBUG
endif
LIB_PTHREAD = -lpthread
LIBS_LD = $(LIB_PTHREAD)
LIB_SRCS = $(foreach d, lib/linux, $(wildcard $(addprefix $(d)/*, .c)))
LIB_OBJS = $(addsuffix .o, $(basename $(LIB_SRCS)))
APP_SRCS = $(foreach d, app, $(wildcard $(addprefix $(d)/*, .c)))
APP_OBJS = $(addsuffix .o, $(basename $(APP_SRCS)))
APPS = $(basename $(APP_SRCS))
LIB_UTILITY = libutility.so
all: clean $(LIB_UTILITY) $(APP_OBJ)
$(LIB_UTILITY): $(LIB_OBJS)
$(CC) -o $(LIB_UTILITY) $(LIB_OBJS) $(CFLAGS) -fPIC -shared -lpthread
$(APP_OBJ): $(APP_SRC)
$(CC) -c $(APP_SRC) $(CFLAGS)
apps: $(APP_OBJS)
for app_obj in $(APPS) ; do \
app_bin=$$app_obj.bin ; \
$(CC) -o $$app_bin $$app_obj.o $(CFLAGS) -lpthread -L./ -lutility -Wl,-rpath=. ; \
done
clean:
-rm -f $(shell find . -name "*.[o]")
-rm -f *.bin
prepare:
-find . -name "*.c" | xargs astyle --style=allman
-find . -name "*.h" | xargs astyle --style=allman
-find . -name "*.c" | xargs dos2unix
-find . -name "*.h" | xargs dos2unix
finish:
-find . -name "*.c" | xargs dos2unix
-find . -name "*.h" | xargs dos2unix
-find . -name "*.c" | xargs chmod a+w
-find . -name "*.h" | xargs chmod a+w