physfs/Makefile

309 lines
10 KiB
Makefile
Raw Normal View History

2001-07-06 04:32:29 +02:00
#-----------------------------------------------------------------------------#
# PhysicsFS -- A filesystem abstraction.
#
# Please see the file LICENSE in the source's root directory.
# This file written by Ryan C. Gordon.
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Makefile for building PhysicsFS on Unix-like systems. Follow the
# instructions for editing this file, then run "make" on the command line.
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Set to your liking.
#-----------------------------------------------------------------------------#
CC = gcc
LINKER = gcc
#-----------------------------------------------------------------------------#
# If this makefile fails to detect Cygwin correctly, or you want to force
# the build process's behaviour, set it to "true" or "false" (w/o quotes).
#-----------------------------------------------------------------------------#
#cygwin := true
#cygwin := false
cygwin := autodetect
#-----------------------------------------------------------------------------#
# Set this to true if you want to create a debug build.
#-----------------------------------------------------------------------------#
#debugging := false
debugging := true
#-----------------------------------------------------------------------------#
# Set the archive types you'd like to support.
# Note that various archives may need external libraries.
#-----------------------------------------------------------------------------#
2001-07-23 06:45:26 +02:00
use_archive_zip := true
use_archive_grp := true
2001-07-06 04:32:29 +02:00
#-----------------------------------------------------------------------------#
# Set to "true" if you'd like to build a DLL. Set to "false" otherwise.
#-----------------------------------------------------------------------------#
#build_dll := false
build_dll := true
#-----------------------------------------------------------------------------#
# Set one of the below. Currently, none of these are used.
#-----------------------------------------------------------------------------#
#use_asm = -DUSE_I386_ASM
use_asm = -DUSE_PORTABLE_C
2001-08-01 12:20:56 +02:00
#-----------------------------------------------------------------------------#
# Set this to where you want PhysicsFS installed. It will put the
# files in $(install_prefix)/bin, $(install_prefix)/lib, and
# $(install_prefix)/include ...
#-----------------------------------------------------------------------------#
install_prefix := /usr/local
2001-07-06 04:32:29 +02:00
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Everything below this line is probably okay.
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# CygWin autodetect.
#-----------------------------------------------------------------------------#
ifeq ($(strip $(cygwin)),autodetect)
ifneq ($(strip $(shell gcc -v 2>&1 |grep "cygwin")),)
cygwin := true
else
cygwin := false
endif
endif
#-----------------------------------------------------------------------------#
# Platform-specific binary stuff.
#-----------------------------------------------------------------------------#
ifeq ($(strip $(cygwin)),true)
# !!! FIXME
build_dll := false
# !!! FIXME
ASM = nasmw
EXE_EXT = .exe
DLL_EXT = .dll
STATICLIB_EXT = .a
ASMOBJFMT = win32
ASMDEFS = -dC_IDENTIFIERS_UNDERSCORED
CFLAGS += -DC_IDENTIFIERS_UNDERSCORED
else
ASM = nasm
EXE_EXT =
DLL_EXT = .so
STATICLIB_EXT = .a
ASMOBJFMT = elf
endif
ifeq ($(strip $(build_dll)),true)
LIB_EXT := $(DLL_EXT)
2001-07-15 20:55:19 +02:00
SHAREDFLAGS += -shared
2001-07-06 04:32:29 +02:00
else
LIB_EXT := $(STATICLIB_EXT)
endif
2001-08-01 12:20:56 +02:00
#-----------------------------------------------------------------------------#
# Version crapola.
#-----------------------------------------------------------------------------#
VERMAJOR := $(shell grep "define PHYSFS_VER_MAJOR" physfs.h | sed "s/\#define PHYSFS_VER_MAJOR //")
VERMINOR := $(shell grep "define PHYSFS_VER_MINOR" physfs.h | sed "s/\#define PHYSFS_VER_MINOR //")
VERPATCH := $(shell grep "define PHYSFS_VER_PATCH" physfs.h | sed "s/\#define PHYSFS_VER_PATCH //")
VERMAJOR := $(strip $(VERMAJOR))
VERMINOR := $(strip $(VERMINOR))
VERPATCH := $(strip $(VERPATCH))
VERFULL := $(VERMAJOR).$(VERMINOR).$(VERPATCH)
2001-07-06 04:32:29 +02:00
#-----------------------------------------------------------------------------#
# General compiler, assembler, and linker flags.
#-----------------------------------------------------------------------------#
BINDIR := bin
SRCDIR := .
CFLAGS += $(use_asm) -I$(SRCDIR) -I/usr/include/readline -D_REENTRANT -fsigned-char -DPLATFORM_UNIX
2001-07-07 05:46:48 +02:00
CFLAGS += -Wall -Werror -fno-exceptions -fno-rtti -ansi -pedantic
2001-07-06 04:32:29 +02:00
LDFLAGS += -lm
ifeq ($(strip $(debugging)),true)
CFLAGS += -DDEBUG -g -fno-omit-frame-pointer
LDFLAGS += -g -fno-omit-frame-pointer
else
CFLAGS += -DNDEBUG -O2 -fomit-frame-pointer
LDFLAGS += -O2 -fomit-frame-pointer
endif
ASMFLAGS := -f $(ASMOBJFMT) $(ASMDEFS)
TESTLDFLAGS := -lreadline
2001-07-06 04:32:29 +02:00
#-----------------------------------------------------------------------------#
# Source and target names.
#-----------------------------------------------------------------------------#
BASELIBNAME := physfs
2001-08-01 12:20:56 +02:00
ifneq ($(strip $(cygwin)),true)
BASELIBNAME := lib$(strip $(BASELIBNAME))
endif
2001-07-06 04:32:29 +02:00
MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
2001-07-15 20:55:19 +02:00
TESTSRCS := test/test_physfs.c
2001-07-07 10:28:51 +02:00
MAINSRCS := physfs.c platform/unix.c archivers/dir.c
2001-07-06 04:32:29 +02:00
ifeq ($(strip $(use_archive_zip)),true)
2001-07-23 06:45:26 +02:00
MAINSRCS += archivers/zip.c archivers/unzip.c
2001-07-06 04:32:29 +02:00
CFLAGS += -DPHYSFS_SUPPORTS_ZIP
2001-07-23 06:45:26 +02:00
LDFLAGS += -lz
2001-07-06 04:32:29 +02:00
endif
ifeq ($(strip $(use_archive_grp)),true)
MAINSRCS += archivers/grp.c
CFLAGS += -DPHYSFS_SUPPORTS_GRP
endif
2001-07-15 20:55:19 +02:00
TESTEXE := $(BINDIR)/test_physfs$(EXE_EXT)
2001-07-06 04:32:29 +02:00
# Rule for getting list of objects from source
MAINOBJS1 := $(MAINSRCS:.c=.o)
MAINOBJS2 := $(MAINOBJS1:.cpp=.o)
MAINOBJS3 := $(MAINOBJS2:.asm=.o)
MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f))
MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f))
2001-07-15 20:55:19 +02:00
TESTOBJS1 := $(TESTSRCS:.c=.o)
TESTOBJS2 := $(TESTOBJS1:.cpp=.o)
TESTOBJS3 := $(TESTOBJS2:.asm=.o)
TESTOBJS := $(foreach f,$(TESTOBJS3),$(BINDIR)/$(f))
TESTSRCS := $(foreach f,$(TESTSRCS),$(SRCDIR)/$(f))
2001-07-06 04:32:29 +02:00
CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \
$(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \
$(wildcard *~) $(wildcard *.err) \
$(wildcard .\#*) core
#-----------------------------------------------------------------------------#
# Rules.
#-----------------------------------------------------------------------------#
# Rules for turning source files into .o files
$(BINDIR)/%.o: $(SRCDIR)/%.cpp
$(CC) -c -o $@ $< $(CFLAGS)
$(BINDIR)/%.o: $(SRCDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS)
$(BINDIR)/%.o: $(SRCDIR)/%.asm
$(ASM) $(ASMFLAGS) -o $@ $<
2001-08-01 12:20:56 +02:00
.PHONY: all clean distclean listobjs install
2001-07-06 04:32:29 +02:00
2001-07-15 20:55:19 +02:00
all: $(BINDIR) $(MAINLIB) $(TESTEXE)
2001-07-06 04:32:29 +02:00
$(MAINLIB) : $(BINDIR) $(MAINOBJS)
2001-07-15 20:55:19 +02:00
$(LINKER) -o $(MAINLIB) $(LDFLAGS) $(SHAREDFLAGS) $(MAINOBJS)
$(TESTEXE) : $(MAINLIB) $(TESTOBJS)
$(LINKER) -o $(TESTEXE) $(LDFLAGS) $(TESTLDFLAGS) $(TESTOBJS) $(MAINLIB)
2001-07-15 20:55:19 +02:00
2001-07-06 04:32:29 +02:00
2001-08-01 12:20:56 +02:00
install: all
mkdir -p $(install_prefix)/bin
mkdir -p $(install_prefix)/lib
mkdir -p $(install_prefix)/include
cp $(SRCDIR)/physfs.h $(install_prefix)/include
cp $(TESTEXE) $(install_prefix)/bin
ifeq ($(strip $(cygwin)),true)
cp $(MAINLIB) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
else
cp $(MAINLIB) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL))
ln -sf $(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL)) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
ln -sf $(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL)) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERMAJOR))
chmod 0755 $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL))
chmod 0644 $(install_prefix)/include/physfs.h
endif
2001-07-06 04:32:29 +02:00
$(BINDIR):
mkdir -p $(BINDIR)
mkdir -p $(BINDIR)/archivers
2001-07-07 10:28:51 +02:00
mkdir -p $(BINDIR)/platform
2001-07-15 20:55:19 +02:00
mkdir -p $(BINDIR)/test
2001-07-06 04:32:29 +02:00
distclean: clean
2001-07-06 04:32:29 +02:00
clean:
rm -f $(CLEANUP)
rm -rf $(BINDIR)
listobjs:
@echo SOURCES:
@echo $(MAINSRCS)
@echo
@echo OBJECTS:
@echo $(MAINOBJS)
@echo
@echo BINARIES:
@echo $(MAINLIB)
showcfg:
@echo "Using CygWin : $(cygwin)"
@echo "Debugging : $(debugging)"
@echo "ASM flag : $(use_asm)"
@echo "Building DLLs : $(build_dll)"
2001-08-01 12:20:56 +02:00
@echo "Install prefix : $(install_prefix)"
@echo "PhysFS version : $(VERFULL)"
2001-07-06 04:32:29 +02:00
@echo "Supports .ZIP : $(use_archive_zip)"
#-----------------------------------------------------------------------------#
# This section is pretty much just for Ryan's use to make distributions.
# You Probably Should Not Touch.
#-----------------------------------------------------------------------------#
# These are the files needed in a binary distribution, regardless of what
# platform is being used.
BINSCOMMON := LICENSE.TXT physfs.h
.PHONY: package msbins win32bins nocygwin
package: clean
2001-08-01 12:20:56 +02:00
cd .. ; mv physfs physfs-$(VERFULL) ; tar -cyvvf ./physfs-$(VERFULL).tar.bz2 --exclude="*CVS*" physfs-$(VERFULL) ; mv physfs-$(VERFULL) physfs
2001-07-06 04:32:29 +02:00
ifeq ($(strip $(cygwin)),true)
msbins: win32bins
win32bins: clean all
2001-08-07 04:56:50 +02:00
echo -e "\r\n\r\n\r\nHEY YOU.\r\n\r\n\r\nTake a look at README-win32bins.txt FIRST.\r\n\r\n\r\n--ryan. (icculus@clutteredmind.org)\r\n\r\n" |zip -9rz ../physfs-win32bins-$(shell date +%m%d%Y).zip $(MAINLIB) $(EXTRAPACKAGELIBS) README-win32bins.txt
2001-07-06 04:32:29 +02:00
else
msbins: nocygwin
win32bins: nocygwin
nocygwin:
@echo This must be done on a Windows box in the Cygwin environment.
endif
#-----------------------------------------------------------------------------#
# That's all, folks.
#-----------------------------------------------------------------------------#
# end of Makefile ...