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
23 # may need to remove --param max-inline-insns-single=500 for older versions of gccs
24 WARN :=-Wstrict-prototypes
26 #--param max-inline-insns-single=500
31 #OPTIMIZE :=-O3 -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=4
33 DLL_COMMAND := -shared
35 dependson := $(shell cat depends)
37 HEADERS :=-I. -I./source
38 others := $(dependson)
39 others := $(addprefix -I../,$(others))
40 others := $(addsuffix /_build/headers,$(others))
44 DLL_L := $(addprefix -L../,$(DLL_L))
45 DLL_L := $(addsuffix /_build/dll,$(DLL_L))
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)
60 CFLAGS += -falign-loops=16
63 DLL_COMMAND := -dynamiclib
64 FLAT_NAMESPACE := -flat_namespace
67 ifeq ($(SYS),DragonFly)
72 CFLAGS += -falign-loops=16
80 ifneq (,$(findstring CYGW,$(SYS)))
84 ifneq (,$(findstring MINGW,$(SYS)))
88 ifneq (,$(findstring Windows,$(SYS)))
92 OPTIMIZE :=-Zi -MD -D_USE_MATH_DEFINES -DWIN32 -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE
97 LINKDLLOUTFLAG :=-out:
98 LINKDIRFLAG := -libpath:
100 DLL_LIB_SUFFIX := .lib
101 DLL_COMMAND := -link /INCREMENTAL:NO -subsystem:WINDOWS -machine:X86 -DLL $(DEF_FILE)
103 DLL_EXTRAS := ws2_32.lib shell32.lib
105 RANLIB := echo no ranlib
108 ### FILES #########################################################
110 NAME := $(notdir $(subst $() ,_,$(shell pwd)))
111 LIBR := _build/lib/lib$(NAME).a
112 DLL := _build/dll/lib$(NAME).$(DLL_SUFFIX)
113 infiles := $(wildcard source/*.c)
114 #infiles += $(wildcard *.S)
115 asmfiles := $(wildcard source/*.S)
116 hfiles := $(wildcard source/*.h)
117 objects := $(notdir $(infiles))
118 objects := $(basename $(objects))
119 objects := $(addsuffix .o,$(objects))
120 objects := $(addprefix _build/objs/,$(objects))
122 vmall_objects := $(notdir $(infiles))
123 vmall_objects := $(basename $(vmall_objects))
124 vmall_objects := $(addsuffix .o,$(vmall_objects))
125 vmall_objects := $(addprefix _build/vmall_objs/,$(vmall_objects))
128 DLL_L := $(dependson)
129 DLL_L := $(addprefix $(LINKDIRFLAG)../,$(DLL_L))
130 DLL_L := $(addsuffix /_build/dll,$(DLL_L))
132 DLL_l := $(dependson)
133 DLL_l := $(addprefix $(LINKLIBFLAG),$(DLL_l))
134 DLL_l := $(addsuffix $(DLL_LIB_SUFFIX),$(DLL_l))
138 ### RULES ###########################################################
144 mkdir -p _build/headers
149 ifneq (,$(findstring Windows,$(SYS)))
150 mkdir -p _build/vmall_objs
154 cp $(hfiles) _build/headers
158 _build/objs/%.o: source/%.c
159 $(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\" $(CFLAGS) -c $< $(CCOUTFLAG)$@
161 _build/vmall_objs/%.o: source/%.c
162 $(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\" $(CFLAGS) \
163 -DBUILDING_IOVMALL_DLL -c $< $(CCOUTFLAG)$@
169 vmall_objs: _build/vmall_objs $(vmall_objects)
173 $(CC) $(CFLAGS) -c $(asmfiles) $(CCOUTFLAG)_build/objs/asm.o || true
175 $(AR) $(ARFLAGS) $(AROUTFLAG)$@ _build/objs/*.o
179 $(LINKDLL) $(DLL_COMMAND) $(FLAT_NAMESPACE) $(DLL_L) _build/objs/*.o $(LINKDLLOUTFLAG)$(DLL) $(DLL_l) $(DLL_EXTRAS)
180 ifneq (,$(findstring Windows,$(SYS)))
181 mt.exe -manifest $@.manifest -outputresource:$@