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
68 CFLAGS += -falign-loops=16
76 ifneq (,$(findstring CYGW,$(SYS)))
80 ifneq (,$(findstring MINGW,$(SYS)))
84 ifneq (,$(findstring Windows,$(SYS)))
88 OPTIMIZE :=-Zi -MDd -D_USE_MATH_DEFINES -DWIN32 -D_DEBUG -D_CRTDBG_MAP_ALLOC
93 LINKDLLOUTFLAG :=-out:
94 LINKDIRFLAG := -libpath:
96 DLL_LIB_SUFFIX := .lib
97 DLL_COMMAND := -link /INCREMENTAL:NO -subsystem:WINDOWS -machine:X86 -DLL $(DEF_FILE)
99 DLL_EXTRAS := ws2_32.lib
101 RANLIB := echo no ranlib
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))
134 ### RULES ###########################################################
140 mkdir -p _build/headers
145 ifneq (,$(findstring Windows,$(SYS)))
146 mkdir -p _build/vmall_objs
150 cp $(hfiles) _build/headers
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)$@
165 vmall_objs: _build/vmall_objs $(vmall_objects)
169 $(CC) $(CFLAGS) -c $(asmfiles) $(CCOUTFLAG)_build/objs/asm.o || true
171 $(AR) $(ARFLAGS) $(AROUTFLAG)$@ _build/objs/*.o
175 $(LINKDLL) $(DLL_COMMAND) $(FLAT_NAMESPACE) $(DLL_L) _build/objs/*.o $(LINKDLLOUTFLAG)$(DLL) $(DLL_l) $(DLL_EXTRAS)