1 # Copyright (c) 2015, Louis P. Santillan <lpsantil (at] gmail.com> 2 # All rights reserved. 3 # See LICENSE for licensing details. 4 DESTDIR ?= /opt/local 5 6 # Pulled the code below from lib/Makefile. Might be nicer to derive this somehow without sed 7 # Version numbers 8 VERSION ?= 129 9 RELEASE ?= r$(VERSION) 10 LIBVER_MAJOR=$(shell sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h) 11 LIBVER_MINOR=$(shell sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h) 12 LIBVER_PATCH=$(shell sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h) 13 LIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH) 14 15 ###################################################################### 16 17 CROSS ?= i586-pc-msdosdjgpp 18 CC = $(CROSS)-gcc 19 AR = $(CROSS)-ar 20 LD = $(CROSS)-gcc 21 22 CFLAGS ?= -O3 -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\" 23 LDFLAGS ?= -s 24 SRC = programs/bench.c programs/lz4io.c programs/lz4cli.c 25 OBJ = $(SRC:.c=.o) 26 SDEPS = $(SRC:.c=.d) 27 IDIR = lib 28 EDIR = . 29 EXE = lz4.exe 30 LNK = lz4 31 LDIR = lib 32 LSRC = lib/lz4.c lib/lz4hc.c lib/lz4frame.c lib/xxhash.c 33 INC = $(LSRC:.c=.h) 34 LOBJ = $(LSRC:.c=.o) 35 LSDEPS = $(LSRC:.c=.d) 36 LIB = $(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 40 ifeq ($(WITH_DEBUG), 1) 41 CFLAGS += -g 42 LDFLAGS += -g 43 endif 44 45 # Since LDFLAGS defaults to "-s", probably better to override unless 46 # you have a default you would like to maintain 47 ifeq ($(WITH_PROFILING), 1) 48 CFLAGS += -pg 49 LDFLAGS += -pg 50 endif 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 64 all: $(LIB) $(EXE) 65 66 $(LIB): $(LOBJ) 67 $(AR) -rcs $@ $^ 68 69 $(EXE): $(LOBJ) $(OBJ) 70 $(LD) $(LDFLAGS) $(LOBJ) $(OBJ) -o $(EDIR)/$@ 71 72 clean: 73 rm -f $(OBJ) $(EXE) $(LOBJ) $(LIB) *.tmp $(SDEPS) $(LSDEPS) $(TSDEPS) 74 75 install: $(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 91 uninstall: .footprint 92 @for T in $(shell cat .footprint); do rm -v $$T; done 93 94 -include $(SDEPS) $(LSDEPS) 95 96 showconfig: 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 125 gstat: 126 git status 127 128 gpush: 129 git commit 130 git push 131