Convert any file into a PNG and back!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.1 KiB

3 months ago
### OCTAPNG MAKEFILE ###
.POSIX:
#.
#. --- USAGE
#.
#. make [OPTIONS] [TARGETS]
#.
#. --- OPTIONS
#.
#. builddir=BUILDDIR Compiled binary path. (default=.)
#. exename=EXENAME Compiled binary name. (default=octapng)
#. exeprfx=EXEPRFX Compiled binary prefix.
#. exesufx=EXESUFX Compiled binary extension.
#. objsufx=OBJSUFX Compiled object extension. (default=.o)
#.
#. prefix=PREFIX Installation path. (default=/usr/local)
#. Uppercase `PREFIX=...` also works.
3 months ago
#. bindir=BINDIR Installed binary path. (default=PREFIX/bin)
#. datadir=DATADIR Installed data path. (default=PREFIX/share)
#. mandir=MANDIR Installed manuals path. (default=DATADIR/man)
3 months ago
#. man1dir=MAN1DIR Installed man1 path. (default=MANDIR/man1)
#. DESTDIR=DESTDIR Staged installation path.
#. If used, PREFIX must start with a `/` .
3 months ago
#.
#. warnings=... Additional warning flags.
#. cflags=... Additional general compiler flags.
#. ldflags=... Additional general linker flags.
#. cflibs=... Additional library compiler flags.
#. ldlibs=... Additional library linker flags.
#.
#. --- ADVANCED OPTIONS
#.
#. CC=... Compiler command. (default=gcc)
#. CCPRFX=... Compiler command prefix.
#.
#. WARNINGS=... Overwrite warning flags.
#. CFLAGS=... Overwrite general compiler flags.
#. LDFLAGS=... Overwrite general linker flags.
#. CFLIBS=... Overwrite library compiler flags.
#. LDLIBS=... Overwrite library linker flags.
#.
#. CFLIBS_NOPC=... Overwrite library compiler flags for
#. targets `nopc` and `nopc_basic`.
#. LDLIBS_NOPC=... Overwrite library linker flags for
#. targets `nopc` and `nopc_basic`.
#.
#. --- TARGETS
#.
#. all Compile program. (default)
#. nopc Compile program without `pkg-config`.
#. nopc_basic Compile program without `pkg-config` in
#. non-POSIX environments. (ignores BUILDDIR)
#.
#. clean Delete compiled program.
#. install Install compiled program into PREFIX.
#. uninstall Delete installed program from PREFIX.
#.
### OPTIONS ###
# build files & dirs
builddir=.
exename=octapng
exeprfx=
exesufx=
objsufx=.o
# install dirs
DESTDIR=
PREFIX=/usr/local
prefix=$(PREFIX)
3 months ago
bindir=$(prefix)/bin
datadir=$(prefix)/share
mandir=$(datadir)/man
3 months ago
man1dir=$(mandir)/man1
# compiler
CC=gcc
CCPRFX=
# compilation flags
WARNINGS=-W -Wall -Wconversion -Wshadow -Wcast-qual -Wwrite-strings \
-Wunused-result $(warnings)
3 months ago
CFLAGS=-ansi -pedantic -O1 $(cflags)
LDFLAGS=-static $(ldflags)
# library flags
CFLIBS=`pkg-config --cflags libpng zlib` $(cflibs)
LDLIBS=`pkg-config --libs libpng zlib` -lm $(ldlibs)
CFLIBS_NOPC=-Iinclude -Llib $(cflibs)
LDLIBS_NOPC=-lpng -lz -lm $(ldlibs)
### INTERNAL VARS ###
# source
srcdir=src
CFILES=$(srcdir)/octapng.c $(srcdir)/parg.c \
$(srcdir)/enc.c $(srcdir)/dec.c $(srcdir)/ioe.c \
$(srcdir)/crc.c $(srcdir)/ver.c
HFILES=$(srcdir)/opng.h $(srcdir)/opngthis.h \
$(srcdir)/ioe.h $(srcdir)/crc.h $(srcdir)/parg.h
# misc
EXENAME=$(exeprfx)$(exename)$(exesufx)
EXE=$(builddir)/$(EXENAME)
COMMONFLAGS=$(WARNINGS) $(CFLAGS) $(LDFLAGS)
MAN1NAME=octapng.1
MAN1=man/$(MAN1NAME)
### TARGETS ###
all: $(EXE)
$(EXE): $(CFILES)
@mkdir -p $(builddir)
$(CCPRFX)$(CC) $(COMMONFLAGS) $(CFLIBS) \
-o $@ -DEXENAME=\"$(exename)\" $(CFILES) $(LDLIBS)
nopc: $(CFILES)
@mkdir -p $(builddir)
$(CCPRFX)$(CC) $(COMMONFLAGS) $(CFLIBS_NOPC) \
-o $(EXE) -DEXENAME=\"$(exename)\" $(CFILES) $(LDLIBS_NOPC)
nopc_basic: $(CFILES)
$(CCPRFX)$(CC) $(COMMONFLAGS) $(CFLIBS_NOPC) \
-o $(EXENAME) -DEXENAME=\"$(exename)\" $(CFILES) $(LDLIBS_NOPC)
clean:
rm -f $(EXE)
install: all
@mkdir -p "$(DESTDIR)$(bindir)"
@mkdir -p "$(DESTDIR)$(man1dir)"
cp -t "$(DESTDIR)$(bindir)" $(EXE)
cp -t "$(DESTDIR)$(man1dir)" $(MAN1)
3 months ago
uninstall:
rm -f "$(DESTDIR)$(bindir)/$(EXENAME)"
rm -f "$(DESTDIR)$(man1dir)/$(MAN1NAME)"
3 months ago
help:
@cat Makefile | grep "#\."