]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.0.0/liblfds600/makefile.linux
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.0.0 / liblfds600 / makefile.linux
1 ##### paths #####
2 BINDIR  = bin
3 INCDIR  = inc
4 OBJDIR  = obj
5 SRCDIR  = src
6
7 ##### misc #####
8 QUIETLY = 1>/dev/null 2>/dev/null
9
10 ##### sources, objects and libraries #####
11 BINNAME = liblfds600
12 AR_BINARY = $(BINDIR)/$(BINNAME).a
13 SO_BINARY = $(BINDIR)/$(BINNAME).so
14 SRCDIRS = lfds600_abstraction lfds600_freelist lfds600_queue lfds600_ringbuffer lfds600_slist lfds600_stack
15 # TRD : be aware - in the linux makefile, with the one-pass linking behaviour of the GNU linker, the order
16 #       of source files matters!  this is because it leads to the ordering of objects in the library and
17 #       that in turn, since the data structures all use the freelist API and the abstraction API, has to be
18 #       correct 
19 SOURCES = lfds600_queue_delete.c lfds600_queue_new.c lfds600_queue_query.c lfds600_queue_queue.c \
20           lfds600_ringbuffer_delete.c lfds600_ringbuffer_get_and_put.c lfds600_ringbuffer_new.c lfds600_ringbuffer_query.c \
21           lfds600_slist_delete.c lfds600_slist_get_and_set.c lfds600_slist_link.c lfds600_slist_new.c \
22           lfds600_stack_delete.c lfds600_stack_new.c lfds600_stack_push_pop.c lfds600_stack_query.c \
23           lfds600_freelist_delete.c lfds600_freelist_get_and_set.c lfds600_freelist_new.c lfds600_freelist_query.c lfds600_freelist_pop_push.c \
24           lfds600_abstraction_aligned_free.c lfds600_abstraction_aligned_malloc.c lfds600_abstraction_cas.c lfds600_abstraction_dcas.c lfds600_abstraction_increment.c
25 OBJECTS = $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SOURCES)))
26
27 ##### CPU variants #####
28 GCCARCH = $(shell uname -m)
29
30 ifeq ($(GCCARCH),x86_64)
31   GCCARCH = core2
32 endif
33
34 ifeq ($(findstring arm,$(GCCARCH)),arm)
35   GCCARCH = armv6k
36 endif
37
38 ##### tools #####
39 MAKE    = make
40 MFLAGS  = 
41
42 DG      = gcc
43 DGFLAGS = -MM -std=c99 -I"$(SRCDIR)" -I"$(INCDIR)"
44
45 CC      = gcc
46 CBASE   = -Wall -Wno-unknown-pragmas -std=c99 -march=$(GCCARCH) -c -I"$(SRCDIR)" -I"$(INCDIR)"
47 CFREL   = -O2 -finline-functions -Wno-strict-aliasing
48 CFDBG   = -O0 -g
49
50 AR      = ar
51 AFLAGS  = -rcs
52
53 LD      = gcc
54 LFBASE  = -Wall -std=c99 -shared
55 LFREL   = -O2 -s
56 LFDBG   = -O0 -g
57
58 ##### rel/dbg .a/.so variants #####
59 ifeq ($(findstring so,$(MAKECMDGOALS)),so)
60   CBASE := $(CBASE) -fpic
61 endif
62
63 CFLAGS  = $(CBASE) $(CFDBG)
64 LFLAGS  = $(LFBASE) $(LFDBG)
65
66 ifeq ($(findstring rel,$(MAKECMDGOALS)),rel)
67   CFLAGS  = $(CBASE) $(CFREL)
68   LFLAGS  = $(LFBASE) $(LFREL)
69 endif
70
71 ##### search paths #####
72 vpath %.c $(patsubst %,$(SRCDIR)/%:,$(SRCDIRS))
73
74 ##### implicit rules #####
75 $(OBJDIR)/%.o : %.c
76         $(DG) $(DGFLAGS) $< >$(OBJDIR)/$*.d
77         $(CC) $(CFLAGS) -o $@ $<
78
79 ##### explicit rules #####
80 $(AR_BINARY) : $(OBJECTS)
81         $(AR) $(AFLAGS) $(AR_BINARY) $(OBJECTS)
82
83 $(SO_BINARY) : $(OBJECTS)
84         $(LD) $(LFLAGS) $(SYSLIBS) $(OBJECTS) -o $(SO_BINARY)
85
86 ##### phony #####
87 .PHONY : clean arrel ardbg sorel sodbg
88
89 clean : 
90         @rm -f $(BINDIR)/$(BINNAME).* $(OBJDIR)/*.o $(OBJDIR)/*.d
91
92 arrel : $(AR_BINARY)
93 ardbg : $(AR_BINARY)
94
95 sorel : $(SO_BINARY)
96 sodbg : $(SO_BINARY)
97
98 ##### dependencies #####
99 -include $(DEPENDS)
100
101 ##### notes #####
102 # TRD : we use -std=c99 purely to permit C++ style comments
103