Refactor Makefile
Declare it as POSIX-compliant Use $() instead of ${} Separate stock CFLAGS from user CFLAGS
This commit is contained in:
parent
25ee995ead
commit
e32415744c
53
Makefile
53
Makefile
@ -1,50 +1,49 @@
|
||||
# See LICENSE file for copyright and license details.
|
||||
.POSIX:
|
||||
|
||||
include config.mk
|
||||
|
||||
SRC = ii.c strlcpy.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
IICFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE $(CFLAGS)
|
||||
|
||||
all: ii
|
||||
|
||||
options:
|
||||
@echo ii build options:
|
||||
@echo "CFLAGS = ${CFLAGS}"
|
||||
@echo "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
|
||||
.o:
|
||||
$(LD) -o $@ $< $(LDFLAGS)
|
||||
@echo "CFLAGS = $(IICFLAGS)"
|
||||
@echo "LDFLAGS = $(LDFLAGS)"
|
||||
@echo "CC = $(CC)"
|
||||
|
||||
.c.o:
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
$(CC) $(IICFLAGS) -c $<
|
||||
|
||||
ii: ${OBJ}
|
||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
ii: $(OBJ)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
|
||||
${OBJ}: arg.h
|
||||
$(OBJ): arg.h
|
||||
|
||||
install: all
|
||||
mkdir -p ${DESTDIR}${DOCDIR}
|
||||
mkdir -p ${DESTDIR}${BINDIR}
|
||||
mkdir -p ${DESTDIR}${MAN1DIR}
|
||||
install -d ${DESTDIR}${BINDIR} ${DESTDIR}${MAN1DIR}
|
||||
install -m 644 CHANGES README FAQ LICENSE ${DESTDIR}${DOCDIR}
|
||||
install -m 775 ii ${DESTDIR}${BINDIR}
|
||||
sed "s/VERSION/${VERSION}/g" < ii.1 > ${DESTDIR}${MAN1DIR}/ii.1
|
||||
chmod 644 ${DESTDIR}${MAN1DIR}/ii.1
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
||||
mkdir -p $(DESTDIR)$(DOCPREFIX)/ii
|
||||
install -m 644 CHANGES README FAQ LICENSE $(DESTDIR)$(DOCPREFIX)/ii
|
||||
install -m 775 ii $(DESTDIR)$(PREFIX)/bin
|
||||
sed "s/VERSION/$(VERSION)/g" < ii.1 > $(DESTDIR)$(MANPREFIX)/man1/ii.1
|
||||
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/ii.1
|
||||
|
||||
uninstall: all
|
||||
rm -f ${DESTDIR}${MAN1DIR}/ii.1 \
|
||||
${DESTDIR}${BINDIR}/ii
|
||||
rm -rf ${DESTDIR}${DOCDIR}
|
||||
rm -f $(DESTDIR)$(MANPREFIX)/man1/ii.1 $(DESTDIR)$(PREFIX)/bin/ii
|
||||
rm -rf $(DESTDIR)$(DOCPREFIX)/ii
|
||||
|
||||
dist: clean
|
||||
mkdir -p ii-${VERSION}
|
||||
mkdir -p ii-$(VERSION)
|
||||
cp -R Makefile CHANGES README FAQ LICENSE strlcpy.c arg.h \
|
||||
config.mk ii.c ii.1 ii-${VERSION}
|
||||
tar -cf ii-${VERSION}.tar ii-${VERSION}
|
||||
gzip ii-${VERSION}.tar
|
||||
rm -rf ii-${VERSION}
|
||||
config.mk ii.c ii.1 ii-$(VERSION)
|
||||
tar -cf ii-$(VERSION).tar ii-$(VERSION)
|
||||
gzip ii-$(VERSION).tar
|
||||
rm -rf ii-$(VERSION)
|
||||
|
||||
clean:
|
||||
rm -f ii *.o
|
||||
|
24
config.mk
24
config.mk
@ -2,24 +2,10 @@
|
||||
VERSION = 1.8
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
BINDIR = ${PREFIX}/bin
|
||||
MANDIR = ${PREFIX}/share/man
|
||||
MAN1DIR = ${MANDIR}/man1
|
||||
DOCDIR = ${PREFIX}/share/doc/ii
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
DOCPREFIX = ${PREFIX}/share/doc
|
||||
|
||||
# includes and libs
|
||||
INCLUDES = -I. -I/usr/include
|
||||
CFLAGS = -Os
|
||||
LDFLAGS = -s
|
||||
LIBS =
|
||||
|
||||
# compiler
|
||||
CC = cc
|
||||
|
||||
# debug
|
||||
#CFLAGS = -g -O0 -pedantic -Wall ${INCLUDES} -DVERSION=\"${VERSION}\" \
|
||||
# -std=c99 -D_DEFAULT_SOURCE
|
||||
#LDFLAGS = ${LIBS}
|
||||
|
||||
# release
|
||||
CFLAGS = -Os ${INCLUDES} -DVERSION=\"${VERSION}\" -std=c99 -D_DEFAULT_SOURCE
|
||||
LDFLAGS = -s ${LIBS}
|
||||
|
Loading…
Reference in New Issue
Block a user