Adding DOConnection to protos exports of Socket
[io/jrb1.git] / Makefile.lib
blobd9d19eca90b9a091e8d464fe267771758202a64e
1 ifeq ($(shell [ -f Makefile.local ] && echo true),true)
2 ALL_BEGIN := $(MAKE) -f Makefile.local all_begin
3 ALL_END := $(MAKE) -f Makefile.local all_end
4 MAKE_LOCAL_CLEAN := $(MAKE) -f Makefile.local clean
5 else
6 ALL_BEGIN := 
7 ALL_END := 
8 MAKE_LOCAL_CLEAN := 
9 endif
11 #CC ?= g++
13 RANLIB ?= ranlib
14 AR     ?= ar
15 ARFLAGS := rcu 
16 AROUTFLAG :=
17 CCOUTFLAG := -o 
18 LINKDLL := $(CC)
19 LINKDLLOUTFLAG := -o 
20 LINKDIRFLAG := -L
21 LINKLIBFLAG := -l
23 # may need to remove --param max-inline-insns-single=500 for older versions of gccs
24 WARN :=-Wstrict-prototypes 
25 #-Winline
26 #--param max-inline-insns-single=500
28 #-ansi -pedantic
29 OPTIMIZE :=-O3 -g 
30 #-msse2 -msse -mmmx
31 #OPTIMIZE :=-O3 -ffast-math -ftree-vectorize  -ftree-vectorizer-verbose=4
32 DLL_SUFFIX := so
33 DLL_COMMAND := -shared
34 FLAT_NAMESPACE :=
35 dependson := $(shell cat depends)
37 HEADERS  :=-I. -I./source
38 others := $(dependson)
39 others := $(addprefix -I../,$(others))
40 others := $(addsuffix /_build/headers,$(others))
41 HEADERS += $(others)
43 DLL_L := $(dependson)
44 DLL_L := $(addprefix -L../,$(DLL_L))
45 DLL_L := $(addsuffix /_build/dll,$(DLL_L))
47 DLL_l := $(dependson)
48 DLL_l := $(addprefix -l,$(DLL_l))
50 CFLAGS = $(OPTIMIZE) $(WARN) $(HEADERS) #--param max-inline-insns-single=500
52 # Uncommment for Coros to register their stack with Valgrind
53 #CFLAGS += -DUSE_VALGRIND
55 ### PLATFORM #####################################################
57 SYS ?= $(shell uname -s)
59 ifeq ($(SYS),Darwin)
60 CFLAGS += -falign-loops=16
61 CFLAGS += -fPIC
62 DLL_SUFFIX := dylib
63 DLL_COMMAND := -dynamiclib
64 FLAT_NAMESPACE := -flat_namespace
65 endif
67 ifeq ($(SYS),Linux)
68 CFLAGS += -falign-loops=16
69 CFLAGS += -fPIC
70 endif
72 ifeq ($(SYS),IRIX)
73 RANLIB ?= touch
74 endif
76 ifneq (,$(findstring CYGW,$(SYS)))
77 DLL_SUFFIX := dll
78 endif
80 ifneq (,$(findstring MINGW,$(SYS)))
81 DLL_SUFFIX := dll
82 endif
84 ifneq (,$(findstring Windows,$(SYS)))
85 CC := cl -nologo
86 CCOUTFLAG :=-Fo
87 WARN := 
88 OPTIMIZE :=-Zi -MD -D_USE_MATH_DEFINES -DWIN32 -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE
89 AR := link -lib
90 AROUTFLAG :=-out:
91 ARFLAGS :=
92 LINKDLL := link 
93 LINKDLLOUTFLAG :=-out:
94 LINKDIRFLAG := -libpath:
95 LINKLIBFLAG := lib
96 DLL_LIB_SUFFIX := .lib
97 DLL_COMMAND := -link /INCREMENTAL:NO -subsystem:WINDOWS -machine:X86 -DLL $(DEF_FILE)
98 DLL_SUFFIX := dll
99 DLL_EXTRAS := ws2_32.lib
100 FLAT_NAMESPACE :=
101 RANLIB := echo no ranlib
102 endif
104 ### FILES #########################################################
106 NAME    := $(notdir $(subst $() ,_,$(shell pwd)))
107 LIBR    := _build/lib/lib$(NAME).a
108 DLL     := _build/dll/lib$(NAME).$(DLL_SUFFIX)
109 infiles := $(wildcard source/*.c) 
110 #infiles += $(wildcard *.S)
111 asmfiles := $(wildcard source/*.S)
112 hfiles  := $(wildcard source/*.h)
113 objects := $(notdir $(infiles))
114 objects := $(basename $(objects))
115 objects := $(addsuffix .o,$(objects))
116 objects := $(addprefix _build/objs/,$(objects))
118 vmall_objects := $(notdir $(infiles))
119 vmall_objects := $(basename $(vmall_objects))
120 vmall_objects := $(addsuffix .o,$(vmall_objects))
121 vmall_objects := $(addprefix _build/vmall_objs/,$(vmall_objects))
124 DLL_L := $(dependson)
125 DLL_L := $(addprefix $(LINKDIRFLAG)../,$(DLL_L))
126 DLL_L := $(addsuffix /_build/dll,$(DLL_L))
128 DLL_l := $(dependson)
129 DLL_l := $(addprefix $(LINKLIBFLAG),$(DLL_l))
130 DLL_l := $(addsuffix $(DLL_LIB_SUFFIX),$(DLL_l))
132 DEF_FILE :=
134 ### RULES ###########################################################
136 all:
137         $(ALL_BEGIN) 
138         mkdir -p _build
139         mkdir -p _build/objs
140         mkdir -p _build/headers
141         mkdir -p _build/lib
142         mkdir -p _build/dll
143         $(MAKE) $(LIBR)
144         $(MAKE) $(DLL) 
145 ifneq (,$(findstring Windows,$(SYS)))
146         mkdir -p _build/vmall_objs
147         $(MAKE) vmall_objs
148 endif
149 ifneq (,$(hfiles))
150         cp $(hfiles) _build/headers
151 endif
152         $(ALL_END)
154 _build/objs/%.o: source/%.c
155         $(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\" $(CFLAGS) -c $< $(CCOUTFLAG)$@
157 _build/vmall_objs/%.o: source/%.c
158         $(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\" $(CFLAGS) \
159         -DBUILDING_IOVMALL_DLL -c $< $(CCOUTFLAG)$@
162 _build/vmall_objs:
163         mkdir -p $@
165 vmall_objs: _build/vmall_objs $(vmall_objects)
167 $(LIBR): $(objects)
168 ifneq ($(asmfiles),)
169         $(CC) $(CFLAGS) -c $(asmfiles) $(CCOUTFLAG)_build/objs/asm.o || true
170 endif
171         $(AR) $(ARFLAGS) $(AROUTFLAG)$@ _build/objs/*.o
172         $(RANLIB) $@
174 $(DLL): $(objects)
175         $(LINKDLL) $(DLL_COMMAND) $(FLAT_NAMESPACE) $(DLL_L) _build/objs/*.o $(LINKDLLOUTFLAG)$(DLL) $(DLL_l) $(DLL_EXTRAS)
177 clean:
178         rm -rf _build
179         $(MAKE_LOCAL_CLEAN)