Skip to content

Commit

Permalink
miscellaneous changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiggers committed Jun 2, 2016
1 parent 81baeff commit fdc8aaa
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
51 changes: 30 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
#
# Use 'make help' to list available targets.
#
# Define V=1 to enable "verbose" mode, showing all executed commands.
#
# Define DECOMPRESSION_ONLY=yes to omit all compression code, building a
# Define DECOMPRESSION_ONLY to omit all compression code, building a
# decompression-only library. If doing this, you must also build a specific
# library target such as 'libxpack.a', as the programs will no longer compile.
#
# TODO: ENABLE_PREPROCESSING option
#
##############################################################################

#### Common compiler flags.
#### Flags given here are not intended to be overridden, but you can add more
#### by defining CFLAGS in the environment or on the 'make' command line.

cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \
1>&2 2>/dev/null; then echo $(1); fi)

override CFLAGS := \
$(CFLAGS) -O2 -fomit-frame-pointer -std=gnu89 -I. -Icommon \
-Wall -Wundef \
$(call cc-option,-Wdeclaration-after-statement) \
$(call cc-option,-Wmissing-prototypes) \
$(call cc-option,-Wstrict-prototypes) \
$(call cc-option,-Wvla)

CC ?= gcc
AR ?= ar
##############################################################################

STATIC_LIB_SUFFIX := .a
SHARED_LIB_SUFFIX := .so
PROG_SUFFIX :=
PROG_CFLAGS :=
PIC_REQUIRED := yes
HARD_LINKS := yes
PIC_REQUIRED := 1
HARD_LINKS := 1

# Compiling for Windows with MinGW?
ifneq ($(findstring -mingw,$(CC)),)
Expand All @@ -27,20 +44,12 @@ ifneq ($(findstring -mingw,$(CC)),)
SHARED_LIB_SUFFIX := .dll
PROG_SUFFIX := .exe
PROG_CFLAGS := -static -municode
PIC_REQUIRED := no
HARD_LINKS := no
PIC_REQUIRED :=
HARD_LINKS :=
endif

##############################################################################

#### Common compiler flags; not intended to be overridden

override CFLAGS += -O2 -fomit-frame-pointer -std=gnu89 -I. -Icommon \
-Wall -Wundef -Wdeclaration-after-statement \
-Wmissing-prototypes -Wstrict-prototypes

##############################################################################

#### Quiet make is enabled by default. Define V=1 to disable.

ifneq ($(findstring s,$(MAKEFLAGS)),s)
Expand All @@ -66,13 +75,13 @@ SHARED_LIB := libxpack$(SHARED_LIB_SUFFIX)

LIB_CFLAGS += $(CFLAGS) -fvisibility=hidden -D_ANSI_SOURCE

DECOMPRESSION_ONLY := no
ifeq ($(DECOMPRESSION_ONLY),yes)
DECOMPRESSION_ONLY :=
ifdef DECOMPRESSION_ONLY
LIB_CFLAGS += -DDECOMPRESSION_ONLY=1
endif

ENABLE_PREPROCESSING := no
ifeq ($(ENABLE_PREPROCESSING),yes)
ENABLE_PREPROCESSING :=
ifdef ENABLE_PREPROCESSING
LIB_CFLAGS += -DENABLE_PREPROCESSING=1
endif

Expand All @@ -85,7 +94,7 @@ LIB_SRC := lib/x86_cpu_features.c \

LIB_OBJ := $(LIB_SRC:.c=.o)
LIB_PIC_OBJ := $(LIB_SRC:.c=.pic.o)
ifeq ($(PIC_REQUIRED),yes)
ifdef PIC_REQUIRED
SHLIB_OBJ := $(LIB_PIC_OBJ)
else
SHLIB_OBJ := $(LIB_OBJ)
Expand Down Expand Up @@ -156,7 +165,7 @@ xpack$(PROG_SUFFIX):programs/xpack.o $(PROG_COMMON_OBJ) $(STATIC_LIB)

ALL_TARGETS += xpack$(PROG_SUFFIX)

ifeq ($(HARD_LINKS),yes)
ifdef HARD_LINKS
# Hard link xunpack to xpack
xunpack$(PROG_SUFFIX):xpack$(PROG_SUFFIX)
$(QUIET_LN) ln -f $< $@
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ file for details.

## For UNIX

Just run `make`. You need GNU Make and either GCC or Clang. There is no `make
install` yet; just copy the file(s) to where you want.
Just run `make`. You need GNU Make and either GCC or Clang. GCC is recommended
because it builds slightly faster binaries. There is no `make install` yet;
just copy the file(s) to where you want.

By default, all targets are built, including the library and programs. `make
help` shows the available targets. There are also several options which can be
Expand Down
14 changes: 5 additions & 9 deletions common/common_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,11 @@ typedef size_t machine_word_t;
/* Miscellaneous macros */
/* ========================================================================== */

#define ARRAY_LEN(A) (sizeof(A) / sizeof((A)[0]))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))
#define MAX(a, b) ((a) >= (b) ? (a) : (b))

#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
# define STATIC_ASSERT(expr) _Static_assert((expr), "")
#else
# define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2 * !(expr)]))
#endif
#define ARRAY_LEN(A) (sizeof(A) / sizeof((A)[0]))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
#define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2 * !(expr)]))

/* ========================================================================== */
/* Endianness handling */
Expand Down
2 changes: 1 addition & 1 deletion tools/make-windows-releases
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eu

for arch in 'i686' 'x86_64'; do
make -j CC=${arch}-w64-mingw32-gcc
make -j CC=${arch}-w64-mingw32-gcc CFLAGS="-Werror"
dir=xpack-$(git describe --tags | tr -d v)-windows-${arch}-bin
rm -rf $dir ${dir}.zip
mkdir $dir
Expand Down

0 comments on commit fdc8aaa

Please sign in to comment.