Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

209 lines (166 sloc) 5.085 kb
ifeq ($(shell [ -f Makefile.local ] && echo true),true)
ALL_BEGIN := $(MAKE) -f Makefile.local all_begin
ALL_END := $(MAKE) -f Makefile.local all_end
MAKE_LOCAL_CLEAN := $(MAKE) -f Makefile.local clean
else
ALL_BEGIN :=
ALL_END :=
MAKE_LOCAL_CLEAN :=
endif
#CC ?= g++
RANLIB ?= ranlib
AR ?= ar
ARFLAGS := rcu
AROUTFLAG :=
CCOUTFLAG := -o
LINKDLL := $(CC)
LINKDLLOUTFLAG := -o
LINKDIRFLAG := -L
LINKLIBFLAG := -l
INSTALL_PREFIX_DEFINE := $(INSTALL_PREFIX)
# may need to remove --param max-inline-insns-single=500 for older versions of gccs
WARN :=-Wstrict-prototypes
#-Winline
#--param max-inline-insns-single=500
#-ansi -pedantic
OPTIMIZE :=-O3 -g
#-msse2 -msse -mmmx
#OPTIMIZE :=-O3 -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=4
DLL_SUFFIX := so
DLL_COMMAND := -shared
FLAT_NAMESPACE :=
dependson := $(shell cat depends)
HEADERS :=-I. -I./source
others := $(dependson)
others := $(addprefix -I../,$(others))
others := $(addsuffix /_build/headers,$(others))
HEADERS += $(others)
DLL_L := $(dependson)
DLL_L := $(addprefix -L../,$(DLL_L))
DLL_L := $(addsuffix /_build/dll,$(DLL_L))
DLL_l := $(dependson)
DLL_l := $(addprefix -l,$(DLL_l))
CFLAGS = $(OPTIMIZE) $(WARN) $(HEADERS) #--param max-inline-insns-single=500
# Uncommment for Coros to register their stack with Valgrind
#CFLAGS += -DUSE_VALGRIND
### PLATFORM #####################################################
SYS ?= $(shell uname -s)
ifeq ($(SYS),Darwin)
CFLAGS += -falign-loops=16
CFLAGS += -fPIC
DLL_SUFFIX := dylib
DLL_COMMAND := -dynamiclib
FLAT_NAMESPACE := -flat_namespace
endif
ifeq ($(SYS),DragonFly)
LFLAGS += -lm
endif
ifeq ($(SYS),Linux)
CFLAGS += -falign-loops=16
CFLAGS += -fPIC
endif
ifeq ($(SYS),IRIX)
RANLIB ?= touch
endif
ifneq (,$(findstring CYGW,$(SYS)))
DLL_SUFFIX := dll
endif
ifneq (,$(findstring MINGW,$(SYS)))
DLL_SUFFIX := dll
endif
ifneq (,$(findstring Windows,$(SYS)))
CC := cl -nologo
CCOUTFLAG :=-Fo
WARN :=
#OPTIMIZE :=-Zi -MDd -D_USE_MATH_DEFINES -DWIN32 -D_DEBUG -D_CRT_SECURE_NO_DEPRECATE
OPTIMIZE :=-O2 -EHsc -MD -D_USE_MATH_DEFINES -DWIN32 -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE
AR := link -lib
AROUTFLAG :=-out:
ARFLAGS :=
LINKDLL := link
LINKDLLOUTFLAG :=-out:
LINKDIRFLAG := -libpath:
LINKLIBFLAG :=
DLL_LIB_SUFFIX := .lib
DLL_LIB_PREFIX :=
DLL_COMMAND := -link /INCREMENTAL:NO -subsystem:WINDOWS -machine:X86 -DLL $(DEF_FILE)
DLL_SUFFIX := dll
DLL_EXTRAS := ws2_32.lib shell32.lib
FLAT_NAMESPACE :=
RANLIB := echo no ranlib
INSTALL_PREFIX_DEFINE := $(shell cygpath -am $(INSTALL_PREFIX))
endif
### FILES #########################################################
NAME := $(notdir $(subst $() ,_,$(shell pwd)))
LIBR := _build/lib/lib$(NAME).a
DLL := _build/dll/lib$(NAME).$(DLL_SUFFIX)
infiles := $(wildcard source/*.c)
#infiles += $(wildcard *.S)
asmfiles := $(wildcard source/*.S)
hfiles := $(wildcard source/*.h)
buildhfiles := $(subst source/,_build/headers/,$(hfiles))
objects := $(notdir $(infiles))
objects := $(basename $(objects))
objects := $(addsuffix .o,$(objects))
objects := $(addprefix _build/objs/,$(objects))
vmall_objects := $(notdir $(infiles))
vmall_objects := $(basename $(vmall_objects))
vmall_objects := $(addsuffix .o,$(vmall_objects))
vmall_objects := $(addprefix _build/vmall_objs/,$(vmall_objects))
DLL_L := $(dependson)
DLL_L := $(addprefix $(LINKDIRFLAG)../,$(DLL_L))
DLL_L := $(addsuffix /_build/dll,$(DLL_L))
DLL_l := $(dependson)
DLL_l := $(addprefix $(LINKLIBFLAG),$(DLL_l))
DLL_l := $(addsuffix $(DLL_LIB_SUFFIX),$(DLL_l))
DEF_FILE :=
### RULES ###########################################################
all: _build/objs _build/headers _build/lib _build/dll $(buildhfiles)
$(ALL_BEGIN)
$(MAKE) $(LIBR)
$(MAKE) $(DLL)
ifneq (,$(findstring Windows,$(SYS)))
mkdir -p _build/vmall_objs
$(MAKE) vmall_objs
endif
$(ALL_END)
_build:
mkdir -p $@
_build/objs: _build
mkdir -p $@
_build/headers: _build
mkdir -p $@
_build/lib: _build
mkdir -p $@
_build/dll: _build
mkdir -p $@
# pull in dependency info for *existing* .o files
-include $(objects:.o=.d)
_build/objs/%.o: source/%.c
ifeq (,$(findstring Windows,$(SYS)))
$(CC) -MM -MT $@ -MF $(@:.o=.d) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX_DEFINE)\" $(CFLAGS) -c $< $(CCOUTFLAG)$@
endif
$(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX_DEFINE)\" $(CFLAGS) -c $< $(CCOUTFLAG)$@
_build/vmall_objs/%.o: source/%.c
$(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX_DEFINE)\" $(CFLAGS) \
-DBUILDING_IOVMALL_DLL -c $< $(CCOUTFLAG)$@
_build/headers/%.h: source/%.h _build/headers
cp $< $@
_build/vmall_objs:
mkdir -p $@
vmall_objs: _build/vmall_objs $(vmall_objects)
$(LIBR): $(objects)
ifneq ($(asmfiles),)
$(CC) $(CFLAGS) -c $(asmfiles) $(CCOUTFLAG)_build/objs/asm.o || true
endif
$(AR) $(ARFLAGS) $(AROUTFLAG)$@ _build/objs/*.o
$(RANLIB) $@
$(DLL): $(objects)
$(LINKDLL) $(DLL_COMMAND) $(FLAT_NAMESPACE) $(DLL_L) _build/objs/*.o $(LINKDLLOUTFLAG)$(DLL) $(DLL_l) $(DLL_EXTRAS)
ifneq (,$(findstring Windows,$(SYS)))
mt.exe -manifest $@.manifest -outputresource:$@
rm $@.manifest
endif
clean:
rm -rf _build
$(MAKE_LOCAL_CLEAN)
Jump to Line
Something went wrong with that request. Please try again.