OSDN Git Service

Since the nios2 port is the only one to use the get_gp_value() function,
[uclinux-h8/elf2flt.git] / Makefile.in
index 5f0e6f7..1b192c4 100644 (file)
@@ -1,39 +1,87 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+libdir = @libdir@
+includedir = @includedir@
 
 CC = @CC@
 CPU = @target_cpu@
 TARGET = @target_alias@
-CFLAGS = @CFLAGS@ -static -DTARGET_$(CPU)
-LDFLAGS = @LDFLAGS@ @LIBS@
+CFLAGS = @CFLAGS@
+INCLUDES = @bfd_include_dir@ @binutils_include_dir@ @zlib_include_dir@
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
 INSTALL = @INSTALL@
-INSTALLDIR = @prefix@
+DEFS = @DEFS@ -DTARGET_$(CPU)
+EXEEXT = @EXEEXT@
+OBJEXT = @OBJEXT@
+
+HOST = @host_alias@
+
+ifneq (,$(findstring mingw32,$(HOST)))
+   LIBS :=  $(LIBS) -lws2_32
+endif
+
+# force link order under cygwin to avoid getopts / libiberty clash
+ifneq ($(strip $(shell gcc -v 2>&1 | grep "cygwin")),)
+   LIBS := -lcygwin $(LIBS)
+endif
+
+CCFLAGS = $(CFLAGS) $(DEFS) $(INCLUDES)
 
-PROGS = elf2flt flthdr
+LDFILE= elf2flt.ld
+ifeq ($(strip $(CPU)),e1)
+SRC_LDFILE= $(srcdir)/$(CPU)-elf2flt.ld
+else 
+SRC_LDFILE= elf2flt.ld
+endif
 
+target_bindir = $(prefix)/$(TARGET)/bin
+target_libdir = $(prefix)/$(TARGET)/lib
 
-all: $(PROGS)
 
-elf2flt: elf2flt.c Makefile
-       $(CC) $(CFLAGS) -o $@ elf2flt.c $(LDFLAGS)
+PROG_ELF2FLT = elf2flt$(EXEEXT)
+PROG_FLTHDR = flthdr$(EXEEXT)
+PROGS = $(PROG_ELF2FLT) $(PROG_FLTHDR)
 
-flthdr: flthdr.c Makefile
-       $(CC) $(CFLAGS) -o $@ flthdr.c $(LDFLAGS)
+all: $(PROGS) ld-elf2flt
+
+$(PROG_ELF2FLT): $(srcdir)/elf2flt.c compress.o $(srcdir)/stubs.c
+       $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+$(PROG_FLTHDR): $(srcdir)/flthdr.c compress.o
+       $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+ld-elf2flt: $(srcdir)/ld-elf2flt.in
+       ./config.status $@
+
+Makefile: $(srcdir)/Makefile.in
+       ./config.status $@
 
 clean:
-       -rm -f $(PROGS) *.[oa]
+       -rm -f $(PROGS) *.$(OBJEXT)
 
 distclean: clean
-       -rm -f Makefile config.log config.status config.cache
+       -rm -f Makefile config.log config.status config.cache ld-elf2flt
 
 install:
-       $(INSTALL) -s -m 755 flthdr $(INSTALLDIR)/bin/$(TARGET)-flthdr
-       $(INSTALL) -s -m 755 flthdr $(INSTALLDIR)/$(TARGET)/bin/flthdr
-       $(INSTALL) -s -m 755 elf2flt $(INSTALLDIR)/bin/$(TARGET)-elf2flt
-       $(INSTALL) -s -m 755 elf2flt $(INSTALLDIR)/$(TARGET)/bin/elf2flt
-       [ -f $(INSTALLDIR)/bin/$(TARGET)-ld.real ] || \
-               mv $(INSTALLDIR)/bin/$(TARGET)-ld $(INSTALLDIR)/bin/$(TARGET)-ld.real
-       [ -f $(INSTALLDIR)/$(TARGET)/bin/ld.real ] || \
-               mv $(INSTALLDIR)/$(TARGET)/bin/ld $(INSTALLDIR)/$(TARGET)/bin/ld.real
-       $(INSTALL) -m 755 ld-elf2flt $(INSTALLDIR)/bin/$(TARGET)-ld
-       $(INSTALL) -m 755 ld-elf2flt $(INSTALLDIR)/$(TARGET)/bin/ld
-       $(INSTALL) -m 644 elf2flt.ld $(INSTALLDIR)/$(TARGET)/lib
+       $(INSTALL) -d $(bindir)
+       $(INSTALL) -d $(target_bindir)
+       $(INSTALL) -d $(target_libdir)
+       $(INSTALL) -m 755 $(PROG_FLTHDR) $(bindir)/$(TARGET)-$(PROG_FLTHDR)
+       $(INSTALL) -m 755 $(PROG_FLTHDR) $(target_bindir)/$(PROG_FLTHDR)
+       $(INSTALL) -m 755 $(PROG_ELF2FLT) $(bindir)/$(TARGET)-$(PROG_ELF2FLT)
+       $(INSTALL) -m 755 $(PROG_ELF2FLT) $(target_bindir)/$(PROG_ELF2FLT)
+       [ -f $(bindir)/$(TARGET)-ld.real$(EXEEXT) ] || \
+               mv $(bindir)/$(TARGET)-ld$(EXEEXT) $(bindir)/$(TARGET)-ld.real$(EXEEXT)
+       [ -f $(target_bindir)/ld.real$(EXEEXT) ] || \
+               mv $(target_bindir)/ld$(EXEEXT) $(target_bindir)/ld.real$(EXEEXT)
+       $(INSTALL) -m 755 ld-elf2flt $(bindir)/$(TARGET)-ld
+       $(INSTALL) -m 755 ld-elf2flt $(target_bindir)/ld
+       $(INSTALL) -m 644 $(SRC_LDFILE) $(target_libdir)/$(LDFILE)
+