-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile.comet
126 lines (96 loc) · 2.92 KB
/
Makefile.comet
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#
# (c) 2017 by University of Delaware, Argonne National Laboratory, San Diego
# Supercomputer Center, National University of Defense Technology,
# National Supercomputer Center in Guangzhou, and Sun Yat-sen University.
#
# See COPYRIGHT in top-level directory.
#
# skeleton of generic makefile
OBJDIR := build
SRCDIRS :=
USRINCS :=
USRLIBS :=
# config binaries
CPP :=
CC := mpicc
CXX := mpic++
LD := mpic++
AR := ar
SHELL := /bin/sh
RM := rm -f
# DEPFLAGS:= -M
CPPFLAGS:= -DENABLE_PROFILER
CPPFLAGS+= -DENABLE_TRACKER
CPPFLAGS+= -DNDEBUG
# CPPFLAGS+= -DFT_REG
# Using pkg-config for c/cxxflags
# SHRFLAGS:= $(shell pkg-config --cflags gtk+-2.0)
SHRFLAGS:= -g -Wno-write-strings -Wall -Wconversion -O3
# SHRFLAGS+= -I$(USRINCS)
# SHRFLAGS:= -pg -I$(USRINCS) -fpermissive
CFLAGS := $(SHRFLAGS) -std=c99
CXXFLAGS:= $(SHRFLAGS) -std=c++11 -fpermissive
# Using pkg-config for libs
# LDFLAGS := $(shell pkg-config --libs gtk+-2.0)
# LDFLAGS := -lmpl -lpthread
# LDFLAGS += -lboost_system -lboost_filesystem -lboost_regex
# LDFLAGS += $(shell pkg-config --libs mpich)
# LDFLAGS += -L$(HOME)/.local/usr/lib -Wl,-rpath -Wl,$(HOME)/.local/usr/lib -lmpi -lrt
# LDFLAGS += $(USRLIBS)
# LDFLAGS += -rdynamic
ARFLAGS := -rcv
HEADERS := $(wildcard *.h)
HEADERS += $(wildcard *.hpp)
HEADERS += $(wildcard $(USRINCS)/*.h)
SRCS := $(wildcard *.c)
SRCS += $(wildcard *.cpp)
SRCS += $(wildcard *.cc)
OBJS := $(patsubst %.c, $(OBJDIR)/%.o, $(wildcard *.c))
OBJS += $(patsubst %.cpp, $(OBJDIR)/%.o, $(wildcard *.cpp))
DEPS := $(patsubst %.o, %.d, $(OBJS))
SHTARGET:= libmimir.so
STTARGET:= libmimir.a
#============================================
# real things
.PHONY : all objs clean lib shlib
.DEFAULT :
@test -f build_config/$@.mk
@if [ ! -d build.$@ ]; then mkdir build.$@; fi
@cat Makefile build_config/$@.mk > makefile.$@
$(MAKE) "OBJDIR=build.$@" "STTARGET=$(patsubst %.a, %_$@.a, $(STTARGET))" \
-f makefile.$@ lib
@$(RM) makefile.$@
all : lib
lib : $(OBJS)
$(AR) $(ARFLAGS) $(STTARGET) $(OBJS)
shlib : $(OBJS)
$(LD) $(CXXFLAGS) $(SHRFLAGS) $(LDFLAGS) -shared -o $(SHTARGET) $(OBJS)
# basic rules
objs : $(OBJS)
$(DEPS) : $(SRCS) $(HEADERS)
-include $(DEPS)
# automation rules
$(OBJDIR)/%.d : %.c
@if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi
@$(CC) -MM $(CFLAGS) $< -o $@
@sed -i '1 s/^/$(OBJDIR)\//' $@
@cp -f $@ $@.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $@.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $@
@rm -f $@.tmp
$(OBJDIR)/%.d : %.cpp
@if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi
@$(CC) -MM $(CXXFLAGS) $< -o $@
@sed -i '1 s/^/$(OBJDIR)\//' $@
@cp -f $@ $@.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $@.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $@
@rm -f $@.tmp
$(OBJDIR)/%.o : %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o : %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
clean :
@$(RM) $(DEPS) $(OBJS) $(STTARGET) $(SHTARGET)
clean-% :
@$(RM) -r build.$(@:clean-%=%) *$(@:clean-%=%).a