1# Copyright (c) 2015, Louis P. Santillan <lpsantil@gmail.com> 2# All rights reserved. 3# See LICENSE for licensing details. 4DESTDIR ?= /opt/local 5 6# Pulled the code below from lib/Makefile. Might be nicer to derive this somehow without sed 7# Version numbers 8VERSION ?= 129 9RELEASE ?= r$(VERSION) 10LIBVER_MAJOR=$(shell sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h) 11LIBVER_MINOR=$(shell sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h) 12LIBVER_PATCH=$(shell sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h) 13LIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH) 14 15###################################################################### 16 17CROSS ?= i586-pc-msdosdjgpp 18CC = $(CROSS)-gcc 19AR = $(CROSS)-ar 20LD = $(CROSS)-gcc 21 22CFLAGS ?= -O3 -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\" 23LDFLAGS ?= -s 24SRC = programs/bench.c programs/lz4io.c programs/lz4cli.c 25OBJ = $(SRC:.c=.o) 26SDEPS = $(SRC:.c=.d) 27IDIR = lib 28EDIR = . 29EXE = lz4.exe 30LNK = lz4 31LDIR = lib 32LSRC = lib/lz4.c lib/lz4hc.c lib/lz4frame.c lib/xxhash.c 33INC = $(LSRC:.c=.h) 34LOBJ = $(LSRC:.c=.o) 35LSDEPS = $(LSRC:.c=.d) 36LIB = $(LDIR)/lib$(LNK).a 37 38# Since LDFLAGS defaults to "-s", probably better to override unless 39# you have a default you would like to maintain 40ifeq ($(WITH_DEBUG), 1) 41 CFLAGS += -g 42 LDFLAGS += -g 43endif 44 45# Since LDFLAGS defaults to "-s", probably better to override unless 46# you have a default you would like to maintain 47ifeq ($(WITH_PROFILING), 1) 48 CFLAGS += -pg 49 LDFLAGS += -pg 50endif 51 52%.o: %.c $(INC) Makefile 53 $(CC) $(CFLAGS) -MMD -MP -I$(IDIR) -c $< -o $@ 54 55%.exe: %.o $(LIB) Makefile 56 $(LD) $< -L$(LDIR) -l$(LNK) $(LDFLAGS) $(LIBDEP) -o $@ 57 58###################################################################### 59######################## DO NOT MODIFY BELOW ######################### 60###################################################################### 61 62.PHONY: all install uninstall showconfig gstat gpush 63 64all: $(LIB) $(EXE) 65 66$(LIB): $(LOBJ) 67 $(AR) -rcs $@ $^ 68 69$(EXE): $(LOBJ) $(OBJ) 70 $(LD) $(LDFLAGS) $(LOBJ) $(OBJ) -o $(EDIR)/$@ 71 72clean: 73 rm -f $(OBJ) $(EXE) $(LOBJ) $(LIB) *.tmp $(SDEPS) $(LSDEPS) $(TSDEPS) 74 75install: $(INC) $(LIB) $(EXE) 76 mkdir -p $(DESTDIR)/bin $(DESTDIR)/include $(DESTDIR)/lib 77 rm -f .footprint 78 echo $(DESTDIR)/bin/$(EXE) >> .footprint 79 cp -v $(EXE) $(DESTDIR)/bin/ 80 @for T in $(LIB); \ 81 do ( \ 82 echo $(DESTDIR)/$$T >> .footprint; \ 83 cp -v --parents $$T $(DESTDIR) \ 84 ); done 85 @for T in $(INC); \ 86 do ( \ 87 echo $(DESTDIR)/include/`basename -a $$T` >> .footprint; \ 88 cp -v $$T $(DESTDIR)/include/ \ 89 ); done 90 91uninstall: .footprint 92 @for T in $(shell cat .footprint); do rm -v $$T; done 93 94-include $(SDEPS) $(LSDEPS) 95 96showconfig: 97 @echo "PWD="$(PWD) 98 @echo "VERSION="$(VERSION) 99 @echo "RELEASE="$(RELEASE) 100 @echo "LIBVER_MAJOR="$(LIBVER_MAJOR) 101 @echo "LIBVER_MINOR="$(LIBVER_MINOR) 102 @echo "LIBVER_PATCH="$(LIBVER_PATCH) 103 @echo "LIBVER="$(LIBVER) 104 @echo "CROSS="$(CROSS) 105 @echo "CC="$(CC) 106 @echo "AR="$(AR) 107 @echo "LD="$(LD) 108 @echo "DESTDIR="$(DESTDIR) 109 @echo "CFLAGS="$(CFLAGS) 110 @echo "LDFLAGS="$(LDFLAGS) 111 @echo "SRC="$(SRC) 112 @echo "OBJ="$(OBJ) 113 @echo "IDIR="$(IDIR) 114 @echo "INC="$(INC) 115 @echo "EDIR="$(EDIR) 116 @echo "EXE="$(EXE) 117 @echo "LDIR="$(LDIR) 118 @echo "LSRC="$(LSRC) 119 @echo "LOBJ="$(LOBJ) 120 @echo "LNK="$(LNK) 121 @echo "LIB="$(LIB) 122 @echo "SDEPS="$(SDEPS) 123 @echo "LSDEPS="$(LSDEPS) 124 125gstat: 126 git status 127 128gpush: 129 git commit 130 git push 131