Makefile
changeset 34 86c247b7be8d
parent 22 49f6101707b4
child 36 60b6076ae5c2
equal deleted inserted replaced
33:313a6bc49a46 34:86c247b7be8d
   101   ASMOBJFMT = elf
   101   ASMOBJFMT = elf
   102 endif
   102 endif
   103 
   103 
   104 ifeq ($(strip $(build_dll)),true)
   104 ifeq ($(strip $(build_dll)),true)
   105 LIB_EXT := $(DLL_EXT)
   105 LIB_EXT := $(DLL_EXT)
   106 LDFLAGS += -shared
   106 SHAREDFLAGS += -shared
   107 else
   107 else
   108 LIB_EXT := $(STATICLIB_EXT)
   108 LIB_EXT := $(STATICLIB_EXT)
   109 endif
   109 endif
   110 
   110 
   111 #-----------------------------------------------------------------------------#
   111 #-----------------------------------------------------------------------------#
   136 #-----------------------------------------------------------------------------#
   136 #-----------------------------------------------------------------------------#
   137 
   137 
   138 BASELIBNAME := physfs
   138 BASELIBNAME := physfs
   139 MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
   139 MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
   140 
   140 
       
   141 TESTSRCS := test/test_physfs.c
       
   142 
   141 MAINSRCS := physfs.c platform/unix.c archivers/dir.c
   143 MAINSRCS := physfs.c platform/unix.c archivers/dir.c
   142 
   144 
   143 ifeq ($(strip $(use_archive_zip)),true)
   145 ifeq ($(strip $(use_archive_zip)),true)
   144 MAINSRCS += archivers/zip.c
   146 MAINSRCS += archivers/zip.c
   145 CFLAGS += -DPHYSFS_SUPPORTS_ZIP
   147 CFLAGS += -DPHYSFS_SUPPORTS_ZIP
   147 
   149 
   148 ifeq ($(strip $(use_archive_grp)),true)
   150 ifeq ($(strip $(use_archive_grp)),true)
   149 MAINSRCS += archivers/grp.c
   151 MAINSRCS += archivers/grp.c
   150 CFLAGS += -DPHYSFS_SUPPORTS_GRP
   152 CFLAGS += -DPHYSFS_SUPPORTS_GRP
   151 endif
   153 endif
       
   154 
       
   155 TESTEXE := $(BINDIR)/test_physfs$(EXE_EXT)
   152 
   156 
   153 # Rule for getting list of objects from source
   157 # Rule for getting list of objects from source
   154 MAINOBJS1 := $(MAINSRCS:.c=.o)
   158 MAINOBJS1 := $(MAINSRCS:.c=.o)
   155 MAINOBJS2 := $(MAINOBJS1:.cpp=.o)
   159 MAINOBJS2 := $(MAINOBJS1:.cpp=.o)
   156 MAINOBJS3 := $(MAINOBJS2:.asm=.o)
   160 MAINOBJS3 := $(MAINOBJS2:.asm=.o)
   157 
       
   158 MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f))
   161 MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f))
   159 MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f))
   162 MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f))
       
   163 
       
   164 TESTOBJS1 := $(TESTSRCS:.c=.o)
       
   165 TESTOBJS2 := $(TESTOBJS1:.cpp=.o)
       
   166 TESTOBJS3 := $(TESTOBJS2:.asm=.o)
       
   167 TESTOBJS := $(foreach f,$(TESTOBJS3),$(BINDIR)/$(f))
       
   168 TESTSRCS := $(foreach f,$(TESTSRCS),$(SRCDIR)/$(f))
   160 
   169 
   161 CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \
   170 CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \
   162           $(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \
   171           $(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \
   163           $(wildcard *~) $(wildcard *.err) \
   172           $(wildcard *~) $(wildcard *.err) \
   164           $(wildcard .\#*) core
   173           $(wildcard .\#*) core
   178 $(BINDIR)/%.o: $(SRCDIR)/%.asm
   187 $(BINDIR)/%.o: $(SRCDIR)/%.asm
   179 	$(ASM) $(ASMFLAGS) -o $@ $<
   188 	$(ASM) $(ASMFLAGS) -o $@ $<
   180 
   189 
   181 .PHONY: all clean distclean listobjs
   190 .PHONY: all clean distclean listobjs
   182 
   191 
   183 all: $(BINDIR) $(MAINLIB)
   192 all: $(BINDIR) $(MAINLIB) $(TESTEXE)
   184 
   193 
   185 $(MAINLIB) : $(BINDIR) $(MAINOBJS)
   194 $(MAINLIB) : $(BINDIR) $(MAINOBJS)
   186 	$(LINKER) -o $(MAINLIB) $(LDFLAGS) $(MAINOBJS)
   195 	$(LINKER) -o $(MAINLIB) $(LDFLAGS) $(SHAREDFLAGS) $(MAINOBJS)
       
   196 
       
   197 $(TESTEXE) : $(MAINLIB) $(TESTOBJS)
       
   198 	$(LINKER) -o $(TESTEXE) $(LDFLAGS) $(TESTOBJS) $(MAINLIB)
       
   199 
   187 
   200 
   188 $(BINDIR):
   201 $(BINDIR):
   189 	mkdir -p $(BINDIR)
   202 	mkdir -p $(BINDIR)
   190 	mkdir -p $(BINDIR)/archivers
   203 	mkdir -p $(BINDIR)/archivers
   191 	mkdir -p $(BINDIR)/platform
   204 	mkdir -p $(BINDIR)/platform
       
   205 	mkdir -p $(BINDIR)/test
   192 
   206 
   193 distclean: clean
   207 distclean: clean
   194 
   208 
   195 clean:
   209 clean:
   196 	rm -f $(CLEANUP)
   210 	rm -f $(CLEANUP)