Skip to content

Commit

Permalink
Accept compiler and flags from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
plusky committed May 16, 2016
1 parent e0e937e commit 7a3ae30
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
CC = gcc
CXX = g++
CC ?= gcc
CXX ?= g++

CFLAGS += -W -Wall -Wextra -ansi -pedantic -O2 -Wno-unused-function
CXXFLAGS += -W -Wall -Wextra -ansi -pedantic -O2
LDFLAGS += -fPIC
LIBS += -lm

CFLAGS = -W -Wall -Wextra -ansi -pedantic -lm -O2 -Wno-unused-function
CXXFLAGS = -W -Wall -Wextra -ansi -pedantic -O2

ZOPFLILIB_SRC = src/zopfli/blocksplitter.c src/zopfli/cache.c\
src/zopfli/deflate.c src/zopfli/gzip_container.c\
Expand All @@ -20,22 +23,22 @@ ZOPFLIPNGBIN_SRC := src/zopflipng/zopflipng_bin.cc

# Zopfli binary
zopfli:
$(CC) $(ZOPFLILIB_SRC) $(ZOPFLIBIN_SRC) $(CFLAGS) -o zopfli
$(CC) $(ZOPFLILIB_SRC) $(ZOPFLIBIN_SRC) $(CFLAGS) $(LDFLAFS) -o zopfli $(LIBS)

# Zopfli shared library
libzopfli:
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -fPIC -c
$(CC) $(ZOPFLILIB_OBJ) $(CFLAGS) -shared -Wl,-soname,libzopfli.so.1 -o libzopfli.so.1.0.1
$(CC) $(ZOPFLILIB_OBJ) $(CFLAGS) $(LDFLAFS) -shared -Wl,-soname,libzopfli.so.1 -o libzopfli.so.1.0.1 $(LIBS)

# ZopfliPNG binary
zopflipng:
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -c
$(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(ZOPFLIPNGBIN_SRC) $(CFLAGS) -o zopflipng
$(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(ZOPFLIPNGBIN_SRC) $(CFLAGS) $(LDFLAFS) -o zopflipng $(LIBS)

# ZopfliPNG shared library
libzopflipng:
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -fPIC -c
$(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(CFLAGS) -fPIC --shared -Wl,-soname,libzopflipng.so.1 -o libzopflipng.so.1.0.0
$(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(CFLAGS) $(LDFLAFS) --shared -Wl,-soname,libzopflipng.so.1 -o libzopflipng.so.1.0.0 $(LIBS)

# Remove all libraries and binaries
clean:
Expand Down

0 comments on commit 7a3ae30

Please sign in to comment.