This repository has been archived by the owner on Jun 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
executable file
·88 lines (59 loc) · 1.75 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Compilation
CC=gcc
CFLAGS=-Wall -std=c99 -g -Iinclude
# Directory
INCDIR=include
SRCDIR=src
OBJDIR=object
# Main rules
PROGRAMS = period periodic launch_daemon
LIBS = libmessage.so libperror.so
OTHER = now when
# Macro
OBJDIR_CREATE = if ! test -d $(OBJDIR) ; then mkdir $(OBJDIR) ; fi
OBJDIR_DELETE = if test -d $(OBJDIR) ; then rmdir $(OBJDIR) ; fi
# to use libmessage.so : export LD_LIBRARY_PATH=${PWD} on the shell
.PHONY : all
all : $(LIBS) $(PROGRAMS) $(OTHER)
.PHONY : prog
prog : lib $(PROGRAMS)
.PHONY : lib
lib : $(LIBS)
.PHONY : other
other : $(OTHER)
launch_daemon : $(OBJDIR)/launch_daemon.o $(INCDIR)/perror.h
@echo make : launch_daemon
@$(CC) $(CFLAGS) -L${PWD} $< -lperror -o $@
periodic : $(OBJDIR)/periodic.o $(OBJDIR)/file.o $(INCDIR)/perror.h $(INCDIR)/message.h
@echo make : $@
@$(CC) $(CFLAGS) -L${PWD} $< $(OBJDIR)/file.o -lmessage -lperror -o $@
period : $(OBJDIR)/period.o $(OBJDIR)/command.o $(OBJDIR)/file.o $(INCDIR)/perror.h $(INCDIR)/message.h
@echo make : $@
@$(CC) $(CFLAGS) -L${PWD} $< $(OBJDIR)/command.o $(OBJDIR)/file.o -lmessage -lperror -o $@
lib%.so : $(OBJDIR)/%.o
@echo make : $@
@$(CC) -shared $< -o $@
$(OBJDIR)/message.o : $(SRCDIR)/message.c $(INCDIR)/message.h
@echo make : $@
@$(OBJDIR_CREATE)
@$(CC) $(CFLAGS) -fPIC -c -o $@ $<
$(OBJDIR)/perror.o : $(SRCDIR)/perror.c $(INCDIR)/perror.h
@echo make : $@
@$(OBJDIR_CREATE)
@$(CC) $(CFLAGS) -fPIC -c -o $@ $<
$(OBJDIR)/%.o : $(SRCDIR)/%.c
@echo make : $@
@$(OBJDIR_CREATE)
@$(CC) $(CFLAGS) -c -o $@ $<
% : $(SRCDIR)/%.c
@echo make : $@
@$(CC) $(CFLAGS) -o $@ $<
.PHONY : clean
clean :
@echo make : clean
@rm -f $(OBJDIR)/*.o ;
@$(OBJDIR_DELETE)
.PHONY : mrproper
mrproper : clean
@echo make : mrproper
@rm -f $(PROGRAMS) $(LIBS) $(OTHER)