# trace - get simulator trace
# clean - remove object files
-version ?= #auto filled on release
+version ?= 2.18.0
+host_cpu ?= $(shell uname -m | sed -e 's/amd/x86_/')
+arch ?= $(shell uname | grep -v -e Linux -e BSD )
CC = gcc
AS = yasm
SIM = sde $(SIMFLAGS) --
+AWK = awk
DEBUG = -g
DEBUG_yasm = -g dwarf2
DEBUG_nasm = -g
# Default arch= build options
-CFLAGS_gcc = -Wall
+CFLAGS_ = -Wall
ASFLAGS_ = -f elf64
ARFLAGS_ = cr $@
STRIP_gcc = strip -d -R .comment $@
# arch=mingw build options
ASFLAGS_mingw = -f win64
ARFLAGS_mingw = cr $@
-lsrcmingw = $(lsrc)
-unit_testsmingw = $(unit_tests)
-examplesmingw = $(examples)
-perf_testsmingw = $(perf_tests)
+LDFLAGS_mingw = -Wl,--force-exe-suffix
+
+LDFLAGS_so = -Wl,-soname,$(soname)
ifeq ($(arch),mingw)
CC=x86_64-w64-mingw32-gcc
AR=x86_64-w64-mingw32-ar
- LDFLAGS = -Wl,--force-exe-suffix
endif
+# arch=noarch build options
+ARFLAGS_noarch = cr $@
+ifeq ($(arch),noarch)
+ host_cpu=base_aliases
+endif
+
+ASFLAGS_Darwin = -f macho64 --prefix=_
+ARFLAGS_Darwin = -r $@
+ifeq ($(arch),Darwin)
+ LDFLAGS_so =
+ STRIP_gcc =
+endif
INCLUDE = $(patsubst %,-I%/,$(subst :, ,$(VPATH)))
CFLAGS = $(CFLAGS_$(arch)) $(CFLAGS_$(CC)) $(DEBUG) -O2 $(DEFINES) $(INCLUDE)
ARFLAGS = $(ARFLAGS_$(arch))
DEFINES += $(addprefix -D , $D)
+lsrc += $(lsrc_$(host_cpu))
O = bin
-lobj += $(patsubst %.c,%.o,$(patsubst %.asm,%.o,$(lsrc$(arch)) $(lsrc_intrinsic)))
+lobj += $(patsubst %.c,%.o,$(patsubst %.asm,%.o,$(lsrc) $(lsrc_intrinsic)))
objs = $(addprefix $(O)/,$(notdir $(lobj)))
perf_testswin64 = $(perf_tests)
# Build and run unit tests, performance tests, etc.
-all_tests = $(notdir $(sort $(perf_tests$(arch)) $(check_tests$(arch)) $(unit_tests$(arch)) $(examples$(arch)) $(other_tests)))
-all_unit_tests = $(notdir $(sort $(check_tests$(arch)) $(unit_tests$(arch))))
-all_perf_tests = $(notdir $(sort $(perf_tests$(arch))))
+all_tests = $(notdir $(sort $(perf_tests) $(check_tests) $(unit_tests) $(examples) $(other_tests)))
+all_unit_tests = $(notdir $(sort $(check_tests) $(unit_tests)))
+all_perf_tests = $(notdir $(sort $(perf_tests)))
+all_check_tests = $(notdir $(sort $(check_tests)))
$(all_unit_tests): % : %.c $(lib_name)
$(all_perf_tests): % : %.c $(lib_name)
-$(sort $(notdir $(examples$(arch)))): % : %.c $(lib_name)
+$(sort $(notdir $(examples))): % : %.c $(lib_name)
$(sort $(notdir $(other_tests))): % : %.c $(lib_name)
sim test trace: $(addsuffix .run,$(all_unit_tests))
perf: $(addsuffix .run,$(all_perf_tests))
-ex: $(notdir $(examples$(arch)))
+check: $(addsuffix .run,$(all_check_tests))
+ex: $(notdir $(examples))
all: lib $(all_tests)
other: $(notdir $(other_tests))
tests: $(all_unit_tests)
perfs: $(all_perf_tests)
+checks: $(all_check_tests)
check test perf: SIM=
trace: SIMFLAGS = -debugtrace
check test sim:
@echo Completed run: $<
# Other build rules
-msg = $(if $(DEBUG),DEBUG) $(patsubst 32,32-bit,$(arch)) $D
+msg = $(if $(DEBUG),DEBUG) $(patsubst 32,32-bit,$(host_cpu)) $D
$(O)/%.o: %.asm
@echo " ---> Building $< $(msg)"
soname = $(so_lib_inst).$(word 1, $(subst ., ,$(version)))
slib: $(so_lib_name)
-aobjs += $(addprefix $(O)/,$(patsubst %.asm,%.o,$(filter %.asm,$(notdir $(lsrc$(arch)) $(lsrc_intrinsic)))))
-shared_objs += $(addprefix $(O)/shared_ver_,$(patsubst %.c,%.o,$(filter %.c,$(notdir $(lsrc$(arch)) $(lsrc_intrinsic)))))
+aobjs += $(addprefix $(O)/,$(patsubst %.asm,%.o,$(filter %.asm,$(notdir $(lsrc) $(lsrc_intrinsic)))))
+shared_objs += $(addprefix $(O)/shared_ver_,$(patsubst %.c,%.o,$(filter %.c,$(notdir $(lsrc) $(lsrc_intrinsic)))))
$(O)/shared_ver_%.o: %.c
@echo " ---> Building shared $< $(msg)"
$(shared_objs): CFLAGS += -fPIC
$(shared_objs) $(aobjs): | $(O)
-$(so_lib_name): LDFLAGS+=-Wl,-soname,$(soname)
+$(so_lib_name): LDFLAGS+=$(LDFLAGS_so)
$(so_lib_name): $(shared_objs) $(aobjs)
@echo " ---> Creating Shared Lib $@"
@$(CC) $(CFLAGS) --shared $(LDFLAGS) -o $@ $^
@(cd $(@D); ln -f -s $(so_lib_inst) $(soname))
+
+isa-l.h:
+ @echo 'Building $@'
+ @echo '' >> $@
+ @echo '#ifndef _ISAL_H_' >> $@
+ @echo '#define _ISAL_H_' >> $@
+ @echo '' >> $@
+ @echo '#define.ISAL_MAJOR_VERSION.${version}' | ${AWK} -F . '{print $$1, $$2, $$3}' >> $@
+ @echo '#define.ISAL_MINOR_VERSION.${version}' | ${AWK} -F . '{print $$1, $$2, $$4}' >> $@
+ @echo '#define.ISAL_PATCH_VERSION.${version}' | ${AWK} -F . '{print $$1, $$2, $$5}' >> $@
+ @echo '#define ISAL_MAKE_VERSION(maj, min, patch) ((maj) * 0x10000 + (min) * 0x100 + (patch))' >> $@
+ @echo '#define ISAL_VERSION ISAL_MAKE_VERSION(ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION)' >> $@
+ @echo '' >> $@
+ @for unit in $(sort $(extern_hdrs)); do echo "#include <isa-l/$$unit>" | sed -e 's;include/;;' >> $@; done
+ @echo '#endif //_ISAL_H_' >> $@
+
+
# Target for install
prefix = /usr/local
install_dirs = $(prefix)/lib $(prefix)/include/isa-l
install: $(sort $(extern_hdrs)) | $(install_dirs) $(lib_name) $(so_lib_name) isa-l.h
install -m 644 $(lib_name) $(prefix)/lib/libisal.a
install -m 644 $^ $(prefix)/include/isa-l/.
- install -m 664 include/isa-l.h $(prefix)/include/.
+ install -m 664 isa-l.h $(prefix)/include/.
+ install -m 664 include/types.h $(prefix)/include/isa-l/.
install -m 664 $(so_lib_name) $(prefix)/lib/$(so_lib_ver)
(cd $(prefix)/lib && ln -f -s $(so_lib_ver) $(soname) && ln -f -s $(so_lib_ver) $(so_lib_inst))
ifeq ($(shell uname),Darwin)
(cd $(prefix)/lib && ln -f -s $(so_lib_ver) $(basename $(so_lib_inst)).dylib)
-endif
+ which glibtool && glibtool --mode=finish $(prefix)/lib
+else
which libtool && libtool --mode=finish $(prefix)/lib || \
echo 'Lib installed at $(prefix)/lib. Run system-dependent programs to add shared lib path.'
+endif
uninstall:
$(RM) $(prefix)/lib/libisal.a
@$(RM) -r $(O) *.o *.a $(all_tests) $(lib_name) $(so_lib_name)
+doc: isa-l.h
+ (cat Doxyfile; echo 'PROJECT_NUMBER=$(version)') | doxygen -
+ $(MAKE) -C generated_doc/latex &> generated_doc/latex_build_api.log
+ cp generated_doc/latex/refman.pdf isa-l_api_$(version).pdf