]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/test_and_benchmark/test/build/gcc_gnumake_hosted/Makefile
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / test_and_benchmark / test / build / gcc_gnumake_hosted / Makefile
1 ##### notes #####
2 # TRD : -fno-strict-aliasing is needed because GCC has messed up type punning and __may_alias__ does absolutely nothing
3 #       -Wno-unused-but-set-variable and -Wno-uninitialized are needed because GCC seems confused by the atomic intrinsics
4 #       the code base for release has been compiled with those warnings enabled, to show any valid errors
5
6 ##### paths #####
7 BINDIR     := ../../bin
8 OBJDIR     := ../../obj
9 SRCDIR     := ../../src
10 LIBINCDIRS := ../../../../liblfds710/inc/ ../../../libtest/inc/ ../../../libshared/inc/
11 LIBBINDIRS := ../../../../liblfds710/bin/ ../../../libtest/bin/ ../../../libshared/bin/
12
13 ##### misc #####
14 QUIETLY    := 1>/dev/null 2>/dev/null
15 NULL       := 
16 SPACE      := $(NULL) # TRD : with a trailing space
17
18 ##### sources, objects and libraries #####
19 BINNAME    := test
20 BINARY     := $(BINDIR)/$(BINNAME)
21 SRCDIRS    := .
22 SOURCES    := main.c misc.c callbacks.c util_cmdline.c
23 OBJECTS    := $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SOURCES)))
24 SYSLIBS    := -lm -lpthread -lrt
25 USRLIBS    := -ltest -lshared -llfds710
26 LIBINCDIRS := $(subst $(SPACE), -I,$(LIBINCDIRS))
27 LIBBINDIRS := $(subst $(SPACE), -L,$(LIBBINDIRS))
28
29 ##### tools #####
30 DG                     := gcc
31 DGFLAGS_MANDATORY      := -MM
32 DGFLAGS_OPTIONAL       := 
33
34 CC                     := gcc
35 CFLAGS_MANDATORY       := -c -pthread -I$(LIBINCDIRS)
36 CFLAGS_OPTIONAL        := -Wall -Werror -Wno-unknown-pragmas
37 CFLAGS_MANDATORY_COV   := -O0 -ggdb -DCOVERAGE -fprofile-arcs -ftest-coverage
38 CFLAGS_MANDATORY_DBG   := -O0 -ggdb -D_DEBUG
39 CFLAGS_MANDATORY_PROF  := -O0 -ggdb -DPROF     -pg
40 CFLAGS_MANDATORY_REL   := -O2       -DNDEBUG
41 CFLAGS_MANDATORY_TSAN  := -O0 -ggdb -DTSAN     -fsanitize=thread -fPIC
42
43 LD                     := gcc
44 LDFLAGS_MANDATORY      := -pthread -L$(LIBBINDIRS)
45 LDFLAGS_OPTIONAL       := -Wall -Werror
46 LDFLAGS_MANDATORY_COV  := -O0 -fprofile-arcs -ftest-coverage
47 LDFLAGS_MANDATORY_DBG  := -O0 -ggdb
48 LDFLAGS_MANDATORY_PROF := -O0 -pg
49 LDFLAGS_MANDATORY_REL  := -O2 -s
50 LDFLAGS_MANDATORY_TSAN := -O0 -fsanitize=thread -pie
51
52 ##### build variants #####
53 ifeq ($(MAKECMDGOALS),) # TRD : default to debug
54   CFLAGS_MANDATORY  += $(CFLAGS_MANDATORY_DBG)
55   LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_DBG)
56 endif
57
58 ifeq ($(findstring cov,$(MAKECMDGOALS)),cov)
59   CFLAGS_MANDATORY  += $(CFLAGS_MANDATORY_COV)
60   LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_COV)
61   SYSLIBS += -lgcov
62 endif
63
64 ifeq ($(findstring dbg,$(MAKECMDGOALS)),dbg)
65   CFLAGS_MANDATORY  += $(CFLAGS_MANDATORY_DBG)
66   LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_DBG)
67 endif
68
69 ifeq ($(findstring prof,$(MAKECMDGOALS)),prof)
70   CFLAGS_MANDATORY  += $(CFLAGS_MANDATORY_PROF)
71   LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_PROF)
72 endif
73
74 ifeq ($(findstring rel,$(MAKECMDGOALS)),rel)
75   CFLAGS_MANDATORY  += $(CFLAGS_MANDATORY_REL)
76   LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_REL)
77 endif
78
79 ifeq ($(findstring tsan,$(MAKECMDGOALS)),tsan)
80   CFLAGS_MANDATORY  += $(CFLAGS_MANDATORY_TSAN)
81   LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_TSAN)
82 endif
83
84 ##### search paths #####
85 vpath %.c $(patsubst %,$(SRCDIR)/%:,$(SRCDIRS))
86
87 ##### implicit rules #####
88 $(OBJDIR)/%.o : %.c
89         $(DG) $(DGFLAGS_OPTIONAL) $(DGFLAGS) $(DGFLAGS_MANDATORY) $< >$(OBJDIR)/$*.d
90         $(CC) $(CFLAGS_OPTIONAL) $(CFLAGS) $(CFLAGS_MANDATORY) -o $@ $<
91
92 ##### explicit rules #####
93 $(BINARY) : $(OBJECTS)
94         $(LD) -o $(BINARY) $(LDFLAGS_OPTIONAL) $(LDFLAGS) $(LDFLAGS_MANDATORY) $(OBJECTS) $(USRLIBS) $(SYSLIBS)
95         chmod +x $(BINARY)
96
97 ##### phony #####
98 .PHONY : clean cov dbg prof rel tsan vanilla
99
100 clean : 
101         @rm -f $(BINDIR)/$(BINNAME) $(OBJDIR)/*.o $(OBJDIR)/*.d $(OBJDIR)/*.gcda $(OBJDIR)/*.gcno
102
103 cov     : $(BINARY)
104 dbg     : $(BINARY)
105 prof    : $(BINARY)
106 rel     : $(BINARY)
107 tsan    : $(BINARY)
108 vanilla : $(BINARY)
109
110 ##### dependencies #####
111 -include $(DEPENDS)
112