127b27ec6Sopenharmony_ci# Copyright (c) 2015, Louis P. Santillan <lpsantil@gmail.com>
227b27ec6Sopenharmony_ci# All rights reserved.
327b27ec6Sopenharmony_ci# See LICENSE for licensing details.
427b27ec6Sopenharmony_ciDESTDIR ?= /opt/local
527b27ec6Sopenharmony_ci
627b27ec6Sopenharmony_ci# Pulled the code below from lib/Makefile.  Might be nicer to derive this somehow without sed
727b27ec6Sopenharmony_ci# Version numbers
827b27ec6Sopenharmony_ciVERSION ?= 129
927b27ec6Sopenharmony_ciRELEASE ?= r$(VERSION)
1027b27ec6Sopenharmony_ciLIBVER_MAJOR=$(shell sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h)
1127b27ec6Sopenharmony_ciLIBVER_MINOR=$(shell sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h)
1227b27ec6Sopenharmony_ciLIBVER_PATCH=$(shell sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lib/lz4.h)
1327b27ec6Sopenharmony_ciLIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
1427b27ec6Sopenharmony_ci
1527b27ec6Sopenharmony_ci######################################################################
1627b27ec6Sopenharmony_ci
1727b27ec6Sopenharmony_ciCROSS ?= i586-pc-msdosdjgpp
1827b27ec6Sopenharmony_ciCC = $(CROSS)-gcc
1927b27ec6Sopenharmony_ciAR = $(CROSS)-ar
2027b27ec6Sopenharmony_ciLD = $(CROSS)-gcc
2127b27ec6Sopenharmony_ci
2227b27ec6Sopenharmony_ciCFLAGS ?= -O3 -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\"
2327b27ec6Sopenharmony_ciLDFLAGS ?= -s
2427b27ec6Sopenharmony_ciSRC = programs/bench.c programs/lz4io.c programs/lz4cli.c
2527b27ec6Sopenharmony_ciOBJ = $(SRC:.c=.o)
2627b27ec6Sopenharmony_ciSDEPS = $(SRC:.c=.d)
2727b27ec6Sopenharmony_ciIDIR = lib
2827b27ec6Sopenharmony_ciEDIR = .
2927b27ec6Sopenharmony_ciEXE = lz4.exe
3027b27ec6Sopenharmony_ciLNK = lz4
3127b27ec6Sopenharmony_ciLDIR = lib
3227b27ec6Sopenharmony_ciLSRC = lib/lz4.c lib/lz4hc.c lib/lz4frame.c lib/xxhash.c
3327b27ec6Sopenharmony_ciINC = $(LSRC:.c=.h)
3427b27ec6Sopenharmony_ciLOBJ = $(LSRC:.c=.o)
3527b27ec6Sopenharmony_ciLSDEPS = $(LSRC:.c=.d)
3627b27ec6Sopenharmony_ciLIB = $(LDIR)/lib$(LNK).a
3727b27ec6Sopenharmony_ci
3827b27ec6Sopenharmony_ci# Since LDFLAGS defaults to "-s", probably better to override unless
3927b27ec6Sopenharmony_ci# you have a default you would like to maintain
4027b27ec6Sopenharmony_ciifeq ($(WITH_DEBUG), 1)
4127b27ec6Sopenharmony_ci	CFLAGS += -g
4227b27ec6Sopenharmony_ci	LDFLAGS += -g
4327b27ec6Sopenharmony_ciendif
4427b27ec6Sopenharmony_ci
4527b27ec6Sopenharmony_ci# Since LDFLAGS defaults to "-s", probably better to override unless
4627b27ec6Sopenharmony_ci# you have a default you would like to maintain
4727b27ec6Sopenharmony_ciifeq ($(WITH_PROFILING), 1)
4827b27ec6Sopenharmony_ci	CFLAGS += -pg
4927b27ec6Sopenharmony_ci	LDFLAGS += -pg
5027b27ec6Sopenharmony_ciendif
5127b27ec6Sopenharmony_ci
5227b27ec6Sopenharmony_ci%.o: %.c $(INC) Makefile
5327b27ec6Sopenharmony_ci	$(CC) $(CFLAGS) -MMD -MP -I$(IDIR) -c $< -o $@
5427b27ec6Sopenharmony_ci
5527b27ec6Sopenharmony_ci%.exe: %.o $(LIB) Makefile
5627b27ec6Sopenharmony_ci	$(LD) $< -L$(LDIR) -l$(LNK) $(LDFLAGS) $(LIBDEP) -o $@
5727b27ec6Sopenharmony_ci
5827b27ec6Sopenharmony_ci######################################################################
5927b27ec6Sopenharmony_ci######################## DO NOT MODIFY BELOW #########################
6027b27ec6Sopenharmony_ci######################################################################
6127b27ec6Sopenharmony_ci
6227b27ec6Sopenharmony_ci.PHONY: all install uninstall showconfig gstat gpush
6327b27ec6Sopenharmony_ci
6427b27ec6Sopenharmony_ciall: $(LIB) $(EXE)
6527b27ec6Sopenharmony_ci
6627b27ec6Sopenharmony_ci$(LIB): $(LOBJ)
6727b27ec6Sopenharmony_ci	$(AR) -rcs $@ $^
6827b27ec6Sopenharmony_ci
6927b27ec6Sopenharmony_ci$(EXE): $(LOBJ) $(OBJ)
7027b27ec6Sopenharmony_ci	$(LD) $(LDFLAGS) $(LOBJ) $(OBJ) -o $(EDIR)/$@
7127b27ec6Sopenharmony_ci
7227b27ec6Sopenharmony_ciclean:
7327b27ec6Sopenharmony_ci	rm -f $(OBJ) $(EXE) $(LOBJ) $(LIB) *.tmp $(SDEPS) $(LSDEPS) $(TSDEPS)
7427b27ec6Sopenharmony_ci
7527b27ec6Sopenharmony_ciinstall: $(INC) $(LIB) $(EXE)
7627b27ec6Sopenharmony_ci	mkdir -p $(DESTDIR)/bin $(DESTDIR)/include $(DESTDIR)/lib
7727b27ec6Sopenharmony_ci	rm -f .footprint
7827b27ec6Sopenharmony_ci	echo $(DESTDIR)/bin/$(EXE) >> .footprint
7927b27ec6Sopenharmony_ci	cp -v $(EXE) $(DESTDIR)/bin/
8027b27ec6Sopenharmony_ci	@for T in $(LIB); \
8127b27ec6Sopenharmony_ci	do ( \
8227b27ec6Sopenharmony_ci		echo $(DESTDIR)/$$T >> .footprint; \
8327b27ec6Sopenharmony_ci		cp -v --parents $$T $(DESTDIR) \
8427b27ec6Sopenharmony_ci	); done
8527b27ec6Sopenharmony_ci	@for T in $(INC); \
8627b27ec6Sopenharmony_ci	do ( \
8727b27ec6Sopenharmony_ci		echo $(DESTDIR)/include/`basename -a $$T` >> .footprint; \
8827b27ec6Sopenharmony_ci		cp -v $$T $(DESTDIR)/include/ \
8927b27ec6Sopenharmony_ci	); done
9027b27ec6Sopenharmony_ci
9127b27ec6Sopenharmony_ciuninstall: .footprint
9227b27ec6Sopenharmony_ci	@for T in $(shell cat .footprint); do rm -v $$T; done
9327b27ec6Sopenharmony_ci
9427b27ec6Sopenharmony_ci-include $(SDEPS) $(LSDEPS)
9527b27ec6Sopenharmony_ci
9627b27ec6Sopenharmony_cishowconfig:
9727b27ec6Sopenharmony_ci	@echo "PWD="$(PWD)
9827b27ec6Sopenharmony_ci	@echo "VERSION="$(VERSION)
9927b27ec6Sopenharmony_ci	@echo "RELEASE="$(RELEASE)
10027b27ec6Sopenharmony_ci	@echo "LIBVER_MAJOR="$(LIBVER_MAJOR)
10127b27ec6Sopenharmony_ci	@echo "LIBVER_MINOR="$(LIBVER_MINOR)
10227b27ec6Sopenharmony_ci	@echo "LIBVER_PATCH="$(LIBVER_PATCH)
10327b27ec6Sopenharmony_ci	@echo "LIBVER="$(LIBVER)
10427b27ec6Sopenharmony_ci	@echo "CROSS="$(CROSS)
10527b27ec6Sopenharmony_ci	@echo "CC="$(CC)
10627b27ec6Sopenharmony_ci	@echo "AR="$(AR)
10727b27ec6Sopenharmony_ci	@echo "LD="$(LD)
10827b27ec6Sopenharmony_ci	@echo "DESTDIR="$(DESTDIR)
10927b27ec6Sopenharmony_ci	@echo "CFLAGS="$(CFLAGS)
11027b27ec6Sopenharmony_ci	@echo "LDFLAGS="$(LDFLAGS)
11127b27ec6Sopenharmony_ci	@echo "SRC="$(SRC)
11227b27ec6Sopenharmony_ci	@echo "OBJ="$(OBJ)
11327b27ec6Sopenharmony_ci	@echo "IDIR="$(IDIR)
11427b27ec6Sopenharmony_ci	@echo "INC="$(INC)
11527b27ec6Sopenharmony_ci	@echo "EDIR="$(EDIR)
11627b27ec6Sopenharmony_ci	@echo "EXE="$(EXE)
11727b27ec6Sopenharmony_ci	@echo "LDIR="$(LDIR)
11827b27ec6Sopenharmony_ci	@echo "LSRC="$(LSRC)
11927b27ec6Sopenharmony_ci	@echo "LOBJ="$(LOBJ)
12027b27ec6Sopenharmony_ci	@echo "LNK="$(LNK)
12127b27ec6Sopenharmony_ci	@echo "LIB="$(LIB)
12227b27ec6Sopenharmony_ci	@echo "SDEPS="$(SDEPS)
12327b27ec6Sopenharmony_ci	@echo "LSDEPS="$(LSDEPS)
12427b27ec6Sopenharmony_ci
12527b27ec6Sopenharmony_cigstat:
12627b27ec6Sopenharmony_ci	git status
12727b27ec6Sopenharmony_ci
12827b27ec6Sopenharmony_cigpush:
12927b27ec6Sopenharmony_ci	git commit
13027b27ec6Sopenharmony_ci	git push
131