-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
79 lines (63 loc) · 2.34 KB
/
Makefile.in
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
#Compiler and Linker
CC := @CC@
GCC := @CC@
#The Target Binary Program
TARGET := main
SHAREDLIBTARGET := libfoo
TESTTARGET := test_suite
#The Directories, Source, Includes, Objects, Binary and Resources
SRCDIR := src
EXTDIR := ext
TESTDIR := test
INCDIR := inc
BUILDDIR := obj
TARGETDIR := bin
RESDIR := res
SRCEXT := c
DEPEXT := d
OBJEXT := o
LIBEXT := so
LIBDIR := lib
LIBFILES := $(wildcard lib/*.so)
LIBLINK := $(addprefix -l, $(LIBFILES))
current_dir = $(shell pwd)
#Flags, Libraries and Includes
CXXSTD := -Wno-deprecated-register -g -O0
CFLAGS := $(CXXSTD) -fopenmp -Wall -O3 -g
DYNLIBPARAM := -dynamiclib
INC := -I$(INCDIR) -I/usr/local/include -Isrc -Isrc/test -I$(EXTDIR) -I/c/MinGW/msys/1.0/local/include
LINKLIB := -L$(LIBDIR) -L/usr/local/lib -L/c/MinGW/msys/1.0/local/lib
SHAREDPARAM := -shared
PROGRAMFILES := $(shell find $(SRCDIR)/ -type f -name "*.$(SRCEXT)" -not -path "*modules*")
TESTFILES := $(shell find $(TESTDIR)/ $(SRCDIR)/ ! -name 'main.c' -type f -name "*.$(SRCEXT)")
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(PROGRAMFILES:.$(SRCEXT)=.$(OBJEXT)))
all: directories main tests
directories:
mkdir -p $(TARGETDIR)
mkdir -p $(BUILDDIR)
mkdir -p $(TESTDIR)
mkdir -p $(INCDIR)
main_nodeps:
$(CC) $(CXXSTD) $(INC) $(LINKLIB) $(PROGRAMFILES) -lm -o $(TARGETDIR)/$(TARGET)
main: $(OBJECTS)
$(CC) $(LINKLIB) -o $(TARGETDIR)/$(TARGET) $^
sharedlib: $(OBJECTS)
$(CC) $(SHAREDPARAM) -o $(LIBDIR)/$(SHAREDLIBTARGET).$(LIBEXT) $^
print-% : ; @echo $* = $($*)
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(dir $@)
$(CC) $(CXXSTD) $(INC) -c -o $@ $<
@$(CC) $(CXXSTD) $(INC) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp
@sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT)
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT)
@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp
-include build/scanner.mk
-include build/shared.mk
tests:
$(CC) $(CXXSTD) $(INC) $(LINKLIB) $(TESTFILES) -lcspec -lm -o $(TARGETDIR)/$(TESTTARGET)
find ./test/ -name "*.c" -exec rm -f {} \;
.PHONY: all tests clean
clean:
rm -rf obj && mkdir obj
rm -rf bin/* obj/*