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
|
ifndef FLEXTBUILD
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
LIBS+=$(FLEXTPATH)/$(FLEXTNAME).a
endif
LDFLAGS += -shared -Wl,-x
##############################################
ifdef DEBUG
CFLAGS += -g -D_DEBUG
else
CFLAGS += $(OFLAGS) -DNDEBUG
LDFLAGS += -Wl,-S
endif
##############################################
ifdef FLEXTBUILD
OUTNAME=$(FLEXTNAME)
ifdef SHARED
EXT=dll
else
EXT=a
BUILDLIB=1
endif
else
OUTNAME=$(NAME)
endif
##############################################
TARGETPATH=$(OUTPATH)/$(OUTSUB)
TARGET=$(TARGETPATH)/$(OUTNAME).$(EXT)
##############################################
CSRCS=$(patsubst %.c,$(SRCDIR)/%.c,$(filter %.c,$(SRCS)))
CPPSRCS=$(patsubst %.cpp,$(SRCDIR)/%.cpp,$(filter %.cpp,$(SRCS)))
COBJS=$(patsubst %.c,$(TARGETPATH)/%.o,$(filter %.c,$(SRCS)))
CPPOBJS=$(patsubst %.cpp,$(TARGETPATH)/%.opp,$(filter %.cpp,$(SRCS)))
# default target
_all_: $(TARGET)
$(CSRCS) $(CPPSRCS): $(patsubst %,$(SRCDIR)/%,$(HDRS))
touch $@
$(TARGETPATH):
-mkdir $(OUTPATH)
-mkdir $@
$(TARGETPATH)/%.opp : $(SRCDIR)/%.cpp
$(CXX) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGETPATH)/%.o : $(SRCDIR)/%.c
$(CC) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGET) :: $(TARGETPATH)
$(TARGET) :: $(COBJS) $(CPPOBJS)
ifdef BUILDLIB
$(AR) rc $@ $(COBJS) $(CPPOBJS)
else
$(CXX) $(LDFLAGS) $(LIBPATH) -o $@ $(COBJS) $(CPPOBJS) $(LIBS)
chmod 755 $@
endif
##############################################
_clean_:
rm $(COBJS) $(CPPOBJS) $(TARGET)
##############################################
$(INSTPATH):
-mkdir $@
$(FLEXTPATH):
-mkdir $@
_install_:: $(INSTPATH) $(FLEXTPATH)
_install_:: $(TARGET)
ifdef FLEXTBUILD
cp $(TARGET) $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(FLEXTPATH)
else
install $(TARGET) $(INSTPATH)
endif
|