Skip to content

Commit

Permalink
Build into build/$(CFG) instead of the source tree.
Browse files Browse the repository at this point in the history
This makes multiple configuration files actually useful.
E.g. now you can have a debug build, a release build an a cross-compiled build with MinGW in parallel.

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@4561 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
chmallon committed May 28, 2011
1 parent 2988505 commit 560fefd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
*.d
*.ncb
*.o
*.suo
*.vcproj.*
/Debug
/Release
/build
/config.*
/makeobj/makeobj
/makeobj/makeobj.exe
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ endif
CCFLAGS += $(CFLAGS)
CXXFLAGS += $(CFLAGS)

PROG ?= sim

BUILDDIR ?= build/$(CFG)
PROG ?= sim

include common.mk

Expand Down
26 changes: 15 additions & 11 deletions common.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
DEPS = $(filter %.d, $(SOURCES:%.cc=%.d) $(SOURCES:%.c=%.d) $(SOURCES:%.m=%.d) $(SOURCES:%.mm=%.d))
OBJECTS = $(filter %.o, $(SOURCES:%.cc=%.o) $(SOURCES:%.c=%.o) $(SOURCES:%.m=%.o) $(SOURCES:%.mm=%.o) $(SOURCES:%.rc=%.o))
DEPS := $(patsubst %, $(BUILDDIR)/%.d, $(basename $(filter-out %.rc, $(SOURCES))))
OBJS := $(patsubst %, $(BUILDDIR)/%.o, $(basename $(SOURCES)))
DIRS := $(sort $(dir $(OBJS)))

# Make build directories
DUMMY := $(shell mkdir -p $(DIRS))

.PHONY: clean depend

Expand All @@ -11,38 +15,38 @@ else
Q =
endif

all: $(PROG)
all: $(BUILDDIR)/$(PROG)

$(PROG): $(OBJECTS)
$(BUILDDIR)/$(PROG): $(OBJS)
@echo "===> LD $@"
$(Q)$(CXX) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
$(Q)$(CXX) $(OBJS) $(LDFLAGS) $(LIBS) -o $@

clean:
@echo "===> Cleaning up"
$(Q)rm -f $(PROG) $(OBJECTS) $(DEPS)
$(Q)rm -fr $(BUILDDIR)

-include $(DEPS)

# Silence stale header dependency errors
%.h:
@true

%.o: %.mm
$(BUILDDIR)/%.o: %.mm
@echo "===> Obj-c OSX $<"
$(Q)$(CXX) $(CXXFLAGS) $(OBJCFLAGS) -c -MMD -o $@ $<

%.o: %.m
$(BUILDDIR)/%.o: %.m
@echo "===> Obj-c OSX $<"
$(Q)$(CXX) $(CXXFLAGS) $(OBJCFLAGS) -c -MMD -o $@ $<

%.o: %.c
$(BUILDDIR)/%.o: %.c
@echo "===> CC $<"
$(Q)$(CC) $(CCFLAGS) -c -MMD -o $@ $<

%.o: %.cc
$(BUILDDIR)/%.o: %.cc
@echo "===> CXX $<"
$(Q)$(CXX) $(CXXFLAGS) -c -MMD -o $@ $<

%.o: %.rc
$(BUILDDIR)/%.o: %.rc
@echo "===> RES $<"
$(Q)$(WINDRES) -O COFF $< $@

0 comments on commit 560fefd

Please sign in to comment.