diff --git a/src/Makefile b/src/Makefile index 43e8543..b119621 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,6 @@ SHELL := bash +TARGET := jcad export GTKMM_VERSION := 2.4 export GTKGLEXTMM_VERSION := 1.2 @@ -9,14 +10,14 @@ export CPPFLAGS += -I"$(shell cd)" else export CPPFLAGS += -I"$(shell pwd)" endif -export CXXFLAGS := -Wall -O2 +export CXXFLAGS := -Wall -O2 \ + `pkg-config --cflags gtkmm-$(GTKMM_VERSION)` \ + `pkg-config --cflags gtkglextmm-$(GTKGLEXTMM_VERSION)` export LDFLAGS := `pkg-config --libs gtkmm-$(GTKMM_VERSION)` \ `pkg-config --libs gtkglextmm-$(GTKGLEXTMM_VERSION)` SUBDIRS := engine gui main -all: $(TARGET) - .PHONY: $(TARGET) $(TARGET): @for d in $(SUBDIRS); \ diff --git a/src/engine/Makefile b/src/engine/Makefile index 544f762..a210eec 100644 --- a/src/engine/Makefile +++ b/src/engine/Makefile @@ -1,30 +1,23 @@ -SRCS := Profile.cpp -MODULES := Profile.o -TARGET := engine.a -GTKMM_VERSION := 2.4 -GTKGLEXTMM_VERSION := 1.2 -CPPFLAGS = -I.. -CXXFLAGS = -O2 $(CPPFLAGS) \ - `pkg-config --cflags gtkmm-$(GTKMM_VERSION)` \ - `pkg-config --cflags gtkglextmm-$(GTKGLEXTMM_VERSION)` -DEPS := $(SRCS:.cpp=.d) +OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) +DEPS := $(OBJS:.o=.dep) -all: $(TARGET) +all: $(DEPS) $(OBJS) -$(TARGET): $(MODULES) - $(AR) rcv $@ $? +%.o: %.cc + $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< -%.o: %.cpp - $(CXX) -c -o $@ $(CXXFLAGS) $< - -.PHONY: clean -clean: - $(RM) -f *.o *.d *~ $(TARGET) - -%.d: %.cpp +# Make dependency files +%.dep: %.cc @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< | \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@ + $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -include $(DEPS) +clean: + -$(RM) -f *.o *.dep + +# Include dependency files +ifndef CLEAN +-include $(DEPS) +endif diff --git a/src/engine/Profile.cpp b/src/engine/Profile.cc similarity index 100% rename from src/engine/Profile.cpp rename to src/engine/Profile.cc diff --git a/src/gui/Displayer.cpp b/src/gui/Displayer.cc similarity index 100% rename from src/gui/Displayer.cpp rename to src/gui/Displayer.cc diff --git a/src/gui/GUI.cpp b/src/gui/GUI.cc similarity index 100% rename from src/gui/GUI.cpp rename to src/gui/GUI.cc diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cc similarity index 100% rename from src/gui/MainWindow.cpp rename to src/gui/MainWindow.cc diff --git a/src/gui/Makefile b/src/gui/Makefile index ccf3227..a210eec 100644 --- a/src/gui/Makefile +++ b/src/gui/Makefile @@ -1,30 +1,23 @@ -SRCS := MainWindow.cpp GUI.cpp Displayer.cpp ProfileDisplayer.cpp PartDisplayer.cpp -MODULES := MainWindow.o GUI.o Displayer.o ProfileDisplayer.o PartDisplayer.o -TARGET := gui.a -GTKMM_VERSION := 2.4 -GTKGLEXTMM_VERSION := 1.2 -CPPFLAGS = -I.. -CXXFLAGS = -O2 $(CPPFLAGS) \ - `pkg-config --cflags gtkmm-$(GTKMM_VERSION)` \ - `pkg-config --cflags gtkglextmm-$(GTKGLEXTMM_VERSION)` -DEPS := $(SRCS:.cpp=.d) +OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) +DEPS := $(OBJS:.o=.dep) -all: $(TARGET) +all: $(DEPS) $(OBJS) -$(TARGET): $(MODULES) - $(AR) rcv $@ $? +%.o: %.cc + $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< -%.o: %.cpp - $(CXX) -c -o $@ $(CXXFLAGS) $< - -.PHONY: clean -clean: - $(RM) -f *.o *.d *~ $(TARGET) - -%.d: %.cpp +# Make dependency files +%.dep: %.cc @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< | \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@ + $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -include $(DEPS) +clean: + -$(RM) -f *.o *.dep + +# Include dependency files +ifndef CLEAN +-include $(DEPS) +endif diff --git a/src/gui/PartDisplayer.cpp b/src/gui/PartDisplayer.cc similarity index 100% rename from src/gui/PartDisplayer.cpp rename to src/gui/PartDisplayer.cc diff --git a/src/gui/ProfileDisplayer.cpp b/src/gui/ProfileDisplayer.cc similarity index 100% rename from src/gui/ProfileDisplayer.cpp rename to src/gui/ProfileDisplayer.cc diff --git a/src/main/Makefile b/src/main/Makefile index 2a3d888..a210eec 100644 --- a/src/main/Makefile +++ b/src/main/Makefile @@ -1,26 +1,23 @@ -SRCS := main.cpp -MODULES := main.o -TARGET := main.a -DEPS := $(SRCS:.cpp=.d) -CPPFLAGS := -I.. -CXXFLAGS := -O2 $(CPPFLAGS) +OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) +DEPS := $(OBJS:.o=.dep) -all: $(TARGET) +all: $(DEPS) $(OBJS) -$(TARGET): $(MODULES) - $(AR) rcv $@ $? +%.o: %.cc + $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< -%.o: %.cpp - $(CXX) -c -o $@ $(CXXFLAGS) $< - -.PHONY: clean -clean: - $(RM) -f *.o *.d *~ $(TARGET) - -%.d: %.cpp +# Make dependency files +%.dep: %.cc @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< | \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@ + $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ -include $(DEPS) +clean: + -$(RM) -f *.o *.dep + +# Include dependency files +ifndef CLEAN +-include $(DEPS) +endif diff --git a/src/main/main.cpp b/src/main/jcad.cc similarity index 100% rename from src/main/main.cpp rename to src/main/jcad.cc