* src/Makefile.in, sim/ucsim/avr.src/Makefile.in,
[fw/sdcc] / src / Makefile.in
index 6d0e631ce6a1ba7680d8c83cdd790fda81761036..31868f6006b86a5a644f034e4dc8578055d0bf95 100644 (file)
@@ -2,47 +2,74 @@
 #
 #
 
-PRJDIR         = ..
+srcdir         = @srcdir@
+top_srcdir     = @top_srcdir@
+top_builddir   = @top_builddir@
+VPATH =           @srcdir@
 
-include $(PRJDIR)/Makefile.common
+include $(top_builddir)/Makefile.common
 
-PORTS          = mcs51 z80
+USE_ALT_LEX    = 0
+
+PORTS          = $(shell cat ../ports.build)
+ALLPORTS       = $(shell cat ../ports.all)
 PORT_LIBS      = $(PORTS:%=%/port.a)
 
-LIBS           = -lgc @LIBS@
-LIBDIRS                = -L$(PRJDIR)/support/gc
+LIBS           = -lm @LIBS@
+
+#CFLAGS          += -Werror
+CPPFLAGS       += -I$(srcdir)
+LDFLAGS                = @LDFLAGS@
+
+ifdef SDCC_SUB_VERSION
+CFLAGS         += -DSDCC_SUB_VERSION_STR=\"$(SDCC_SUB_VERSION)\"
+endif
 
-OBJECTS        = SDCCy.o SDCClex.o SDCCerr.o SDCChasht.o SDCCmain.o \
+SLIBOBJS       = SDCCerr.o NewAlloc.o MySystem.o BuildCmd.o dbuf.o dbuf_string.o findme.o
+
+OBJECTS        = SDCCy.o SDCChasht.o SDCCmain.o \
                  SDCCsymt.o SDCCopt.o SDCCast.o SDCCmem.o SDCCval.o \
                  SDCCicode.o SDCCbitv.o SDCCset.o SDCClabel.o \
                  SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o \
-                 SDCClrange.o SDCCptropt.o SDCCpeeph.o SDCCglue.o spawn.o
+                 SDCClrange.o SDCCptropt.o SDCCpeeph.o SDCCglue.o \
+                 asm.o SDCCmacro.o SDCCutil.o SDCCdebug.o cdbFile.o SDCCdwarf2.o
+
+SPECIAL                = SDCCy.h 
+ifeq ($(USE_ALT_LEX), 1)
+OBJECTS                += altlex.o
+SPECIAL                += reswords.h
+else
+OBJECTS                += SDCClex.o
+endif
+
+SLIBSOURCES    = $(patsubst %.o,$(SLIB)/%.c,$(SLIBOBJS))
 SOURCES                = $(patsubst %.o,%.c,$(OBJECTS))
 
-TARGET         = $(PRJDIR)/bin/sdcc
+TARGET         = $(top_builddir)/bin/sdcc$(EXEEXT)
 
 # Compiling entire program or any subproject
 # ------------------------------------------
-all: ports checkconf $(PRJDIR)/support/gc/libgc.a $(TARGET)
+all: checkconf version.h $(TARGET)
 
-ports:
-       for i in $(PORTS); do $(MAKE) -C $$i; done
+$(PORT_LIBS): FORCE 
+       $(MAKE) -C $(dir $@)
 
-$(PRJDIR)/support/gc/libgc.a:
-       cd $(PRJDIR)/support/gc && $(MAKE)
+FORCE:
 
+$(top_builddir)/support/gc/libgc.a:
+       $(MAKE) -C $(top_builddir)/support/gc
 
 # Compiling and installing everything and runing test
 # ---------------------------------------------------
 install: all installdirs
-       $(INSTALL) -s $(TARGET) $(bindir)/sdcc
+       $(INSTALL) $(TARGET) `echo $(DESTDIR)$(bindir)/sdcc$(EXEEXT)|sed '$(transform)'`
+       $(STRIP) `echo $(DESTDIR)$(bindir)/sdcc$(EXEEXT)|sed '$(transform)'`
 
 
 # Deleting all the installed files
 # --------------------------------
 uninstall:
-       rm -f $(bindir)/sdcc
-
+       rm -f $(DESTDIR)$(bindir)/sdcc$(EXEEXT)
 
 # Performing self-test
 # --------------------
@@ -57,28 +84,40 @@ installcheck:
 # Creating installation directories
 # ---------------------------------
 installdirs:
-       $(INSTALL) -d $(bindir)
+       $(INSTALL) -d $(DESTDIR)$(bindir)
 
 
 # Creating dependencies
 # ---------------------
-dep: Makefile.dep
+dep: version.h Makefile.dep
 
-Makefile.dep: $(SOURCES) *.h $(PRJDIR)/*.h
-       $(CPP) $(CPPFLAGS) $(M_OR_MM) $(SOURCES) >Makefile.dep
+Makefile.dep: version.h $(SOURCES) $(SLIBSOURCES) $(SPECIAL)
+       $(CPP) $(CPPFLAGS) $(M_OR_MM) $(filter %.c,$^) >Makefile.dep
 
-include Makefile.dep
-include clean.mk
+# don't include Makefile.dep for the listed targets:
+ifeq "$(findstring $(MAKECMDGOALS),uninstall check installcheck installdirs checkconf \
+                                   clean distclean mostlyclean realclean)" ""
+  include Makefile.dep
+endif
+include $(srcdir)/clean.mk
 
 
 # My rules
 # --------
-$(TARGET): $(OBJECTS) $(PORT_LIBS)
-       $(CC) -o $@ $(OBJECTS) $(PORT_LIBS) $(LIBDIRS) $(LIBS)
+$(TARGET): $(SLIBOBJS) $(OBJECTS) $(PORT_LIBS)
+       $(CC) $(LDFLAGS) -o $@ $(SLIBOBJS) $(OBJECTS) $(PORT_LIBS) $(LIBDIRS) $(LIBS)
 
 .c.o:
        $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
 
+$(SLIBOBJS):%.o:$(SLIB)/%.c
+       $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
+
+reswords.h: reswords.gperf Makefile
+       gperf -o -k1,2,4 -t -C -N is_reserved_word $< > $@
+
+altlex.o: altlex.c SDCCy.h reswords.h
+
 SDCCy.h: SDCCy.c
 
 SDCCy.c: SDCC.y
@@ -87,8 +126,8 @@ SDCCy.c: SDCC.y
 SDCClex.c: SDCC.lex SDCCy.h
        $(LEX) -t $< >$@
 
-SDCCpeeph.rul: SDCCpeeph.def
-       $(AWK) -f SDCCpeeph.awk SDCCpeeph.def > SDCCpeeph.rul
+version.h: ../ChangeLog
+       $(AWK) -f $(srcdir)/version.awk $< > $@
 
 .y.c:
        rm -f $*.cc $*.h
@@ -104,10 +143,9 @@ SDCCpeeph.rul: SDCCpeeph.def
 # Remaking configuration
 # ----------------------
 checkconf:
-       @if [ -f $(PRJDIR)/devel ]; then\
-         $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
+       @if [ -f $(top_builddir)/devel ]; then\
+         $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" top_builddir="$(top_builddir)" \
          freshconf;\
        fi
 
 # End of main_in.mk/main.mk
-