Makefile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. #-----------------------------------------------------------------------------#
  34. # Set to "true" if you'd like to build a DLL. Set to "false" otherwise.
  35. #-----------------------------------------------------------------------------#
  36. #build_dll := false
  37. build_dll := true
  38. #-----------------------------------------------------------------------------#
  39. # Set one of the below. Currently, none of these are used.
  40. #-----------------------------------------------------------------------------#
  41. #use_asm = -DUSE_I386_ASM
  42. use_asm = -DUSE_PORTABLE_C
  43. #-----------------------------------------------------------------------------#
  44. #-----------------------------------------------------------------------------#
  45. #-----------------------------------------------------------------------------#
  46. #-----------------------------------------------------------------------------#
  47. # Everything below this line is probably okay.
  48. #-----------------------------------------------------------------------------#
  49. #-----------------------------------------------------------------------------#
  50. #-----------------------------------------------------------------------------#
  51. #-----------------------------------------------------------------------------#
  52. #-----------------------------------------------------------------------------#
  53. # CygWin autodetect.
  54. #-----------------------------------------------------------------------------#
  55. ifeq ($(strip $(cygwin)),autodetect)
  56. ifneq ($(strip $(shell gcc -v 2>&1 |grep "cygwin")),)
  57. cygwin := true
  58. else
  59. cygwin := false
  60. endif
  61. endif
  62. #-----------------------------------------------------------------------------#
  63. # Platform-specific binary stuff.
  64. #-----------------------------------------------------------------------------#
  65. ifeq ($(strip $(cygwin)),true)
  66. # !!! FIXME
  67. build_dll := false
  68. # !!! FIXME
  69. ASM = nasmw
  70. EXE_EXT = .exe
  71. DLL_EXT = .dll
  72. STATICLIB_EXT = .a
  73. ASMOBJFMT = win32
  74. ASMDEFS = -dC_IDENTIFIERS_UNDERSCORED
  75. CFLAGS += -DC_IDENTIFIERS_UNDERSCORED
  76. else
  77. ASM = nasm
  78. EXE_EXT =
  79. DLL_EXT = .so
  80. STATICLIB_EXT = .a
  81. ASMOBJFMT = elf
  82. endif
  83. ifeq ($(strip $(build_dll)),true)
  84. LIB_EXT := $(DLL_EXT)
  85. LDFLAGS += -shared
  86. else
  87. LIB_EXT := $(STATICLIB_EXT)
  88. endif
  89. #-----------------------------------------------------------------------------#
  90. # General compiler, assembler, and linker flags.
  91. #-----------------------------------------------------------------------------#
  92. BINDIR := bin
  93. SRCDIR := .
  94. CFLAGS += $(use_asm) -I$(SRCDIR) -D_REENTRANT -fsigned-char -DPLATFORM_UNIX
  95. CFLAGS += -Wall -Werror -fno-exceptions -fno-rtti -ansi -pendantic
  96. LDFLAGS += -lm
  97. ifeq ($(strip $(debugging)),true)
  98. CFLAGS += -DDEBUG -g -fno-omit-frame-pointer
  99. LDFLAGS += -g -fno-omit-frame-pointer
  100. else
  101. CFLAGS += -DNDEBUG -O2 -fomit-frame-pointer
  102. LDFLAGS += -O2 -fomit-frame-pointer
  103. endif
  104. ASMFLAGS := -f $(ASMOBJFMT) $(ASMDEFS)
  105. #-----------------------------------------------------------------------------#
  106. # Source and target names.
  107. #-----------------------------------------------------------------------------#
  108. BASELIBNAME := physfs
  109. MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
  110. MAINSRCS := physfs.c unix.c dir.c
  111. ifeq ($(strip $(use_archive_zip)),true)
  112. MAINSRCS += zip.c
  113. CFLAGS += -DPHYSFS_SUPPORTS_ZIP
  114. endif
  115. # Rule for getting list of objects from source
  116. MAINOBJS1 := $(MAINSRCS:.c=.o)
  117. MAINOBJS2 := $(MAINOBJS1:.cpp=.o)
  118. MAINOBJS3 := $(MAINOBJS2:.asm=.o)
  119. MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f))
  120. MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f))
  121. CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \
  122. $(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \
  123. $(wildcard *~) $(wildcard *.err) \
  124. $(wildcard .\#*) core
  125. #-----------------------------------------------------------------------------#
  126. # Rules.
  127. #-----------------------------------------------------------------------------#
  128. # Rules for turning source files into .o files
  129. $(BINDIR)/%.o: $(SRCDIR)/%.cpp
  130. $(CC) -c -o $@ $< $(CFLAGS)
  131. $(BINDIR)/%.o: $(SRCDIR)/%.c
  132. $(CC) -c -o $@ $< $(CFLAGS)
  133. $(BINDIR)/%.o: $(SRCDIR)/%.asm
  134. $(ASM) $(ASMFLAGS) -o $@ $<
  135. .PHONY: all clean listobjs
  136. all: $(BINDIR) $(MAINLIB)
  137. $(MAINLIB) : $(BINDIR) $(MAINOBJS)
  138. $(LINKER) -o $(MAINLIB) $(LDFLAGS) $(MAINOBJS)
  139. $(BINDIR):
  140. mkdir -p $(BINDIR)
  141. clean:
  142. rm -f $(CLEANUP)
  143. rm -rf $(BINDIR)
  144. listobjs:
  145. @echo SOURCES:
  146. @echo $(MAINSRCS)
  147. @echo
  148. @echo OBJECTS:
  149. @echo $(MAINOBJS)
  150. @echo
  151. @echo BINARIES:
  152. @echo $(MAINLIB)
  153. showcfg:
  154. @echo "Using CygWin : $(cygwin)"
  155. @echo "Debugging : $(debugging)"
  156. @echo "ASM flag : $(use_asm)"
  157. @echo "Building DLLs : $(build_dll)"
  158. @echo "Supports .ZIP : $(use_archive_zip)"
  159. #-----------------------------------------------------------------------------#
  160. # This section is pretty much just for Ryan's use to make distributions.
  161. # You Probably Should Not Touch.
  162. #-----------------------------------------------------------------------------#
  163. # These are the files needed in a binary distribution, regardless of what
  164. # platform is being used.
  165. BINSCOMMON := LICENSE.TXT physfs.h
  166. .PHONY: package msbins win32bins nocygwin
  167. package: clean
  168. cd .. ; zip -9rz ./physfs-src-$(shell date +%m%d%Y).zip physfs -x "*CVS*" < physfs/FILEID.DIZ
  169. ifeq ($(strip $(cygwin)),true)
  170. msbins: win32bins
  171. win32bins: clean all
  172. 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
  173. else
  174. msbins: nocygwin
  175. win32bins: nocygwin
  176. nocygwin:
  177. @echo This must be done on a Windows box in the Cygwin environment.
  178. endif
  179. #-----------------------------------------------------------------------------#
  180. # That's all, folks.
  181. #-----------------------------------------------------------------------------#
  182. # end of Makefile ...