diff --git a/GNUmakef.inc b/GNUmakef.inc index 7158dc0..679fb6d 100644 --- a/GNUmakef.inc +++ b/GNUmakef.inc @@ -1,6 +1,6 @@ # -*- makefile -*- -.PHONY: all clean +.PHONY: all clean sourcelist deps clean_sl all: $(TARGET) @@ -18,12 +18,13 @@ FDEPPATH=$(TOP)/$(DEPPATH)/$(PLATFORM) .SUFFIXES: .c .cpp .all .rc +sourcelist: bld$(PLATFORM).inc + bld$(PLATFORM).inc: $(TARGET).all @echo making sourcelist @grep -w $(PLATFORM) $< \ | sed 's;^\([[:alnum:]_]*\)[ ]*\([[:alnum:]_]*\).*;SOURCES+=\1.\2;' > $@; [ -s $@ ] || rm -f $@ -ifeq ($(FDEPPATH)/dep,$(wildcard $(FDEPPATH)/de?)) $(FDEPPATH)/$(TARGET)/%.d: %.cpp @echo making depends for $< @$(SHELL) -ec '$(CXX) -c -M $(CPPFLAGS) $< \ @@ -33,7 +34,6 @@ $(FDEPPATH)/$(TARGET)/%.d: %.c @echo making depends for $< @$(SHELL) -ec '$(CC) -c -M $(CFLAGS) $< \ | sed '\''s;\($*\)\$(OBJEXT)[ :]*;$(subst /,\/,$(FOBJPATH))\/\1\$(OBJEXT) $(subst /,\/,$@): ;g'\'' > $@; [ -s $@ ] || rm -f $@' -endif $(FOBJPATH)/%$(OBJEXT): %.cpp @echo building $(basename $<)$(OBJEXT) @@ -55,6 +55,54 @@ $(FOBJPATH)/%.res: %.rc @rc $(subst -I,-i ,$(INCS)) -x1 -r $< endif +SOURCES= +ifeq ($(FDEPPATH)/source.lst,$(wildcard $(FDEPPATH)/source.ls?)) +include bld$(PLATFORM).inc +endif + +ifeq ($(PLATFORM),cyg) +OBJS=$(addprefix $(FOBJPATH)/,$(patsubst %.rc,$(OBJEXT),$(patsubst %.c,$(OBJEXT),$(patsubst %.cpp,%$(OBJEXT),$(filter %.c %.cpp %.rc,$(SOURCES)))))) +else +ifeq ($(PLATFORM),emx) +OBJS=$(addprefix $(FOBJPATH)/,$(patsubst %.rc,%.res,$(patsubst %.c,%$(OBJEXT),$(patsubst %.cpp,%$(OBJEXT),$(filter %.c %.cpp %.rc,$(SOURCES)))))) +else +OBJS=$(addprefix $(FOBJPATH)/,$(patsubst %.c,%$(OBJEXT),$(patsubst %.cpp,%$(OBJEXT),$(filter %.c %.cpp %.rc,$(SOURCES))))) +endif +endif +DEPS=$(addprefix $(FDEPPATH)/$(TARGET)/,$(patsubst %.c,%.d,$(patsubst %.cpp,%.d,$(filter %.c %.cpp,$(SOURCES))))) + +clean: + @echo cleaning... + @-rm -f $(OBJS) $(DEPS) + +clean_sl: + @echo deleting sourcelist + @-rm -f bld$(PLATFORM).inc + +deps: $(DEPS) + +ifeq ($(FDEPPATH)/dep,$(wildcard $(FDEPPATH)/de?)) +ifneq ($(DEPS),) +include $(DEPS) +endif +endif + +$(FOBJPATH)/%$(OBJEXT): %.c + @echo building $(basename $<)$(OBJEXT) + @$(CC) -c $(CFLAGS) -o $@ $< + +ifeq ($(PLATFORM),cyg) +$(FOBJPATH)/%$(OBJEXT): %.rc + @echo creating resources + @$(WINDRES) -o $@ $< +endif + +ifeq ($(PLATFORM),emx) +$(FOBJPATH)/%.res: %.rc + @echo creating resources + @rc $(subst -I,-i ,$(INCS)) -x1 -r $< +endif + SOURCES= -include bld$(PLATFORM).inc ifeq ($(PLATFORM),cyg) diff --git a/Makefile b/Makefile index 1415123..78f9c2c 100644 --- a/Makefile +++ b/Makefile @@ -2,19 +2,21 @@ include GNUmakef.def +.PHONY: all clean distclean dirs sourcelists deps + LIBS=gall gcfg gmb3 glibc uulib EXECUTABLES=golded3 goldnode rddt -all: - @$(MAKE) dirs - @echo -n >$(DEPPATH)/$(PLATFORM)/dep - @for i in $(foreach dir,$(LIBS),goldlib/$(dir)); do cd $$i && $(MAKE) && cd ../..; done - @for i in $(EXECUTABLES); do cd $$i && $(MAKE) && cd ..; done +all: sourcelists deps + @$(SHELL) -ec 'for i in $(foreach dir,$(LIBS),goldlib/$(dir)); do cd $$i; $(MAKE) all; cd ../..; done' + @$(SHELL) -ec 'for i in $(EXECUTABLES); do cd $$i; $(MAKE) all; cd ..; done' -clean: - @rm -f $(DEPPATH)/$(PLATFORM)/dep - @for i in $(foreach dir,$(LIBS),goldlib/$(dir)); do cd $$i && $(MAKE) clean && cd ../..; done - @for i in $(EXECUTABLES); do cd $$i && $(MAKE) clean && cd ..; done +clean: nodeps sourcelists + @$(SHELL) -ec 'for i in $(foreach dir,$(LIBS),goldlib/$(dir)); do cd $$i; $(MAKE) clean; cd ../..; done' + @$(SHELL) -ec 'for i in $(EXECUTABLES); do cd $$i; $(MAKE) clean; cd ..; done' + @-rm -f $(DEPPATH)/$(PLATFORM)/source.lst + @$(SHELL) -ec 'for i in $(foreach dir,$(LIBS),goldlib/$(dir)); do cd $$i; $(MAKE) clean_sl; cd ../..; done' + @$(SHELL) -ec 'for i in $(EXECUTABLES); do cd $$i; $(MAKE) clean_sl; cd ..; done' dirs: @mkdir -p $(BIN) $(LIBPATH)/$(PLATFORM) @@ -22,3 +24,16 @@ dirs: @mkdir -p $(foreach dir,$(EXECUTABLES),$(OBJPATH)/$(PLATFORM)/$(dir)) @mkdir -p $(foreach dir,$(LIBS),$(DEPPATH)/$(PLATFORM)/$(dir)) @mkdir -p $(foreach dir,$(EXECUTABLES),$(DEPPATH)/$(PLATFORM)/$(dir)) + +deps: + @$(SHELL) -ec 'for i in $(foreach dir,$(LIBS),goldlib/$(dir)); do cd $$i; $(MAKE) deps; cd ../..; done' + @$(SHELL) -ec 'for i in $(EXECUTABLES); do cd $$i; $(MAKE) deps; cd ..; done' + @echo -n >$(DEPPATH)/$(PLATFORM)/dep + +nodeps: + @-rm -f $(DEPPATH)/$(PLATFORM)/dep + +sourcelists: dirs + @$(SHELL) -ec 'for i in $(foreach dir,$(LIBS),goldlib/$(dir)); do cd $$i; $(MAKE) sourcelist; cd ../..; done' + @$(SHELL) -ec 'for i in $(EXECUTABLES); do cd $$i; $(MAKE) sourcelist; cd ..; done' + @echo -n >$(DEPPATH)/$(PLATFORM)/source.lst