Makefile++

This commit is contained in:
Mathias Panzenböck 2013-01-06 06:21:09 +01:00
parent ee685f6f32
commit f99838ec24
2 changed files with 34 additions and 15 deletions

View File

@ -1,5 +1,5 @@
PREFIX=/usr/local
TARGET=posix
TARGET=$(shell uname|tr '[A-Z]' '[a-z]')$(shell getconf LONG_BIT)
INCLUDE=
LIBDIRS=
LIBS=
@ -25,30 +25,49 @@ OBJ=\
CC=gcc
LD=$(CC)
COMMON_CFLAGS=-Wall -Werror -Wextra -std=gnu99 -O2 -g $(INCLUDE) $(LIBDIRS) -D_FILE_OFFSET_BITS=64
CFLAGS=$(COMMON_CFLAGS) -pedantic
POSIX_CFLAGS=$(COMMON_CFLAGS) -pedantic
CFLAGS=$(POSIX_CFLAGS)
WINDOWS_CFLAGS=$(COMMON_CFLAGS) -DWINVER=0x500
WINDOWS_LIBS=-lws2_32 -liberty
APPNAME=audioextract
BIN=$(BUILDDIR)/$(APPNAME)
ifeq ($(TARGET),win32)
PLATFORM=windows
CC=i686-pc-mingw32-gcc
CFLAGS=$(COMMON_CFLAGS) -m32 -DWINVER=0x500
LIBS=-lws2_32 -liberty
CFLAGS=$(WINDOWS_CFLAGS) -m32
LDFLAGS=-m32
LIBS=$(WINDOWS_LIBS)
APPNAME=audioextract.exe
else
ifeq ($(TARGET),win64)
PLATFORM=windows
CC=x86_64-w64-mingw32-gcc
CFLAGS=$(COMMON_CFLAGS) -m64 -DWINVER=0x500
LIBS=-lws2_32 -liberty
APPNAME=audioextract64.exe
CFLAGS=$(WINDOWS_CFLAGS) -m64
LDFLAGS=-m64
LIBS=$(WINDOWS_LIBS)
else
ifeq ($(TARGET),linux32)
CFLAGS=$(POSIX_CFLAGS) -m32
LDFLAGS=-m32
else
ifeq ($(TARGET),linux64)
CFLAGS=$(POSIX_CFLAGS) -m64
LDFLAGS=-m64
endif
endif
endif
endif
.PHONY: all clean install uninstall
.PHONY: all clean install uninstall builddir
all: $(BIN)
builddir: $(BUILDDIR)
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(BIN): $(OBJ)
$(LD) $(LIBDIRS) $(LDFLAGS) $(OBJ) -o $@ $(LIBS)

View File

@ -6,18 +6,18 @@ Extract audio files that are embedded within other files.
Setup
-----
mkdir build-posix
make builddir
make
make install PREFIX=/usr
Cross compile for Windows:
Cross compile for Windows (uses `i686-pc-mingw32-gcc`):
mkdir build-win32
make TARGET=win32 builddir
make TARGET=win32
Or:
Or (uses `x86_64-w64-mingw32-gcc`):
mkdir build-win64
make TARGET=win64 builddir
make TARGET=win64
**NOTE:** 32bit binaries can only process 2 GB of a file at once. The rest of
@ -28,8 +28,8 @@ This also means that using a 32bit binary extracted files can never be larger
than 2 GB.
This is because `audioextract` uses `mmap` to read files, wich maps files to
memory. On 32bit the address space of the main memory is simply not big enough.
64bit binaries can read up to 8 EB (8 Exabytes) at once.
memory. On 32bit platforms the address space of the main memory is simply not
big enough. 64bit binaries can read up to 8 EB (8 Exabytes) at once.
Usage
-----