# # Copyright (c) 2011-2015, Emulex # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # OS = $(shell uname -s) UNAME_P = $(shell uname -p) ifdef CROSS ifeq ($(CROSS),arm64) # Setup the cross compiling tools CC = aarch64-linux-gnu-gcc LD = aarch64-linux-gnu-ld AR = aarch64-linux-gnu-ar # Override uname -p to pick up ARM64 definitions UNAME_P = aarch64 else ifeq ($(CROSS),i386) LIB = $(OBJDIR)/elxcdul.i386.a ZLIB = zlib/libz.i386.a else $(error "Unsupported architecture $(CROSS)") endif endif DEFINES = INCLUDES = -I. -Izlib/ WARNINGS = -Wall -Werror DEBUG = -g RELEASE_FILES = \ ecd_api.h \ ecdtest.c \ ecdtest.make \ README # If not excluding BSD, then add in the BSD elxcdul.a # Used for Linux-only driver source distrubution builds ifneq ($(EXCLUDE_BSD),TRUE) RELEASE_FILES += \ bsd_objs/elxcdul.a endif # If not excluding Linux, then add in the Linux elxcdul.a # Used BSD-only driver source distrubution builds ifneq ($(EXCLUDE_LINUX),TRUE) RELEASE_FILES += \ linux_objs/elxcdul.a \ linux_objs/elxcdul.arm64.a endif CFLAGS = $(DEFINES) $(INCLUDES) $(WARNINGS) LDFLAGS = ifeq ($(OS), FreeBSD) OBJDIR = bsd_objs endif ifeq ($(OS), Linux) OBJDIR = linux_objs ifeq ($(CROSS),i386) CFLAGS += -m32 LDFLAGS += -melf_i386 endif ifeq ($(UNAME_P),aarch64) LIB = $(OBJDIR)/elxcdul.arm64.a ZLIB = zlib/libz.arm64.a endif endif LIB ?= $(OBJDIR)/elxcdul.a ZLIB ?= zlib/libz.a LIBSRCS = ecd.c cdbc.c LIBOBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(LIBSRCS)) all : $(OBJDIR) $(LIB) $(OBJDIR): -mkdir -p $@ list_release_files: @echo $(RELEASE_FILES) $(OBJDIR)/%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< $(LIB) : $(LIBOBJS) $(eval LINKER_OUT := $(@:%.a=%.o)) $(LD) $(LDFLAGS) -r -o $(LINKER_OUT) $(LIBOBJS) $(ZLIB) $(AR) $(ARFLAGS) $@ $(LINKER_OUT) clean: rm -f $(OBJDIR)/*.o clobber: clean rm -rf $(OBJDIR) rm -f .depend ecdtest rm -rf release .depend: $(CC) -MM $(CFLAGS) $(LIBSRCS) > .depend -include .depend CUST_DIST_FILES = ecdtest.c ecd_api.h $(OBJDIR)/elxcdul.a $(OBJDIR)/elxcdul.i386.a README tarfile = elxcdul-VERSION.tgz custdist: clobber $(OBJDIR) $(LIB) @echo "Creating customer tar file: $(tarfile)" @if [ \! -d release ] ; then \ mkdir release; \ fi @rm -f release/* @cp $(CUST_DIST_FILES) release @sed release/Makefile @(cd release; tar cfz ../elxcdul-VERSION.tgz *; )