-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (47 loc) · 1.26 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
#
# "Basic" Makefile
#
.PHONY: all check clean CLEAN
.SECONDARY: $(EXES) $(OBJS) $(LIBS)
SRCDIR = src
INCDIR = include
TSTDIR = test
OBJDIR = obj
LIBDIR = lib
BINDIR = bin
DIRS = $(BINDIR) $(LIBDIR) $(OBJDIR)
LIBNAME = shmemx
LIBSRC = $(wildcard $(SRCDIR)/*.c)
EXESRC = $(wildcard $(TSTDIR)/*.c)
INCS = $(wildcard $(INCDIR)/*.h)
OBJS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(LIBSRC))
LIBS = $(LIBDIR)/lib$(LIBNAME).a
EXES = $(patsubst $(TSTDIR)/%.c,$(BINDIR)/%,$(EXESRC))
TSTS = $(patsubst $(TSTDIR)/%.c,$(BINDIR)/%.tt,$(EXESRC))
CC = oshcc
CFLAGS = -O3 -std=c11 -Wall -Wextra -pedantic -Werror
CPPFLAGS = -D_POSIX_VERSION=200809L -D_XOPEN_VERSION=700 -I$(INCDIR)
LDFLAGS = -L$(LIBDIR) -l$(LIBNAME)
NPES = 16
LAUNCHCMD = oshrun
LAUNCHOPT = -n $(NPES)
all: $(DIRS) $(EXES)
check: $(TSTS)
clean:
rm -rf $(BINDIR)/* $(LIBDIR)/*.a $(OBJDIR)/*.o
CLEAN:
rm -rf $(DIRS)
$(OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(LIBDIR)/%.a : $(OBJS)
ar r $@ $<
$(BINDIR)/% : $(TSTDIR)/%.c $(LIBDIR)/lib$(LIBNAME).a $(INCS)
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS)
$(BINDIR)/%.tt : $(BINDIR)/%
$(LAUNCHCMD) $(LAUNCHOPT) $<
$(BINDIR) :
mkdir -p $(BINDIR)
$(LIBDIR) :
mkdir -p $(LIBDIR)
$(OBJDIR) :
mkdir -p $(OBJDIR)