Skip to content

Commit

Permalink
Fix compiler/linker flags handling
Browse files Browse the repository at this point in the history
- Make flags always overridable by user ({C,LD}FLAGS ?=)
- Move customizable bits (-O, -g) into default CFLAGS/LDFLAGS, and leave mandatory ones in BASIC_{C,LD}FLAGS
- Apply BASIC_{C,LD}FLAGS before {C,LD}FLAGS, because the latter may
  contain e.g. additional -I/-L paths and these should come after local
  ones such as -I./argparse
  • Loading branch information
AMDmi3 committed Jul 8, 2016
1 parent 6ac9ae3 commit c83c08c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions Makefile
Expand Up @@ -7,7 +7,7 @@ all::

### Defaults

BASIC_CFLAGS = -O2 -std=c99 -Wall -I./argparse
BASIC_CFLAGS = -std=c99 -Wall -I./argparse
BASIC_LDFLAGS = -lm -lsodium

# Guard against environment variables
Expand All @@ -29,13 +29,13 @@ uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')

# CFLAGS and LDFLAGS are for users to override
CFLAGS = -g -O2 -Wall
LDFLAGS =
CFLAGS ?= -g -O2 -Wall
LDFLAGS ?=
STRIP ?= strip

# We use ALL_* variants
ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
ALL_LDFLAGS = $(LDFLAGS) $(BASIC_LDFLAGS)
ALL_CFLAGS = $(BASIC_CFLAGS) $(CFLAGS)
ALL_LDFLAGS = $(BASIC_LDFLAGS) $(LDFLAGS)

ifdef PREFIX
prefix = $(PREFIX)
Expand Down
9 changes: 6 additions & 3 deletions argparse/Makefile
@@ -1,10 +1,13 @@
# Defaults
BASIC_CFLAGS = -Wall -O3 -g -ggdb -fPIC
CFLAGS ?= -O3 -g -ggdb
LDFLAGS ?=

BASIC_CFLAGS = -Wall -fPIC
BASIC_LDFLAGS = -lm

# We use ALL_* variants
ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
ALL_LDFLAGS = $(LDFLAGS) $(BASIC_LDFLAGS)
ALL_CFLAGS = $(BASIC_CFLAGS) $(CFLAGS)
ALL_LDFLAGS = $(BASIC_LDFLAGS) $(LDFLAGS)

LIBNAME=libargparse

Expand Down

0 comments on commit c83c08c

Please sign in to comment.