Makefile 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. #-----------------------------------------------------------------------------#
  2. # PhysicsFS -- A filesystem abstraction.
  3. #
  4. # Please see the file LICENSE in the source's root directory.
  5. # This file written by Ryan C. Gordon.
  6. #-----------------------------------------------------------------------------#
  7. #-----------------------------------------------------------------------------#
  8. # Makefile for building PhysicsFS on Unix-like systems. Follow the
  9. # instructions for editing this file, then run "make" on the command line.
  10. #-----------------------------------------------------------------------------#
  11. #-----------------------------------------------------------------------------#
  12. # Set to your liking.
  13. #-----------------------------------------------------------------------------#
  14. CC = gcc
  15. LINKER = gcc
  16. #-----------------------------------------------------------------------------#
  17. # If this makefile fails to detect Cygwin correctly, or you want to force
  18. # the build process's behaviour, set it to "true" or "false" (w/o quotes).
  19. #-----------------------------------------------------------------------------#
  20. #cygwin := true
  21. #cygwin := false
  22. cygwin := autodetect
  23. #-----------------------------------------------------------------------------#
  24. # Set this to true if you want to create a debug build.
  25. #-----------------------------------------------------------------------------#
  26. #debugging := false
  27. debugging := true
  28. #-----------------------------------------------------------------------------#
  29. # Set the archive types you'd like to support.
  30. # Note that various archives may need external libraries.
  31. #-----------------------------------------------------------------------------#
  32. use_archive_zip := false
  33. use_archive_grp := true
  34. #-----------------------------------------------------------------------------#
  35. # Set to "true" if you'd like to build a DLL. Set to "false" otherwise.
  36. #-----------------------------------------------------------------------------#
  37. #build_dll := false
  38. build_dll := true
  39. #-----------------------------------------------------------------------------#
  40. # Set one of the below. Currently, none of these are used.
  41. #-----------------------------------------------------------------------------#
  42. #use_asm = -DUSE_I386_ASM
  43. use_asm = -DUSE_PORTABLE_C
  44. #-----------------------------------------------------------------------------#
  45. #-----------------------------------------------------------------------------#
  46. #-----------------------------------------------------------------------------#
  47. #-----------------------------------------------------------------------------#
  48. # Everything below this line is probably okay.
  49. #-----------------------------------------------------------------------------#
  50. #-----------------------------------------------------------------------------#
  51. #-----------------------------------------------------------------------------#
  52. #-----------------------------------------------------------------------------#
  53. #-----------------------------------------------------------------------------#
  54. # CygWin autodetect.
  55. #-----------------------------------------------------------------------------#
  56. ifeq ($(strip $(cygwin)),autodetect)
  57. ifneq ($(strip $(shell gcc -v 2>&1 |grep "cygwin")),)
  58. cygwin := true
  59. else
  60. cygwin := false
  61. endif
  62. endif
  63. #-----------------------------------------------------------------------------#
  64. # Platform-specific binary stuff.
  65. #-----------------------------------------------------------------------------#
  66. ifeq ($(strip $(cygwin)),true)
  67. # !!! FIXME
  68. build_dll := false
  69. # !!! FIXME
  70. ASM = nasmw
  71. EXE_EXT = .exe
  72. DLL_EXT = .dll
  73. STATICLIB_EXT = .a
  74. ASMOBJFMT = win32
  75. ASMDEFS = -dC_IDENTIFIERS_UNDERSCORED
  76. CFLAGS += -DC_IDENTIFIERS_UNDERSCORED
  77. else
  78. ASM = nasm
  79. EXE_EXT =
  80. DLL_EXT = .so
  81. STATICLIB_EXT = .a
  82. ASMOBJFMT = elf
  83. endif
  84. ifeq ($(strip $(build_dll)),true)
  85. LIB_EXT := $(DLL_EXT)
  86. LDFLAGS += -shared
  87. else
  88. LIB_EXT := $(STATICLIB_EXT)
  89. endif
  90. #-----------------------------------------------------------------------------#
  91. # General compiler, assembler, and linker flags.
  92. #-----------------------------------------------------------------------------#
  93. BINDIR := bin
  94. SRCDIR := .
  95. CFLAGS += $(use_asm) -I$(SRCDIR) -D_REENTRANT -fsigned-char -DPLATFORM_UNIX
  96. CFLAGS += -Wall -Werror -fno-exceptions -fno-rtti -ansi -pedantic
  97. LDFLAGS += -lm
  98. ifeq ($(strip $(debugging)),true)
  99. CFLAGS += -DDEBUG -g -fno-omit-frame-pointer
  100. LDFLAGS += -g -fno-omit-frame-pointer
  101. else
  102. CFLAGS += -DNDEBUG -O2 -fomit-frame-pointer
  103. LDFLAGS += -O2 -fomit-frame-pointer
  104. endif
  105. ASMFLAGS := -f $(ASMOBJFMT) $(ASMDEFS)
  106. #-----------------------------------------------------------------------------#
  107. # Source and target names.
  108. #-----------------------------------------------------------------------------#
  109. BASELIBNAME := physfs
  110. MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
  111. MAINSRCS := physfs.c platform/unix.c archivers/dir.c
  112. ifeq ($(strip $(use_archive_zip)),true)
  113. MAINSRCS += archivers/zip.c
  114. CFLAGS += -DPHYSFS_SUPPORTS_ZIP
  115. endif
  116. # Rule for getting list of objects from source
  117. MAINOBJS1 := $(MAINSRCS:.c=.o)
  118. MAINOBJS2 := $(MAINOBJS1:.cpp=.o)
  119. MAINOBJS3 := $(MAINOBJS2:.asm=.o)
  120. MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f))
  121. MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f))
  122. CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \
  123. $(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \
  124. $(wildcard *~) $(wildcard *.err) \
  125. $(wildcard .\#*) core
  126. #-----------------------------------------------------------------------------#
  127. # Rules.
  128. #-----------------------------------------------------------------------------#
  129. # Rules for turning source files into .o files
  130. $(BINDIR)/%.o: $(SRCDIR)/%.cpp
  131. $(CC) -c -o $@ $< $(CFLAGS)
  132. $(BINDIR)/%.o: $(SRCDIR)/%.c
  133. $(CC) -c -o $@ $< $(CFLAGS)
  134. $(BINDIR)/%.o: $(SRCDIR)/%.asm
  135. $(ASM) $(ASMFLAGS) -o $@ $<
  136. .PHONY: all clean distclean listobjs
  137. all: $(BINDIR) $(MAINLIB)
  138. $(MAINLIB) : $(BINDIR) $(MAINOBJS)
  139. $(LINKER) -o $(MAINLIB) $(LDFLAGS) $(MAINOBJS)
  140. $(BINDIR):
  141. mkdir -p $(BINDIR)
  142. mkdir -p $(BINDIR)/archivers
  143. mkdir -p $(BINDIR)/platform
  144. distclean: clean
  145. clean:
  146. rm -f $(CLEANUP)
  147. rm -rf $(BINDIR)
  148. listobjs:
  149. @echo SOURCES:
  150. @echo $(MAINSRCS)
  151. @echo
  152. @echo OBJECTS:
  153. @echo $(MAINOBJS)
  154. @echo
  155. @echo BINARIES:
  156. @echo $(MAINLIB)
  157. showcfg:
  158. @echo "Using CygWin : $(cygwin)"
  159. @echo "Debugging : $(debugging)"
  160. @echo "ASM flag : $(use_asm)"
  161. @echo "Building DLLs : $(build_dll)"
  162. @echo "Supports .ZIP : $(use_archive_zip)"
  163. #-----------------------------------------------------------------------------#
  164. # This section is pretty much just for Ryan's use to make distributions.
  165. # You Probably Should Not Touch.
  166. #-----------------------------------------------------------------------------#
  167. # These are the files needed in a binary distribution, regardless of what
  168. # platform is being used.
  169. BINSCOMMON := LICENSE.TXT physfs.h
  170. .PHONY: package msbins win32bins nocygwin
  171. package: clean
  172. cd .. ; zip -9rz ./physfs-src-$(shell date +%m%d%Y).zip physfs -x "*CVS*" < physfs/FILEID.DIZ
  173. ifeq ($(strip $(cygwin)),true)
  174. msbins: win32bins
  175. win32bins: clean all
  176. 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@linuxgames.com)\r\n\r\n" |zip -9rz ../physfs-win32bins-$(shell date +%m%d%Y).zip $(MAINLIB) $(EXTRAPACKAGELIBS) README-win32bins.txt
  177. else
  178. msbins: nocygwin
  179. win32bins: nocygwin
  180. nocygwin:
  181. @echo This must be done on a Windows box in the Cygwin environment.
  182. endif
  183. #-----------------------------------------------------------------------------#
  184. # That's all, folks.
  185. #-----------------------------------------------------------------------------#
  186. # end of Makefile ...